Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7495c95

Browse files
Merge pull request #492 from arduino/martab1994-patch-7
Update content.md
2 parents cbfdfb1 + 5ffdbde commit 7495c95

File tree

1 file changed

+15
-15
lines changed
  • content/hardware/04.pro/shields/portenta-vision-shield/tutorials/getting-started-camera

1 file changed

+15
-15
lines changed

‎content/hardware/04.pro/shields/portenta-vision-shield/tutorials/getting-started-camera/content.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ This tutorial shows you how to capture frames from the Arduino Portenta Vision S
1515

1616
## Goals
1717

18-
- Capturing the frames from the camera.
19-
- Sending the frames as a byte stream through a Serial connection.
20-
- Visualising the frames in Processing.
18+
- Capturing the frames from the camera
19+
- Sending the frames as a byte stream through a Serial connection
20+
- Visualising the frames in Processing
2121

2222
### Required Hardware and Software
2323

@@ -28,10 +28,10 @@ This tutorial shows you how to capture frames from the Arduino Portenta Vision S
2828
- Processing 3.5.4+
2929

3030
## Instructions
31-
Accessing the Vision Shield's camera data is done with the help of both Arduino and the Processing IDE. The Arduino sketch handles the capture of image data by the on-board camera while the java applet created with Processing helps to visualize this data with the help of a serial connection. The following steps will run you through how to capture, package the data through the serial port and visualize the output in Processing.
31+
Accessing the Vision Shield's camera data is done with the help of both Arduino and the Processing IDE. The Arduino sketch handles the capture of image data by the on-board camera, while the java applet created with Processing helps to visualize this data with the help of a serial connection. The following steps will run you through how to capture, package the data through the serial port and visualize the output in Processing.
3232

3333
### 1. The Basic Setup
34-
Connect the Vision Shield to your Portenta H7 as shown in the figure. The top and bottom high density connecters are connected to the corresponding ones on the underside of the H7 board. Plug in the H7 to your computer using the USB C cable.
34+
Connect the Portenta Vision Shield to your Portenta H7 as shown in the figure. The top and bottom high density connecters are connected to the corresponding ones on the underside of the H7 board. Plug in the H7 to your computer using the USB C cable.
3535

3636
![Connecting the Vision Shield to Portenta](assets/vs_ard_gs_attach_boards.svg)
3737

