Updated by Andrey Kamaev about 13 years ago
DESCRIPTION OF THE BUG
The @setMouseCallBack@ setMouseCallBack provides an incorrect (x,y) when the user clicks on an image that is larger than the screen.
When the image finds the screen mouse clicking works fine.
When only 10% of the image falls outside my screen the error is small.
When 50% of the image doesn't fit the screen the error is larger. Therefore it must be related to the visible area and the image size.
The following code demonstrates demostrates the bug, make sure to select more image.rows than your screen is able to display.
This bug was detected under windows 32-bit and windows 64-bit.
Thanks in advance, and keep up the good work!
best wishes, Frank ter Haar
SAMPLE CODE
<pre><code class="cpp">
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
string title = "mouse callback bug";
int image_height_too_large_for_your_screen = 2000;
void onMouseClick(int event, int x, int y, int flags, void* param )
{
if(event != CV_EVENT_LBUTTONDOWN) return;
printf("%d, %d\n",x,y);
Mat* in = (Mat*)param;
Mat tmp;
in->copyTo( tmp );
circle(tmp,Point(x,y),5,Scalar(255));
string text = "this is not where I clicked";
cv::putText(tmp,text,Point(x,y),0, 0.5, Scalar(255));
imshow(title, tmp);
}
int main( int argc, char** argv )
{
Mat image = Mat::zeros(image_height_too_large_for_your_screen, 800, CV_8U);
cv::imshow(title, image);
cv::setMouseCallback( title, onMouseClick, (void *)(&image) );
cv::waitKey(0);
}
</code></pre>
The @setMouseCallBack@ setMouseCallBack provides an incorrect (x,y) when the user clicks on an image that is larger than the screen.
When the image finds the screen mouse clicking works fine.
When only 10% of the image falls outside my screen the error is small.
When 50% of the image doesn't fit the screen the error is larger. Therefore it must be related to the visible area and the image size.
The following code demonstrates demostrates the bug, make sure to select more image.rows than your screen is able to display.
This bug was detected under windows 32-bit and windows 64-bit.
Thanks in advance, and keep up the good work!
best wishes, Frank ter Haar
SAMPLE CODE
<pre><code class="cpp">
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
string title = "mouse callback bug";
int image_height_too_large_for_your_screen = 2000;
void onMouseClick(int event, int x, int y, int flags, void* param )
{
if(event != CV_EVENT_LBUTTONDOWN) return;
printf("%d, %d\n",x,y);
Mat* in = (Mat*)param;
Mat tmp;
in->copyTo( tmp );
circle(tmp,Point(x,y),5,Scalar(255));
string text = "this is not where I clicked";
cv::putText(tmp,text,Point(x,y),0, 0.5, Scalar(255));
imshow(title, tmp);
}
int main( int argc, char** argv )
{
Mat image = Mat::zeros(image_height_too_large_for_your_screen, 800, CV_8U);
cv::imshow(title, image);
cv::setMouseCallback( title, onMouseClick, (void *)(&image) );
cv::waitKey(0);
}
</code></pre>