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 ?
     
  6. Zlatagor

    Zlatagor New Member

    Joined:
    Nov 25, 2022
    Messages:
    1
    Likes Received:
    0
    Did you attempt to install OpenCV using pip? If not, you can give it a try by typing "pip install opencv-python" in your terminal. This will likely install the most up-to-date version of OpenCV on your computer.
     
  7. Enmmabern

    Enmmabern New Member

    Joined:
    Mar 7, 2023
    Messages:
    1
    Likes Received:
    0
    Hey there! I'm new to this forum and saw your post about OpenCV installation errors. I feel your pain - I've been there before! Have you tried using Smart Engines SDK instead? It's an alternative that's super easy to install and use. Just Google it and follow the instructions.For QR code scanning in Python, I recommend checking out this script I found on GitHub. It's easy to understand and modify to fit your needs. Make sure to install the necessary dependencies before running it.If you still want to stick with OpenCV, I suggest checking out this tutorial on YouTube. It's super helpful and has step-by-step instructions that should help you get it installed correctly.
     

Share This Page