openmv/usr/examples/mjpeg.py
Kwabena W. Agyeman 5316b26d83 Added a new mjpeg module for Mjpeg support.
The built-in mjpeg module allows you to record videos seamlessly. It
will automatically compress the frame buffer using the extra space in the
main ram. So... you don't have to pass it jpeg images. Gets 7 FPS at
320x240 while connected to the computer too (it has to compress the
frame twice in this situation).

Anyway, the module work like Gif.
2016-03-05 20:03:48 -05:00

32 lines
863 B
Python

# Mjpeg recording example:
#
# You can use your OpenMV Cam to record mjpeg files. You can either feed the
# recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished
# recording an Mjpeg file you can use VLC to play it. If you're on Ubuntu then
# the built-in video player will work too.
import sensor, image, time, mjpeg
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565) # you can also use grayscale
# Warm up the cam
for i in range(10):
sensor.snapshot()
# FPS clock
clock = time.clock()
mjpeg = mjpeg.Mjpeg("/test.mjpeg") # video setup to use current resolution
for i in range(300):
clock.tick()
img = sensor.snapshot()
mjpeg.add_frame(img)
# Print FPS.
# Note: Actual FPS is higher, the IDE slows down streaming.
print(clock.fps())
mjpeg.close(clock.fps())
print("done")