Saturday, 12 April 2014

edge detection menggunakan canny opencv

berikut ini program untuk edge detection menggunakan canny dari 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 );
//———————————————
IplImage* canny = cvCreateImage (cvGetSize (gray), IPL_DEPTH_8U, 0 );
cvCanny( gray, canny, 70, 200, 3);
cvShowImage ("Canny", canny);
//——————————————
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