forked from andrew/feedmill-recounter
chore: tidy stale 1920x1080 docstrings and drop dead writer
This commit is contained in:
1 parent
6610a466ee
commit
0fe59abb4a
3 files changed
+19
-19
No files matched your search
@@ -158,10 +158,9 @@ def upload():
|
||||
def _static_roi(zone: dict) -> TruckROI:
|
||||
"""Build the fixed zone ROI in FCP's 1280x720 analysis frame.
|
||||
|
||||
The zone preset is authored for 1920x1080 (zones.json reference_resolution)
|
||||
and scaled down to the analysis frame exactly like FCP does
|
||||
(predict.py:687-689) — it must not be scaled to the uploaded clip's
|
||||
native size.
|
||||
Zone presets are authored in 1280x720 (zones.json reference_resolution is
|
||||
[1280, 720]), so the scale factor is 1.0. The zone must not be scaled to
|
||||
the uploaded clip's native size.
|
||||
"""
|
||||
return build_static_roi(zone, *ANALYSIS_SIZE)
|
||||
|
||||
@@ -169,8 +168,7 @@ def _static_roi(zone: dict) -> TruckROI:
|
||||
def _static_polygon(zone: dict) -> Polygon | None:
|
||||
"""Build the counting polygon in FCP's 1280x720 analysis frame.
|
||||
|
||||
Same arithmetic as FCP's hardcoded detection_polygon (predict.py:688-698):
|
||||
the zone's counting_area scaled by 1280/1920 x 720/1080, truncated.
|
||||
The zone's counting_area is in the same 1280x720 space (scale factor 1.0).
|
||||
"""
|
||||
return build_counting_polygon(zone, *ANALYSIS_SIZE)
|
||||
|
||||
@@ -178,8 +176,7 @@ def _static_polygon(zone: dict) -> Polygon | None:
|
||||
def _static_truck_polygon(zone: dict) -> Polygon | None:
|
||||
"""Build the truck-area polygon in FCP's 1280x720 analysis frame.
|
||||
|
||||
Same arithmetic as FCP's hardcoded truck_polygon (predict.py:706-712):
|
||||
the zone's truck_area scaled by 1280/1920 x 720/1080, truncated.
|
||||
The zone's truck_area is in the same 1280x720 space (scale factor 1.0).
|
||||
"""
|
||||
return build_truck_polygon(zone, *ANALYSIS_SIZE)
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@ def load_zone_config(path: str) -> dict[str, Any]:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def save_zone_config(config: dict[str, Any], path: str) -> None:
|
||||
"""Save zone config dict to zones.json."""
|
||||
with open(path, "w") as f:
|
||||
json.dump(config, f, indent=2)
|
||||
|
||||
|
||||
def build_static_roi(zone: dict[str, Any], video_w: int, video_h: int) -> TruckROI:
|
||||
"""Build a TruckROI from a zone config dict, scaling from reference resolution.
|
||||
|
||||
|
||||
+14
-5
@@ -10,6 +10,7 @@ import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
@@ -29,11 +30,19 @@ def load_zones(path: str) -> dict:
|
||||
def save_zones(config: dict, path: str):
|
||||
if os.path.exists(path):
|
||||
shutil.copy2(path, path + ".bak")
|
||||
tmp = path + ".tmp"
|
||||
with open(tmp, "w", encoding="utf-8") as f:
|
||||
json.dump(config, f, indent=2)
|
||||
f.write("\n")
|
||||
os.replace(tmp, path)
|
||||
fd, tmp = tempfile.mkstemp(prefix=".zones.", suffix=".tmp",
|
||||
dir=os.path.dirname(path) or ".")
|
||||
try:
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
||||
json.dump(config, f, indent=2)
|
||||
f.write("\n")
|
||||
os.replace(tmp, path)
|
||||
except BaseException:
|
||||
try:
|
||||
os.remove(tmp)
|
||||
except OSError:
|
||||
pass
|
||||
raise
|
||||
|
||||
|
||||
def merge_preset(config: dict, preset_name: str, preset: dict) -> None:
|
||||
|
||||
Reference in new issue
Block a user