我是OpenCV的新手我试图在visual studio 2012中读取图像,但无法使用imshow
加载图像,但在使用cvLoadImage
时它可以正常工作。
当我执行以下代码时,它可以正常工作但
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
using namespace std;
using namespace cv;
//char key;
int main()
{
IplImage *image = cvLoadImage("test1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
cvNamedWindow("hah", WINDOW_AUTOSIZE);
cvShowImage("hah", image);
waitKey(5000);
return 1;
}`
但是当我编写以下代码时,它会抛出异常并且图像不会渲染
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
using namespace std;
using namespace cv;
//char key;
int main()
{
Mat image = imread("test1.jpg");
namedWindow("My");
imshow("My", image);
waitKey(50000);
return 1;
}
我无法理解这是什么问题。