Skip to content

Commit c272aab

Browse files
authored
Merge pull request #10 from openmv/update_readme
misc: Update readme.
2 parents 406af92 + b42a2a7 commit c272aab

File tree

1 file changed

+68
-56
lines changed

1 file changed

+68
-56
lines changed

README.md

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,22 @@ Python library and CLI for communicating with OpenMV cameras using Protocol V2.
88
pip install openmv
99
```
1010

11-
For video streaming support (requires pygame):
12-
13-
```bash
14-
pip install openmv[gui]
15-
```
16-
1711
## CLI Usage
1812

1913
### Stream Video
2014

2115
```bash
22-
# Stream from default port (/dev/ttyACM0)
23-
openmv
24-
2516
# Stream from specific port
26-
openmv --port /dev/ttyACM1
17+
openmv --port /dev/ttyACM0
2718

2819
# Run a custom script
2920
openmv --script my_script.py
3021

3122
# Adjust display scale
3223
openmv --scale 2
33-
```
34-
35-
### Camera Info
36-
37-
```bash
38-
openmv --info
39-
```
40-
41-
### Reset Camera
42-
43-
```bash
44-
openmv --reset
45-
```
4624

47-
### Enter Bootloader
48-
49-
```bash
50-
openmv --boot
25+
# Enable firmware symbols
26+
openmv --firmware path/to/firmware.elf
5127
```
5228

5329
### Benchmark Mode
@@ -58,42 +34,56 @@ openmv --bench
5834

5935
### Controls (Stream Mode)
6036

61-
- `C` - Capture screenshot to `capture.png`
6237
- `ESC` - Exit
38+
- `P` - Cycle profiler overlay (Off → Performance → Events)
39+
- `M` - Toggle profiler mode (Inclusive ↔ Exclusive)
40+
- `R` - Reset profiler counters
6341

6442
## Library Usage
6543

6644
```python
67-
from openmv import OMVCamera
45+
from openmv import Camera
46+
47+
script = """
48+
import csi, time
6849
69-
# Connect to camera
70-
with OMVCamera('/dev/ttyACM0') as camera:
71-
# Get system info
72-
info = camera.system_info()
73-
print(f"Firmware: {info['firmware_version']}")
74-
75-
# Execute a script
76-
camera.exec('''
77-
import csi
7850
csi0 = csi.CSI()
7951
csi0.reset()
80-
''')
52+
csi0.pixformat(csi.RGB565)
53+
csi0.framesize(csi.QVGA)
54+
clock = time.clock()
55+
while True:
56+
clock.tick()
57+
img = csi0.snapshot()
58+
print(clock.fps(), "FPS")
59+
"""
60+
61+
# Connect to camera
62+
with Camera('/dev/ttyACM0') as camera:
63+
# Stop running script (if any)
64+
camera.stop()
65+
66+
# Execute script and enable streaming
67+
camera.exec(script)
68+
camera.streaming(True, raw=False, res=(512, 512))
8169

82-
# Read frames
83-
camera.streaming(True)
70+
# Read frames and output
8471
while True:
8572
if frame := camera.read_frame():
8673
print(f"Frame: {frame['width']}x{frame['height']}")
74+
75+
if text := camera.read_stdout():
76+
print(text, end='')
8777
```
8878

8979
## API Reference
9080

91-
### OMVCamera
81+
### Camera
9282

9383
Main class for camera communication.
9484

9585
```python
96-
OMVCamera(
86+
Camera(
9787
port, # Serial port (e.g., '/dev/ttyACM0')
9888
baudrate=921600, # Serial baudrate
9989
crc=True, # Enable CRC validation
@@ -103,36 +93,58 @@ OMVCamera(
10393
timeout=1.0, # Protocol timeout in seconds
10494
max_retry=3, # Maximum retries
10595
max_payload=4096, # Maximum payload size
96+
drop_rate=0.0, # Packet drop simulation (testing only)
10697
)
10798
```
10899

109100
#### Methods
110101

102+
**Connection Management:**
111103
- `connect()` / `disconnect()` - Manage connection
104+
- `is_connected()` - Check connection status
105+
106+
**Script Execution:**
112107
- `exec(script)` - Execute a MicroPython script
113108
- `stop()` - Stop the running script
114-
- `reset()` - Reset the camera
115-
- `boot()` - Enter bootloader mode
109+
110+
**Video Streaming:**
116111
- `streaming(enable, raw=False, res=None)` - Enable/disable video streaming
117-
- `read_frame()` - Read a video frame
118-
- `read_stdout()` - Read script output
119-
- `read_status()` - Poll channel status
112+
- `read_frame()` - Read a video frame (returns dict with width, height, format, depth, data, raw_size)
113+
114+
**Output and Status:**
115+
- `read_stdout()` - Read script output text
116+
- `read_status()` - Poll channel status (returns dict of channel readiness)
117+
118+
**Channel Operations:**
119+
- `has_channel(name)` - Check if a channel exists
120+
- `channel_read(name, size=None)` - Read data from a custom channel
121+
- `channel_write(name, data)` - Write data to a custom channel
122+
- `channel_size(name)` - Get size of available data in a channel
123+
124+
**Profiler (if available):**
125+
- `read_profile()` - Read profiler data
126+
- `profiler_mode(exclusive)` - Set profiler mode (inclusive/exclusive)
127+
- `profiler_reset(config=None)` - Reset profiler counters
128+
- `profiler_event(counter_num, event_id)` - Configure event counter
129+
130+
**System Information:**
120131
- `system_info()` - Get camera system information
121-
- `channel_read(name)` / `channel_write(name, data)` - Custom channel I/O
132+
- `host_stats()` / `device_stats()` - Get protocol statistics
122133

123134
### Exceptions
124135

125-
- `OMVPException` - Base protocol exception
126-
- `OMVPTimeoutException` - Timeout during communication
127-
- `OMVPChecksumException` - CRC validation failure
128-
- `OMVPSequenceException` - Sequence number mismatch
136+
- `OMVException` - Base protocol exception
137+
- `TimeoutException` - Timeout during communication
138+
- `ChecksumException` - CRC validation failure
139+
- `SequenceException` - Sequence number mismatch
129140

130141
## Requirements
131142

132143
- Python 3.8+
133-
- pyserial
134-
- numpy
135-
- pygame (optional, for video streaming)
144+
- pyserial >= 3.5
145+
- numpy >= 1.20.0
146+
- pygame >= 2.0.0
147+
- pyelftools
136148

137149
## License
138150

0 commit comments

Comments
 (0)