init - 初始化项目
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
//! [includes]
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
//! [includes]
|
||||
|
||||
int main()
|
||||
{
|
||||
//! [imread]
|
||||
std::string image_path = samples::findFile("starry_night.jpg");
|
||||
Mat img = imread(image_path, IMREAD_COLOR);
|
||||
//! [imread]
|
||||
|
||||
//! [empty]
|
||||
if(img.empty())
|
||||
{
|
||||
std::cout << "Could not read the image: " << image_path << std::endl;
|
||||
return 1;
|
||||
}
|
||||
//! [empty]
|
||||
|
||||
//! [imshow]
|
||||
imshow("Display window", img);
|
||||
int k = waitKey(0); // Wait for a keystroke in the window
|
||||
//! [imshow]
|
||||
|
||||
//! [imsave]
|
||||
if(k == 's')
|
||||
{
|
||||
imwrite("starry_night.png", img);
|
||||
}
|
||||
//! [imsave]
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user