OpenCV添加鼠标事件

来源:互联网 发布:java 跨行字符串 编辑:程序博客网 时间:2024/06/06 15:49


#include "stdafx.h"
#include "Camkit.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
using namespace std;
using namespace ck;
using namespace cv;

static void OnMouse( int event, int x, int y, int, void* p)
{
AxisCamera *pp;
pp = (AxisCamera *)p;
switch(event)
{
case CV_EVENT_LBUTTONDOWN:
pp->Center(x, y);
break;
default:
;
}
}


int _tmain(int argc, _TCHAR* argv[])
{

///////////////////////////////////////////////////////////////
AxisCamera ac("172.16.200.254","172.16.200.254", 1280, 720, 25);
ac.StartGrab();
namedWindow("axis");
setMouseCallback("axis", OnMouse, &ac);
Mat mm;
bool run = true;
while(run)
{
ac.Img().copyTo(mm);
imshow("axis", mm);
int key = waitKey(1);
switch(key)
{
case 27:
run = false;
break;
case 'i':
ac.RZoom(500);
break;
case 'o':
ac.RZoom(-500);
break;
case 'p':
ac.GetPosition(false);
break;
default:
;
}
}
ac.StopGrab();
return 0;
}


0 0
原创粉丝点击