Saturday, 12 April 2014

gray scale webcam opencv

berikut ini program untuk gray scale camera webcam menggunakan library opencv....selamat mencoba
------------------------------------------------------------------------------------------------------------
hasil

------------------------------------------------------------------------------------------------------------
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>

using namespace std;
using namespace cv;


void main()
{
int key = 0;
CvCapture *capture = cvCaptureFromCAM (0);
//keluar pke keyboard ‘q’
while( key !='q' )
{
IplImage *frame = cvQueryFrame(capture);

if( !frame ) break;
//……..di sini penambahan program utk grayscalenya……
IplImage* gray = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 0 );
cvCvtColor( frame, gray, CV_BGR2GRAY);
cvShowImage( "Grayscale", gray );
//——————————————
cvShowImage( "colour", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
key = cvWaitKey( 0 );
}
// cvDestroyWindow( “Example2″ );
cvReleaseCapture( &capture );
//return 0;
}
------------------------------------------------------------------------------------------------------------
hasil

No comments:

Post a Comment