In tools/rpc: Remove the desktop RPC library. · openmv/openmv@0d4a786 · GitHub , the rpc_usb_vcp_master is removed. If i need to transform image and imu data to raspberry pi through USB, which library should I use? Thank you very much
See the new OpenMV pip command line tool: GitHub - openmv/openmv-python: Python Library and CLI for communicating with OpenMV Cameras · GitHub
Here are examples of what you can do with the new v5.0.0 serial protocol: openmv-projects/tools at master · openmv/openmv-projects · GitHub
You can pretty much move any data you like back and forth between the camera and PC.
It’s completely better than what the RPC VCP was.
Thank you very much for super helpful answer.
Sample code in protocol manual page stream data slowly
from openmv.camera import Camera
import time
# The on-cam script above, stored as a string (or read from a file).
SCRIPT = open("frame_streamer_on_cam.py").read()
ts = time.monotonic_ns()
with Camera("/dev/ttyACM0", baudrate=921600) as cam:
cam.stop()
cam.exec(SCRIPT)
while True:
status = cam.read_status()
if not cam.has_channel("frame") or not status.get("frame"):
continue
h, w, size = cam._channel_shape(cam.get_channel(name="frame"))
if cam.channel_size("frame") < size:
continue
data = cam.channel_read("frame", size)
ts2 = time.monotonic_ns()
print('interval', (ts2 - ts)//1000000, 'ms')
ts = ts2
opemv side
import csi
import protocol
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.VGA)
csi0.framerate(10)
img = csi0.snapshot()
img_mv = memoryview(img.bytearray())
frame_ready = True
class FrameChannel:
def size(self):
return len(img_mv)
def shape(self):
return (img.height(), img.width(), len(img_mv))
def poll(self):
return frame_ready
def read(self, offset, size):
global frame_ready
end = offset + size
chunk = img_mv[offset:end]
if end >= len(img_mv):
frame_ready = False
return chunk
protocol.register(name="frame", backend=FrameChannel())
while True:
if not frame_ready:
img = csi0.snapshot()
img_mv = memoryview(img.bytearray())
frame_ready = True
host side get frame at a regular interval 649ms
Change read to readp
def readp(self, offset, size):
This uses a much faster version of the read command. However, it doesn’t work nicely on windows. Use mac or linux.
Also, disable acks in the Camera constructor. You can also disable crcbut, that doesn’t help much.
Disabling acks gives you the most speed boost. Then, use readp. Then, disabling crcs.
…
Note, you want read/crcs for windows. You can get away without acks as long as you handle exceptions.
Thank you so much for helping. By using readp() and ack=False, it is much faster on Raspberry Pi / Debian now.