Skip to content

Commit fc5d801

Browse files
authored
Fix rectangle previews (#754)
Now they don't freeze or show the original image when there's no rectangles
1 parent 6435def commit fc5d801

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

ui/src/main/java/edu/wpi/grip/ui/preview/RectangleSocketPreviewView.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,20 @@ protected void convertImage() {
6060
final List<Rect> rectangles = report.getRectangles();
6161
Mat input = report.getImage();
6262

63-
// If rectangles were found, draw them on the image before displaying it
64-
if (!rectangles.isEmpty()) {
65-
if (input.channels() == 3) {
66-
input.copyTo(tmp);
67-
} else {
68-
cvtColor(input, tmp, CV_GRAY2BGR);
69-
}
63+
if (input.channels() == 3) {
64+
input.copyTo(tmp);
65+
} else {
66+
cvtColor(input, tmp, CV_GRAY2BGR);
67+
}
7068

71-
// If we don't want to see the background image, set it to black
72-
if (!this.showInputImage) {
73-
bitwise_xor(tmp, tmp, tmp);
74-
}
69+
// If we don't want to see the background image, set it to black
70+
if (!this.showInputImage) {
71+
bitwise_xor(tmp, tmp, tmp);
72+
}
7573

76-
for (Rect r : rectangles) {
77-
rectangle(tmp, r, Scalar.WHITE, 3, LINE_8, 0);
78-
}
74+
// If rectangles were found, draw them on the image before displaying it
75+
for (Rect r : rectangles) {
76+
rectangle(tmp, r, Scalar.WHITE, 3, LINE_8, 0);
7977
}
8078
final Mat convertInput = tmp;
8179
final int numRegions = rectangles.size();

0 commit comments

Comments
 (0)