Difference between revisions of "OpenCV/IO/DisplayImage"

From ProgrammingExamples
Jump to: navigation, search
(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…')
 
m (CMakeLists.txt)
 
Line 37: Line 37:
  
 
ADD_EXECUTABLE(DisplayImage DisplayImage.cxx)
 
ADD_EXECUTABLE(DisplayImage DisplayImage.cxx)
TARGET_LINK_LIBRARIES(DisplayImage opencv_core opencv_highgui
+
TARGET_LINK_LIBRARIES(DisplayImage ${OpenCV_LIBS})
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
+
          opencv_features2d opencv_calib3d opencv_legacy opencv_contrib
+
)
+
 
</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})