opencv计算机视觉——鼠标响应

  • o6_992700
    了解作者
  • 22.9MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-27 03:21
    上传日期
资源包括opencv学习中的一些典型示例程序——鼠标响应方面,均已经通过测试。从基础的编程语法到精讲的实例程序,程序的思想和资源来源于如下书籍: 1、OpenCV 2 计算机视觉编程手册_中文版(必学 ) 2、OpenCV 2 Computer.Vision.Application.Programming. 3、OpenCV实例精解(必学) 4、学习OpenCV(中文版) 5、基于OpenCV的计算机视觉技术实现 6、深入理解OpenCV:实用计算机视觉项目解析——中文PDF扫描版 其中相关的电子版书籍可以见我的其他资源。
opencv.rar
  • HighGUI_switch
  • Debug
  • HighGUI_switch.pdb
    1.2MB
  • HighGUI_switch.ilk
    347.1KB
  • HighGUI_switch.exe
    29KB
  • ipch
  • highgui_switch-9aeeec51
  • highgui_switch-21e6322.ipch
    53.9MB
  • HighGUI_switch.suo
    12KB
  • HighGUI_switch
  • Debug
  • cl.command.1.tlog
    810B
  • HighGUI_switch_manifest.rc
    218B
  • link.3712-cvtres.read.1.tlog
    2B
  • rc.command.1.tlog
    706B
  • CL.read.1.tlog
    17.5KB
  • vc100.idb
    539KB
  • mt.read.1.tlog
    454B
  • HighGUI_switch.vcxprojResolveAssemblyReference.cache
    713B
  • link-cvtres.read.1.tlog
    2B
  • link.read.1.tlog
    8.7KB
  • rc.read.1.tlog
    426B
  • link.write.1.tlog
    1.1KB
  • link.3712.read.1.tlog
    2B
  • CL.write.1.tlog
    498B
  • HighGUI_switch.exe.intermediate.manifest
    381B
  • vc100.pdb
    900KB
  • main.obj
    90.2KB
  • link.command.1.tlog
    3.4KB
  • mt.write.1.tlog
    454B
  • HighGUI_switch.exe.embed.manifest.res
    472B
  • link.3712-cvtres.write.1.tlog
    2B
  • HighGUI_switch.exe.embed.manifest
    406B
  • HighGUI_switch.log
    160B
  • HighGUI_switch.lastbuildstate
    118B
  • HighGUI_switch.write.1.tlog
    0B
  • mt.command.1.tlog
    480B
  • rc.write.1.tlog
    434B
  • link-cvtres.write.1.tlog
    2B
  • link.3712.write.1.tlog
    2B
  • HighGUI_switch.vcxproj
    3.8KB
  • main.cpp
    920B
  • Lena.jpg
    31.3KB
  • HighGUI_switch.vcxproj.user
    143B
  • pic.jpg
    112.6KB
  • HighGUI_switch.vcxproj.filters
    953B
  • HighGUI_switch.sln
    909B
  • HighGUI_switch.sdf
    13MB
  • HighGUI_Mouse_event(利用鼠标在窗口中画矩形)
  • HighGUI_Mouse_event.sln
    924B
  • HighGUI_Mouse_event
  • Debug
  • cl.command.1.tlog
    902B
  • HighGUI_Mouse_event.write.1.tlog
    0B
  • rc.command.1.tlog
    848B
  • CL.read.1.tlog
    17.5KB
  • vc100.idb
    539KB
  • mt.read.1.tlog
    566B
  • link.4908-cvtres.read.1.tlog
    2B
  • link-cvtres.read.1.tlog
    2B
  • link.read.1.tlog
    9KB
  • rc.read.1.tlog
    538B
  • link.write.1.tlog
    1.4KB
  • CL.write.1.tlog
    636B
  • HighGUI_Mouse_event.log
    210B
  • vc100.pdb
    900KB
  • HighGUI_Mouse_event.vcxprojResolveAssemblyReference.cache
    713B
  • main.obj
    95.1KB
  • link.command.1.tlog
    3.6KB
  • HighGUI_Mouse_event.lastbuildstate
    158B
  • mt.write.1.tlog
    566B
  • HighGUI_Mouse_event.exe.intermediate.manifest
    381B
  • HighGUI_Mouse_event.exe.embed.manifest
    406B
  • link.4908-cvtres.write.1.tlog
    2B
  • HighGUI_Mouse_event.exe.embed.manifest.res
    472B
  • HighGUI_Mouse_event_manifest.rc
    228B
  • mt.command.1.tlog
    556B
  • rc.write.1.tlog
    546B
  • link-cvtres.write.1.tlog
    2B
  • link.4908.write.1.tlog
    2B
  • link.4908.read.1.tlog
    2B
  • HighGUI_Mouse_event.vcxproj.filters
    953B
  • main.cpp
    1.7KB
  • HighGUI_Mouse_event.vcxproj
    3.8KB
  • HighGUI_Mouse_event.vcxproj.user
    143B
  • Debug
  • HighGUI_Mouse_event.pdb
    1.2MB
  • HighGUI_Mouse_event.exe
    31KB
  • HighGUI_Mouse_event.ilk
    359.4KB
  • ipch
  • highgui_mouse_event-750b9457
  • highgui_mouse_event-43999d1a.ipch
    53.9MB
  • HighGUI_Mouse_event.opensdf
    34B
  • HighGUI_Mouse_event.sdf
    13.1MB
  • HighGUI_Mouse_event.suo
    22.5KB
内容介绍
//利用鼠标在窗口中画矩形 #include "cv.h" #include "highgui.h" using namespace cv; void my_mouse_callback(int event,int x,int y,int flags,void* param);//回调函数的声明 CvRect box; //生成一个矩形结构的全局变量 bool drawing_box=false; void draw_box(IplImage* img,CvRect rect)//画矩形函数 { cvRectangle(img,cvPoint(box.x,box.y),cvPoint(box.x+box.width,box.y+box.height),cvScalar(0,0,255),2,8); } int main(int argc,char** argv) { box=cvRect(-1,-1,0,0); IplImage* img=cvCreateImage(cvSize(500,500),IPL_DEPTH_8U,3); cvZero(img);//将图片设置为黑底 IplImage* temp=cvCloneImage(img);//将img复制到temp中 cvNamedWindow("Drawing_Rect",CV_WINDOW_AUTOSIZE); cvSetMouseCallback("Drawing_Rect",my_mouse_callback,(void*) img);//注册回调函数 while (1) { cvCopyImage(img,temp); if (drawing_box) { draw_box(temp,box); cvShowImage("Drawing_Rect",temp); } if (cvWaitKey(15)==27) { break; } } cvReleaseImage(&img); cvReleaseImage(&temp); cvDestroyWindow("Drawing_Rect"); //cvDestoryAllWindows();//清理所有窗口 } void my_mouse_callback(int event,int x,int y,int flags,void* param)//回调函数 { IplImage* img=(IplImage*)param; switch(event) { case CV_EVENT_MOUSEMOVE: { if (drawing_box) { box.width=x-box.x;//用鼠标实时的位置减去起点位置,得到矩形的长和宽 box.height=y-box.y; } } break; case CV_EVENT_LBUTTONDOWN: { drawing_box=true; box=cvRect(x,y,0,0);//x和y是捕捉鼠标的位置,这里相当于标记了起点 } break; case CV_EVENT_LBUTTONUP: { drawing_box=false; if (box.width<0) { box.x+=box.width; box.width*=-1; } if (box.height<0) { box.x+=box.height; box.height*=-1; } draw_box(img,box); } break; } }
评论
    相关推荐