Ask Your Question
1

Why this error in cvtColor function happens?

asked 2013-04-01 01:13:11 -0500

kirk-777 gravatar image

Why I have error in python script? I have python 2.6.6 installed on Centos 6.4 x64

 [root@--- ~]# python test.py 1.mp4
    OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /root/opencv-2.4.4/modules/imgproc/src/color.cpp, line 3326
    Traceback (most recent call last):
      File "test.py", line 231, in <module>
        print process(fileName)
      File "test.py", line 198, in process
        detector = Detector(frame)
      File "test.py", line 127, in __init__
        self._initAvg(frame)
      File "test.py", line 171, in _initAvg
        f = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.error: /root/opencv-2.4.4/modules/imgproc/src/color.cpp:3326: error: (-215) scn == 3 || scn == 4 in function cvtColor

link to 1.mp4

link on my script

edit retag flag offensive close merge delete

Comments

I'm facing a similar issue. Oddly the same code works with ver2.43 and not with ver2.47. Could you please write about how you resolved it?

UtkarshV gravatar imageUtkarshV ( 2014-01-04 23:42:53 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
4

answered 2013-04-01 03:40:03 -0500

Andrey Pavlenko gravatar image

This assertion failure massage usually means that you're trying to convert an empty image. Add a check for empty image before you start processing it.

edit flag offensive delete link more

Comments

Thanks. Was facing something similar. This fixed my problem.

UtkarshV gravatar imageUtkarshV ( 2014-01-05 00:16:52 -0500 )edit
0

answered 2015-04-19 11:33:01 -0500

I noticed that I should use / instead of \ for the windows path. Thank you for the previous answer that alerted for a possible empty image.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-01 01:13:11 -0500

Seen: 19,167 times

Last updated: Apr 01 '13