Sunday, April 7, 2013

My First OpenCV Sample Program

This is my first OpenCV code that was compiled and run on my Ubuntu 13.04 machine.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
    // read an image
    cv::Mat image = cv::imread("my_photo.jpg");
    // create image window named "My Image"
    cv::namedWindow("My Photo");
    // show the image on window
    cv::imshow("My Photo", image);
    // wait key for 5000 ms
    return 1;
g++ -o hello hello.cpp `pkg-config opencv --cflags --libs`