当前位置:网站首页>Opencv personal notes

Opencv personal notes

2022-07-07 16:30:00 qq_ fifty-seven million two hundred and fifty-one thousand thre

One 、 Show how to get a picture and display it on the window

#include <iostream>
#include<opencv2/opencv.hpp>


using namespace std;
using namespace cv;

int main() {
	Mat src = imread("D:\\timg (1).jpg", IMREAD_GRAYSCALE);// Read in the data in the form of a matrix , The second parameter represents displaying a grayscale image .
	if (src.empty())
	{
		printf("could not load image");// If the picture doesn't exist   Will not be able to read , Print to terminal .
		return -1;
	}
	// Call this function when the image beyond the screen cannot be displayed .
	namedWindow(" Input window ", WINDOW_FREERATIO);// Created a new window , Parameters 1 Name , The second parameter represents a free scale 
	imshow(" Input window ", src);// Indicates that it is displayed on the newly created input window , The first parameter represents the window name ,src Represents a data object Mat 
	waitKey(0);// Execute to this sentence , Program blocking . The parameter represents the delay time . Company ms
	destroyAllWindows();// Destroy the previously created display window 
	return 0;


}

Two 、 What is an image

The image is on the screen

原网站

版权声明
本文为[qq_ fifty-seven million two hundred and fifty-one thousand thre]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130608249411.html