Skip to content

Commit 0bbbf71

Browse files
committed
fix regression
1 parent 658644b commit 0bbbf71

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

SEImplementation/SEImplementation/Plugin/MeasurementFrameRectangle/MeasurementFrameRectangle.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class MeasurementFrameRectangle: public Property {
4242
m_min_coord{-1, -1}, m_max_coord{-1, -1}, m_min_coord_image{-1, -1},
4343
m_max_coord_image{-1, -1}, m_bad_projection{bad_projection} {}
4444

45-
MeasurementFrameRectangle(ImageCoordinate min_coord_image, ImageCoordinate max_coord_image):
45+
MeasurementFrameRectangle(PixelCoordinate min_coord, PixelCoordinate max_coord,
46+
ImageCoordinate min_coord_image, ImageCoordinate max_coord_image):
47+
m_min_coord(min_coord), m_max_coord(max_coord),
4648
m_min_coord_image(min_coord_image), m_max_coord_image(max_coord_image), m_bad_projection{false} {
49+
assert(min_coord.m_x <= max_coord.m_x && min_coord.m_y <= max_coord.m_y);
4750
assert(min_coord_image.m_x <= max_coord_image.m_x && min_coord_image.m_y <= max_coord_image.m_y);
48-
m_min_coord = PixelCoordinate(static_cast<int>(min_coord_image.m_x + 0.5), static_cast<int>(min_coord_image.m_y + 0.5));
49-
m_max_coord = PixelCoordinate(static_cast<int>(max_coord_image.m_x + 0.5), static_cast<int>(max_coord_image.m_y + 0.5));
5051
}
5152

5253
PixelCoordinate getTopLeft() const {

SEImplementation/src/lib/Plugin/MeasurementFrameRectangle/MeasurementFrameRectangleTask.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,26 @@ void MeasurementFrameRectangleTask::computeProperties(SourceInterface& source) c
6767
auto max_x = std::max(coord1.m_x, std::max(coord2.m_x, std::max(coord3.m_x, coord4.m_x)));
6868
auto max_y = std::max(coord1.m_y, std::max(coord2.m_y, std::max(coord3.m_y, coord4.m_y)));
6969

70+
PixelCoordinate min_coord, max_coord;
71+
min_coord.m_x = int(min_x);
72+
min_coord.m_y = int(min_y);
73+
max_coord.m_x = int(max_x) + 1;
74+
max_coord.m_y = int(max_y) + 1;
75+
7076
// The full boundaries may lie outside of the frame
71-
if (bad_coordinates || max_x < 0.0 || max_y < 0.0 ||
72-
min_x >= measurement_frame_info.getWidth() - 0.5 || min_y >= measurement_frame_info.getHeight() - 0.5) {
77+
if (bad_coordinates || max_coord.m_x < 0 || max_coord.m_y < 0 ||
78+
min_coord.m_x >= measurement_frame_info.getWidth() || min_coord.m_y >= measurement_frame_info.getHeight()) {
7379
source.setIndexedProperty<MeasurementFrameRectangle>(m_instance, bad_coordinates);
7480
}
7581
// Clip the coordinates to fit the available image
7682
else {
77-
min_x = std::max(0.0, min_x);
78-
min_y = std::max(0.0, min_y);
79-
max_x = std::min(double(measurement_frame_info.getWidth()) - 0.5, max_x);
80-
max_y = std::min(double(measurement_frame_info.getHeight()) - 0.5, max_y);
83+
min_coord.m_x = std::max(0, min_coord.m_x);
84+
min_coord.m_y = std::max(0, min_coord.m_y);
85+
max_coord.m_x = std::min(measurement_frame_info.getWidth() - 1, max_coord.m_x);
86+
max_coord.m_y = std::min(measurement_frame_info.getHeight() - 1, max_coord.m_y);
8187

8288
source.setIndexedProperty<MeasurementFrameRectangle>(
83-
m_instance, ImageCoordinate(min_x, min_y), ImageCoordinate(max_x, max_y));
89+
m_instance, min_coord, max_coord, ImageCoordinate(min_x, min_y), ImageCoordinate(max_x, max_y));
8490
}
8591
}
8692

SEImplementation/src/lib/Plugin/MeasurementFrameRectangle/MeasurementFrameRectangleTaskNoDetect.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,26 @@ void MeasurementFrameRectangleTaskNoDetect::computeProperties(SourceInterface& s
6464
auto max_x = std::max(coord1.m_x, std::max(coord2.m_x, std::max(coord3.m_x, coord4.m_x)));
6565
auto max_y = std::max(coord1.m_y, std::max(coord2.m_y, std::max(coord3.m_y, coord4.m_y)));
6666

67+
PixelCoordinate min_coord, max_coord;
68+
min_coord.m_x = int(min_x);
69+
min_coord.m_y = int(min_y);
70+
max_coord.m_x = int(max_x) + 1;
71+
max_coord.m_y = int(max_y) + 1;
72+
6773
// The full boundaries may lie outside of the frame
68-
if (bad_coordinates || max_x < 0.0 || max_y < 0.0 ||
69-
min_x >= measurement_frame_info.getWidth() - 0.5 || min_y >= measurement_frame_info.getHeight() - 0.5) {
74+
if (bad_coordinates || max_coord.m_x < 0 || max_coord.m_y < 0 ||
75+
min_coord.m_x >= measurement_frame_info.getWidth() || min_coord.m_y >= measurement_frame_info.getHeight()) {
7076
source.setIndexedProperty<MeasurementFrameRectangle>(m_instance, bad_coordinates);
7177
}
7278
// Clip the coordinates to fit the available image
7379
else {
74-
min_x = std::max(0.0, min_x);
75-
min_y = std::max(0.0, min_y);
76-
max_x = std::min(double(measurement_frame_info.getWidth()) - 0.5, max_x);
77-
max_y = std::min(double(measurement_frame_info.getHeight()) - 0.5, max_y);
80+
min_coord.m_x = std::max(0, min_coord.m_x);
81+
min_coord.m_y = std::max(0, min_coord.m_y);
82+
max_coord.m_x = std::min(measurement_frame_info.getWidth() - 1, max_coord.m_x);
83+
max_coord.m_y = std::min(measurement_frame_info.getHeight() - 1, max_coord.m_y);
7884

7985
source.setIndexedProperty<MeasurementFrameRectangle>(
80-
m_instance, ImageCoordinate(min_x, min_y), ImageCoordinate(max_x, max_y));
86+
m_instance, min_coord, max_coord, ImageCoordinate(min_x, min_y), ImageCoordinate(max_x, max_y));
8187
}
8288
}
8389

0 commit comments

Comments
 (0)