opencv在播放视频中画框框


加载一下自己的opencv库,修改一下视频路径就可运行,运行后在视频中画一个框,视频就开始播放,在播放中还可以在画框,但是视频中只会存在一个框
资源截图
代码片段和文件信息
#include 
#include 
#include 
void my_mouse_callback(intintintintvoid*);//鼠标事件回调函数
void DrawRect(IplImage*CvRect);
bool Drawing=false;
bool out=false;
int xx1xx2yy1yy2;  
CvRect box;
int main()
{
IplImage* pframe=NULL;
CvCapture* pCapture=NULL;
box=cvRect(00-1-1);
char* filename=“F:\OPENCV实验室\00011.avi“;
pCapture=cvCaptureFromAVI(filename);
cvNamedWindow(“video“0);
pframe=cvQueryframe(pCapture);
IplImage* temp1=cvCloneImage(pframe); 
cvSetMouseCallback(“video“my_mouse_callback(void*)pframe);
while(out==false)
{
 cvCopyImage(pframetemp1);
if(Drawing)
{
DrawRect(temp1box);
}

cvShowImage(“video“temp1);
if(cvWaitKey(38)==27)
break;

}
while(pframe=cvQueryframe(pCapture))
{
cvRectangle(pframecvPoint(xx1yy1)cvPoint(xx2yy2)cvScalar(0x000xff0x00)2);
cvShowImage(“video“pframe);
cvWaitKey(38);
}

return 0;
}
void my_mouse_callback(int eventint xint yint flagsvoid* param)//鼠标事件回调函数
{
IplImage* img=(IplImage*)param;
switch(event)
{
case CV_EVENT_MOUSEMOVE:
{
if(Drawing)
{
box.width=x-box.x;
box.height=y-box.y;
}
}
break;
case CV_EVENT_LBUTTONDOWN:
{
Drawing=true;
box=cvRect(xy00);
}
break;
case CV_EVENT_LBUTTONUP:
{
Drawing=false;
if(box.width<0)
{
box.x+=box.width;
box.width*=-1;
}
if(box.height<0)
{
box.y+=box.height;
box.height*=-1;
}
out=true;
DrawRect(imgbox);
}
break;
}
}
void DrawRect(IplImage* imgCvRect rect )
{
xx1=box.x;
xx2=box.x+box.width;
yy1=box.y;
yy2=box.y+box.height;
cvRectangle(imgcvPoint(xx1yy1)cvPoint(xx2yy2)cvScalar(0x000xff0x00)2);

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-12-12 13:50  IV
     目录           0  2014-12-12 13:50  IVDebug
     文件       30720  2014-12-12 13:27  IVDebugIV.exe
     文件      389600  2014-12-12 13:27  IVDebugIV.ilk
     文件     1313792  2014-12-12 13:27  IVDebugIV.pdb
     目录           0  2014-12-12 13:50  IVipch
     目录           0  2014-12-12 13:50  IVipchiv-2968b012
     文件    56688640  2014-12-12 10:36  IVipchiv-2968b012iv-3b59c50b.ipch
     目录           0  2014-12-12 13:50  IVIV
     文件         873  2014-12-12 10:32  IVIV.sln
     文件       10752  2014-12-12 13:49  IVIV.suo
     目录           0  2014-12-12 13:50  IVIVDebug
     文件         754  2014-12-12 13:27  IVIVDebugcl.command.1.tlog
     文件       19050  2014-12-12 13:27  IVIVDebugCL.read.1.tlog
     文件         492  2014-12-12 13:27  IVIVDebugCL.write.1.tlog
     文件         406  2014-12-12 10:53  IVIVDebugIV.exe.embed.manifest
     文件         472  2014-12-12 10:53  IVIVDebugIV.exe.embed.manifest.res
     文件         381  2014-12-12 13:27  IVIVDebugIV.exe.intermediate.manifest
     文件          91  2014-12-12 13:27  IVIVDebugIV.lastbuildstate
     文件        2296  2014-12-12 13:27  IVIVDebugIV.log
     文件        1413  2014-12-12 10:32  IVIVDebugIV.vcxprojResolveAssemblyReference.cache
     文件           0  2014-12-12 10:53  IVIVDebugIV.write.1.tlog
     文件         194  2014-12-12 10:53  IVIVDebugIV_manifest.rc
     文件           2  2014-12-12 13:27  IVIVDebuglink-cvtres.read.1.tlog
     文件           2  2014-12-12 13:27  IVIVDebuglink-cvtres.write.1.tlog
     文件           2  2014-12-12 13:27  IVIVDebuglink.7264-cvtres.read.1.tlog
     文件           2  2014-12-12 13:27  IVIVDebuglink.7264-cvtres.write.1.tlog
     文件           2  2014-12-12 13:27  IVIVDebuglink.7264.read.1.tlog
     文件           2  2014-12-12 13:27  IVIVDebuglink.7264.write.1.tlog
     文件        1842  2014-12-12 13:27  IVIVDebuglink.command.1.tlog
     文件        3588  2014-12-12 13:27  IVIVDebuglink.read.1.tlog
............此处省略14个文件信息

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

发表评论

评论列表(条)