OpenCV/IO/DisplayImage

From ProgrammingExamples
< OpenCV
Revision as of 16:47, 21 January 2011 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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})