[ create a new paste ] login | about

Link: http://codepad.org/RBBCINss    [ raw code | fork ]

C++, pasted on Mar 6:
#include <cv.h>
#include <highgui.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
	// получаем любую подключённую камеру
	CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 );
	assert( capture );

	//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);//1280); 
	//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);//960); 

	// узнаем ширину и высоту кадра
	double width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
	double height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
	printf("[i] %.0f x %.0f\n", width, height );

	IplImage* frame=0;

	int counter=0;
	char *filename = "pic.jpg";

	while(true){
		// получаем кадр
		frame = cvQueryFrame( capture );
		
		if(counter%5 == 0)
		{
			cvSaveImage(filename, frame);
			counter = 0;
		}
			++counter;
	}
	// освобождаем ресурсы
	cvReleaseCapture( &capture );
	return 0;
}


Create a new paste based on this one


Comments: