You must have:
cv::waitKey(0);
instead of:
system("pause");
The latter just doesn't work. OpenCV needs to pump messages to get the window displayed and updated, and inside that waitKey
function is all of the mechanism to do so.
As the documentation says, waitKey
only works if you have a HighGUI window open, so in your code, you probably need to do this:
cv::Mat image = cv::imread("F:/office_Renzym/test3.jpg",CV_LOAD_IMAGE_UNCHANGED);
if(image.empty())
{
cout<<"image not loaded";
}
else
{
cv::namedWindow( "test", CV_WINDOW_AUTOSIZE );
cv::imshow("test",image);
cv::waitKey(0);
}
In case there's a problem with the image format, you might try loading like this:
cv::Mat image = cv::imread("F:/office_Renzym/test3.jpg",CV_LOAD_IMAGE_COLOR);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…