I built one project in Visual Studio 2017 in C++ language. This project is related to the motion analysis. In my project folder itself, I have the OpenCV folder it’s having the only bin, include, and lib files folder. I wrote the code like this. cv::imshow throws some error like this.
int Test()
{
try
{
cv::Mat image = cv::imread(“C:\Users\User\Desktop\photos\p1.jpg”);
if (!image.empty()) {
// Display the image in a window
//cv::imwrite("C:\\Users\\User\\Desktop\\Image\\Gowri.jpg", image);
cv::imshow("Image", image);
cv::waitKey(0);
cv::destroyAllWindows();
}
else
{
throw std::runtime_error("Error loading the image.");
}
}
catch (const std::exception& e)
{
// Handle OpenCV exception
CString errorMsg;
errorMsg.Format(_T("OpenCV Exception: %hs"), e.what());
AfxMessageBox(errorMsg, MB_ICONERROR);
}
return 0;
}
I had tried to rebuild the OpenCV using this command “C:\Program Files\Cmake\bin\cmake” -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON C:/Users/User/Desktop/FD6/FD6/OpenCV.
But Still, the error is not resolved. What can I do now? Please give me the suggestion to resolve this error.
-
Visual Studio 2017 version.
-
Windows 11 (64) bit.
-
Open CV 3.4.1 Version