Skip to content

Commit be35177

Browse files
#378 added functionality for "black bars on the side" case
1 parent 62ae130 commit be35177

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

atom_rviz_plugins/image_display_with_click/src/mouse_watcher.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ bool MouseWatcher::eventFilter(QObject * obj, QEvent * event)
4949
else // case where the window is wider than the image
5050
{
5151
cout << "black bars on side!" << endl;
52-
// TODO add the computation of pix_x and pix_y for this case
52+
pix_y = int(float(windowPos.y()) / float(win_height) * float(img_height));
53+
54+
int resized_img_width = int(float(win_height) / float(img_height) * float(img_width));
55+
int bias = int( ( float(win_width) - float(resized_img_width) )/2.0);
56+
pix_x = (float(windowPos.x()) - bias) / float(resized_img_width) * float(img_width);
57+
cout << "pix_x = " << pix_x << endl;
58+
cout << "resized_img_width = " << resized_img_width << endl;
59+
cout << "bias = " << bias << endl;
60+
cout << "pix_y = " << pix_y << endl;
5361
}
5462

5563
// Check if clicked point is inside the image, publish if so

0 commit comments

Comments
 (0)