error: (-215) scn == 3 || scn == 4 in function cv::ipp_cvtColor [closed]
I am trying to use following code :
import numpy as np
import cv2
cap=cv2.VideoCapture('video.avi')
ret, old_frame = cap.read()
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 !
can it be, your video is grayscale encoded already ?
Is the avi encoded in bayer or something?
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?
How can i check if the video is encoded ? I happens with all videos not only with one particular .
Read a single frame and print out all of the information about it. For example, after your .read() do this:
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.