怎么在mfc中调用opencv函数打开图像
1个回答
展开全部
// 打开图片文件
CString strFilter = "所有文件(*.*)|*.*|";
CFileDialog dlg(TRUE, NULL, NULL, NULL, strFilter,this);
if(!dlg.DoModal() == IDOK)
return;
CString strFileName = dlg.GetPathName();
CFileStatus status;
if(!CFile::GetStatus(strFileName,status))
{
MessageBox(strFileName + "不存在", "信息提示", MB_OK);
return;
}
IplImage* img = cvLoadImage(strFileName.GetBuffer(0));
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(img);
cvDestroyWindow("Example1");
CString strFilter = "所有文件(*.*)|*.*|";
CFileDialog dlg(TRUE, NULL, NULL, NULL, strFilter,this);
if(!dlg.DoModal() == IDOK)
return;
CString strFileName = dlg.GetPathName();
CFileStatus status;
if(!CFile::GetStatus(strFileName,status))
{
MessageBox(strFileName + "不存在", "信息提示", MB_OK);
return;
}
IplImage* img = cvLoadImage(strFileName.GetBuffer(0));
cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(img);
cvDestroyWindow("Example1");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询