0

I'm working on an Udoo trying to get the camera to take a picture that I can manipulate inside Python.

So far, the camera works with

gst-launch-1.0 imxv4l2videosrc ! imxipuvideosink

I can also take a single picture with

gst-launch-1.0 imxv4l2videosrc num-buffers=1 ! video/x-raw ! jpegenc ! filesink location=output.jpg

From here it seems like you can read straight from a gstreamer stream in Python with OpenCV.

Here is my python code:

import cv2
cam = cv2.VideoCapture("imxv4l2videosrc ! video/x-raw ! appsink")
ret, image = cam.read()

However, ret is False, and image is nothing.

Some places say this only works with OpenCV 3.0+, and others say 2.4.x, but I can't seem to find an actual answer to what version it works on.

If I need to update to OpenCV 3.0, which part to I update? I downloaded OpenCV via the apt repositories under the package python-opencv. So do I need to update Python? Can I just build OpenCV from source, and Python will automatically be using the newest version? I'm so confused.

Community
  • 1
  • 1
justynnuff
  • 461
  • 1
  • 6
  • 20

1 Answers1

1

The Ubuntu/Debian version is old 2.4.x, to get the last one you need to compile it from source.

Here two tutorials on how to do that:

  1. https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.html#installing-opencv-from-source
  2. http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/

The first is for Python 2.7 on Fedora, the second for Python 3.4 on Ubuntu.

Ceppo93
  • 1,026
  • 10
  • 11
  • 1
    I cross referenced both your links and got OpenCV with Python 2.7 running on an Udoo Dual. In case anyone lands here from a search, I posted on the Udoo forums: http://www.udoo.org/forum/threads/using-udoo-camera-with-opencvs-videocapture-class-2-0.6130/#post-23716 – justynnuff Nov 30 '16 at 07:30