Zuschnitt als Regel statt als gespeichertes Bild
Die Sichtung merkt sich jetzt, WO der Vogel im Foto sitzt (vier Zahlen); die Anzeige schneidet daraus bei jedem Aufruf. Eine geaenderte Regel wirkt damit sofort auf den ganzen Bestand. Altbestand faellt auf das alte Bild zurueck.
This commit is contained in:
1 parent
f572c20080
commit
a97f066e92
14 files changed
+421
-19
No files matched your search
@@ -35,6 +35,9 @@ def payload_of(sighting: Sighting) -> dict:
|
||||
"frames_with_bird": sighting.frames_with_bird,
|
||||
"votes": {k: round(v, 4) for k, v in sighting.votes.items()},
|
||||
"mean_bird_score": round(sighting.mean_bird_score, 4),
|
||||
# Vier Zahlen statt eines zweiten Bildes: siehe web/dex/zuschnitt.py.
|
||||
"box": ([round(w, 5) for w in sighting.best_box]
|
||||
if getattr(sighting, "best_box", None) else None),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ class Warteschlange:
|
||||
"votes": {g.species.slug: round(g.confidence, 4)
|
||||
for g in (result.guesses[:5] if result else [])},
|
||||
}
|
||||
# Wo der Vogel sitzt. Die Sammlung schneidet daraus selbst zu --
|
||||
# siehe web/dex/zuschnitt.py.
|
||||
if box is not None:
|
||||
nutzlast["box"] = [round(box.x0, 5), round(box.y0, 5),
|
||||
round(box.x1, 5), round(box.y1, 5)]
|
||||
dateien = {}
|
||||
if ausschnitt is not None:
|
||||
dateien["crop"] = ("crop.jpg", _encode(ausschnitt, 640), "image/jpeg")
|
||||
|
||||
@@ -36,6 +36,9 @@ class Sighting:
|
||||
best_crop: Image.Image | None
|
||||
best_sharpness: float
|
||||
mean_bird_score: float
|
||||
# Wo der Vogel im besten Bild sitzt, relativ. Die Sammlung schneidet
|
||||
# daraus selbst zu -- siehe web/dex/zuschnitt.py.
|
||||
best_box: tuple[float, float, float, float] | None = None
|
||||
|
||||
@property
|
||||
def duration_s(self) -> float:
|
||||
@@ -127,6 +130,7 @@ class Watcher:
|
||||
self._best_sharp = -1.0
|
||||
self._best_image: Image.Image | None = None
|
||||
self._best_crop: Image.Image | None = None
|
||||
self._best_box: tuple[float, float, float, float] | None = None
|
||||
self._bird_scores: list[float] = []
|
||||
self._frame_i = 0
|
||||
|
||||
@@ -230,6 +234,7 @@ class Watcher:
|
||||
self._best_sharp = score
|
||||
self._best_image = frame.copy()
|
||||
self._best_crop = box.anzeige_ausschnitt(frame)
|
||||
self._best_box = (box.x0, box.y0, box.x1, box.y1)
|
||||
|
||||
def _vote(self, box: Box, result: Result) -> None:
|
||||
# Gewicht: wie sicher ist der Detektor, wie groß ist der Vogel im Bild,
|
||||
@@ -279,6 +284,7 @@ class Watcher:
|
||||
frames_with_bird=self._bird_frames,
|
||||
best_image=self._best_image,
|
||||
best_crop=self._best_crop,
|
||||
best_box=self._best_box,
|
||||
best_sharpness=max(0.0, self._best_sharp),
|
||||
mean_bird_score=mittel,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user