@@ -71,7 +71,7 @@ void setup() {
7171
}
7272
```
7373

74-
In the loop we need to capture each Frame and send it over a serial connection to the Processing sketch that will display the frames. We will use the `grab(uint8_t *buffer, uint32_t timeout=5000);` function to fetch the frame from the frame buffer and save it into our custom data buffer.
74+
In the loop you need to capture each Frame and send it over a serial connection to the Processing sketch that will display the frames. You will use the `grab(uint8_t *buffer, uint32_t timeout=5000);` function to fetch the frame from the frame buffer and save it into your custom data buffer.
7575

7676
```cpp
7777
void loop() {
@@ -102,7 +102,7 @@ Open a new processing sketch file and name it `CameraCapture.pde`.
102102

103103
![Create a processing sketch](assets/vs_ard_open_pde_sketch.png)
104104

105-
Let's start by importing the libraries and initializing the variables you will need to process the captured data. To process the data sent by the Vision Shield you will need to import the following libraries:
105+
Let's start by importing the libraries and initializing the variables you will need to process. To process the data sent by the Vision Shield, you will need to import the following libraries:
106106

107107
- `processing.serial.*`: a [Serial Library](https://processing.org/reference/libraries/serial/index.html) that is used to read and write data to external devices over the serial line.
108108
- `java.nio.ByteBuffer`: a java class that provides access to operations on byte buffers
@@ -112,7 +112,7 @@ import processing.serial.*;
112112
import java.nio.ByteBuffer;
113113
```
114114

115-
Next we initialize the following variables to process the received pixels from the serial port. We set the dimensions, pixel count, and bytes required per frame.
115+
Next, you can initialize the following variables to process the received pixels from the serial port. You can set the dimensions, pixel count and bytes required per frame.
116116

117117
```java
118118
// must match resolution used in the sketch
@@ -123,7 +123,7 @@ final int cameraPixelCount = cameraWidth * cameraHeight;
123123
final int bytesPerFrame = cameraWidth * cameraHeight * cameraBytesPerPixel;
124124
```
125125

126-
To receive the frames you will need a Serial port, a PImage object and an array to store the pixel values of the frame. Add the following variables to the code.
126+
To receive the frames, you will need a Serial port, a PImage object and an array to store the pixel values of the frame. Add the following variables to the code.
127127

128128
```java
129129
Serial myPort;
@@ -134,7 +134,7 @@ int lastUpdate = 0;
134134
boolean shouldRedraw = false;
135135
```
136136

137-
Here we will establish a connection to the serial port and prepare the buffer to store the frame pixels. Additionally we send a byte to the Arduino sketch from Processing to let it know that it's ready to receive data.
137+
Here, you will establish a connection to the serial port and prepare the buffer to store the frame pixels. Additionally, you can send a byte to the Arduino sketch from Processing to let it know that it is ready to receive data.
138138

139139
```java
140140
void setup() {
@@ -156,7 +156,7 @@ void setup() {
156156
}
157157
```
158158

159-
The draw function checks if the connection is still alive and if there is any new data that can be drawn as an image. In that case the original image gets copied into a new image object so that it can be scaled up.
159+
The draw function checks if the connection is still alive and if there is any new data that can be drawn as an image. In that case, the original image gets copied into a new image object so that it can be scaled up.
160160

161161
```java
162162
void draw() {
@@ -210,7 +210,7 @@ void serialEvent(Serial myPort) {
210210
}
211211
```
212212

213-
The first thing we do inside this method is to update the timestamp for when the last data was read. This is to detect and recover from a connection timeout. Then read the bytes from the `frameBuffer` array which you can do with the help of the [`readBytes()`](https://processing.org/reference/libraries/serial/Serial_readBytes_.html) method that returns the number of bytes read.
213+
The first thing you can do inside this method is to update the timestamp when the last data was read. This is to detect and recover from a connection timeout. Then read the bytes from the `frameBuffer` array which you can do with the help of the [`readBytes()`](https://processing.org/reference/libraries/serial/Serial_readBytes_.html) method that returns the number of bytes read.
214214

215215
```java
216216
lastUpdate = millis();
@@ -240,7 +240,7 @@ while (bb.hasRemaining()) {
240240
}
241241
```
242242

243-
Once all the pixels have been updated, you need to tell the sketch to redraw the image. Additionally we send an acknowledgement back to the arduino sketch to ask it to send the pixels for the next frame. We update the image with `updatePixels()` and write `1` to the serial port for the acknowledgement.
243+
Once all the pixels have been updated, you need to tell the sketch to redraw the image. Additionally, you can send an acknowledgement back to the arduino sketch to ask it to send the pixels for the next frame. You can update the image with `updatePixels()` and write `1` to the serial port for the acknowledgement.
244244

245245
```cpp
246246
myImage.updatePixels();
@@ -255,13 +255,13 @@ myPort.write(1);
255255

256256
### 5. Upload the Sketch
257257

258-
Select the right serial port on your IDE and upload the Arduino sketch to your H7. After a successful upload, run the `CameraViewer.pde` sketch in Processing. You should be able to see the rendered camera output on the Processing canvas.
258+
Select the right serial port on your IDE and upload the Arduino sketch to your Portenta H7. After a successful upload, run the `CameraViewer.pde` sketch in Processing. You should be able to see the rendered camera output on the Processing canvas.
259259

260260
![Camera output on Processing](assets/vs_ard_frames_captured.png)
261261

262262
## Conclusion
263263

264-
In this tutorial you learnt how to capture the frames from your Vision Shield's Camera and to visualize the frames through Processing. This knowledge can be useful for you to build and experiment simple computer vision applications for both outdoor and indoor environments.
264+
In this tutorial you learnt how to capture the frames from your Portenta Vision Shield's Camera and to visualize the frames through Processing. This knowledge can be useful for you to build and experiment simple computer vision applications for both outdoor and indoor environments.
265265

266266
### Complete Sketch
267267
The `CaptureRawBytes.ino` Sketch.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /