VorlonCD / bi-aidetection

Alarm system for Blue Iris based on Artificial Intelligence.
https://ipcamtalk.com/threads/tool-tutorial-free-ai-person-detection-for-blue-iris.37330/
GNU General Public License v2.0
207 stars 45 forks source link

Object over confidence limit is not triggering alert #195

Closed tankdeer closed 3 years ago

tankdeer commented 3 years ago

I have my driveway camera configured for person and a handful of vehicle types. My wife just came home and triggered the camera, but the alert was marked as irrelevant, despite the car being picked up well over the confidence limit.

Confidence limits per object. All at default 30-100 image

Prediction Tolerances for the camera are pretty low. Not sure how this works when both are specified. Almost seems like they're cumulative based on some of the results I'm seeing? image

Car was marked at 56%, which should trigger. But it also says duplicate, because it was also marked as a Truck, and a Bus at lower confidence image

Is it being marked irrelevant because it thinks it's a duplicate? If so, I think that's a bug. If one of the duplicate items is over the confidence limit, it should Alert, and disregard the others.

Side note, the neighbor's car parked on the street (which I probably need to mask) was marked as 35%, but with the result of TooSmallPercent. This is what's making me wonder if they are cumulative, as it should Alert on that being over 30% too.

Here's the log from the detection:

3/5/2021 9:39:01 AM | AddImageToQueue | ====================== Adding new image to queue (Count=1): C:\BlueIris\aiinput\Driveway.20210305_093901325.jpg | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 877 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:01 AM | ImageQueueLoop | Adding task for file 'Driveway.20210305_093901325.jpg' (Image QueueTime='0.0' mins, URL Queue wait='0ms', URLOrder=1, URLOriginalOrder=1) on URL 'http://127.0.0.1:8090/v1/vision/detection' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 878 | 0 |   | 21 | True | AITool.[2021-03-05].log
3/5/2021 9:39:01 AM | DetectObjects | Starting analysis of C:\BlueIris\aiinput\Driveway.20210305_093901325.jpg... | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 880 | 2 |   | 31 | True | AITool.[2021-03-05].log
3/5/2021 9:39:01 AM | LoadImage | Image file is valid. Resolution=1920x1080, LockMS=60ms (max=10000ms), retries=1, size=1.51 MB: Driveway.20210305_093901325.jpg | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | None | 881 | 2 |   | 31 | True | AITool.[2021-03-05].log
3/5/2021 9:39:01 AM | DetectObjects | (Image resolution=1920x1080 @ 96 DPI and 1.51 MB) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 882 | 1 |   | 31 | True | AITool.[2021-03-05].log
3/5/2021 9:39:01 AM | GetDetectionsFromAIServer | (1/6) Uploading a 1.51 MB image to 'DeepStack' (CAM_LowerThresholdOverride=15,Upper=100)(0.15) AI Server at http://127.0.0.1:8090/v1/vision/detection | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 883 | 2 |   | 31 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | (2/6) Posted in 658ms, StatusCode='OK', Received a 393 byte JSON response: '{"success":true,"predictions":[{"confidence":0.18254715,"label":"bus","y_min":300,"x_min":1115,"y_max":680,"x_max":1461},{"confi...' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 885 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | (3/6) Processing results... | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 886 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 1% Current 'Car' key=339091, Tested 'Bus' key=467396 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 888 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 99% Current 'Truck' key=469617, Tested 'Bus' key=467396 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 890 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 4% Current 'Truck' key=469617, Tested 'Car' key=339091 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 891 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | [Linked Server] Duplicate prediction 0 Old=Bus (18%), New=Truck (43%) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 894 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 99% Current 'Car' key=467231, Tested 'Bus' key=467396 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 895 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 6% Current 'Car' key=467231, Tested 'Car' key=339091 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 896 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | Equals | Percentage Intersection of object: 99% Current 'Car' key=467231, Tested 'Truck' key=469617 | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 897 | 2 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | [Linked Server] Duplicate prediction 0 Old=Bus (18%), New=Car (56%) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 900 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Detected objects: | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 901 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Result='DuplicateObject', Detail='Car (56%)', ObjType='Vehicle', DynMaskResult='Unknown', DynMaskType='Unknown', ImgMaskResult='NoMaskImageFile', ImgMaskType='None' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 902 | 1 | Silver | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Result='TooSmallPercent', Detail='Car (35%)', ObjType='Vehicle', DynMaskResult='Unknown', DynMaskType='Unknown', ImgMaskResult='Unknown', ImgMaskType='Unknown' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 903 | 1 | Silver | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Result='UnwantedObject', Detail='Truck (43%)', ObjType='Vehicle', DynMaskResult='Unknown', DynMaskType='Unknown', ImgMaskResult='NoMaskImageFile', ImgMaskType='None' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 904 | 1 | Silver | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Result='DuplicateObject', Detail='Bus (18%)', ObjType='Vehicle', DynMaskResult='Unknown', DynMaskType='Unknown', ImgMaskResult='Unknown', ImgMaskType='Unknown' | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 905 | 1 | Silver | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | 1x irrelevant, so it's an irrelevant alert. | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 906 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | (5/6) Performing CANCEL actions: | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 907 | 1 |   | 61 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | RunTriggers | Action 'All' done. Succeeded=True, Trigger=False, Queued=False, Queue Count=0 (Min=0,Max=0,Avg=0), Total time=200ms (Min=6ms,Max=31342ms,Avg=6310ms), Queue time=0 (Min=3ms,Max=31254ms,Avg=25706ms), Action Time=200ms (Min=5ms,Max=1111ms,Avg=140ms), Image=C:\BlueIris\aiinput\Driveway.20210305_093901325.jpg | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 910 | 3 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | (6/6) Camera Driveway caused an irrelevant alert. | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 911 | 3 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Total Time:   1169 ms (Count=    21, Min=   393 ms, Max=  1968 ms, Avg=   894 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 912 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | AI (URL) Time:    658 ms (Count=    21, Min=   303 ms, Max=120184 ms, Avg=   545 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 913 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | File lock Time:     60 ms (Count=    13, Min=     2 ms, Max=   127 ms, Avg=   103 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 914 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | File load Time:     35 ms (Count=    21, Min=     9 ms, Max=   209 ms, Avg=    37 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 915 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Image Queue Time:     51 ms (Count=    21, Min=     1 ms, Max=    67 ms, Avg=    27 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 916 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Image Life Time:   1169 ms (Count=    21, Min=   394 ms, Max=  1968 ms, Avg=   895 ms) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 917 | 4 |   | 55 | True | AITool.[2021-03-05].log
3/5/2021 9:39:02 AM | DetectObjects | Image Queue Depth:      1    (Count=    27, Min=     1,    Max=     1,    Avg=     1) | Debug | AITOOLS.EXE | Deepstack_Objects:127.0.0.1:8090 | Driveway | Driveway.20210305_093901325.jpg | 918 | 5 |   | 55 | True | AITool.[2021-03-05].log

