ROI + Video + Canny?

asked 2015-10-26 03:31:59 -0500

MValeriy gravatar image

updated 2015-10-26 03:44:23 -0500

berak gravatar image

Hello , I have a question . I want to select an area and then convert the calculation with function Kanny( or convert whole image , and then Select certain field ) . After I 'd like the distance between lines displayed is measured . Program for Kenny and solely for ROI I have . but I can not link the two , unfortunately . See illustrations. Could you please help me with Canny function ? it's not working. and How can I measure the area ?

excuse me for GOOGLE ENGLISH

image description image description

#include<opencv2\opencv.hpp>
 #include <opencv2\highgui\highgui.hpp>
#include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
 #include <string.h>


 int main(int argc, char *argv[])
 {
 CvCapture *capture = 0;
 IplImage *frame, *img1;
 IplImage *gray;
 int key = 0;

  // Camera
 capture = cvCaptureFromCAM( 0 );

 if ( !capture ) {
 printf("Failed cvCaptureFromCAM!\n" );
 exit(0);
 }

 // create a window for the video
 cvNamedWindow( "ROI", CV_WINDOW_AUTOSIZE );

 while( key != 'q' )
 {


 /////////////////////////////////ROI//////////////////////////////

 IplImage* frame = cvQueryFrame( capture );


 if( !frame ) break;

//ROI 
 cvSetImageROI(frame, cvRect(0, 360, 1024, 50));    

 // create destination image 
 IplImage *img1 = cvCreateImage(cvGetSize(frame),
 frame->depth,
 frame->nChannels);

 //FUNKTION CaNNY
 cvCvtColor(frame, gray, CV_BGR2GRAY);
 cvCanny(gray, gray, 30, 90);



 //Kopie 
 cvCopy(gray, img1, NULL);

 cvResetImageROI(frame);

 /////////////////////////////////ROI//////////////////////////////



 cvShowImage( "ROI", frame );

 key = cvWaitKey( 1 );
 }


 cvDestroyWindow( "ROI" );
 cvReleaseCapture( &capture );
 return 0;
 }
edit retag flag offensive close merge delete

Comments

3

the first thing you have to do : throw that code away

please avoid the deprecated c-api, it is no more useful, and a terrible obstacle for noobs.

then, have a look at opencv tutorials

berak gravatar imageberak ( 2015-10-26 03:46:58 -0500 )edit