zm_detect.py error when testing zm_event_start.sh

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

Anyone seen an error like this one before and got around it?

I'm working in a freenas jail with zoneminder 1.32.3 with apache.
Had some trouble getting the API running but I've fixed that now
error.jpg
error.jpg (75.54 KiB) Viewed 8913 times
I did have to edit ZMLog.py to get this far as it was complaining that my zm.conf couldn't be found in /etc/zm/zm.conf (it's at /usr/local/etc/zm.conf)

I'm wondering if there's more edits to these files that need to be made, but I would have thought it should be picking this up from config files somewhere else?

Thanks for any help!
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

when the zm_event_start.sh is triggered by the event server this is what I'm getting in the logs..

Code: Select all

2020-03-18 15:58:50	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 hook end returned with text: json:[] exit:127	zmeventnotification.pl	
2020-03-18 15:58:49	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Invoking hook on event end:'/usr/local/lib/zmeventnotification/bin/zm_event_end.sh' 467 1 "Front Garden" "Motion: New"	zmeventnotification.pl	
2020-03-18 15:58:47	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Event 467 for Monitor 1 has finished	zmeventnotification.pl	
2020-03-18 15:58:47	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Not sending over MQTT as notify filters are on_success:all and on_fail:none	zmeventnotification.pl	
2020-03-18 15:58:47	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Monitor 1 event: should send out as 4.13035988807678 is >= interval of	zmeventnotification.pl	
2020-03-18 15:58:47	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Checking alarm rules for MQTT 127.0.0.1	zmeventnotification.pl	
2020-03-18 15:58:47	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Matching alarm to connection rules...	zmeventnotification.pl	
2020-03-18 15:58:46	zmeventnotification		77481	INF	|----> FORK:Front Garden (1), eid:466 Not sending event end alarm, as we did not send a start alarm for this, or start hook processing failed	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 hook start returned with text: json:[] exit:127	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77501	INF	|----> FORK:Front Garden (1), eid:467 Invoking hook on event start:'/usr/local/lib/zmeventnotification/bin/zm_event_start.sh' 467 1 "Front Garden" "Motion New"	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77501	INF	PARENT: Forked process:77501 to handle alarm eid:467	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77137	INF	PARENT: There are 1 new Events to process	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77137	INF	PARENT: New event 467 reported for Monitor:1 (Name:Front Garden) Motion New	zmeventnotification.pl	
2020-03-18 15:58:45	zmeventnotification		77137	INF	PARENT: There are 1 active child forks...	zmeventnotification.pl

User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by asker »

You can't pass --config to zm_event_start.sh.
That is a parameter for zmdetect.py

If you are invoking zm_event_start.sh, edit that file and change CONFIG_FILE

With respect to logging, that is correct, by default it assumes "/etc/zm". You can change zm_detect.py "log.init" statements to override the conf_path https://github.com/pliablepixels/pyzm/b ... Log.py#L71
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

thanks!

I've got logpath overridden to /var/log/zm in the args and conf_path changed to /usr/local/etc already but it still seemed to be having an issue with ZM_PATH_LOGS as if it's not defined or something.

Then I noticed the line

for f in glob.glob(config['conf_path']+'/conf.d/*.conf'):

realised it wasn't picking up my extra config files so changed that to

for f in glob.glob(config['conf_path']+'/zoneminder/*.conf'):

Which has moved things along a bit although now I'm getting this;

File "/usr/local/lib/python3.7/site-packages/pyzm/ZMLog.py", in line 162 in init config_table = meta.tables[Config]
KeyError: 'Config'

looking at the code it definitely looks like that's getting defined though.

Thanks so much for the help!
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

In ZMLogs.py I had to change;

config_table = meta.tables['Config']
log_table = meta.tables['Logs']

To

config_table = meta.tables['config']
log_table = meta.tables['logs']

no errors now and nothing returned in the console... which I guess is correct behaviour? No boxes around people in zmninja desktop yet but I'm guessing I just need to mess around with objectconfig.ini to get that working next.

Although please let me know if you think doing this might have messed something up somewhere :)
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

Actually, I'm still getting

eid:919 hook start returned with text: json:[] exit:127

In the zoneminder logs... which looks like it's a problem
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by asker »

exit 127 may mean the script is not found. Check if the paths are correct. Your screenshot shows /usr/local/lib/zmeventnotification. By default, the script configs use /var/lib/zmeventnotification


Out of curiosity: who maintains this ZM port and why are all paths/DB names different? Is it because of platform requirements?

