• 大小: 19.57MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-05
  • 语言: C/C++
  • 标签: opencv  

资源简介

opencv中用来保存摄像头录的录像,c++语言摄像头播放录像

资源截图

代码片段和文件信息

#include “cv.h“
#include “highgui.h“

main(int argc char** argv[])
{
CvCapture* capture=0;
cvNamedWindow(“e“CV_WINDOW_AUTOSIZE);
int fps=30;
/*capture=cvCreateFileCapture(“E:\\c++image data\\lesson2\\avi\\video.long.xvid.avi“);
IplImage* frame;
while(1)
{
frame=cvQueryframe(capture);
if(!frame)
break;
cvShowImage(“e“frame);
char c=cvWaitKey(33);
if(c==27) break;
}*/
capture=cvCreateCameraCapture(0);
if(!capture){
return -1;
}
IplImage* bgr_frame=cvQueryframe(capture);
double outCompressCodec=cvGetCaptureProperty(captureCV_CAP_PROP_FOURCC);
CvSize size=cvSize(
(int)cvGetCaptureProperty(captureCV_CAP_PROP_frame_WIDTH)
(int)cvGetCaptureProperty(captureCV_CAP_PROP_frame_HEIGHT)
);
CvVideoWriter* writer=cvCreateVideoWriter(
“camera.long.xvid.avi“
//CV_FOURCC(‘M‘‘J‘‘P‘‘G‘)
outCompressCodec
fps
size
1
);
/*IplImage* logpolar_frame=cvCreateImage(
size
IPL_DEPTH_8U
3
);*/
while((bgr_frame=cvQueryframe(capture))!=NULL){
/*cvLogPolar(bgr_framelogpolar_framecvPoint2D32f(bgr_frame->width/2
bgr_frame->height/2)
40
CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);*/
cvWriteframe(writerbgr_frame);
cvShowImage(“e“bgr_frame);
char c=cvWaitKey(10);
if(c==27) break;
}
cvReleaseVideoWriter(&writer);
// cvReleaseImage(&logpolar_frame);
cvReleaseCapture(&capture);
return (0);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-09-22 21:10  save camera video\
     文件    37789696  2011-09-22 21:00  save camera video\camera.long.xvid.avi
     目录           0  2011-09-21 00:11  save camera video\Debug\
     文件      188503  2011-09-20 21:07  save camera video\Debug\save camera video.exe
     文件      197824  2011-09-20 21:07  save camera video\Debug\save camera video.ilk
     文件     4100128  2011-09-20 21:04  save camera video\Debug\save camera video.pch
     文件      443392  2011-09-20 21:07  save camera video\Debug\save camera video.pdb
     文件       14923  2011-09-20 21:07  save camera video\Debug\save.obj
     文件      156672  2011-09-22 21:00  save camera video\Debug\vc60.idb
     文件       94208  2011-09-20 21:07  save camera video\Debug\vc60.pdb
     文件        4235  2011-09-20 21:03  save camera video\save camera video.dsp
     文件         542  2011-09-20 20:59  save camera video\save camera video.dsw
     文件       41984  2011-09-22 21:10  save camera video\save camera video.ncb
     文件       48640  2011-09-22 21:10  save camera video\save camera video.opt
     文件         268  2011-09-22 20:59  save camera video\save camera video.plg
     文件        1420  2011-09-20 21:07  save camera video\save.cpp

评论

共有 条评论