keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.65k stars 230 forks source link

Frigate Vehicle Detections Crash on Android Unifi Protect 1.4.8 #137

Closed lcasale closed 2 years ago

lcasale commented 2 years ago

Describe the bug Does not seem vehicle detection is working properly. From the web client, it shows as a basic motion event. The Android app will crash if you try to view the camera timeline and the vehicle event is on the timeline (either by scrolling to the event or immediately if the event was recent enough.

To Reproduce Steps to reproduce the behavior:

  1. Trigger Frigate vehicle event from a Frigate camera
  2. Try to view vehicle event on web (no crash but shows as basic motion instead of vehicle detection)
  3. Try to view vehicle event on iOS (no crash but shows as basic motion instead of vehicle detection)
  4. Try to view vehicle event on Android 1.4.8 - app crashes

Expected behavior The event should show as a vehicle event on all channels and Android should not crash

Screenshots markup_1147 Screenshot_20211231-100955

Camera (please complete the following information):

Additional context Unifi OS: 2.2.12 Unifi Protect: 1.20.3 Android Unifi Protect: 1.4.8 Edit: Person smart detection events work fine across all channels.

keshavdv commented 2 years ago

Thanks for using the template! Can you share the log output of the proxy with the verbose flag enabled when the vehicle enters and exits the scene?

lcasale commented 2 years ago

So I've done a little playing around and made some progress but still not finding what's causing the crash.

In frigate.py, I added one more condition to look for "vehicle" since I combined car, truck, motorcycle, etc objects as "vehicle" in frigate. This is to pickup the event from Frigate and shouldn't have any impact to Unifi Protect.

frigate.py

   @classmethod
    def label_to_object_type(cls, label: str) -> Optional[SmartDetectObjectType]:
        if label == "person":
            return SmartDetectObjectType.PERSON
        elif label == "car":
            return SmartDetectObjectType.CAR
        elif label == "vehicle":
            return SmartDetectObjectType.CAR

My frigate config

model:
  labelmap:
    2: vehicle
    3: vehicle
    5: vehicle
    7: vehicle
    15: animal
    16: animal
    17: animal
    18: animal
    19: animal
    22: animal

I also modified base.py to change the SmartDetectObjectType enum CAR from "car" to "vehicle". When I did this, Unifi Protect picked up the correct vehicle event but still crashes on Android.

class SmartDetectObjectType(Enum):
    PERSON = "person"
    CAR = "vehicle"

Screenshot 2021-12-31 130857

I captured verbose logs with both CAR = "car" and CAR = "vehicle". _unifi-driveway_logs_CAR.txt _unifi-driveway_logs_VEHICLE.txt

keshavdv commented 2 years ago

Can you test out the newest version of the development docker image (keshavdv/unifi-cam-proxy:dev)? It has a few of the fixes you called out, but for me, the detection seems to work without crashing the app even for vehicles (version 1.4.8)

lcasale commented 2 years ago

Confirmed vehicle detection is working and it's no longer crashing. I also updated my UNVR to 2.3.10 so not sure if that was the root cause. Thanks!