python 2.7 - error: <destination> color.cpp:3650: error: (-215) scn == 3 || scn == 4 in function cvtColor -
i'm trying record video using cv2.videowriter frames 2 channels rather 3 or 4, error describes. how can fix frames able part of video?
here's guts of function:
video = cv2.videocapture('video.mp4') fourcc = cv2.cv.cv_fourcc('d', 'i', 'v', 'x') out = cv2.videowriter("video.mov", int(fourcc), int(get_framerate(video)), (int(get_width(video)), int(get_height(video))), 0) while(video.isopened()): ret, frame = video.read() if (ret == true): grayframe = cv2.cvtcolor(frame, cv2.color_rgb2gray) ret, final_frame = cv2.threshold(grayframe, 65, 255, cv2.thresh_binary) cv2.imshow("frame", final_frame) out.write(final_frame) else: break if cv2.waitkey(10) == 27: cv2.destroyallwindows() break video.release() out.release() return
the image showing, when reaches out.write, spits out error:
error: /tmp/opencv20150506-38415-u2kidu/opencv- 2.4.11/modules/imgproc/src/color.cpp:3650: error:(-215) scn == 3 || scn == 4 in function cvtcolor
i know image 2 channels, , need 3 or 4 channels, don't know how fix it.
Comments
Post a Comment