• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! [includes]
2 #include <opencv2/core/core.hpp>
3 #include <opencv2/imgcodecs.hpp>
4 #include <opencv2/highgui/highgui.hpp>
5 
6 #include <iostream>
7 #include <string>
8 //! [includes]
9 
10 //! [namespace]
11 using namespace cv;
12 //! [namespace]
13 
14 using namespace std;
15 
main(int argc,char ** argv)16 int main( int argc, char** argv )
17 {
18     //! [load]
19     string imageName("../data/HappyFish.jpg"); // by default
20     if( argc > 1)
21     {
22         imageName = argv[1];
23     }
24     //! [load]
25 
26     //! [mat]
27     Mat image;
28     //! [mat]
29 
30     //! [imread]
31     image = imread(imageName.c_str(), IMREAD_COLOR); // Read the file
32     //! [imread]
33 
34     if( image.empty() )                      // Check for invalid input
35     {
36         cout <<  "Could not open or find the image" << std::endl ;
37         return -1;
38     }
39 
40     //! [window]
41     namedWindow( "Display window", WINDOW_AUTOSIZE ); // Create a window for display.
42     //! [window]
43 
44     //! [imshow]
45     imshow( "Display window", image );                // Show our image inside it.
46     //! [imshow]
47 
48     //! [wait]
49     waitKey(0); // Wait for a keystroke in the window
50     //! [wait]
51     return 0;
52 }
53