OpenCV4.8及OpenCV4.4 VS2019MFC编程在调用imred()函数时,debug X64试运行没问题。
release X64试运行时出现下面错误。
void CEasyPictureDlg::OnBnClickedOpen()
{CFileDialog fdlg(TRUE, NULL, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("All files(*.*)|*.*||"));if (fdlg.DoModal() == IDOK){m_Path = fdlg.GetPathName();m_strEx = fdlg.GetFileExt();m_strName = fdlg.GetFileName();m_Path.ReleaseBuffer();m_strEx.ReleaseBuffer();m_strName.ReleaseBuffer();if (m_strEx == "BMP" || m_strEx == "bmp" || m_strEx == "dib" || m_strEx == "TIF" || m_strEx == "tif" || m_strEx == "tiff" || m_strEx == "PNG" || m_strEx == "png"|| m_strEx == "jpg" || m_strEx == "JPG" || m_strEx == "jpe" || m_strEx == "jpeg" || m_strEx == "jp2" || m_strEx == "webp" || m_strEx == "avif" || m_strEx == "pbm"|| m_strEx == "pgm" || m_strEx == "ppm" || m_strEx == "pxm" || m_strEx == "pnm" || m_strEx == "pfm" || m_strEx == "sr" || m_strEx == "ras" || m_strEx == "exr"|| m_strEx == "hdr" || m_strEx == "pic"){m_str = CT2A(m_Path);src = imread(m_str);//src = imread("E:\\photo lib\\clip.png");dst[0] = dst[1] = src;if (src.empty())MessageBox(_T("打开图像文件失败!"));else{//fGlobalAngle = 0;Invalidate();}}else{MessageBox(_T("你要打开的文件不是本程序支持的图像文件!"), MB_OK);}}}
无论是直接输入字符串或者使用字符串变量,一旦调用imread()函数release X64试运行时就会出错,而debug X64试运行则不会出错,编程平台为Win7。