Showing posts with label OpenCV. Show all posts
Showing posts with label OpenCV. Show all posts

Sunday, April 7, 2013

How To Install OpenCV on Ubuntu

I followed the instruction on this blog to install OpenCV on Ubuntu 13.04.

http://karytech.blogspot.com/2012/05/opencv-24-on-ubuntu-1204.html

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
    cv::waitKey(5000);
    return 1;
}
g++ -o hello hello.cpp `pkg-config opencv --cflags --libs`
./hello