#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <vector>
int main()
{
CvCapture *capture;
IplImage *frame;
IplImage *frame2;
capture=cvCreateCameraCapture(0);
cvNamedWindow("Webcam",0);
CvVideoWriter *writer;
char AviFileName[]="Output.avi";
int AviForamt = -1;
int FPS = 30;
int AviColor = 1;
CvSize AviSize = cvSize(640,480);
writer=cvCreateVideoWriter(AviFileName,AviForamt,FPS,AviSize,AviColor);
std::vector<IplImage*> ivecRawImage;
std::vector<IplImage*> ivecFinishImage;
CvScalar Color = CV_RGB(255,0,0);
int Thickness = 3;
int counter = 0;
CvPoint FromPoint1 = cvPoint(100,100);
CvPoint ToPoint1 = cvPoint(800,600);
bool bFinishavi = false;
while(true)
{
counter ++;
frame = cvQueryFrame(capture);
cvShowImage("Webcam",frame);
if(counter>30 && counter<299){
IplImage *RealImage = cvCreateImage(cvGetSize(frame),frame->depth, 3);
cvCopy(frame,RealImage);
ivecRawImage.push_back(RealImage);
}
if(counter == 299){
for(int i=0;i<ivecRawImage.size();i++){
cvLine(ivecRawImage[i],FromPoint1,ToPoint1,Color,Thickness);
ivecFinishImage.push_back(ivecRawImage[i]);
}
bFinishavi = true;
}
if(bFinishavi == true){
for(int i=0;i<ivecFinishImage.size();i++){
cvWriteFrame(writer,ivecFinishImage[i]);
}
}
if(counter == 300) break;
}
cvReleaseCapture(&capture);
cvReleaseVideoWriter(&writer);
cvDestroyWindow("Webcam");
}
留言列表