forked from oreillymedia/Learning-OpenCV-3_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_02-01.cpp
More file actions
33 lines (24 loc) · 693 Bytes
/
example_02-01.cpp
File metadata and controls
33 lines (24 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Example 2-1. A simple OpenCV program that loads an image from disk and displays it
//on the screen
#include <opencv2/opencv.hpp>
void help(char** argv ) {
std::cout << "\n"
<< "A simple OpenCV program that loads and displays an image from disk\n"
<< argv[0] <<" <path/filename>\n"
<< "For example:\n"
<< argv[0] << " ../fruits.jpg\n"
<< std::endl;
}
int main( int argc, char** argv ) {
if (argc != 2) {
help(argv);
return 0;
}
cv::Mat img = cv::imread( argv[1], -1 );
if( img.empty() ) return -1;
cv::namedWindow( "Example 2-1", cv::WINDOW_AUTOSIZE );
cv::imshow( "Example 2-1", img );
cv::waitKey( 0 );
cv::destroyWindow( "Example 2-1" );
return 0;
}