Python-OpenCV cv2 OpenCV Error: Assertion failed (scn == 3 || scn == 4) in unknown function, file ..\..\..\modules\imgproc\src\color.cpp

前端 未结 4 1213
半阙折子戏
半阙折子戏 2020-12-09 02:32

I am trying to learn contours in python using cv2.

I tried the following code given in a tutorial guide:

import cv2
import numpy as np
from matplotli         


        
4条回答
  •  有刺的猬
    2020-12-09 02:59

    It says your input image should have 3 or 4 channels before applying the function cv2.cvtColor.

    so check your image shape before applying the function by print im.shape. if the result is None type (most of the times, this is the problem), your image is not loaded correctly, most probably because your path is not correct.

    The point is that your image should have 3 dimensions, rows, columns and depth.

提交回复
热议问题