I've only had all this setup for a couple days, so it's entirely possible I screwed something up, but my other cameras seem to be working fine, and this one works with Person, just the car is wonky.

Let me know if you need me to do anything, and thanks for an awesome tool

VorlonCD commented 3 years ago

Just a super quick look, but change the minimum size percent to 0. Note the result on one of the cars is "TooSmallPercent" and that the PercentOfImage was .3, so that would have prevented the car from first being detected and prevented any duplicates after that from being relative. The percent of image calc doesnt seem right sometimes but as far as I can tell the math works out.

tankdeer commented 3 years ago

So I tried that, and re-processed the image, and as you thought, it did pick up the car across the street. However, it's still ignoring the main car that's in the actual driveway. To clarify, I don't care about cars parked on the street. I was thinking I would mask them, but seeing now that minimum size handles that nicely.

Parked car marked as relevant now: image

But car pulling into driveway is still ignored as a duplicate image

So perhaps I was confused and thought that "TooSmallPercent" was in reference to the confident limit, but is actually percent of image. If that's the case, I think that portion is ok.

Not triggering on the 56% match on the main car is the main problem

VorlonCD commented 3 years ago

I'm going to try to tweak the order the detection are processed and duplicates removed since I think that may be the factor here.

If you have deepstack set to High, try Medium. And/or to reduce the number of duplicate items processed by aitool by enabling: History tab > Settings > Restrict Threshold at source. That way it wont even show the lower confidence predictions where it thinks your car is a truck or van. Or meat popsickle.

tankdeer commented 3 years ago

Deepstack is set to Medium, Restrict Threshold at source is already enabled.

I actually tried disabling that, and it did seem to pick up the car when I reprocessed the image. It still saw it as a duplicate truck with lower confidence, but it picked the main subject as car and alerted on that. It didn't see the car in the background, which is fine with me, and I think what you were saying. image

image

maximosm commented 3 years ago

Where we can find the last updatet Versions?

tankdeer commented 3 years ago

I found it linked in another open issue

tankdeer commented 3 years ago

Ok, so my wife just came home, and triggered the motion alert in the driveway again. I had left Restrict Threshold at source disabled from the other day, and the results were quite different this time. This time, it was flagged as a false alert (I am not sure what it does to consider that - no objects found?)

