我在linux终端(linux中的c++)中编译了以下代码,并使用OpenCv 3.3
在服务器上以无符号字符*的形式显示图片,我将其转换为cv::Mat,如下所示:
Mat charToMat(unsigned char * bytes, int width, int height){
return Mat(height, width, CV_8UC3, bytes);
}
然后我尝试了两种方法从cv::Mat转换为IplImage*,但在每种情况下,都会出现分段错误。
单程:
int * ft(Mat ft, int width, int height, int countA4) {
sourceImg = cvCreateImage(cvSize(ft.cols, ft.rows), 8, 3);
IplImage im = ft;
cvCopy(&im, sourceImg); // Segmentation Fault
}
双向:
int * ft (Mat ft, int width, int height, int countA4) {
IplImage im = ft;
sourceImg = cvCloneImage(&im);// Segmentation Fault
}
如果有人知道解决办法?
最佳答案
我认为你把Mat改成Iplimage是个问题。
我想试试这样的:
int * ft (Mat ft, int width, int height, int countA4) {
IplImage* img = new IplImage(ft);
sourceImg = cvCloneImage(im);
}
有关更多信息,请尝试此Converting cv::Mat to IplImage*