Why does assertion fail here

后端 未结 2 1054
萌比男神i
萌比男神i 2021-01-28 03:27

Why does the assertion fail here when i create a CvMat *? It does not happen with an image i load in cv::Mat using a pointer.

    struct RGB { unsig         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 03:51

    Because sizeof(RGB) != sizeof(float), which is what you filled the matrix with here:

     CvMat* mat = cvCreateMat(300,300,CV_32FC1); 
    

    CV_32FC1 means 1 component, 32-bit floating point. You probably want CV_8UC3. See here or another OpenCV reference.

提交回复
热议问题