Skip to content

feat(alerts): display detection crop overlay on main image#209

Merged
MateoLostanlen merged 14 commits into
mainfrom
feat/detection-crop-overlay
Jun 17, 2026
Merged

feat(alerts): display detection crop overlay on main image#209
MateoLostanlen merged 14 commits into
mainfrom
feat/detection-crop-overlay

Conversation

@MateoLostanlen

@MateoLostanlen MateoLostanlen commented Apr 27, 2026

Copy link
Copy Markdown
Member

Why

Make faster decisions on small fires from afar. The crop gives reviewers a tight, zoomed-in view of the smoke so they can confirm or dismiss without waiting on the full frame.

Companion PRs:

Demo: https://www.loom.com/share/0f5a3c5310044779abf3bb9dcdbc02ec

Note on the demo: the source images are already compressed HD frames, so the actual resolution benefit of the crop isn't really visible in the video. On real raw frames the close-up will be noticeably sharper.

What changes

  • Surface the new optional crop_url returned by GET /sequences/{id}/detections (with with_crop=true) in the detection schema.
  • Render the crop as a small (~150px) thumbnail pinned to a top corner of the detection viewer, flipping between top-left and top-right based on the bbox center so it never sits on the smoke.
  • Add a toggle button next to the existing bbox toggle so reviewers can hide the close-up. The overlay is automatically skipped for older detections without a crop.
  • Add buttonDisplayCrop / buttonHideCrop labels in en/fr/es/de (close-up / gros plan / primer plano / Nahaufnahme).

How to test

Run against the dev env with the engine and api PR branches. Heads-up: the current engine PR loops the same image, which makes the demo less convincing. For testing prefer the send_detection_crop_changing_images branch on pyro-engine, which is the same PR plus image rotation. A separate PR will fold that change into engine soon.

Note

This is a first proposal, fully open to discussion on both design and implementation. Feel free to commit directly on this branch if needed.

Surface optional crop_url returned by /sequences/{id}/detections
when with_crop=true. Field is nullable for older detections without
a crop.
Display the optional crop image returned by the API as a small
thumbnail pinned to the top-left of the detection viewer, with a
toggle button alongside the existing bbox toggle. The overlay is
only rendered when crop_url is present.
Add buttonDisplayCrop / buttonHideCrop in en/fr/es/de under the
alerts namespace.
Replace 'crop' with 'recadrage' which is the correct French term.
Place the crop preview opposite the detection: top-left when the
bbox center is on the right half of the image, top-right otherwise.
Avoids the overlay sitting on top of the smoke.
Use close-up / gros plan / primer plano / Nahaufnahme to better
convey that the inset shows a zoomed-in view of the smoke.
Render the crop at its native 224px width to match the model input
size, so reviewers see the full-resolution close-up.
@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
new-pyro-platform Ready Ready Preview, Comment Jun 16, 2026 6:19am

@MateoLostanlen

Copy link
Copy Markdown
Member Author

I have a few questions to discuss together.
The crop moves from right to left depending on the detection position, which is good, but it hides the little window that shows us where we're zooming. How do we handle this, do we shift the crop, or maybe the crop disappears as soon as we zoom in?
What window size should we use? 150 here, the base image is 224x224.
The name, we say "crop" in English normally, I'm not really sure how to translate it

@MateoLostanlen MateoLostanlen requested review from fe51 and m-julio April 27, 2026 06:34
@fe51

fe51 commented Apr 28, 2026

Copy link
Copy Markdown
Member

Hi Mateo, thanks for making a first proposition to #203 !

At this stage of the discussion, provided the crop dimensions remain 224×224, I will try to include the full crop !

Now, as discussed and pointed out in your comment, the crop image must not alter the "map zoom" (At least we need to avoid it)

What about a display that’s always at the bottom right if the light is mainly in the left-hand area (the centre of the bounding boxes of the sequences? Or just the first one?), and vice versa?

So, when might this approach cause problems?
If a bounding box is so wide that, even though it is mainly on one side, it overlaps onto the other side, and the bounding box and the crop area overlap?
On the one hand, this is a situation where we would need to count the number of occurrences; on the other hand, let us remember that the crop area is not displayed by default at this stage (and if it were, one would simply need to click to hide it).

…verlay

# Conflicts:
#	src/components/Alerts/AlertDetails/AlertImages/AlertImages.tsx
#	src/services/alerts.ts
…verlay

# Conflicts:
#	src/components/Alerts/AlertDetails/AlertImages/AlertImages.tsx
@MateoLostanlen

Copy link
Copy Markdown
Member Author

Hi @fe51 , I updated the PR to have the crop at imge bottom, let me know what you think

https://www.loom.com/share/3b241412aa5d4d6dab18908dbd4f86fa

@fe51

fe51 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the PR !
Some functionnal remark before asking react expert review !

  • Button to hide/show "close-up". Would be nice to keep a similar design to show hide bbox, so a cross-out obj

  • Cameras that are not from pyronear station hardware, actually does not have the crop, the button should not be visible when no crop is available ? What do you think ? Actually wierd for a user having these not usable button (ex some cam in ardeche)

@MateoLostanlen

MateoLostanlen commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Hi @fe51 , as discussed on the side, I've updated the button.

For the second question, I'd actually suggest the opposite: making a change on the engine so it applies everywhere, even when it's not a 4K cam. It acts as a kind of zoom, which is pretty handy.

Screenshot 2026-06-09 at 16 58 34 Screenshot 2026-06-09 at 16 58 46

@fe51

fe51 commented Jun 9, 2026

Copy link
Copy Markdown
Member

I agree.

Hence, OK for functionnal aspects

Then, to be reviewed and merge only when crop is available for any alert (api side)) ?

Comment thread src/services/alerts.ts Outdated
others_bboxes: z.nullable(z.string()),
created_at: z.iso.datetime({ local: true }),
url: z.string(),
crop_url: z.nullable(z.string()).optional(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is .optional() ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have both null and undefined covered you should use nullish : https://zod.dev/api?id=nullish#nullish

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, switched to z.string().nullish()

@m-julio m-julio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on mobile ?

@MateoLostanlen

Copy link
Copy Markdown
Member Author

Hi @m-julio, I haven't tested it on mobile yet. How do you usually do it,through the Vercel preview? I don't think I have access to it, so let me know how you go about it

@MateoLostanlen

Copy link
Copy Markdown
Member Author

Hi @m-julio, just tested on mobile it works
Screenshot 2026-06-16 at 08 16 39

@MateoLostanlen MateoLostanlen merged commit ce7b5da into main Jun 17, 2026
3 checks passed
@MateoLostanlen MateoLostanlen deleted the feat/detection-crop-overlay branch June 17, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants