【发布时间】:2017-09-28 23:00:06
【问题描述】:
我在 linux 终端(linux 中的 c++)中编译了以下代码,并且正在使用 OpenCv 3.3 在服务器上以 unsigned char * 的形式传入图片,我将其转换为 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
}
2路:
int * ft (Mat ft, int width, int height, int countA4) {
IplImage im = ft;
sourceImg = cvCloneImage(&im);// Segmentation Fault
}
如果有人知道解决方案?
【问题讨论】:
标签: c++ linux opencv segmentation-fault