1 | initial version |
There is no standard event to handle mousewheel down or up on the onMouse method. You can, however, combine more than one event to create a drag mouse effect, which would complete your task.
Something like
void MouseCB::onMouse( int event, int x, int y, int flags, void* userData)
{
if (event == CV_EVENT_LBUTTONDOWN)
{
int leftcornerX = x;
int leftcornerY = y;
while( event != CV_EVENT_LBUTTONUP)
{
//method to retrieve your originalframe with no rectangles drawn -> either the original frame is a
//global variable, or you have to pass it using the void* userData input argument.
Mat copy = originalframe;
rectangle(copy, Point(leftcornerX, leftcornerY), Point(x, y), Scalar(255, 0, 0), 1, 8, 0);
imshow("Frame", copy);
waitKey(10);
}
}
}
This draws a rectangle between the point you first clicked with the left mouse button and the current mouse position, until you lift the mouse button.
2 | No.2 Revision |
There is no standard event to handle mousewheel down or up on the onMouse method. You can, however, combine more than one event to create a drag mouse effect, which would complete your task.
Something like
void MouseCB::onMouse( int event, int x, int y, int flags, void* userData)
{
if (event == CV_EVENT_LBUTTONDOWN)
{
int leftcornerX = x;
int leftcornerY = y;
while( event != CV_EVENT_LBUTTONUP)
{
//method to retrieve your originalframe with no rectangles drawn -> either the original frame is a
//global variable, or you have to pass it using the void* userData input argument.
Mat copy = originalframe;
rectangle(copy, Point(leftcornerX, leftcornerY), Point(x, y), Scalar(255, 0, 0), 1, 8, 0);
imshow("Frame", copy);
waitKey(10);
}
}
}
This draws a rectangle between the point you first clicked with the left mouse button and the current mouse position, until you lift the mouse button.