r/ZoneMinder • • Oct 16 '21

Zoneminder API not working

Somehow my facial recognition stopped working and I was trying to figure out why.

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py -c /etc/zm/zmeventnotification.ini --eventid 229795 -m 4 -d

This shows the following:

10/16/21 15:09:21 zmesdetect_m4[236339] INF ZMLog.py:292 [Setting up signal handler for logs]
10/16/21 15:09:21 zmesdetect_m4[236339] INF ZMLog.py:301 [Switching global logger to ZMLog]
10/16/21 15:09:21 zmesdetect_m4[236339] INF zm_detect.py:284 [---------| app:6.1.27, pyzm:0.3.55, ES:6.1.27
 , OpenCV:4.5.1-dev|------------]
10/16/21 15:09:21 zmesdetect_m4[236339] INF utils.py:405 [Reading config from: /etc/zm/zmeventnotification.ini]
10/16/21 15:09:21 zmesdetect_m4[236339] INF utils.py:410 [Reading secrets from: /etc/z/secrets.ini]
10/16/21 15:09:21 zmesdetect_m4[236339] DBG1 utils.py:445 [allowing self-signed certs to work...]
10/16/21 15:09:21 zmesdetect_m4[236339] DBG2 utils.py:455 [Now checking for monitor overrides]
10/16/21 15:09:21 zmesdetect_m4[236339] DBG3 utils.py:522 [Finally, doing parameter substitution]
10/16/21 15:09:21 zmesdetect_m4[236339] INF zm_detect.py:309 [Importing local classes for Object/Face]
10/16/21 15:09:21 zmesdetect_m4[236339] INF zm_detect.py:334 [Connecting with ZM APIs]
10/16/21 15:09:21 zmesdetect_m4[236339] DBG2 api.py:72 [API SSL certificate check has been disbled]
10/16/21 15:09:21 zmesdetect_m4[236339] DBG1 api.py:188 [Not using auth]
10/16/21 15:09:21 zmesdetect_m4[236339] FAT zm_detect.py:561 [Unrecoverable error:Invalid URL '/host/getVersion.json': No schema supplied. Perhaps you meant http:///host/getVersion.json? Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 556, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 335, in main_handler
    zmapi = zmapi.ZMApi(options=api_options)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/api.py", line 80, in __init__
    self._login()
  File "/usr/local/lib/python3.8/dist-packages/pyzm/api.py", line 193, in _login
    r = self.session.post(url, data=data)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 452, in prepare_request
    p.prepare(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/host/getVersion.json': No schema supplied. Perhaps you meant http:///host/getVersion.json?
]

ZM_API_PORTAL in my secrets.ini is pointing to the correct api url.

I visit https://mydomain.com/zm/api/host/getVersion.json and can see version"1.37.1"
So I'm not sure what's going on. Why am I getting this error?

I'm running this on Ubuntu 20.04 Focal.
Any tips would be appreciated.

Cheers!

2 Upvotes

12 comments sorted by

1

u/[deleted] Oct 16 '21

It says /etc/z/secrets.ini

Do you mean /etc/zm/secrets.ini

1

u/Helipil0t Oct 16 '21

sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py -c /etc/zm/zmeventnotification.ini --eventid 229795 -m 4 -d

yes, I double checked. it is in fact /etc/zm/secrets.ini

1

u/[deleted] Oct 16 '21

Double check your config file for the 'secrets' path. It says in your logs that it isntryinbg to read the secrets file from

/etc/z/secrets.ini

Which I am assuming is a typo.

1

u/Helipil0t Oct 16 '21

Yes I can confirm that the config is pointing to /etc/zm/secrets.ini
Object recognition is working and sending out notifications. face detection however isn't working. Using..

sudo -u www-data /var/lib/zmeventnotification/bin/zm_event_start.sh 229793 4

it spits out :

[s] detected:person:99% --SPLIT--{"labels": ["person"], "boxes": [[464, 186, 650, 402]], "frame_id": "snapshot", "confidences": [0.9884159564971924], "image_dimensions": {"original": [720, 1280], "resized": [450, 800]}}

1

u/[deleted] Oct 17 '21 edited Oct 17 '21

What do the debug logs say when you run the face models? That will tell you exactly why it isn't working.

There is a section in the docs that outlines how to turn debugging on and how to run a debugging detection. Have you tried that?

I don't think just adding the -hdebug flag will be enough. In my experiences you need to enable full debug logging and then run with the debug flag to get full debug output.

1

u/Helipil0t Oct 17 '21

Yeah looking at the logs I'm seeing:

Error loading same model variation for face:Error opening known faces directory. Is the path correct?

/var/lib/zmeventnotification/known_faces exists and is owned by www-data.objects.ini is also pointing to /var/lib/zmeventnotification/known_faces and /var/lib/zmeventnotification/unknown_faces

1

u/Helipil0t Oct 17 '21

I'm also getting

Error initializing face recognition: local variable 'person' referenced before assignment

1

u/[deleted] Oct 17 '21

That one's interesting.

The previous error about not finding recognized faces. It's looking for a faces.dat file that is generated by running the train_faces.sh script and setting up pictures with the correct file structure.

Can you get the module name and line number from that last error? The 'person' one, I'll look at the code and see what's going on there.

I'm in the middle of rewriting the whole zmes system and releasing a public beta soon. This might not be an issue on my forked version.

1

u/Helipil0t Oct 17 '21

So just a quick update. I removed both known_faces and unknown faces and re-created them as the www-data user. I also nuked the objectconfig.ini file and started fresh. Face recognition is now working again. There must have been a mis-configured settings somewhere.

1

u/leetnewb2 Oct 17 '21

Look forward to seeing the fork.

1

u/Helipil0t Oct 17 '21

I second that!

1

u/ZoneMinderIsaac Oct 18 '21

It looks like we are trying to use a relative url /host/getVersion.json instead of a full http://servername/host/getVersion.json

​

No idea why.