error: (-215) scn == 3 || scn == 4 in function cv::ipp_cvtColor [closed]

asked 2016-03-21 16:24:42 -0500

Giorgos_ts gravatar image

I am trying to use following code :

import numpy as np

import cv2


ret, old_frame =

old_gray = cv2.cvtColor(old_frame, cv2.COLOR_BGR2GRAY)

And I end up with following error :

error: (-215) scn == 3 || scn == 4 in function cv::ipp_cvtColor

What could be the cause ? If i change the input of cap from .avi file to 0 (default camera) the programm works fine. Any suggestions? Thanks in advance !

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-04 02:36:37.501414



can it be, your video is grayscale encoded already ?

berak gravatar imageberak ( 2016-03-21 16:48:17 -0500 )edit

Is the avi encoded in bayer or something?

Tetragramm gravatar imageTetragramm ( 2016-03-21 17:41:18 -0500 )edit

I get this same error when my webcam crashes and stops supplying video. Are you certain that you are getting good data from your avi file?

csp256 gravatar imagecsp256 ( 2016-03-21 20:15:04 -0500 )edit

How can i check if the video is encoded ? I happens with all videos not only with one particular .

Giorgos_ts gravatar imageGiorgos_ts ( 2016-03-22 07:22:25 -0500 )edit

Read a single frame and print out all of the information about it. For example, after your .read() do this:

std::cout<<old_frame.rows<<" "<old_frame.cols<<" "<<old_frame.channels<<"\n";

The first three values are the size. If the rows or cols don't match your video size, there's a problem. If cn is not three or four, then it's not a normal color space.

Go ahead and do that, then share the results. If it has the proper number of rows and col, do an imwrite to a .png file and add it to your question so we can look at it and see what's going on.

Tetragramm gravatar imageTetragramm ( 2016-03-22 15:44:49 -0500 )edit