Easily Send Images to OpenCV

So, it’s been asked how to transmit video from the OpenMV Cam to the PC easily. Here’s one way using RTSP with any OpenMV Cam that has WiFi support.

  1. Run the RSTP example on your OpenMV Cam. Either via ethernet or USB is fine.
  2. Install OpenCV Python and run the following code:
# Demo Script

import cv2

# Replace 'your_rtsp_url_here' with the actual RTSP URL of your camera
rtsp_url = 'rtsp://192.168.xxx.xxx:554'

# Create a VideoCapture object
cap = cv2.VideoCapture(rtsp_url)

while True:
    # Read a frame from the stream
    ret, frame = cap.read()

    if not ret:
        print("Error reading frame from the stream.")
        break

    # Display the frame
    cv2.imshow('RTSP Stream', frame)

    # Press 'q' to exit the loop
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the VideoCapture and close the window
cap.release()
cv2.destroyAllWindows()

And you should see video from your OpenMV Cam.

Congratulations! Your OpenMV Cam can now do what you’d normally buy an IP Webcam for. Thanks to the OV5640 support you can also stream 1080p images.

Aside, at a previous employer I had to interface our computer system to IP cameras. While the code on the PC side was easy… the amount of setup on the camera side to get this working was quite painful. You have to configure the IP camera via a webgui that runs on the camera. Of course, you don’t know the camera IP address and if it’s dynamic or static when you get a brand new camera… which makes this much more painful. And then… add trying to configure it on a DHCP network in the office with 1000s of devices. Eventually you end up having to make a private ethernet network with a private DHCP server or static IP network to build these things quickly.