[问题] QT使用OpenCV的资料型态转换

楼主: chuinzong (阿荣)   2019-05-30 17:04:17
开发平台(Platform): (Ex: Win10, Linux, ...)
Linux Ubuntu 16.04
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
GCC+QT
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
OpenCV4.0.0
问题(Question):
目前将Mat档案用Ref放置到function中,
将Mat转换至IplImage。
Mat src;
imshow("ShowSrc", src);
cvWaitKey();
IplImage* image= 0;
*image = IplImage(src);
可是IplImage却无法转换,
出现结果
the inferior stopped because it received a signal from the operating system.
Signal name: SIGSEGV
Signal meaning: Segmentation fault
去找寻此错误,有叙述可能是指标问题,imshow可以显示出图案,故是有值。
想知道问题出现在哪?
喂入的资料(Input):
Test.bmp 一张彩色图片
预期的正确结果(Expected Output):
可以显示其直方图
错误结果(Wrong Output):
the inferior stopped because it received a signal from the operating system.
Signal name: SIGSEGV
Signal meaning: Segmentation fault
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
void MainWindow::on_pushButton_clicked()
{
Mat cvInImg;
cvInImg = imread("Test.bmp");
GaussianBlur( cvInImg, cvInImg, Size(3,3), 0);
Mat cvInHSVImg;
Mat acvChannel[3];
cvtColor(cvInImg,cvInHSVImg,CV_BGR2HSV);
split(cvInHSVImg,acvChannel);
//imshow("OutputEdgeImg",cvEdgeImg);
HistogramDisplay(acvChannel[0]);
...
}
void MainWindow::HistogramDisplay(Mat &src)
{
IplImage* image= 0;
IplImage* imgHistogram = 0;
IplImage* gray= 0;
CvHistogram* hist;
imshow("ShowSrc", src);
cvWaitKey();
*image = IplImage(src);
//size of the histogram -1D histogram
int bins = 256;
int hsize[] = {bins};
...
}
补充说明(Supplement):
作者: nh60211as   2019-05-30 17:25:00
刚刚试不能这样叫,用https://stackoverflow.com/a/15047921

Links booklink

Contact Us: admin [ a t ] ucptt.com