• 大小: 11.35MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-20
  • 语言: 其他
  • 标签: 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  IV\Debug\
     文件       30720  2014-12-12 13:27  IV\Debug\IV.exe
     文件      389600  2014-12-12 13:27  IV\Debug\IV.ilk
     文件     1313792  2014-12-12 13:27  IV\Debug\IV.pdb
     目录           0  2014-12-12 13:50  IV\ipch\
     目录           0  2014-12-12 13:50  IV\ipch\iv-2968b012\
     文件    56688640  2014-12-12 10:36  IV\ipch\iv-2968b012\iv-3b59c50b.ipch
     目录           0  2014-12-12 13:50  IV\IV\
     文件         873  2014-12-12 10:32  IV\IV.sln
     文件       10752  2014-12-12 13:49  IV\IV.suo
     目录           0  2014-12-12 13:50  IV\IV\Debug\
     文件         754  2014-12-12 13:27  IV\IV\Debug\cl.command.1.tlog
     文件       19050  2014-12-12 13:27  IV\IV\Debug\CL.read.1.tlog
     文件         492  2014-12-12 13:27  IV\IV\Debug\CL.write.1.tlog
     文件         406  2014-12-12 10:53  IV\IV\Debug\IV.exe.embed.manifest
     文件         472  2014-12-12 10:53  IV\IV\Debug\IV.exe.embed.manifest.res
     文件         381  2014-12-12 13:27  IV\IV\Debug\IV.exe.intermediate.manifest
     文件          91  2014-12-12 13:27  IV\IV\Debug\IV.lastbuildstate
     文件        2296  2014-12-12 13:27  IV\IV\Debug\IV.log
     文件        1413  2014-12-12 10:32  IV\IV\Debug\IV.vcxprojResolveAssemblyReference.cache
     文件           0  2014-12-12 10:53  IV\IV\Debug\IV.write.1.tlog
     文件         194  2014-12-12 10:53  IV\IV\Debug\IV_manifest.rc
     文件           2  2014-12-12 13:27  IV\IV\Debug\link-cvtres.read.1.tlog
     文件           2  2014-12-12 13:27  IV\IV\Debug\link-cvtres.write.1.tlog
     文件           2  2014-12-12 13:27  IV\IV\Debug\link.7264-cvtres.read.1.tlog
     文件           2  2014-12-12 13:27  IV\IV\Debug\link.7264-cvtres.write.1.tlog
     文件           2  2014-12-12 13:27  IV\IV\Debug\link.7264.read.1.tlog
     文件           2  2014-12-12 13:27  IV\IV\Debug\link.7264.write.1.tlog
     文件        1842  2014-12-12 13:27  IV\IV\Debug\link.command.1.tlog
     文件        3588  2014-12-12 13:27  IV\IV\Debug\link.read.1.tlog
............此处省略14个文件信息

评论

共有 条评论