1. 程式人生 > >用vs2017+opencv3.4讀取圖片

用vs2017+opencv3.4讀取圖片

話不多說,直接看程式碼

#include "opencv2/imgcodecs.hpp";
#include "opencv2/highgui.hpp";
#include "opencv2/imgproc.hpp";
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
Mat src, src_gray, dstimage, m, dst_Canny;
int main()
{
	string rootH = "../../DemoPic/";
	string fileName = "1";//更換圖片
	fileName += ".jpg";
	string root = rootH + fileName;
	src = imread(root);//讀圖
	if (src.empty())
	{
		cout << "Can't find it!" << endl;
		return -1;
	}
	namedWindow("原影象", 0);
	imshow("原影象", src);
	waitKey();
	return 0;
}