OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv:: cvtColor, file ..\..\..\..\opencv\modules\imgproc\src\color.cpp, line 3737

前端 未结 1 414
Happy的楠姐
Happy的楠姐 2020-12-07 02:11

Hi I am trying to run this sample code from OpenCV:

#include \"opencv2\\opencv.hpp\"

using namespace cv;

int main(int, char**)
{
    VideoCapture cap(0);          


        
相关标签:
1条回答
  • 2020-12-07 02:16

    From the conversation in the comments to the question, we saw that VideoCapture gives frame in grayscale. So the call to cvtColor caused the crash.

    ...
    Mat frame;
    cap >> frame; // frame is already CV_8UC1
    //cvtColor(frame, edges, CV_BGR2GRAY); // so don't to convert here, or crash!
    edges = frame.clone(); 
    ...
    
    0 讨论(0)
提交回复
热议问题