Friday, 15 March 2013

mouseevent - opencv set mouse callback -



mouseevent - opencv set mouse callback -

i'm beginner in opencv , print in console specific value of pixel (rgb format) define clicking on it.

after searches managed prind coordinates of click create on image.

if knows how please modify code using:

void mouseevent (int evt, int x, int y, int flags, void* param) { if (evt == cv_event_lbuttondown) { printf("%d %d\n",x ,y ); } }

and utilize phone call function:

cvsetmousecallback("blah blah", mouseevent, 0);

place image in mat called frame, then:

namedwindow("test"); cvsetmousecallback("test", mouseevent, &frame); char key = 0; while ((int)key != 27) { imshow("test", frame); key = waitkey(1); }

where mouseevent defined as:

void mouseevent(int evt, int x, int y, int flags, void* param) { mat* rgb = (mat*) param; if (evt == cv_event_lbuttondown) { printf("%d %d: %d, %d, %d\n", x, y, (int)(*rgb).at<vec3b>(y, x)[0], (int)(*rgb).at<vec3b>(y, x)[1], (int)(*rgb).at<vec3b>(y, x)[2]); } }

opencv mouseevent

No comments:

Post a Comment