You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and open the `.index`. We suggest using the Chrome™ browser.
30
39
31
40
## Supported Cameras
32
41
33
-
The GIGA R1 currently supports the following cameras, via the [Camera](https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Camera) library that is bundled with the [Arduino Mbed PS GIGA Board Package](https://github.com/arduino/ArduinoCore-mbed):
42
+
The GIGA R1 currently supports the following cameras, via the [Camera](https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Camera) library that is bundled with the [Arduino Mbed Core](https://github.com/arduino/ArduinoCore-mbed):
34
43
35
44
-**OV7670** and **OV7675**
36
45
-**GC2145**
@@ -41,13 +50,13 @@ The GIGA R1 currently supports the following cameras, via the [Camera](https://g
41
50
42
51

43
52
44
-
The 20 pin camera connector onboard the GIGA R1 is designed to be directly compatible with some breakout boards from ArduCam.
53
+
The 20 pin camera connector onboard the GIGA R1 is designed to be directly compatible with some breakout boards from ArduCam.
45
54
46
55
This allows you to simply connect the camera module directly to the board, without making any additional circuit.
Some of the 20 pin connector breakout boards from ArduCam can be found [here](https://www.arducam.com/product-category/stm32-camera-modules-dcmi-and-spi/).
59
+
Some of the 20 pin connector breakout boards from ArduCam can be found [here](https://www.arducam.com/product-category/embedded-camera-module/camera-breakout-board/).
51
60
52
61
The complete pin map can be found below:
53
62
@@ -70,13 +79,9 @@ You can also view the schematic for this connector in more detail just below. Th
70
79
71
80

72
81
73
-
## Raw Bytes Over Serial (Processing)
74
-
75
-

82
+
## Raw Bytes Over Serial
76
83
77
-
This example allows you to stream the sensor data from your camera to a Processing application, using serial over USB. This will allow you to see the image directly in your computer.
78
-
79
-
***This example requires a version of [Processing](https://processing.org/download) on your machine.***
84
+
This example allows you to stream the sensor data from your camera to a web interface, using serial over USB. This will allow you to see the image directly in your browser.
80
85
81
86
### Step 1: Arduino
82
87
@@ -93,14 +98,19 @@ This sketch is also available in the Arduino IDE via **Examples > Camera > Camer
93
98
Camera cam(galaxyCore);
94
99
#define IMAGE_MODE CAMERA_RGB565
95
100
#elif defined(ARDUINO_PORTENTA_H7_M7)
101
+
// uncomment the correct camera in use
96
102
#include "hm0360.h"
97
103
HM0360 himax;
104
+
// #include "himax.h";
105
+
// HM01B0 himax;
98
106
Camera cam(himax);
99
107
#define IMAGE_MODE CAMERA_GRAYSCALE
100
108
#elif defined(ARDUINO_GIGA)
101
-
#include "ov7670.h"
102
-
OV7670 ov7670;
103
-
Camera cam(ov7670);
109
+
#include "ov767x.h"
110
+
// uncomment the correct camera in use
111
+
OV7670 ov767x;
112
+
// OV7675 ov767x;
113
+
Camera cam(ov767x);
104
114
#define IMAGE_MODE CAMERA_RGB565
105
115
#else
106
116
#error "This board is unsupported."
@@ -110,188 +120,133 @@ This sketch is also available in the Arduino IDE via **Examples > Camera > Camer
110
120
Other buffer instantiation options:
111
121
FrameBuffer fb(0x30000000);
112
122
FrameBuffer fb(320,240,2);
113
-
*/
114
-
FrameBuffer fb;
115
123
116
-
unsigned long lastUpdate = 0;
124
+
If resolution higher than 320x240 is required, please use external RAM via
125
+
#include "SDRAM.h"
126
+
FrameBuffer fb(SDRAM_START_ADDRESS);
127
+
...
128
+
// and adding in setup()
129
+
SDRAM.begin();
130
+
*/
131
+
constexpr uint16_t CHUNK_SIZE = 512; // Size of chunks in bytes
delay(1); // Optional: Add a small delay to allow the receiver to process the chunk
178
+
}
150
179
151
-
lastUpdate = millis();
152
-
180
+
/**
181
+
* Sends a frame of camera image data over a serial connection.
182
+
*/
183
+
void sendFrame(){
153
184
// Grab frame and write to serial
154
185
if (cam.grabFrame(fb, 3000) == 0) {
155
-
Serial.write(fb.getBuffer(), cam.frameSize());
156
-
} else {
157
-
blinkLED(20);
158
-
}
159
-
}
160
-
161
-
```
162
-
163
-
### Step 2: Processing
186
+
byte* buffer = fb.getBuffer();
187
+
size_t bufferSize = cam.frameSize();
188
+
digitalWrite(LED_BUILTIN, LOW);
164
189
165
-
The following Processing sketch will launch a Java app that allows you to view the camera feed. As data is streamed via serial, make sure you close the Serial Monitor during this process, else it will not work.
// Let the Arduino sketch know we're ready to receive data
220
-
myPort.write(1);
221
-
}
240
+
### Step 2: Web Serial
222
241
223
-
voiddraw() {
224
-
// Time out after a few seconds and ask for new data
225
-
if(millis() - lastUpdate > timeout) {
226
-
println("Connection timed out.");
227
-
myPort.clear();
228
-
myPort.write(1);
229
-
}
230
-
231
-
if(shouldRedraw){
232
-
PImage img = myImage.copy();
233
-
img.resize(640, 480);
234
-
image(img, 0, 0);
235
-
shouldRedraw = false;
236
-
}
237
-
}
242
+
Open the Webserial Interface which allows you to view the camera feed. As data is streamed via serial, make sure you close the Serial Monitor during this process, else it will not work.
238
243
239
-
int[] convertRGB565ToRGB888(short pixelValue){
240
-
//RGB565
241
-
int r = (pixelValue >> (6+5)) & 0x01F;
242
-
int g = (pixelValue >> 5) & 0x03F;
243
-
int b = (pixelValue) & 0x01F;
244
-
//RGB888 - amplify
245
-
r <<= 3;
246
-
g <<= 2;
247
-
b <<= 3;
248
-
return new int[]{r,g,b};
249
-
}
244
+
Press on **Connect** and select the correct port.
250
245
251
-
voidserialEvent(Serial myPort) {
252
-
lastUpdate = millis();
253
-
254
-
// read the received bytes
255
-
myPort.readBytes(frameBuffer);
256
-
257
-
// Access raw bytes via byte buffer
258
-
ByteBuffer bb = ByteBuffer.wrap(frameBuffer);
259
-
260
-
// Ensure proper endianness of the data for > 8 bit values.
261
-
// The 1 byte bb.get() function will always return the bytes in the correct order.
If all goes well, you should now be able to see the camera feed.
248
+
You should now be able to see the camera feed.
294
249
295
250
## Summary
296
251
297
-
In this article, we learned a bit more about the camera connector on board the GIGA R1 board, how it is connected to the STM32H747XI microcontroller, and a simple example on how to connect an inexpensive OV7675 camera module to a Processing application.
252
+
In this article, we learned a bit more about the camera connector on board the GIGA R1 board, how it is connected to the STM32H747XI microcontroller, and a simple example on how to connect an inexpensive OV7675 camera module through web serial.
0 commit comments