#include "highgui.h"
int main( int argc, char** argv )
{
cvNamedWindow( "CAM Capture", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCreateCameraCapture(-1);
assert(capture != NULL);
IplImage* frame;
while(1)
{
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "CAM Capture", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "CAM Capture" );
}
cvCreateFileCapture()
function is replaced bycvCreateCameraCapture()
, as a parameter, we give it not the path to the file, but the camera ID - if you have one camera, then safely set the value to -1.cvCreateVideoWriter()
.cvWriteFrame()
and in conclusion, we will use cvReleaseVdeoWriter()
.#include "highgui.h"
#include "cv.h"
int main(int argc, char** argv[])
{
CvCapture* capture = cvCreateFileCapture("f.avi");
if( !capture )
{
return -1;
}
IplImage* bgr_frame = cvQueryFrame( capture );
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("1.avi", CV_FOURCC('M','J','P','G'), fps, size);
IplImage* logpolar_frame = cvCreateImage( size, IPL_DEPTH_8U, 3);
while( (bgr_frame=cvQueryFrame(capture)) != NULL )
{
cvLogPolar( bgr_frame, logpolar_frame, cvPoint2D32f(bgr_frame->width/2, bgr_frame->height/2),
40, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
cvWriteFrame( writer, logpolar_frame );
}
cvReleaseVideoWriter( &writer );
cvReleaseImage( &logpolar_frame );
cvReleaseCapture( &capture );
return(0);
}
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("1.avi", CV_FOURCC('M','J','P','G'), fps, size);
while( (bgr_frame=cvQueryFrame(capture)) != NULL )
{
cvLogPolar( bgr_frame, logpolar_frame, cvPoint2D32f(bgr_frame->width/2, bgr_frame->height/2),
40, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
cvWriteFrame( writer, logpolar_frame );
}
Source: https://habr.com/ru/post/78150/
All Articles