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
-[Processing](https://processing.org/download) (for displaying camera feed).
30
+
-[Web Serial Web Application](https://arduino.github.io/labs-pages/web-serial-camera/) (for displaying camera feed).
30
31
31
32
## Supported Cameras
32
33
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):
34
+
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
35
35
36
-**OV7670** and **OV7675**
36
37
-**GC2145**
37
38
-**Himax HM01B0**
38
-
-**Himax HM0360**
39
39
40
40
## Camera Connector
41
41
42
42

43
43
44
-
The 20 pin camera connector onboard the GIGA R1 is designed to be directly compatible with some breakout boards from ArduCam.
44
+
The 20 pin camera connector onboard the GIGA R1 is designed to be directly compatible with some breakout boards from ArduCam.
45
45
46
46
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/).
50
+
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
51
52
52
The complete pin map can be found below:
53
53
@@ -70,21 +70,33 @@ You can also view the schematic for this connector in more detail just below. Th
70
70
71
71

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

73
+
## Raw Bytes Over Serial
76
74
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.***
75
+
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
76
81
77
### Step 1: Arduino
82
78
83
79
Upload the following sketch to your board.
84
80
85
-
This sketch is also available in the Arduino IDE via **Examples > Camera > CameraCaptureRawBytes**.
81
+
This sketch is also available in the Arduino IDE via **Examples > Camera > CameraCaptureWebSerial**.
86
82
87
83
```arduino
84
+
/*
85
+
* This example shows how to capture images from the camera and send them over Web Serial.
86
+
*
87
+
* There is a companion web app that receives the images and displays them in a canvas.
88
+
* It can be found in the "extras" folder of this library.
89
+
* The on-board LED lights up while the image is being sent over serial.
90
+
*
91
+
* Instructions:
92
+
* 1. Make sure the correct camera is selected in the #include section below by uncommenting the correct line.
93
+
* 2. Upload this sketch to your camera-equipped board.
94
+
* 3. Open the web app in a browser (Chrome or Edge) by opening the index.html file
95
+
* in the "WebSerialCamera" folder which is located in the "extras" folder.
96
+
*
97
+
* Initial author: Sebastian Romero @sebromero
98
+
*/
99
+
88
100
#include "camera.h"
89
101
90
102
#ifdef ARDUINO_NICLA_VISION
@@ -93,14 +105,19 @@ This sketch is also available in the Arduino IDE via **Examples > Camera > Camer
93
105
Camera cam(galaxyCore);
94
106
#define IMAGE_MODE CAMERA_RGB565
95
107
#elif defined(ARDUINO_PORTENTA_H7_M7)
108
+
// uncomment the correct camera in use
96
109
#include "hm0360.h"
97
110
HM0360 himax;
111
+
// #include "himax.h";
112
+
// HM01B0 himax;
98
113
Camera cam(himax);
99
114
#define IMAGE_MODE CAMERA_GRAYSCALE
100
115
#elif defined(ARDUINO_GIGA)
101
-
#include "ov7670.h"
102
-
OV7670 ov7670;
103
-
Camera cam(ov7670);
116
+
#include "ov767x.h"
117
+
// uncomment the correct camera in use
118
+
OV7670 ov767x;
119
+
// OV7675 ov767x;
120
+
Camera cam(ov767x);
104
121
#define IMAGE_MODE CAMERA_RGB565
105
122
#else
106
123
#error "This board is unsupported."
@@ -110,188 +127,137 @@ This sketch is also available in the Arduino IDE via **Examples > Camera > Camer
110
127
Other buffer instantiation options:
111
128
FrameBuffer fb(0x30000000);
112
129
FrameBuffer fb(320,240,2);
113
-
*/
114
-
FrameBuffer fb;
115
130
116
-
unsigned long lastUpdate = 0;
131
+
If resolution higher than 320x240 is required, please use external RAM via
132
+
#include "SDRAM.h"
133
+
FrameBuffer fb(SDRAM_START_ADDRESS);
134
+
...
135
+
// and adding in setup()
136
+
SDRAM.begin();
137
+
*/
138
+
constexpr uint16_t CHUNK_SIZE = 512; // Size of chunks in bytes
for(size_t i = 0; i < bufferSize; i += CHUNK_SIZE) {
201
+
size_t chunkSize = min(bufferSize - i, CHUNK_SIZE);
202
+
sendChunk(buffer + i, chunkSize);
203
+
}
204
+
205
+
sendChunk(STOP_SEQUENCE, sizeof(STOP_SEQUENCE));
206
+
207
+
digitalWrite(LED_BUILTIN, HIGH);
156
208
} else {
157
209
blinkLED(20);
158
210
}
159
211
}
160
212
161
-
```
162
-
163
-
### Step 2: Processing
164
-
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.
166
-
167
-
***Important! Make sure to replace the following line in the code below: `/dev/cu.usbmodem14301`, with the name of your port.***
168
-
169
-
Click on the **"PLAY"** button to initialize the app.
170
-
171
-
```cpp
172
-
/*
173
-
Use with the Examples -> CameraCaptureRawBytes Arduino sketch.
174
-
This example code is in the public domain.
175
-
*/
176
-
177
-
import processing.serial.*;
178
-
import java.nio.ByteBuffer;
179
-
import java.nio.ByteOrder;
180
-
181
-
Serial myPort;
213
+
/**
214
+
* Sends the camera configuration over a serial connection.
215
+
* This is used to configure the web app to display the image correctly.
216
+
*/
217
+
void sendCameraConfig(){
218
+
Serial.write(IMAGE_MODE);
219
+
Serial.write(RESOLUTION);
220
+
Serial.flush();
221
+
delay(1);
222
+
}
182
223
183
-
// must match resolution used in the Arduino sketch
184
-
finalint cameraWidth = 320;
185
-
finalint cameraHeight = 240;
224
+
void loop() {
225
+
if(!Serial) {
226
+
Serial.begin(115200);
227
+
while(!Serial);
228
+
}
186
229
187
-
// Must match the image mode in the Arduino sketch
finalint timeout = int((bytesPerFrame / float(baudRate / 10)) * 1000 * 2); // Twice the transfer rate
234
+
switch(request){
235
+
case IMAGE_SEND_REQUEST:
236
+
sendFrame();
237
+
break;
238
+
case CONFIG_SEND_REQUEST:
239
+
sendCameraConfig();
240
+
break;
241
+
}
242
+
243
+
}
197
244
198
-
PImage myImage;
199
-
byte[] frameBuffer = new byte[bytesPerFrame];
200
-
int lastUpdate = 0;
201
-
boolean shouldRedraw = false;
245
+
```
202
246
203
-
voidsetup() {
204
-
size(640, 480);
247
+
### Step 2: Web Serial
205
248
206
-
// If you have only ONE serial port active you may use this:
207
-
//myPort = new Serial(this, Serial.list()[0], baudRate); // if you have only ONE serial port active
249
+
Open the [Web Serial Interface](https://arduino.github.io/labs-pages/web-serial-camera/) which allows you to view the camera feed. Make sure to close the Serial Monitor in the Arduino IDE beforehand, otherwise it will not work as the serial port would be occupied.
208
250
209
-
// If you know the serial port name
210
-
//myPort = new Serial(this, "COM5", baudRate); // Windows
211
-
//myPort = new Serial(this, "/dev/ttyACM0", baudRate); // Linux
212
-
myPort = new Serial(this, "/dev/cu.usbmodem14301", baudRate); // Mac
// Ensures that the new image data is drawn in the next draw loop
285
-
shouldRedraw = true;
286
-
287
-
// Let the Arduino sketch know we received all pixels
288
-
// and are ready for the next frame
289
-
myPort.write(1);
290
-
}
291
-
```
257
+
There is also a variety of video filters that can be applied.
292
258
293
-
If all goes well, you should now be able to see the camera feed.
259
+

294
260
295
261
## Summary
296
262
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.
263
+
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 of how to connect ArduCam camera modules through web serial.
0 commit comments