Skip to content

Instantly share code, notes, and snippets.

@devcarmelo
Created July 14, 2013 14:16
Show Gist options
  • Save devcarmelo/4bee98ad1a714412d191 to your computer and use it in GitHub Desktop.
Save devcarmelo/4bee98ad1a714412d191 to your computer and use it in GitHub Desktop.
Como usar el mouse con opencv
#include <opencv2\opencv.hpp>
using namespace cv;
using namespace std;
static void onMouse( int event, int x, int y, int, void* )
{
string msg = "mouse - movido: X = " + to_string(x) + " Y = " + to_string(y);
Mat img(200, 650, CV_8UC3);
switch (event)
{
case CV_EVENT_MOUSEMOVE:
putText(img, msg, Point(10,100), 4, 1, CV_RGB(0,255,0), 0, CV_AA );
imshow("Uso del raton", img);
break;
case CV_EVENT_LBUTTONDOWN : break;
case CV_EVENT_RBUTTONDOWN : break;
case CV_EVENT_MBUTTONDOWN : break;
case CV_EVENT_LBUTTONUP : break;
case CV_EVENT_RBUTTONUP : break;
case CV_EVENT_MBUTTONUP : break;
case CV_EVENT_LBUTTONDBLCLK : break;
case CV_EVENT_RBUTTONDBLCLK : break;
case CV_EVENT_MBUTTONDBLCLK : break;
}
}
int main( int argc, char** argv )
{
namedWindow( "Uso del raton", 0 );
setMouseCallback( "Uso del raton", onMouse);
waitKey();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment