VERSION:OPENCV 2.4.9
ide:vs2010
Os:windows
-----------------------------------------------------------------------------------
Goal
In this tutorial you'll learn how to:
load an image (using imread)
Create a named OpenCV window (using namedwindow)
display an image in an OpenCV window (using imshow)
Source Code
1#include <opencv2/core/core.hpp>2#include <opencv2/highgui/highgui.hpp>3#include <iostream>4 5 using namespaceCV;6 using namespacestd;7 8 intMainintargcChar**argv)9 {Ten if(ARGC! =2) One { Acout <<"usage:display_image Imagetoloadanddisplay"<<Endl; - return-1; - } the - Mat image; -Image = Imread (argv[1], Cv_load_image_color);//Read the file - + if(! Image.data)//Check for Invalid input - { +cout <<"Could not open or find the image"<<Std::endl; A return-1; at } - -Namedwindow ("Display window", window_autosize);//Create a window for display. -Imshow ("Display window", image);//Show our image inside it. - -Waitkey (0);//Wait for a keystroke in the window in return 0; -}
[Pure Small white Learning OpenCV series] official routines 01:load and Display an Image