Some other thoughts:

1. Are you really sure your tables are called 'config' and 'logs' and not 'Config' and 'Logs' in your zm DB? Can you connect to the DB and check?
2. When trying to track down issues, don't just rely on console output. Enable debug logs and inspect them. This entry has instructions on how to setup debugging https://zmeventnotification.readthedocs ... g-problems
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

Actually, I'm not sure who maintains it... it's the default package in a freenas jail when running pkg install zoneminder. Although I'm starting to wish I'd built it from source now with the problems it's caused me.

It seems like I might just have got all of my paths sorted now and it looks like those table names are right.

Although testing zm_direct.py still isn't playing nice. When I'm running that directly with the --config and --eventid I'm now getting a
"AttributeError: module 'cv2.dnn' has no attribute 'readNet'

I built this port of opencv with the contrib modules;
https://www.freshports.org/graphics/opencv

but I've seen it's v3.4.1 and I can't find a more up to date port so if that error is down to the version then I think I might just be blocked here?
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by asker »

JonMoore wrote: Thu Mar 19, 2020 4:07 pm but I've seen it's v3.4.1 and I can't find a more up to date port so if that error is down to the version then I think I might just be blocked here?
Yup, you need 4.x to get the DNN functions. You could try building open cv from source.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by Bluemax »

On what cpu/hardware do you run freenas? I'm planning to run opencv on an i5-2500 (without gpu) but i'm not sure if it will be usable at all.
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

I'm on an i3-6100, so far performance has been totally fine with zoneminder. I'm struggling to get opencv-4.x.x to build from source though so no idea what that'll be like for performance yet. I'll let you know when/if I make it.

Also, I'd LOVE to hear about your install of opencv-4 if you can do it!

Thanks.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by asker »

I did not do anything special.
After downloading both opencv, opencv_contrib and creating a build directory inside opencv as the official instructions say, this was my make script:

Note that the ARCH_BIN/CUDA/CUDNN was enabled because I wanted it to work with my GPU

Code: Select all

# Important get your ARCH_BIN value from https://developer.nvidia.com/cuda-gpus#compute
# If you don't do this, when you use CUDA with openCV it will error out with 'make_policy' related
# errors

ARCH_BIN=6.1
cmake -D CMAKE_BUILD_TYPE=RELEASE \
	-D INSTALL_PYTHON_EXAMPLES=ON \
	-D INSTALL_C_EXAMPLES=OFF \
	-D OPENCV_ENABLE_NONFREE=ON \
	-D WITH_CUDA=ON \
	-D WITH_CUDNN=ON \
	-D OPENCV_DNN_CUDA=ON \
	-D ENABLE_FAST_MATH=1 \
	-D CUDA_FAST_MATH=1 \
	-D CUDA_ARCH_BIN=${ARCH_BIN} \
	-D WITH_CUBLAS=1 \
	-D OPENCV_EXTRA_MODULES_PATH=/home/pp/fiddle/opencv/opencv_contrib/modules  \
	-D HAVE_opencv_python3=ON  \
	-D PYTHON_EXECUTABLE=/usr/bin/python3 \
	-D BUILD_EXAMPLES=ON ..
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

hmm... if object detection relies on opencv-4.x I think I'm boned. Doesn't seem to be anything on google where someone has said they've got it working.

I've got through a number of different make errors so far but am hitting a wall at some references to 'memalign'

I'll keep trying but I think I might just have to wait until someone ports it properly or I switch to ubuntu. If I manage to get it going I'll post my method back here.

Let me know if you hear of anyone with object detection on freenas. And thanks so much for the help so far, it's been great and it's certainly boosted my troubleshooting skills.

Cheers,
Jon
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by Bluemax »

Actually, i had no issues compiling opencv 4.3.0pre (master). I didn't compile the contrib packages or any optional dependencies (png, tiff, python...) though. I haven't deployed it to the target machine yet though.

Code: Select all

git clone https://github.com/opencv/opencv.git
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release ..
make -j3
make install
JonMoore
Posts: 26
Joined: Wed May 26, 2010 5:55 pm

Re: zm_detect.py error when testing zm_event_start.sh

Post by JonMoore »

Ah... I may be wrong, but based on the zmes documentation I think contrib is required.

I'm making progress with the compile though... I've had to change a few things, switching malloc.h to stdlib.h, getting rid of a process to discover number of online processors and changing memalign. I'm up to about 75% :D
Post Reply