Opencv3.0-python: Video processing Times wrong color.cpp:7456:error: ( -215) SCN = 3 | | SCN = 4 Solution

Source: Internet
Author: User

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 ()



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.