Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hi-res stream for plate recognition. #36

Open
RutgerDiehard opened this issue Feb 16, 2024 · 16 comments
Open

Use hi-res stream for plate recognition. #36

RutgerDiehard opened this issue Feb 16, 2024 · 16 comments

Comments

@RutgerDiehard
Copy link

I have a 4K camera that's used to capture person and car objects on my drive. Object detection is fairly reliable using the low-res stream from the camera fed to Frigate. However, plate recognition is very unreliable due to the low-res snapshot.jpg from Frigate. Other Frigate integrations (such as Double-Take for face recognition) allows high-res jpg captures directly from a camera for the highest quality processing once a Frigate snapshot.jpg event is recieved.

Is this something that is available for plate-recongnizer?

@kyle4269
Copy link
Contributor

Sounds to me like you need to use the main stream in frigate config.

@RutgerDiehard
Copy link
Author

Running detection on the main stream in Frigate is enormously CPU intensive. Even though I have tuned the installation as per Frigate documentation, using this just for plate recognizer when object detection itself is working fine on the low-res stream is a massive waste of resources.

Double-take listens for events from Frigate using the low-res stream and when it receives one, accesses the camera direct for a high-res snapshot which it uses for face recognition - discussion here.

This would be a great addition to plate-recognizer and I'm sure a lot of people would use it.

@atv2016
Copy link

atv2016 commented Mar 12, 2024

I agree with @RutgerDiehard, rather then using the snapshot it would be better to use the /clips/camera-eventid-clean.png, this is the full resolution image and also without any bounding box. I would say there is a much better chance of getting a plate on that then those grainy snapshots.

@kyle4269
Copy link
Contributor

I agree with @RutgerDiehard, rather then using the snapshot it would be better to use the /clips/camera-eventid-clean.png, this is the full resolution image and also without any bounding box. I would say there is a much better chance of getting a plate on that then those grainy snapshots.

I think the problem with that option is, the clean png isn't available until the event has ended. I guess we could use it if it's available and if not use the snapshot..

@atv2016
Copy link

atv2016 commented Mar 12, 2024

Hmm that's a good point. When does the event end, is it when a car becomes stationary or out of the picture? Maybe we can use snapshots for cars in motion and the full resolution image for cars that are stationary.

@kyle4269
Copy link
Contributor

"The event ends if the tracked object goes missing for more frames than the configured max_disappeared value." That was from Blake a while ago

@atv2016
Copy link

atv2016 commented Mar 12, 2024

Cool.
Trying to play around with the snapshot and removing the bounding box, but I still see a object bounding box even if I do :
http://192.168.50.34:5000/api/events/1710236252.067698-5mdny9/snapshot.jpg?bbox=0

@kyle4269
Copy link
Contributor

Cool.

Trying to play around with the snapshot and removing the bounding box, but I still see a object bounding box even if I do :

http://192.168.50.34:5000/api/events/1710236252.067698-5mdny9/snapshot.jpg?bbox=0

That'll only work while the event is in progress unfortunately.

@atv2016
Copy link

atv2016 commented Mar 12, 2024

Ah ok - yeah I figured out as much. Guess I'll have to disable bounding box in snapshots per camera feed.

Cheers.

@kyle4269
Copy link
Contributor

That's what I do. I also run my LPR camera on the main stream to get the best quality image for processing.

@atv2016
Copy link

atv2016 commented Mar 12, 2024

What LPR camera are you using ?

@kyle4269
Copy link
Contributor

@atv2016
Copy link

atv2016 commented Mar 12, 2024

Very nice, that's the exact one I was looking at as well. 60mm varifocal I believe ? And not un-affordable either. How is it working for you ?

I think the biggest issue with these is getting the angle right, but maybe not so much a problem with these.

@kyle4269
Copy link
Contributor

Once I got all the camera settings dialed in for my environment, it's been an amazing camera for LPR. You can't go wrong with it especially if you're willing to play around with the settings to get it correct. See the below link for discussions about it.

https://ipcamtalk.com/threads/mini-review-5241-z12e-s2-replacement-for-the-5241-z12e.71898/

@chrisborell
Copy link

Hi! Couldn't we implement the

  events:
    front_gate:
      # mqtt disabled
      mqtt: false
      # picture to be used
      image:
        width: 1280
        height: 720
        latest: http://192.168.1.174:1984/api/frame.jpeg?src=front_gate

like doubletake has - to enable high-res snapshots from an external snapshot URL? This way the mainstream doesn't need to be used?

jakowenko/double-take#102

@RutgerDiehard
Copy link
Author

As an update to this, I've managed to work around the low resolution of the Reolink substream (and poor plate recognition success) by using ffmpeg to re-encode the main 4k stream into a lower resolution detect stream (1280x720) - but still higher resolution than the substream from the camera - that plate recognition is much, much happier with. I do this in the go2rtc section of the Frigate config:

go2rtc:
  streams:
    Front_Door:
      - ffmpeg:rtsp://USER:PASSWORD@CAMERA-IP:554/h265Preview_01_main#video=copy#audio=copy#audio=aac
    Front_Door_Sub:
      - ffmpeg:Front_Door#video=h264#width=1280#height=720#raw=-fpsmax 10#hardware=vaapi

By using hardware=vaapi (for Intel GPUs), I can get the GPU to do the encoding so the CPU is unaffected.

The camera section in Frigate config then looks like this:

cameras:
  Front_Door:
    ffmpeg:
      hwaccel_args: preset-vaapi
      output_args:
        record: preset-record-generic-audio-aac
      inputs:
        - path: rtsp://127.0.0.1:8554/Front_Door
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/Front_Door_Sub
          input_args: preset-rtsp-restream
          roles:
            - detect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants