我正在尝试使用qtgui中的opencv函数将图像转换为canny图像。当我按下gui按钮将原始图像转换为canny时,程序在发布时崩溃,但在调试模式下显示错误R6010。
void MainWindow::edgeImage()
{
IplImage *image1 =cvLoadImage("Desert.jpg");
IplImage *Gray = cvCreateImage( cvGetSize(image1), IPL_DEPTH_8U, 1 );
cvCvtColor(image1, Gray, CV_RGB2GRAY);
IplImage *Edge = cvCreateImage( cvGetSize(image1), IPL_DEPTH_8U, 1 );
cvCanny( Gray, Edge, 10, 100 );
ui->label_2->setPixmap(QPixmap::fromImage(*IplImage2QImage(Edge)) ;
}
提前感谢您的
我对其完美工作的做了一些小改动
void MainWindow::edgeImage()
{
image =cvLoadImage(FileName.toLocal8Bit().data());
Gray = cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1 );
cvCvtColor(image, Gray, CV_RGB2GRAY);
canny= cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1 );
cvCanny(Gray,canny,50,150,3);
QImage imgCanny = QImage((const unsigned char*)canny->imageData,canny->width,canny->height,QImage::Format_Indexed8);
imgCanny.setPixel(0,0,qRgb(0,0,0));
ui->label_3->setPixmap(QPixmap::fromImage(imgCanny).scaled(ui->label_3->size()));
}