OpenScrub 1.0.44__tar.gz → 1.0.45__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OpenScrub
3
- Version: 1.0.44
3
+ Version: 1.0.45
4
4
  Summary: Local, GPU-accelerated redaction for video and screen recordings — blur, black-box, or mosaic faces, names, and any regex-matchable PII, with human review.
5
5
  Project-URL: Homepage, https://github.com/austinmabry/OpenScrub
6
6
  Project-URL: Repository, https://github.com/austinmabry/OpenScrub
@@ -35,7 +35,7 @@ from dataclasses import dataclass, asdict
35
35
  import cv2
36
36
  import numpy as np
37
37
 
38
- VERSION = "1.0.44"
38
+ VERSION = "1.0.45"
39
39
 
40
40
  # ----------------------------------------------------------------------------
41
41
  # OCR backends
@@ -963,7 +963,19 @@ def assign_dense_tracks(dets, max_gap=0.6, reach=1.6):
963
963
  """Group dense per-frame detections into tracks: consecutive samples of
964
964
  the same physical object (a face crossing the frame) get one track id.
965
965
  Purely additive metadata — rendering still uses each per-frame box; the
966
- review UI collapses a track into a single keep/blur decision."""
966
+ review UI collapses a track into a single keep/blur decision.
967
+
968
+ Two association defenses (the same hardening face identity-grouping
969
+ needed on crowd footage):
970
+ - TEMPORAL CANNOT-LINK: a track can absorb at most one sample per
971
+ timestamp — two detections in the SAME frame are different physical
972
+ objects by definition. Without this, three people on a boat merged
973
+ into one review card, and enabling it blurred all of them.
974
+ - Category-scaled reach: 1.6x box size is calibrated for FACES.
975
+ A full-body person box is most of the frame tall, so 1.6x its size
976
+ let different people chain together; person tracks associate within
977
+ 0.5x instead (still generous across detector-flicker gaps —
978
+ smooth_dense_tracks bridges those explicitly)."""
967
979
  tracks = [] # [id, category, last_t, last_box]
968
980
  next_id = 0
969
981
  for d in sorted((x for x in dets if getattr(x, "dense", False)),
@@ -972,15 +984,18 @@ def assign_dense_tracks(dets, max_gap=0.6, reach=1.6):
972
984
  cx0 = (bx[0] + bx[2]) / 2
973
985
  cy0 = (bx[1] + bx[3]) / 2
974
986
  size = max(bx[2] - bx[0], bx[3] - bx[1], 1)
987
+ r = 0.5 if d.category == "person" else reach
975
988
  best = None
976
989
  for tr in tracks:
977
990
  if tr[1] != d.category or d.t_start - tr[2] > max_gap:
978
991
  continue
992
+ if d.t_start - tr[2] < 1e-6:
993
+ continue # co-temporal: already holds a sample here
979
994
  lb = tr[3]
980
995
  lcx = (lb[0] + lb[2]) / 2
981
996
  lcy = (lb[1] + lb[3]) / 2
982
997
  dist = ((cx0 - lcx) ** 2 + (cy0 - lcy) ** 2) ** 0.5
983
- if dist <= reach * size and (best is None or dist < best[0]):
998
+ if dist <= r * size and (best is None or dist < best[0]):
984
999
  best = (dist, tr)
985
1000
  if best is None:
986
1001
  tracks.append([next_id, d.category, d.t_start, bx])
@@ -1327,3 +1327,45 @@ def test_person_seg_forward_crash_degrades_to_boxes():
1327
1327
  assert det.seg is False, "must drop out of seg mode after the failure"
1328
1328
  assert len(rows) == 1 and len(rows[0]) == 5, \
1329
1329
  "box fallback must still return detections"
1330
+
1331
+
1332
+ def test_dense_tracks_never_merge_cotemporal_objects():
1333
+ """Track association hardening (the boat-video bug): three people side
1334
+ by side collapsed into one track — enabling one review card blurred
1335
+ everyone. Two detections in the SAME frame are different physical
1336
+ objects and must NEVER share a track, and person-sized boxes need a
1337
+ tighter association radius than faces (1.6x a full-body box spans most
1338
+ of the frame)."""
1339
+ dets = []
1340
+ for f in range(10):
1341
+ t = f / 30.0
1342
+ for p in range(3): # 3 people, 220px apart
1343
+ x = 100 + p * 220 + f * 2
1344
+ dets.append(openscrub.Detection(t, t + 0.01,
1345
+ (x, 100, x + 200, 500),
1346
+ "person", "person", 0.9, (0, 0),
1347
+ dense=True))
1348
+ n = openscrub.assign_dense_tracks(dets)
1349
+ assert n == 3, "3 co-visible people must yield 3 tracks, got %d" % n
1350
+ per_track = {}
1351
+ for d in dets:
1352
+ per_track.setdefault(d.track, []).append(d)
1353
+ for samples in per_track.values():
1354
+ ts = [round(x.t_start, 3) for x in samples]
1355
+ assert len(set(ts)) == len(ts), \
1356
+ "a track absorbed two samples from the same frame"
1357
+ xs = {x.cbox[0] - i * 2 for i, x in
1358
+ enumerate(sorted(samples, key=lambda z: z.t_start))}
1359
+ assert len(xs) == 1, "a track jumped between different people"
1360
+
1361
+ # faces benefit from the same cannot-link: two adjacent faces in the
1362
+ # same frame stay separate tracks
1363
+ fd = []
1364
+ for f in range(6):
1365
+ t = f / 30.0
1366
+ for p in range(2):
1367
+ x = 100 + p * 90
1368
+ fd.append(openscrub.Detection(t, t + 0.01, (x, 100, x + 60, 160),
1369
+ "face", "face", 0.9, (0, 0),
1370
+ dense=True))
1371
+ assert openscrub.assign_dense_tracks(fd) == 2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes