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
-`sensor.snapshot()` lets you take a picture and return the image so you can save it, stream it or process it.
196
+
-`sensor.snapshot()` lets you take a picture and return the image so you can save it, stream it or process it.
197
+
198
+
### Camera
199
+
200
+
The Portenta Vision Shields's main feature is its onboard camera, based on the HM01B0 ultralow power CMOS image sensor. It is perfect for Machine Learning applications such as object detection, image classification, machine/computer vision, robotics, IoT, and more.
201
+
202
+

203
+
204
+
#### Main Camera Features
205
+
206
+
- Ultra-Low-Power Image Sensor designed for always-on vision devices and applications
- Programmable black level calibration target, frame size, frame rate, exposure, analog gain (up to 8x) and digital gain (up to 4x)
209
+
- Automatic exposure and gain control loop with support for 50 Hz / 60 Hz flicker avoidance
210
+
- Motion Detection circuit with programmable ROI and detection threshold with digital output to serve as an interrupt
211
+
212
+
#### Supported Resolutions
213
+
214
+
- QQVGA (160x120) at 15, 30, 60 and 120 FPS
215
+
- QVGA (320x240) at 15, 30 and 60 FPS
216
+
- B320X320 (320x320) at 15, 30 and 45 FPS
217
+
218
+
#### Power Consumption
219
+
- < 1.1 mW QQVGA resolution at 30 FPS,
220
+
- < 2 mW QVGA resolution at 30 FPS
221
+
- < 4 mW QVGA resolution at 60 FPS
222
+
223
+
The Vision Shield is primarily intended to be used with the OpenMV MicroPython ecosystem. So, it's recommended to use this IDE for machine vision applications.
224
+
225
+
#### Snapshot Example
226
+
227
+
The example code below lets you take a picture and save it on the Portenta H7 local storage or in a Micro SD card as `example.jpg`.
228
+
229
+
```python
230
+
import sensor
231
+
import time
232
+
import machine
233
+
234
+
sensor.reset() # Reset and initialize the sensor.
235
+
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
236
+
sensor.set_framesize(sensor.B320X320) # Set frame size to QVGA (320x240)
237
+
sensor.skip_frames(time=2000) # Wait for settings take effect.
238
+
239
+
led = machine.LED("LED_BLUE")
240
+
241
+
start = time.ticks_ms()
242
+
while time.ticks_diff(time.ticks_ms(), start) <3000:
243
+
sensor.snapshot()
244
+
led.toggle()
245
+
246
+
led.off()
247
+
248
+
img = sensor.snapshot()
249
+
img.save("example.jpg") # or "example.bmp" (or others)
250
+
251
+
raise (Exception("Please reset the camera to see the new file."))
252
+
```
253
+
254
+
***If a Micro SD card is inserted into the Vision Shield, the snapshot will be stored there***
255
+
256
+
After the snapshot is taken, reset the board by pressing the reset button and the image will be on the board storage drive.
257
+
258
+

259
+
260
+
#### Video Recording Example
261
+
262
+
The example code below lets you record a video and save it on the Portenta H7 local storage or in a Micro SD card as `example.mjpeg`.
263
+
264
+
```python
265
+
import sensor
266
+
import time
267
+
import mjpeg
268
+
import machine
269
+
270
+
sensor.reset() # Reset and initialize the sensor.
271
+
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
272
+
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
273
+
sensor.skip_frames(time=2000) # Wait for settings take effect.
274
+
275
+
led = machine.LED("LED_RED")
276
+
277
+
led.on()
278
+
m = mjpeg.Mjpeg("example.mjpeg")
279
+
280
+
clock = time.clock() # Create a clock object to track the FPS.
281
+
for i inrange(50):
282
+
clock.tick()
283
+
m.add_frame(sensor.snapshot())
284
+
print(clock.fps())
285
+
286
+
m.close()
287
+
led.off()
288
+
289
+
raise (Exception("Please reset the camera to see the new file."))
290
+
```
291
+
292
+

0 commit comments