Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenMV Python

Python library and CLI for communicating with OpenMV cameras using Protocol V2.
Python library and CLI for communicating with OpenMV cameras.

## Installation

Expand All @@ -20,7 +20,7 @@ openmv --port /dev/ttyACM0
openmv --port /dev/ttyACM0 --script my_script.py

# Adjust display scale (default is 4x)
openmv --port /dev/ttyACM0 --scale 2
openmv --port /dev/ttyACM0 --scale 5

# Run throughput benchmark
openmv --port /dev/ttyACM0 --bench
Expand All @@ -47,6 +47,7 @@ openmv --port /dev/ttyACM0 --channel ticks
| `--scale N` | 4 | Display scaling factor |
| `--poll MS` | 4 | Poll rate in milliseconds |
| `--bench` | False | Run throughput benchmark mode |
| `--raw` | False | Enable raw streaming mode |
| `--timeout SEC` | 1.0 | Protocol timeout in seconds |
| `--baudrate N` | 921600 | Serial baudrate |
| `--firmware FILE` | None | Firmware ELF file for profiler symbol resolution |
Expand Down Expand Up @@ -101,7 +102,7 @@ with Camera('/dev/ttyACM0') as camera:

# Execute script and enable streaming
camera.exec(script)
camera.streaming(True, raw=False, res=(512, 512))
camera.streaming(True)

# Read frames and output
while True:
Expand Down Expand Up @@ -152,9 +153,7 @@ with Camera('/dev/ttyACM0') as camera:
print(f"Ticks: {data.decode()}")
```

## API Reference

Full API documentation: [docs/api.md](https://github.com/openmv/openmv-python/blob/master/docs/api.md)
## Quick Reference

### Camera

Expand Down Expand Up @@ -183,7 +182,7 @@ Camera(
| `is_connected()` | Check connection status |
| `exec(script)` | Execute a MicroPython script |
| `stop()` | Stop the running script |
| `streaming(enable, raw=False, res=None)` | Enable/disable video streaming |
| `streaming(enable, raw=False, resolution=None)` | Enable/disable video streaming |
| `read_frame()` | Read video frame → `{width, height, format, depth, data, raw_size}` |
| `read_stdout()` | Read script output text |
| `read_status()` | Poll channel status → `{channel_name: bool, ...}` |
Expand Down Expand Up @@ -212,6 +211,10 @@ Camera(
| `ChecksumException` | CRC validation failure |
| `SequenceException` | Sequence number mismatch |

## API documentation

Full API documentation: [docs/api.md](https://github.com/openmv/openmv-python/blob/master/docs/api.md)

## Requirements

- Python 3.8+
Expand Down
6 changes: 3 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ camera.stop()

## Video Streaming

### streaming(enable, raw=False, res=None)
### streaming(enable, raw=False, resolution=None)

Enable or disable video streaming.

```python
camera.streaming(True, raw=False, res=(512, 512))
camera.streaming(True, raw=False, resolution=(512, 512))
```

#### Parameters
Expand All @@ -146,7 +146,7 @@ camera.streaming(True, raw=False, res=(512, 512))
|-----------|------|---------|-------------|
| `enable` | bool | required | Enable or disable streaming |
| `raw` | bool | False | Enable raw streaming mode |
| `res` | tuple | None | Resolution tuple (width, height) for raw mode |
| `resolution` | tuple | None | Resolution tuple (width, height) for raw mode |

---

Expand Down
4 changes: 2 additions & 2 deletions src/openmv/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ def exec(self, script):
self._channel_ioctl(stdin_id, ChannelIOCTL.STDIN_EXEC)

@retry_if_failed
def streaming(self, enable, raw=False, res=None):
def streaming(self, enable, raw=False, resolution=None):
"""Enable or disable streaming"""
stream_id = self.get_channel(name="stream")
if raw:
self._channel_ioctl(stream_id, ChannelIOCTL.STREAM_RAW_CFG, 'II', *res)
self._channel_ioctl(stream_id, ChannelIOCTL.STREAM_RAW_CFG, 'II', *resolution)
self._channel_ioctl(stream_id, ChannelIOCTL.STREAM_RAW_CTRL, 'I', raw)
self._channel_ioctl(stream_id, ChannelIOCTL.STREAM_CTRL, 'I', enable)

Expand Down
2 changes: 1 addition & 1 deletion src/openmv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def main():

# Execute script
camera.exec(script)
camera.streaming(True, raw=False, res=(512, 512))
camera.streaming(True, raw=False, resolution=(512, 512))
logging.info("Script executed, starting display...")

while True:
Expand Down