Using UDOO camera with OpenCV's VideoCapture class 2.0

Discussion in 'General Programming Discussion' started by Justyn Bell, Nov 17, 2016.

  1. Justyn Bell

    Justyn Bell New Member

    Joined:
    Nov 15, 2016
    Messages:
    9
    Likes Received:
    3
    Hi,
    I would like to use the Udoo camera with OpenCV and Python. Essentially, I'm getting the exact same problem, and looking for a solution for the exact same problem as in this thread:
    http://www.udoo.org/forum/threads/using-udoo-camera-with-opencvs-videocapture-class.1807/#post-11682

    It looks like the solution was to use the loopback device so I can use the Udoo's camera as a normal webcam.

    Oh but wait... it's been deprecated in UDOObuntu 2.1:
    http://www.udoo.org/docs/Hardware_&_Accessories/UDOO_Camera_Module.html
    "Warning! This following Loopback Device section is deprecated since UDOObuntu 2.0. It is present only in UDOObuntu 1.0/1.1 versions.", and indeed I don't think the kernel module is present in my UDOObuntu build.

    Is there a way to access the Udoo camera in python/openCV/like a normal USB webcam in UDOObuntu 2.1? Is a rollback the only solution?

    --
    Justyn
     
  2. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
  3. Justyn Bell

    Justyn Bell New Member

    Joined:
    Nov 15, 2016
    Messages:
    9
    Likes Received:
    3
    If anyone stumbles upon this, I got video/image capture working in OpenCV by building OpenCV from source (3.1 at this time), with the following cmake flags

    -D CMAKE_CXX_FLAGS="-Wa,-mimplicit-it=thumb" -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON

    Obviously, there's some dependencies there, such as gtk2.0.

    Then the following Python code works:

    import cv2

    camera = cv2.VideoCapture(0)

    while True:
    return_value,image = camera.read()
    gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
    cv2.imshow('image',gray)
    if cv2.waitKey(1)& 0xFF == ord('s'):
    cv2.imwrite('test.jpg',image)
    break
    camera.release()
    cv2.destroyAllWindows()
     
    modjo and waltervl like this.

Share This Page