Monday, November 26, 2012

Load Modify and Save Image Using OpenCV Highgui

This is simple example for load image, do some image manipulation and save the result.

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

using namespace std;

int main()
    cv::Mat src;
    cv::Mat src_binary;

        cout<<"Cannot load the image !"<<endl;
        return 0;


     cvtColor(src, src_binary, CV_BGR2GRAY); // Convert BGR  to gray
     cv::threshold(src_binary, src_binary, 100, 255, 0); // Threshold the image to convert binary image

    imwrite("/sdcard/result.jpeg",src_binary); // save image

     cvWaitKey(0); // Wait for key press
     return 0;

No comments:

Post a Comment