Video Blending and Video searching

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
User avatar
asker
Posts: 1341
Joined: Sun Mar 01, 2015 12:12 pm

Video Blending and Video searching

Post by asker » Thu Jun 13, 2019 6:20 pm

I'm working on an alpha stage project that lets you create composite blends of ZM events and also searches for missing items etc.

More details:
https://medium.com/zmninja/blended-vide ... Type=repub

Repo:
https://github.com/pliablepixels/zmMagik
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Baylink
Posts: 330
Joined: Sun Jun 19, 2005 3:19 am

Re: Video Blending and Video searching

Post by Baylink » Wed Jul 31, 2019 1:59 pm

Interesting.

Having recently updated to 1.32.3, I've been finding that the ability to see an event timeline for a single monitor helps a lot in this task; how's your New Thing going to work? Or are you that far along yet?

zmc
Posts: 12
Joined: Sun May 24, 2020 2:41 pm

Re: Video Blending and Video searching

Post by zmc » Sat May 30, 2020 6:25 pm

I'm trying to test this out, but having some difficulties... Which version of OpenCV is required (3.x or 4.x)? Is it okay to use OpenCV version 2.4.8 (which installs easily with apt install on Ubuntu) or is it too old? For clarification, I already tried 2.4.8 but had problems with magik.py - I'm trying to determine if those problems are because of the OpenCV version or somewhere else.

I'm new to installing from source and the pip method of installing OpenCV (https://zmeventnotification.readthedocs ... cv-install) ends up with segmentation fault on Ubuntu 18.04.4 LTS.

zmc
Posts: 12
Joined: Sun May 24, 2020 2:41 pm

Re: Video Blending and Video searching

Post by zmc » Sat May 30, 2020 11:13 pm

Based on zmeventnotification docs mentioning that OpenCV 4.1.1 is the minimum version I'm going to assume this is also the case with zmMagik.

Following this manual (https://docs.opencv.org/master/d7/d9f/t ... stall.html) I ended up with ModuleNotFoundError: No module named 'cv2' - at this point I don't know how to fix it so I searched for more tutorials...

Following this manual (https://docs.opencv.org/master/d2/de6/t ... buntu.html) worked, although I ended up with the latest dev-version. During the installation steps I chose
-python3
-gtk3
-no optional dependencies
Result:
>>> import cv2 as cv
>>> print(cv.__version__)
4.3.0-dev

So after I had a working(?) OpenCV & zmMagik installation, I went ahead and tried to run

Code: Select all

python3 ./magik.py --monitors=7 --from "yesterday, 7am" --to "today, 10pm" --blend -c config.ini
and got

Code: Select all

2020-05-29 07:00:00
It looks like your OpenCV version does not include bgsegm. Switching to createBackgroundSubtractorMOG2
Background subtraction initialized
Detection mode is: background_extraction
-----| Arguments to be used:
config=config.ini
input=None
find=None
mask=None
skipframes=1
trailframes=10
blenddelay=2
fps=10
threshold=0.7
confidence=0.6
all=False
write=False
interactive=False
eventid=None
username=zmmagik
password=zmmagik
portal=http://localhost/zm
detection_type=background_extraction
config_file=None
weights_file=None
labels_file=None
meta_file=None
gpu=False
use_opencv_dnn_cuda=False
darknet_lib=None
from=2020-05-29 07:00:00
to=2020-05-30 22:00:00
monitors=7
resize=None
dumpjson=False
annotate=False
blend=True
detectpattern=.*
relevantonly=True
drawboxes=False
minblendarea=1500
fontscale=1
download=True
display=False
show_progress=True
objectonly=False
alarmonly=False
minalarmframes=1
duration=0
balanceintensity=False
present=True


Getting list of events using: http://localhost/zm/api/events/index/StartTime >=:2020-05-29 07:00:00/EndTime <=:2020-05-30 22:                                                                                                                                00:00/MonitorId =:7.json?sort=StartTime&direction=asc&username=zmmagik&password=zmmagik
Traceback (most recent call last):
  File "./magik.py", line 218, in <module>
    process_timeline()
  File "./magik.py", line 77, in process_timeline
    events = resp.json()['events']
KeyError: 'events'
So I tried a different method

Code: Select all

python3 ./magik.py --monitors=7 --eventid 101 --blend -c config.ini
And got a different result

Code: Select all

It looks like your OpenCV version does not include bgsegm. Switching to createBackgroundSubtractorMOG2
Background subtraction initialized
Detection mode is: background_extraction
-----| Arguments to be used:
config=config.ini
input=None
find=None
mask=None
skipframes=1
trailframes=10
blenddelay=2
fps=10
threshold=0.7
confidence=0.6
all=False
write=False
interactive=False
eventid=101
username=zmmagik
password=zmmagik
portal=http://localhost/zm
detection_type=background_extraction
config_file=None
weights_file=None
labels_file=None
meta_file=None
gpu=False
use_opencv_dnn_cuda=False
darknet_lib=None
from=None
to=None
monitors=7
resize=None
dumpjson=False
annotate=False
blend=True
detectpattern=.*
relevantonly=True
drawboxes=False
minblendarea=1500
fontscale=1
download=True
display=False
show_progress=True
objectonly=False
alarmonly=False
minalarmframes=1
duration=0
balanceintensity=False
present=True


Downloading video from url: http://localhost/zm/index.php?view=view_video&eid=101&username=zmmagik&password=zmmagik
Blending: 101.mp4
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2989260] moov atom not found
[ WARN:0] global /home/zonem/opencv/modules/videoio/src/cap_gstreamer.cpp (1745) handleMessage OpenCV | GStreamer warning: yo                                                                                                                                ur GStreamer installation is missing a required plugin
[ WARN:0] global /home/zonem/opencv/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Em                                                                                                                                bedded video playback halted; module uridecodebin0 reported: Your GStreamer installation is missing a plug-in.
[ WARN:0] global /home/zonem/opencv/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to st                                                                                                                                art pipeline
[ WARN:0] global /home/zonem/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning:                                                                                                                                 GStreamer: pipeline have not been created
Traceback (most recent call last):
  File "./magik.py", line 245, in <module>
    res = zmm_blend.blend_video(input_file=g.args['input'], out_file=g.out_file, eid=g.args['eventid'], mid=None, starttime=N                                                                                                                                one, delay=g.args['blenddelay'])
  File "/home/zonem/zmMagik/zmMagik_helpers/blend.py", line 72, in blend_video
    raise ValueError('Error reading video {}'.format(utils.secure_string(input_file)))
ValueError: Error reading video 101.mp4
I think I'm going to continue by trying to study more about this OpenCV/GStreamer issue, but if anyone has the cheat codes to get this thing going I would very much appreciate it :)

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

Re: Video Blending and Video searching

Post by asker » Sun Jun 07, 2020 11:26 am

I use OpenCV 4.3. I think any version above 4.1.2 should work. the "bgsegm" algorithm is part of the contrib package of openCV. From what I've seen, installing openCV using packages often causes issues on different distress (missing modules/broken support etc.). I find it best to purge all openCV packages and install from source (ref)

On the Gstreamer issue - don't know . It may either be a software intstall issue or a video format issue.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests