Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

fix user threshold (#76)

Rory Clear809d88a0c3e1
diff --git a/clearcam.py b/clearcam.py
index 4cd30ad..d7c6277 100644
--- a/clearcam.py
+++ b/clearcam.py
@@ -499,7 +499,7 @@ class VideoCapture:
continue
fail_count = 0
frame = np.frombuffer(raw_bytes, np.uint8).reshape((self.height, self.width, 3))
- filtered_preds = [p for p in self.last_preds if p[4] >= yolo_thresh and (classes is None or str(int(p[5])) in classes)]
+ filtered_preds = [p for p in self.last_preds if (classes is None or str(int(p[5])) in classes)]
if count > 10:
if last_preview_time is None or time.time() - last_preview_time >= 3600: # preview every hour
@@ -2778,15 +2778,12 @@ if __name__ == "__main__":
cam_name = next((arg.split("=", 1)[1] for arg in sys.argv[1:] if arg.startswith("--cam_name=")), "my_camera")
- track_thresh = 0.5 #default 0.6
- yolo_thresh = 0.5
track = True #for now
if track:
from yolox.tracker.byte_tracker import BYTETracker
class Args:
def __init__(self):
- self.track_thresh = track_thresh
self.track_buffer = 60 # frames, was 30
self.mot20 = False
self.match_thresh = 0.9
diff --git a/yolox/tracker/byte_tracker.py b/yolox/tracker/byte_tracker.py
index 3ed4577..9362413 100644
--- a/yolox/tracker/byte_tracker.py
+++ b/yolox/tracker/byte_tracker.py
@@ -165,9 +165,9 @@ class BYTETracker(object):
scale = min(img_size[0] / float(img_h), img_size[1] / float(img_w))
bboxes /= scale
- remain_inds = scores > self.args.track_thresh
+ remain_inds = scores > threshold # prev track thresh
inds_low = scores > 0.1
- inds_high = scores < self.args.track_thresh
+ inds_high = scores < threshold # prev track thresh
inds_second = np.logical_and(inds_low, inds_high)
dets_second = bboxes[inds_second]
@@ -222,7 +222,7 @@ class BYTETracker(object):
detections_second = []
r_tracked_stracks = [strack_pool[i] for i in u_track if strack_pool[i].state == TrackState.Tracked]
dists = matching.iou_distance(r_tracked_stracks, detections_second)
- matches, u_track, u_detection_second = matching.linear_assignment(dists, thresh=0.5)
+ matches, u_track, u_detection_second = matching.linear_assignment(dists, thresh=threshold) # prev 0.5
for itracked, idet in matches:
track = r_tracked_stracks[itracked]
det = detections_second[idet]
@@ -320,4 +320,4 @@ def remove_duplicate_stracks(stracksa, stracksb):
dupa.append(p)
resa = [t for i, t in enumerate(stracksa) if not i in dupa]
resb = [t for i, t in enumerate(stracksb) if not i in dupb]
- return resa, resb
+ return resa, resb
\ No newline at end of file