It looks like Blue Iris took 3 photos, but AI Tool only analyzed two of them - the first, from the pre-trigger, you can't really see much. The last, right before the trigger ended, which you can't really see much. But it ignored the middle one, where you can clearly see the car. I'm guessing this is a result of Restrict Threshold at source being disabled?

I believe normally, it would analyze all 3, and and Alert if one matched the conditions, right? At that point the cooldown timer starts?

If I manually add the middle image, the one that was missed. It sees the car at 64% (well over the threshold), but as before, marks it as irrelevant and a duplicate where it is also 19% sure it's a Truck.

So yeah, something wonky with duplicates it seems, and it seems to be an issue more with Vehicles, or at least that's all I've noticed it on

tankdeer commented 3 years ago

So this is remarkably consistent with vehicles in the driveway. One thing I noticed today, is of the several vehicles it thinks it might be, Truck is always among them. Which is fine, however Truck is marked as UnwantedObject. Which is not true. I have Truck enabled in the camera settings as seen in the first post

image

On one hand a car is not a truck, on the other I'd be happy it if alerted on any vehicle in the driveway. I tried changing the relevant objects around and re-testing, and it didn't make any difference. There's just something with vehicles

VorlonCD commented 3 years ago

This one any better? I think I found a better way of dealing with duplicates and prioritizing the detected objects better.
Make a backup of your original folder just in case. AITool-VorlonCD-v2.0.928.zip

tankdeer commented 3 years ago

Awesome, thank you so much.

I've installed that and ran a few of my saved images through it. So far it does seem to flag the car much better. We'll see how it does next time the camera is trigger for real.

One thing I did notice however, is the Relevant object settings are being duplicated for every camera. For example if I add 'Car' to Driveway, it gets checked on Front Porch too. I assume just overwriting for all by accident. Let me know if I should open a new issue for that or not.

Once I'm confident the duplicate is resolved I'll close this one. Thanks again

VorlonCD commented 3 years ago

The relevant objects added to other cameras are by design so you have them available to "enable" if you like. They are being added as disabled, right?

tankdeer commented 3 years ago

No, they're enabled and overwriting whatever settings I put in. For example. I just enabled Person and Face on my Front Porch camera, with different thresholds: image

Then I went to the driveway, and added a handful of vehicles, in addition to Person: image

When I go back to Front Porch now, you can see it overwrote with the Driveway settings. Same for every camera image

It's not specific to any camera. Any changes I make to one, is applied to all of them. Best I can tell it's just the relevant objects. Other changes seem ok

Tinbum1 commented 3 years ago

I've been seeing the same but it seems to be limited by the camera name somehow. I have a group of cameras named 'Workshop xxxx' and if I change one it applies it to all starting ''Workshop'', but not to those beginning say ''Drive xxxx''. It also seems to be mixing up the AITool camera name with the BI Camera name.

It may have been happening for a while but I've only just noticed it as the last commit meant i had to redo my Relevant objects which I've not done for a while.

tankdeer commented 3 years ago

In my case I don't have any groups defined but that's an interesting observation. No groups = duplicate across all. Groups = duplicate across group?

It only started with this last build. Prior to that, it seemed ok.

Speaking of this last build, so far so good on properly detecting vehicles. Snagged my wife's car just fine earlier today

Edit. Actually, something strange I didn't notice earlier. When my wife came home earlier, she triggered the camera and I got the alert. I have annotations merged at the moment, and saw the car flagged at 72%. Didn't think much other than yay, it's fixed. However I was just looking at the History in AI Tool, and it's not there. It's actually flagged internally as a false alert. I suspect it's just an issue with the history, since I got the notification just fine.

History: image

Image from email notification image

Again, please let me know if these should be opened as separate issues. I don't know which you prefer for tracking purposes.

VorlonCD commented 3 years ago

This one should be working better for relevant objects. Note that if you were using a few builds back, that it should correctly migrate the list forward now, so the object list may be different if you made recent changes to it. AITool-VorlonCD-v2.0.942.zip

tankdeer commented 3 years ago

Dude, you're a badass. Best I can tell this fixed both the issue with the history & the object duplicates, and testing the duplicate vehicles seems to still work as well. Thank you so much. Please put up a donate link somewhere as you certainly earned a few beers/coffees.

As before, I'll run like this a couple days and then close the issue if all is (still) well

Cheers

VorlonCD commented 3 years ago

Latest with a few more changes in relevant object editor: AITool-VorlonCD-v2.0.988.zip