Page 1 of 1

Face recognition config question

Posted: Fri Jun 11, 2021 8:40 pm
by timf
I'm please to report that by and large my ZMes installation is working well - it can event detect our little dog running round the garden !

Just for academic interest I thought I'd turn on facial recognition. I did the face training which seemed to work ok using CNN see below, but I am a little confused as to what I should have in the objectconfig.ini here's what I have for my test monitor. I'll dig into the logs tomorrow but suspect its a config error as everything else seems ok.

Wonder what I'm missing ?

Regards Tim


objectconfig.ini snipprt:

[monitor-2]
# Gates
match_past_detections=no
wait=5

object_detection_pattern=(person|car|dog|truck)

import_zm_zones=yes

gates_zone_detection_pattern=(person|car|dog|truck)

resize=no
detection_sequence=object,face


#####################################
Output when training:

INF [zm_train_faces] [Ignoring monitor specific settings, as you did not provide a monitor id]
DBG3 [zm_train_faces] [Finally, doing parameter substitution]
DBG1 [zm_train_faces] [jan is a directory. Processing all images inside it]
DBG1 [zm_train_faces] [loading face from jan/jan2.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [loading face from jan/jan.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [loading face from jan/jan4.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [loading face from jan/jan3.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [tim is a directory. Processing all images inside it]
DBG1 [zm_train_faces] [loading face from tim/tim3.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [loading face from tim/tim2.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG1 [zm_train_faces] [loading face from tim/tim.jpg]
DBG1 [zm_train_faces] [resizing to 800]
DBG2 [zm_train_faces] [Using algo:ball_tree n_neighbors to be: 3]
DBG1 [zm_train_faces] [Training model ...]
DBG1 [zm_train_faces] [wrote encoding file: /var/lib/zmeventnotification/known_faces/faces.dat]
DBG1 [zm_train_faces] [perf: Face Recognition training took: 28013.77 ms]

Re: Face recognition config question

Posted: Sat Jun 12, 2021 2:58 pm
by asker
1. Don't know if you are missing anything. You've posted logs for training, not for detection. Is face recognition being invoked for detection?
2. Make sure you have read this completely and are using use_sequence=yes. ml_sequence is key here.

Re: Face recognition config question

Posted: Sun Jun 13, 2021 11:15 am
by timf
Hi Asker,

thanks again for your time and patience.

I had read all the guides I could find and they were very helpful but a time a little confusing / contradictory - however I now seem to have face recognition working based on these results:

Issuing this command

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py -c /etc/zm/objectconfig.ini -e 988

results in:

[ WARN:0] global /home/tim/opencvbuild/opencv/modules/dnn/src/cuda4dnn/init.hpp (42) checkVersions CUDART version 11030 reported by cuDNN 8201 does not match with the version reported by CUDART 10010
[s] detected:person:98% jan:100% --SPLIT--{"labels": ["person", "jan"], "boxes": [[158, 80, 724, 456], [442, 98, 540, 196]], "frame_id": "snapshot", "confidences": [0.983090877532959, 1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}

So ignoring the warning message it does seem to detect faces, however the face name does not seem to get attachd to the image box, instead it just says person. Maybe another config option I've missed somewhere ?

I'm still a little confused wth some of the syntax and scope of the declarations such as the following:

use_sequence=yes >> where does this need to be located ? For each montior definition is objectconfig.ini ?

Do the monitor zones still get imported eg zone_name_zone_detection_pattern=(person|car) when placed in a monitor defiinition and using use_sequence=yes

Here's what I have for monitor-3

[monitor-3]

# office
match_past_detections=no
wait=5
import_zm_zones=yes
rhs_zone_detection_pattern=(person|car|dog)
resize=no
my_sequence=face,object
use_sequence=yes

One last question about logging - I'm having troble getting _zmesdetect to log.

Ive tried _zmesdetect_m3 but log is empty.

Once again, many thanks or all the effort involved.

Regards Tim

Re: Face recognition config question

Posted: Sun Jun 13, 2021 12:01 pm
by asker
I had read all the guides I could find and they were very helpful but a time a little confusing / contradictory - however I now seem to have face recognition working based on these results:
If you have time, please specifically point out which parts are contradictory and I'll see if it needs fixing.

[ WARN:0] global /home/tim/opencvbuild/opencv/modules/dnn/src/cuda4dnn/init.hpp (42) checkVersions CUDART version 11030 reported by cuDNN 8201 does not match with the version reported by CUDART 10010
[s] detected:person:98% jan:100% --SPLIT--{"labels": ["person", "jan"], "boxes": [[158, 80, 724, 456], [442, 98, 540, 196]], "frame_id": "snapshot", "confidences": [0.983090877532959, 1], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}

So ignoring the warning message it does seem to detect faces, however the face name does not seem to get attachd to the image box, instead it just says person. Maybe another config option I've missed somewhere ?
I can't figure out if it is detecting faces by 2 lines you posted. You have to enable debug logs (run zm_detect with --debug, read the docs if you missed it) and see if face recognition is actually invoked. Unless you have configured face inside ml_sequence, it won't run. And if you have configured it, debug logs will tell you what is going on.
use_sequence=yes >> where does this need to be located ? For each montior definition is objectconfig.ini ?
The sample config file should give you a complete picture of this. use_sequence, like any other parameter can be specified globally inside the [ml] section, or locally inside each monitor. The way it works is, monitor specific settings override global settings.
Do the monitor zones still get imported eg zone_name_zone_detection_pattern=(person|car) when placed in a monitor defiinition and using use_sequence=yes
Yes. I suspect you aren't enabling debugs - they are critical to understand what is going on when you are starting up. It is as simple as running zm_detect with --debug - it will give you a lot of additional insight.

One last question about logging - I'm having troble getting _zmesdetect to log.
Ive tried _zmesdetect_m3 but log is empty.
Hard to say, as you've not provided specifics.
Here are my ZM log settings
Screen Shot 2021-06-13 at 8.08.53 AM.png
Screen Shot 2021-06-13 at 8.08.53 AM.png (99.5 KiB) Viewed 7492 times

Re: Face recognition config question - SUCCESS

Posted: Sun Jun 13, 2021 1:05 pm
by timf
Thanks for the tips on setting up logging correctly and how the scope of the parameters work.

Turns out the monitor settings were overidding face detection so when I commented out rhs_zone_detection and my_sequence as per below the image now gets tagged with my name !

Simple as that :-)

Time for a beer

Regards Tim


[monitor-3]

# office
match_past_detections=no

wait=5

import_zm_zones=yes

#rhs_zone_detection_pattern=(person|car|dog)

resize=no

#my_sequence=face,object

use_sequence=yes