Ask Your Question

Revision history [back]

beginner errors with Raspberry PI / Opencv / Python

  • I've installed today opencv 2.4.10
  • I'm using some standard code from the tutorial:

    import numpy as np import sys sys.path.append('/usr/local/lib/python2.7/site-packages')

    import cv2
    
    cap = cv2.VideoCapture(0)
    
        # 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)
    
    #cv2.imwrite("I2.jpg",img)
    
    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()
    

*

  • I'm getting the following error messages:

    OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/pi/opencv-2.4.10/modules/imgproc/src/color.cpp, line 3739 Traceback (most recent call last): File "I2_video.py", line 14, in <module> gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.error: /home/pi/opencv-2.4.10/modules/imgproc/src/color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cvtColor