I have the following code compiled in linux terminal (c++ in linux) and am using OpenCv 3.3 On the server comes in picture in the form of unsigned char *, I convert it to cv::Mat as follows:
Mat charToMat(unsigned char * bytes, int width, int height){
return Mat(height, width, CV_8UC3, bytes);
}
Then I tried 2 ways to convert from cv::Mat to IplImage *, but in each case, the Segmentation Fault occurs.
1 way:
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 way:
int * ft (Mat ft, int width, int height, int countA4) {
IplImage im = ft;
sourceImg = cvCloneImage(&im);// Segmentation Fault
}
If anybody knows the solution?