Difference between revisions of "OpenCV/IO/DisplayImage"
From ProgrammingExamples
< OpenCV
Daviddoria (Talk | contribs) (Created page with '==DisplayImage.cxx== <source lang="cpp"> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main(int argc, char*argv[]) { // Read…') |
Daviddoria (Talk | contribs) m (→CMakeLists.txt) |
||
Line 37: | Line 37: | ||
ADD_EXECUTABLE(DisplayImage DisplayImage.cxx) | ADD_EXECUTABLE(DisplayImage DisplayImage.cxx) | ||
− | TARGET_LINK_LIBRARIES(DisplayImage | + | TARGET_LINK_LIBRARIES(DisplayImage ${OpenCV_LIBS}) |
− | + | ||
− | + | ||
− | ) | + | |
</source> | </source> |
Latest revision as of 16:47, 21 January 2011
DisplayImage.cxx
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main(int argc, char*argv[]) { // Read the image cv::Mat image = cv::imread(argv[1], CV_LOAD_IMAGE_COLOR); if(image.empty()) { std::cerr << "Can't read the image!" << std::endl; return -1; } // Display the image cv::namedWindow("image", 1); cv::imshow("matches", image); cv::waitKey(0); return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(DisplayImage) FIND_PACKAGE(OpenCV REQUIRED ) INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} ) ADD_EXECUTABLE(DisplayImage DisplayImage.cxx) TARGET_LINK_LIBRARIES(DisplayImage ${OpenCV_LIBS})