Refine manage overlay: US/CAN state abbreviations, share-QR caption, and an escalating second menu with named-face labels
Build and push server image / build-and-push (push) Successful in 32s
Build and push server image / build-and-push (push) Successful in 32s
Two rounds of follow-up work on the manage-button overlay:
1. Location formatting: US/Canada now show abbreviated state/province
("CA", "ON") instead of the full name, other countries show the full
country name, and each is its own line (was one line, now wraps to
two) so longer international place names have more room without
threatening to overlap the top-right QR box. The bottom-left share QR
also gets a "SCAN TO DOWNLOAD" caption.
2. Escalating menu: pressing the manage button again while its overlay
is already up adds a second level -- each Immich-identified person's
name labeled next to their face in the photo (using Immich's own
face recognition/People data, no detection/recognition added to this
project). A third press exits immediately instead of waiting out the
30s auto-revert timer. No new Immich API needed -- GET /api/faces
already embeds a nullable person.name per face; new
server/app/face_labels.py maps a named face's box into the final
800x480 frame's pixel space (reusing crop-box math extracted from
image_pipeline.py's face-aware cropping). Capped at 4 named faces,
sized to a real firmware RAM budget: each label is its own malloc'd
overlay region on the device, alongside the 4 fixed corner regions
already in use. New GET /frame/face-labels returns a flattened
fixed-slot JSON shape (not a real array) so firmware's existing
flat-scalar parser can read it without needing an actual array
parser. No persistent state needed for the escalation itself -- it's
all local control flow within one continuous awake session
(frame_client.c's run_management_menu()).
This commit is contained in:
@@ -34,6 +34,27 @@ def _build_palette_image() -> Image.Image:
|
||||
_PALETTE_IMAGE = _build_palette_image()
|
||||
|
||||
|
||||
def _plain_center_crop_box(
|
||||
img_width: int, img_height: int, target_width: int, target_height: int
|
||||
) -> tuple[float, float, int, int]:
|
||||
"""The largest target_width:target_height window centered in the
|
||||
source image -- the same box ImageOps.fit() computes internally when
|
||||
there's no face-aware shift to apply. Returns (left, top, crop_w,
|
||||
crop_h); left/top are floats (not yet rounded) since callers that go
|
||||
on to face-shift this box need the unrounded center point."""
|
||||
target_ratio = target_width / target_height
|
||||
if img_width / img_height > target_ratio:
|
||||
crop_h = img_height
|
||||
crop_w = int(crop_h * target_ratio)
|
||||
else:
|
||||
crop_w = img_width
|
||||
crop_h = int(crop_w / target_ratio)
|
||||
|
||||
left = (img_width - crop_w) / 2
|
||||
top = (img_height - crop_h) / 2
|
||||
return left, top, crop_w, crop_h
|
||||
|
||||
|
||||
def _face_aware_crop_box(
|
||||
img_width: int, img_height: int, target_width: int, target_height: int, faces: list[dict]
|
||||
) -> tuple[int, int, int, int]:
|
||||
@@ -63,16 +84,7 @@ def _face_aware_crop_box(
|
||||
min_y = min(min_y, face["boundingBoxY1"] * scale_y)
|
||||
max_y = max(max_y, face["boundingBoxY2"] * scale_y)
|
||||
|
||||
target_ratio = target_width / target_height
|
||||
if img_width / img_height > target_ratio:
|
||||
crop_h = img_height
|
||||
crop_w = int(crop_h * target_ratio)
|
||||
else:
|
||||
crop_w = img_width
|
||||
crop_h = int(crop_w / target_ratio)
|
||||
|
||||
left = (img_width - crop_w) / 2
|
||||
top = (img_height - crop_h) / 2
|
||||
left, top, crop_w, crop_h = _plain_center_crop_box(img_width, img_height, target_width, target_height)
|
||||
|
||||
if max_x - min_x <= crop_w:
|
||||
if min_x < left:
|
||||
|
||||
Reference in New Issue
Block a user