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

前端 未结 4 1214
半阙折子戏
半阙折子戏 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:48

    If you are getting this error on a raspberry PI with PI camera, try running this command first:

    sudo modprobe bcm2835-v4l2
    
    0 讨论(0)
  • 2020-12-09 02:50

    1st print ret. If it is showing false then your image is not taken properly. If it is showing True Try this command - sudo modprobe bcm2835-v4l2 Or in your /etc/modules file add bcm2835-v4l2 at the bottom.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-09 03:13

    I had this problem and couldn't find a solution, but on the web, it was working. My solution was almost funny - you can't have two streams. I turned off the web stream and then it was fine!

    0 讨论(0)
提交回复
热议问题