~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/samples/cpp/tutorial_code/introduction/display_image/display_image.cpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
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
}