You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chameleon/integration/ptz17_trusted_geometry_reco.../trusted_recovery.patch

69 lines
4.2 KiB
Diff

--- a/postprocess.py
+++ b/postprocess.py
@@ -7904,14 +7904,31 @@
geometry_match = validated_geometry_target = None
seeded_geometry = None
geometry_outcome = "geometry_no_box"
- if (gross_visual_jump or geometric_reject) and visual_result.bbox is not None:
+ geometry_reference = visual_result.bbox
+ trusted_geometry_recovery = cam_idx == _PTZ17_CAM_IDX and geometric_reject
+ same_detector_frame = False
+ if trusted_geometry_recovery:
+ # The rejected proposal is unavailable as a spatial reference.
+ # Only a detector pass on this exact sequence may vote.
+ same_detector_frame = (
+ not visual_only and source_seq is not None and source_seq > 0
+ and visual_result.source_seq == source_seq
+ )
+ geometry_reference = (
+ previous_control_bbox if same_detector_frame
+ and isinstance(previous_control_bbox, (tuple, list))
+ and len(previous_control_bbox) == 4 else None
+ )
+ if not same_detector_frame:
+ geometry_outcome = "geometry_no_current_detector_frame"
+ if (gross_visual_jump or geometric_reject) and geometry_reference is not None:
# A large motion is safe only when the *current* detector agrees
# with that new location. A backend result that passed its own
# geometry checks may be refreshed immediately. A rejected
# location needs two independent detector frames; one large
# cloud/building box must never switch the controlled target.
validated_geometry_target = _find_matching_detector_target(
- visual_result.bbox,
+ geometry_reference,
reacquire_targets,
w,
h,
@@ -8005,7 +8022,7 @@
_record_ptz17_recovery(
cam_idx, st, now, source_seq, w, h, visual_result,
input_kind=recovery_input_kind, outcome="geometry_reinitialized",
- trusted_bbox=previous_control_bbox, reference_bbox=visual_result.bbox,
+ trusted_bbox=previous_control_bbox, reference_bbox=geometry_reference,
validation_targets=validation_targets, reacquire_targets=reacquire_targets,
raw_box_count=raw_box_count, detector_match=geometry_match,
selected=validated_geometry_target, seeded=seeded_geometry,
@@ -8017,6 +8034,13 @@
geometric_reject = False
geometry_reinitialized = True
_clear_loss_reacquire_candidate(st, "geometry_reinitialized")
+ if (
+ trusted_geometry_recovery and same_detector_frame and geometric_reject
+ and geometry_match is None and source_seq is not None
+ and source_seq > int(st.get("visual_reacquire_source_seq", -1))
+ ):
+ _clear_loss_reacquire_candidate(st, "geometry_detector_miss")
+ st["visual_reacquire_source_seq"] = source_seq
if geometric_reject:
# visual_tracker.py deliberately keeps the last trusted bbox and
# requires two consistent recovery frames. Do not destroy that
@@ -8044,7 +8068,7 @@
_record_ptz17_recovery(
cam_idx, st, now, source_seq, w, h, visual_result,
input_kind=recovery_input_kind, outcome=geometry_outcome,
- trusted_bbox=previous_control_bbox, reference_bbox=visual_result.bbox,
+ trusted_bbox=previous_control_bbox, reference_bbox=geometry_reference,
validation_targets=validation_targets, reacquire_targets=reacquire_targets,
raw_box_count=raw_box_count,
detector_match=geometry_match, selected=validated_geometry_target,