视频关键帧提取代码


里面含有关键帧提取的代码,还有人脸检测等代码,是vs+opencv实现的
资源截图
代码片段和文件信息
#include
#include
#include
#include
#include
using namespace std;


int main()
{
cvNamedWindow(“result“1);
IplImage* pcrtframe = NULL *frame_copy = NULL;
//CvMat* pcrtframeMat = NULL;
CvCapture* pcrtCapture = NULL;
pcrtCapture = cvCaptureFromFile(“E:\22.avi“); //当前读取的视频
//pcrtframe = cvQueryframe( pcrtCapture );


int outCompressCodec = (int)cvGetCaptureProperty(pcrtCapture CV_CAP_PROP_FOURCC);
int fps = (int)cvGetCaptureProperty(pcrtCaptureCV_CAP_PROP_FPS);
CvVideoWriter *writer = 0;
int isColor = 1;
//int fps     = 25;  // or 30
int frameW  = 432; // 744 for firewire cameras
int frameH  = 240; // 480 for firewire cameras
writer=cvCreateVideoWriter(“out1.avi“CV_FOURCC(‘X‘‘V‘‘I‘‘D‘)fpscvSize(frameWframeH)isColor); //outCompressCodec

CvFont font;    //在图片上显示字符
cvInitFont(&font CV_FONT_HERSHEY_SIMPLEX 1.0 1.0 0 2 8); 


    CvPoint panda1; 
panda1.x=100;
panda1.y=44;

CvPoint panda2; 
panda2.x=197;
panda2.y=109;



long cnt = 0; //变量cnt用于记录帧数
//for(int i=0;i=i+10;)
while(pcrtframe = cvQueryframe( pcrtCapture ))
{



cnt++;


if( !frame_copy ) // 创建图像副本
frame_copy = cvCreateImage( cvSize(pcrtframe->widthpcrtframe->height)
                                            IPL_DEPTH_8U pcrtframe->nChannels );



if( pcrtframe->origin == IPL_ORIGIN_TL )
cvCopy( pcrtframe frame_copy 0 );
else
cvFlip( pcrtframe frame_copy 0 ); 

cvRectangle( frame_copy panda1 panda2 CV_RGB(25000)
                  2 8 0 );
cvPutText(frame_copy “Panda“ cvPoint(panda2.x+3 panda1.y+2) &font CV_RGB(25500));
cvPutText(frame_copy “Walk“ cvPoint(panda2.x+3 panda1.y+25) &font CV_RGB(25500));
cvWaitKey(20);
cout< if((cnt%2==0)&&cnt<=200)
{
panda1.x+=1;
panda2.x+=1;
}
else if(cnt>200)
{
panda1.x+=1;
panda1.y+=2;
panda2.x+=1;
panda2.y+=1;

}


cvWriteframe(writer frame_copy);


cvShowImage( “result“ frame_copy );

cvWaitKey(10);





}

//cout<<“there are “<ames in this video“<
cvReleaseVideoWriter(&writer);
cvDestroyWindow(“result“);
cvReleaseImage(&pcrtframe);
return 0;

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-12-25 21:47  TEST
     文件      106049  2013-11-01 08:51  TEST1.jpg
     目录           0  2014-12-25 21:47  TESTDebug
     文件       85504  2014-12-25 21:47  TESTDebugTEST.exe
     文件      426948  2014-12-25 21:47  TESTDebugTEST.ilk
     文件     1510400  2014-12-25 21:47  TESTDebugTEST.pdb
     文件       25088  2013-11-10 17:33  TESTSkinDectDLL.dll
     目录           0  2014-12-25 21:38  TESTTEST
     文件      106049  2013-11-01 08:51  TESTTEST1.jpg
     文件      110114  2013-11-01 08:51  TESTTEST2.jpg
     目录           0  2014-12-25 21:47  TESTTESTDebug
     文件       32798  2014-12-25 21:44  TESTTESTDebugCL.read.1.tlog
     文件         434  2014-12-25 21:44  TESTTESTDebugCL.write.1.tlog
     文件        1609  2013-11-13 22:26  TESTTESTDebugTEST.Build.CppClean.log
     文件         406  2013-11-13 22:26  TESTTESTDebugTEST.exe.embed.manifest
     文件         472  2013-11-13 22:26  TESTTESTDebugTEST.exe.embed.manifest.res
     文件         381  2013-11-14 15:51  TESTTESTDebugTEST.exe.intermediate.manifest
     文件          67  2014-12-25 21:47  TESTTESTDebugTEST.lastbuildstate
     文件        1500  2014-12-25 21:47  TESTTESTDebugTEST.log
     文件         198  2013-11-13 22:26  TESTTESTDebugTEST_manifest.rc
     文件      161968  2013-11-10 22:29  TESTTESTDebugTestDLL.obj
     文件        1018  2014-12-25 21:44  TESTTESTDebugcl.command.1.tlog
     文件      305584  2014-12-25 21:44  TESTTESTDebughistogram.obj
     文件           2  2014-12-25 21:47  TESTTESTDebuglink-cvtres.read.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink-cvtres.write.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink-rc.read.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink-rc.write.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink.2456-cvtres.read.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink.2456-cvtres.write.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink.2456.read.1.tlog
     文件           2  2014-12-25 21:47  TESTTESTDebuglink.2456.write.1.tlog
............此处省略42个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)