higui function
http://www.cognotics.com/opencv/docs/1.0/ref/opencvref_highgui.htm#decl_CvCapture
------------------------------------------------------------
grey->edge detector
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include <math.h>
using namespace cv;
int main()
{
IplImage* img = cvLoadImage("C:\\ENEL\\OpenCV2.1\\samples\\c\\airplane.jpg");
IplImage* edge = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);
cvCvtColor(img, edge, CV_BGR2GRAY);
cvCanny(edge, edge, 0.3, 0.8);
cvShowImage( "Example1", edge );
cvWaitKey(0);
cvReleaseImage(&img);
cvReleaseImage(&edge);
}
----------------------------------------------------------
video writer
int main( int argc, char* argv[] ) {
CvCapture* capture = 0;
capture = cvCreateFileCapture( "C:\\ENEL\\OpenCV2.1\\samples\\c\\tree.avi" );
if(!capture){
return -1;
}
double fps = cvGetCaptureProperty (
capture,
CV_CAP_PROP_FPS
);
CvSize size = cvSize(
(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT)
);
CvVideoWriter *writer = cvCreateVideoWriter(
"C:\\Users\\abc\\Desktop\\a.avi",
CV_FOURCC('M','J','P','G'),
fps,
size
);
IplImage* frame = cvCreateImage(
size,
IPL_DEPTH_8U,
3
);
while( (frame=cvQueryFrame(capture)) != NULL ) {
cvWriteFrame( writer, frame );
}
cvReleaseVideoWriter( &writer );
cvReleaseImage( &frame );
cvReleaseCapture( &capture );
return(0);
}
--------------------------------------------------------------
better edge detector
http://dasl.mem.drexel.edu/~noahKuntz/openCVTut5.html
No comments:
Post a Comment