When using OPENCV to read video for processing, the error is as follows:
Gray =cv2.cvtcolor (Frame,cv2. Color_bgr2gray) Cv2.error:.. \.. \.. \opencv-3.1.0\modules\imgproc\src\color.cpp:7456:error: ( -215) SCN ==3 | | SCN = 4 in function Cv::ipp_cvtcolor
My original processing of the code did not judge whether the video processing completed, so after adding to the reading of the video frame and read the completion of the judgment, the problem solved.
Attached code:
Def readvideo ():
#cap = Cv2. Videocapture ("Fenlei.mp4")
#cap = Cv2. Videocapture ("Lisaru.mp4")
cap = Cv2. Videocapture ("Susuan.mp4")
while (cap.isopened ()):
ret, frame = Cap.read ()
#这里必须加上判断视频是否读取结束的判断, Otherwise, there was a problem playing to the last frame.
if ret = = True:
#gray = Cv2.cvtcolor (frame, cv2. Color_bgr2gray)
#gray = Cv2.cvtcolor (FRAME,CV2). Color_bgr2gray)
#cv2. Imshow ("Frame", gray)
cv2.imshow ("frame", frame)
else:
break
# Because the video is 10 frames per second, so each frame waits for 100ms
if cv2.waitkey & 0xFF = = Ord (' q '):
break
cap.release ()
Cv2.destroyallwindows ()