opencv error color.cpp

asked 2015-05-11 11:07:16 -0500

updated 2015-05-11 11:10:49 -0500

berak gravatar image

Hello community,

I'm using opencv library to get a flow of movement that triggers a camera.capture() function. I need a filmename.jpg, at the instant of movement.

The test code, i'm using /opencv/samples/lk_track.py. But i got this error.

Lucas-Kanade tracker
====================

Lucas-Kanade sparse optical flow demo. Uses goodFeaturesToTrack
for track initialization and back-tracking for match verification
between frames.

Usage
-----
lk_track.py [<video_source>]


Keys
----
ESC - exit

Xlib:  extension "RANDR" missing on display ":0.0".

(lk_track:3540): GLib-GObject-WARNING **: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialised
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/pi/poli/code/opencv-master/modules/imgproc/src/color.cpp, line 7564
Traceback (most recent call last):
  File "lk_track.py", line 101, in <module>
    main()
  File "lk_track.py", line 97, in main
    App(video_src).run()
  File "lk_track.py", line 47, in run
    frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: /home/pi/poli/code/opencv-master/modules/imgproc/src/color.cpp:7564: error: (-215) scn == 3 || scn == 4 in function cvtColor
edit retag flag offensive close merge delete

Comments

2

cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) <-- you're trying to to convert an image , that is either empty or not colour

try to check if ret is True and frame != none in line 46.

berak gravatar imageberak ( 2015-05-11 11:09:56 -0500 )edit

thank.

I need detect movement, and take a picture, at the instant of movement you can help me?

Gavilac gravatar imageGavilac ( 2015-05-11 13:42:03 -0500 )edit