求解opencv 鼠标事件问题 15
#include"cv.h"#include"highgui.h"voidmy_mouse_callback(intevent0,intx,inty,intflags,v...
#include "cv.h"
#include "highgui.h"
void my_mouse_callback(int event0,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(0x00,0x00,0xff));
}
int tmain()
{
box=cvRect(-1,-1,0,0);
IplImage* image=cvCreateImage(cvSize(200,200),IPL_DEPTH_8U,3);
cvZero(image);
IplImage* temp=cvCloneImage(image);
cvNamedWindow("Box Example");
cvSetMouseCallback("Box Example",my_mouse_callback,(void*)image);
while(1)
{
cvCopyImage(image,temp);
if(drawing_box) draw_box(temp,box);
cvShowImage("Box Example",temp);
if(cvWaitKey(15)==27) break;
}
cvReleaseImage(&image);
cvReleaseImage(&temp);
cvDestroyWindow("Box Example");
}
还有回调函数的定义没有写完
请问 语句CvRect box;
bool drawing_box=false;
void draw_box(IplImage* img,CvRect rect)是什么意思 有什么用啊还有问什么要用这一句啊 展开
#include "highgui.h"
void my_mouse_callback(int event0,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(0x00,0x00,0xff));
}
int tmain()
{
box=cvRect(-1,-1,0,0);
IplImage* image=cvCreateImage(cvSize(200,200),IPL_DEPTH_8U,3);
cvZero(image);
IplImage* temp=cvCloneImage(image);
cvNamedWindow("Box Example");
cvSetMouseCallback("Box Example",my_mouse_callback,(void*)image);
while(1)
{
cvCopyImage(image,temp);
if(drawing_box) draw_box(temp,box);
cvShowImage("Box Example",temp);
if(cvWaitKey(15)==27) break;
}
cvReleaseImage(&image);
cvReleaseImage(&temp);
cvDestroyWindow("Box Example");
}
还有回调函数的定义没有写完
请问 语句CvRect box;
bool drawing_box=false;
void draw_box(IplImage* img,CvRect rect)是什么意思 有什么用啊还有问什么要用这一句啊 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询