roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.51k stars 155 forks source link

Send license plate via MQTT #693

Open gamebird92 opened 6 months ago

gamebird92 commented 6 months ago

Hi everyone, I did some testing with Viseron and CodeProjectAI and it's running very well so far. I want send license plate recognized by CodeProjectAI via MQTT.

My config is this:

ffmpeg:
  camera:
    camera_1:  # This value has to be unique across all cameras
      name: TG-Einfahrt
      host: 192.168.99.22
      port: 554
      path: h264Preview_01_sub
      fps: 10
      protocol: rtsp
      username: admin
      password: kamera

mog2:
  motion_detector:
    cameras:
      camera_1: 
        trigger_recorder: false

nvr:
  camera_1:  # Run NVR for camera_1

codeprojectai:
  host: 192.168.99.21
  port: 32168
  object_detector:
      cameras:
          camera_1:
            fps: 30
            scan_on_motion_only: true
            log_all_objects: true
            labels:
              - label: car
                trigger_recorder: true
              - label: vehicle
                trigger_recorder: true
  license_plate_recognition:
    cameras:
      camera_1:
    labels:
      - car
      - vehicle

mqtt:
  broker: 192.168.20.99
  port: 1883
  username: user
  password: password

I am receiving following sensors on my MQTT gateway:

viseron_sensor_camera_1_license_plate_recognition_state_attributes_domain viseron_sensor_camera_1_license_plate_recognition_state_attributes_name viseron_sensor_camera_1_license_plate_recognition_state_state

Is it possible to send the text that gets read from the license plate via MQTT?

roflcoopter commented 6 months ago

The detected license plate number is sent in the payload, in the attribute called plate Example payload:

{
   "state":"NAH11F",
   "attributes":{
      "name":"Driveway License Plate Recognition Result",
      "domain":"sensor",
      "result":[
         {
            "camera_identifier":"viseron_cuda_camerag",
            "plate":"ABC123",
            "confidence":0.884,
            "known":true
         },
         {
            "camera_identifier":"viseron_cuda_camerag",
            "plate":"DEF456",
            "confidence":0.884,
            "known":false
         }
      ]
   }
}