Closed J-Pipe closed 1 year ago
I'd recommend watching the debug view of the camera (cameras -> open camera -> choose debug in top right -> enabled zones and bounding boxes)
This code hasn't changed in a long time and I've never seen an issue so it's likely a config error. Due be aware objects presence in a zone is based on the bottom center of its bounding box. Object masks work similarly as well.
We'll need a screen recording of the debug view along with MQTT output to be able to identify any issue.
Well I think the first "bug" (unless it is supposed to work like this?) is that if the "type" is "new", then the current_zones seems to be always empty in the "before" message. Not sure if that is intended, but seems like a bug to me.
Below is the example picture. You can see the street_zone outlined in red. The yellow squares are from the 4th and 6th messages in the MQTT messages (linked below) but the "current_zones" is empty. I am also linking the exported video from that was used for this test.
Thanks for the detailed video and messages. Upon looking at the messages it seems to be working as expected. You can notice that in the second message:
{
"before": {
"id": "1670559975.316493-6sfz4l",
"camera": "driveway_cam",
"frame_time": 1670559976.014847,
"snapshot_time": 1670559976.014847,
"label": "car",
"sub_label": null,
"top_score": 0.70703125,
"false_positive": false,
"start_time": 1670559975.316493,
"end_time": null,
"score": 0.7890625,
"box": [
346,
322,
995,
719
],
"area": 257653,
"ratio": 1.6347607052896724,
"region": [
0,
0,
1296,
1296
],
"stationary": false,
"motionless_count": 2,
"position_changes": 1,
"current_zones": [
"driveway_car_zone"
],
"entered_zones": [
"driveway_car_zone"
],
"has_clip": false,
"has_snapshot": true
},
"after": {
"id": "1670559975.316493-6sfz4l",
"camera": "driveway_cam",
"frame_time": 1670559977.219545,
"snapshot_time": 1670559976.014847,
"label": "car",
"sub_label": null,
"top_score": 0.7265625,
"false_positive": false,
"start_time": 1670559975.316493,
"end_time": null,
"score": 0.546875,
"box": [
616,
210,
758,
326
],
"area": 16472,
"ratio": 1.2241379310344827,
"region": [
0,
0,
1464,
1464
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [],
"entered_zones": [
"driveway_car_zone"
],
"has_clip": false,
"has_snapshot": true
},
"type": "update"
}
the before.box
and after.box
are very different, along with the before.area
and after.area
:
{
"before": {
"id": "1670559975.316493-6sfz4l",
"box": [
346,
322,
995,
719
],
"area": 257653,
},
"after": {
"id": "1670559975.316493-6sfz4l",
"box": [
616,
210,
758,
326
],
"area": 16472,
},
"type": "update"
}
this can happen because frigate's tracking is somewhat simple. If it sees multiple of the same object it doesn't use things like size, color, direction of travel to differentiate between them across frames. This means that sometimes frigate will swap which car is which. In this case it appears that frigate thinks the car is in a different location for some of these frames which is why its current_zone
is empty.
You can see this switch back in the third message:
{
"before": {
"id": "1670559975.316493-6sfz4l",
"box": [
616,
210,
758,
326
],
"area": 16472,
"current_zones": [],
"entered_zones": [
"driveway_car_zone"
],
},
"after": {
"id": "1670559975.316493-6sfz4l",
"box": [
494,
62,
798,
483
],
"area": 127984,
"current_zones": [
"driveway_car_zone"
],
"entered_zones": [
"driveway_car_zone"
],
},
"type": "update"
}
Also as far as the type: new
goes, it will not have before.current_zones
because "false_positive": true
, I believe that is working as expected as well.
Sure, I understand that the tracking is not perfect, but for the fourth and sixth messages specifically, how can you explain that after.current_zones is empty, when the after.box is clearly in the street_zone?
how can you explain that after.current_zones is empty, when the after.box is clearly in the street_zone?
this is the fourth message:
{
"before": {
"id": "1670559975.316493-6sfz4l",
"camera": "driveway_cam",
"frame_time": 1670559977.611997,
"snapshot_time": 1670559976.014847,
"label": "car",
"sub_label": null,
"top_score": 0.7265625,
"false_positive": false,
"start_time": 1670559975.316493,
"end_time": null,
"score": 0.609375,
"box": [
494,
62,
798,
483
],
"area": 127984,
"ratio": 0.7220902612826603,
"region": [
196,
0,
804,
608
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [
"driveway_car_zone"
],
"entered_zones": [
"driveway_car_zone"
],
"has_clip": false,
"has_snapshot": true
},
"after": {
"id": "1670559975.316493-6sfz4l",
"camera": "driveway_cam",
"frame_time": 1670559980.810574,
"snapshot_time": 1670559976.014847,
"label": "car",
"sub_label": null,
"top_score": 0.7265625,
"false_positive": false,
"start_time": 1670559975.316493,
"end_time": null,
"score": 0.53515625,
"box": [
90,
71,
441,
249
],
"area": 62478,
"ratio": 1.9719101123595506,
"region": [
0,
0,
1312,
1312
],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": [],
"entered_zones": [
"driveway_car_zone"
],
"has_clip": false,
"has_snapshot": true
},
"type": "update"
}
notice the "score": 0.53515625,
which is below what you have set in your zone filter config
driveway_cam:
...
...
zones:
# Required: name of the zone
# NOTE: This must be different than any camera names, but can match with another zone on another
# camera.
street_zone:
coordinates: 418,282,559,278,527,195,951,226,941,179,782,140,483,96,195,80,0,84,0,189,144,181,154,295,257,290
objects:
- car
- person
filters:
car:
min_area: 1800
max_area: 755000
min_score: 0.5
threshold: 0.6 # <--- greater than the score in the mqtt message
I mean, it seems like it should still say what zone it’s in. In the last message, the score is 59% and that’s when it finally picks up the street_zone 🤔
I mean, it seems like it should still say what zone it’s in.
Your config is specifically telling frigate not to consider an object with a score below 60% as part of the zone, so that would be entirely incorrect if it was always listed in current_zones despite that.
Also, by default frigate does not filter zone presence by score so I'd recommend removing that filter entirely for all zones.
I ran your debug clip multiple times and you can see the different scores having a different result in the zone
I removed the filters from the zone and it now is working consistently
Thank you Nick. I’ll try to play with that tonight and see what results I get.
So, why would before:false_positive
always be true for type:new
objects?
So, why would
before:false_positive
always be true fortype:new
objects?
Nevermind, found the answer: "Message published for each changed event. The first message is published when the tracked object is no longer marked as a false_positive."
So my thinking is that it should still record the current_zone even if it's a false positive. One issue that I'm having is that my car is in the street zone in the before
message, but in the driveway zone in the after
. Since the MQTT message is not including the proper zone when false_positive
is true, it throws things off.
Since the MQTT message is not including the proper zone when false_positive is true, it throws things off.
This is likely due to fps being 1, if the fps is increased even to 2 it would likely be improved.
fps is 5 for all my cameras except baby_cam. I am past the point of trying to debug my situation and this is about the functionality of Frigate. I think the current_zone (and probably entered_zones) should be populated in the first MQTT message of the event. When that message is sent, we know it’s not a false_positive anyways (as that is what triggers the first message to transmit)
fps is 5 for all my cameras except baby_cam
my bad, looked at the wrong one, in any case the idea is the same that increasing the fps is the recommendation.
I have a similar setup with a driveway_entrance and driveway zone, only alerting when a car was in driveway_entrance and is now in driveway, and with 8 fps set I have not missed a notification with that setup.
I can try increasing it but I am past the point of trying to debug my situation and this is about the current functionality of Frigate. I think the current_zone (and probably entered_zones) should be populated in the first MQTT message of the event. When that message is sent, we know it’s not a false_positive anyways (as that is what triggers the first message to transmit). I can try to fix it and submit a PR if you think it will get accepted.
I think the current_zone (and probably entered_zones) should be populated in the first MQTT message of the event.
I mean it is populated in the first message, just after
because before
the object was a true positive, the object was a false positive.
When an object is a false positive frigate is not confident that the object is what the label says. This means that object can not be part of a zone, among other things. The zone not being included in the before
of a new event is not because it just isn't included, the object does not have any zones attached since a false positive doesn't have presence in zones.
significant_update
is trueThis means the fix is not as simple as including information that exists but isn't presented, it'll need to make large changes to either fundamentally change the way frigate treats false positives & zones or have it keep that information just for mqtt in a separate list. It will also be a large breaking change for all existing automations that work off the idea that an object being in a zone means it is not a false positive.
To me, this is an example of https://xyproblem.info/ where the mqtt information is being treated as the problem but in actuality the problem is that frigate does not have enough time to be confident that the car is actually a car before it enters the driveway. https://docs.frigate.video/guides/false_positives also explains how this works.
I can try to fix it and submit a PR if you think it will get accepted.
As you can probably tell, I disagree with this. However, I'm always open to hearing other's opinions / perspectives. Also, what is accepted is up to @blakeblackshear and not me 👍
The issue of current_zones not being populated (even on the type:update
objects) continues to be an issue for me that I cannot resolve. Here is an interesting case that happened today...
In the first after
object, the car should be in the driveway_car_zone, but instead, current_zones
is empty. Looking at the other data, it's not a false_positive, and the score/area/ratio all meet my filters. ODDLY, in the very next MQTT message, the before object does include the proper current_zones
. What would cause this?? I can provide more data if needed (video, screenshots, config info, camera/zone debug info).
{"before":{"id":"1672102387.274661-4gigs3","camera":"driveway_cam","frame_time":1672103572.98488,"snapshot_time":1672103572.523118,"label":"car","sub_label":null,"top_score":0.84375,"false_positive":false,"start_time":1672102387.274661,"end_time":null,"score":0.71484375,"box":[367,111,503,256],"area":19720,"ratio":0.9379310344827586,"region":[175,0,535,360],"stationary":false,"motionless_count":5,"position_changes":3,"current_zones":["street_zone"],"entered_zones":["street_zone"],"has_clip":false,"has_snapshot":false},"after":{"id":"1672102387.274661-4gigs3","camera":"driveway_cam","frame_time":1672103574.78718,"snapshot_time":1672103574.78718,"label":"car","sub_label":null,"top_score":0.84375,"false_positive":false,"start_time":1672102387.274661,"end_time":null,"score":0.7265625,"box":[350,132,539,317],"area":34965,"ratio":1.0216216216216216,"region":[251,34,635,418],"stationary":false,"motionless_count":2,"position_changes":3,"current_zones":[],"entered_zones":["street_zone"],"has_clip":false,"has_snapshot":false},"type":"update"}}
{"before":{"id":"1672102387.274661-4gigs3","camera":"driveway_cam","frame_time":1672103574.78718,"snapshot_time":1672103574.78718,"label":"car","sub_label":null,"top_score":0.84375,"false_positive":false,"start_time":1672102387.274661,"end_time":null,"score":0.7265625,"box":[350,132,539,317],"area":34965,"ratio":1.0216216216216216,"region":[251,34,635,418],"stationary":false,"motionless_count":2,"position_changes":3,"current_zones":["driveway_car_zone"],"entered_zones":["street_zone","driveway_car_zone"],"has_clip":true,"has_snapshot":true},"after":{"id":"1672102387.274661-4gigs3","camera":"driveway_cam","frame_time":1672103580.191988,"snapshot_time":1672103580.191988,"label":"car","sub_label":null,"top_score":0.84375,"false_positive":false,"start_time":1672102387.274661,"end_time":null,"score":0.83203125,"box":[371,199,705,501],"area":100868,"ratio":1.1059602649006623,"region":[122,0,1250,1128],"stationary":false,"motionless_count":13,"position_changes":3,"current_zones":["driveway_car_zone"],"entered_zones":["street_zone","driveway_car_zone"],"has_clip":true,"has_snapshot":true},"type":"update"}}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Looks like over 10 frames were processed in between these two mqtt messages. A message isn't sent for each frame.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the problem you are having
I'm logging the MQTT messages of the events, and sometimes the "current_zones" object is empty even when the object is in a zone that should detect that object.
Version
0.11.1-2eada21
Frigate config file
Relevant log output
FFprobe output from your camera
Frigate stats
Operating system
HassOS
Install method
HassOS Addon
Coral version
USB
Network connection
Wired
Camera make and model
Dahua 6L04351PAGC8C7A
Any other information that may be helpful
No response