add DisplayImage example

This commit is contained in:
neingeist 2014-01-20 12:10:31 +01:00
parent a5f3b5f818
commit fa128033f9
5 changed files with 32 additions and 0 deletions

2
.gitignore vendored
View file

@ -6,3 +6,5 @@ cmake_install.cmake
SVMTest SVMTest
SVMTest.png SVMTest.png
DisplayImage

View file

@ -4,3 +4,6 @@ find_package( OpenCV REQUIRED )
add_executable( SVMTest SVMTest.cpp ) add_executable( SVMTest SVMTest.cpp )
target_link_libraries( SVMTest ${OpenCV_LIBS} ) target_link_libraries( SVMTest ${OpenCV_LIBS} )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )

27
DisplayImage.cpp Normal file
View file

@ -0,0 +1,27 @@
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char **argv)
{
if (argc != 2) {
printf("Usage: DisplayImage image.jpg\n");
return -1;
}
Mat image;
image = imread(argv[1], 1);
if (argc != 2 || !image.data) {
printf("No image data\n");
return -1;
}
namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
imshow("Display Image", image);
waitKey(0);
return 0;
}

BIN
lena.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
lena.tif Normal file

Binary file not shown.