Python library and CLI for communicating with OpenMV cameras using Protocol V2.
pip install openmvFor video streaming support (requires pygame):
pip install openmv[gui]# Stream from default port (/dev/ttyACM0)
openmv
# Stream from specific port
openmv --port /dev/ttyACM1
# Run a custom script
openmv --script my_script.py
# Adjust display scale
openmv --scale 2openmv --infoopenmv --resetopenmv --bootopenmv --benchC- Capture screenshot tocapture.pngESC- Exit
from openmv import OMVCamera
# Connect to camera
with OMVCamera('/dev/ttyACM0') as camera:
# Get system info
info = camera.system_info()
print(f"Firmware: {info['firmware_version']}")
# Execute a script
camera.exec('''
import csi
csi0 = csi.CSI()
csi0.reset()
''')
# Read frames
camera.streaming(True)
while True:
if frame := camera.read_frame():
print(f"Frame: {frame['width']}x{frame['height']}")Main class for camera communication.
OMVCamera(
port, # Serial port (e.g., '/dev/ttyACM0')
baudrate=921600, # Serial baudrate
crc=True, # Enable CRC validation
seq=True, # Enable sequence number validation
ack=True, # Enable packet acknowledgment
events=True, # Enable event notifications
timeout=1.0, # Protocol timeout in seconds
max_retry=3, # Maximum retries
max_payload=4096, # Maximum payload size
)connect()/disconnect()- Manage connectionexec(script)- Execute a MicroPython scriptstop()- Stop the running scriptreset()- Reset the cameraboot()- Enter bootloader modestreaming(enable, raw=False, res=None)- Enable/disable video streamingread_frame()- Read a video frameread_stdout()- Read script outputread_status()- Poll channel statussystem_info()- Get camera system informationchannel_read(name)/channel_write(name, data)- Custom channel I/O
OMVPException- Base protocol exceptionOMVPTimeoutException- Timeout during communicationOMVPChecksumException- CRC validation failureOMVPSequenceException- Sequence number mismatch
- Python 3.8+
- pyserial
- numpy
- pygame (optional, for video streaming)
MIT License - Copyright (c) 2025 OpenMV, LLC.