Skip to content

Commit

Permalink
flip if statement, and fix likely off-by-one error
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinland committed Feb 12, 2025
1 parent 7afd10a commit 9eb3702
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/motion_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,19 @@ def detections_from_gray_imgs(self, gray1, gray2):
xs = [pt[0][0] for pt in c]
ys = [pt[0][1] for pt in c]
xmin, xmax, ymin, ymax = min(xs), max(xs), min(ys), max(ys)
# Add to list of detections if big enough
if (ymax - ymin) * (xmax - xmin) > self.min_box_size:
detections.append(
{
"confidence": 0.5,
"class_name": "motion",
"x_min": int(xmin),
"y_min": int(ymin),
"x_max": int(xmax),
"y_max": int(ymax),
}
)
# Ignore this detection if it's the wrong size
if (ymax - ymin) * (xmax - xmin) < self.min_box_size:
continue

detections.append(
{
"confidence": 0.5,
"class_name": "motion",
"x_min": int(xmin),
"y_min": int(ymin),
"x_max": int(xmax),
"y_max": int(ymax),
}
)

return detections

0 comments on commit 9eb3702

Please sign in to comment.