OpenCV installation error. Need QR code scanning via Python

Discussion in 'UDOO QUAD' started by marklee, Feb 28, 2017.

  1. marklee

    marklee New Member

    Joined:
    Feb 28, 2017
    Messages:
    4
    Likes Received:
    0
    I need to do a project to scan QR codes and trigger a relay. I am using used the default image Ubuntu 14.04 but noticed OpenCV is not installed by default.
    I search around and tried but with no luck to get OpenCV 3.20 installed.

    Does anyone know the correct steps to installed or have a sample working python script to scan for QR codes. You help is much appreciated!
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
  3. marklee

    marklee New Member

    Joined:
    Feb 28, 2017
    Messages:
    4
    Likes Received:
    0
    i ran this and was able to import into python but somehow can't detect the video source.
    Anyone can help?

    sudo apt-get install libopencv-dev python-opencv

    Script:
    import numpy as np
    import cv2
    cap = cv2.VideoCapture(0)
    while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    # Display the resulting frame
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
    break
    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()

    Output:
    HIGHGUI ERROR: libv4l unable to ioctl S_FMT
    HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

    OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp, line 3737
    Traceback (most recent call last):
    File "test.py", line 11, in <module>
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Andrea Rovai likes this.
  5. marklee

    marklee New Member

    Joined:
    Feb 28, 2017
    Messages:
    4
    Likes Received:
    0
    Even this does not work.

    import numpy as np
    import cv2
    cap = cv2.VideoCapture(0)

    Error:
    HIGHGUI ERROR: libv4l unable to ioctl S_FMT
    HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

    And with UDOObuntu 2.0. Can't use it as a loopback device
    http://www.udoo.org/docs/Hardware_&_Accessories/UDOO_Camera_Module.html

    Looks like the camera is quite redundant if can't use the loopback. Any help ?
     

Share This Page