The motion vector code required a few database commands to setup the Ffmpeghw Monitor type and the Mvdect Function. These need to be run by mysql root.
Code: Select all
ALTER TABLE Monitors modify column Type enum('Local','Remote','File','Ffmpeg','Ffmpeghw','Libvlc','cURL') NOT NULL default 'Local';
ALTER TABLE MonitorPresets modify column Type enum('Local','Remote','File','Ffmpeg','Ffmpeghw','Libvlc','cURL') NOT NULL default 'Local';
ALTER TABLE Controls modify column Type enum('Local','Remote','Ffmpeg','Ffmpeghw','Libvlc','cURL') NOT NULL default 'Local';
alter table Monitors modify column Function enum('None','Monitor','Modect','Mvdect','Record','Mocord','Nodect') NOT NULL default 'Monitor';
I have yet to test Ffmpeghw Monitor. It is really only for RPI right now. I don't know of any other h264_mmal codec implementations in other devices that currently work with ffmpeg.
The motion vectors are only available for software decoding of h264 video using Ffmpeg Monitor. This works if the ffmpeg version supports the AVFrameSideData export flag (version 3.x and up).
So if the installed ffmpeg supports it, to use the motion vectors, set Monitor Source Type to Ffmpeg and Function to FnMvdect with your h264 camera.
The analysis is equivalent only to Alarm Pixels in Modect. I don't have any filtering code to ascertain clusters of motion vectors. I don't know if that is even necessary as there are a lot fewer motion vectors from Mvdect than alarm pixels from Modect.
The user can select the sensitivity of the MvDect function by setting Min/Max Alarmed Area in the Zone configuration UI. It is recommended to use 'Percent' for Units.
I figured that I could use that config setting instead of tackling how to introduce new config options to the database.
The analyser tries to save cpu cycles by analysing only if there are enough vectors to satisfy the minimum user specified score.
No guarantees.
Running on an x86, I get these results from zmsample.sh
Mvdect at idle.
Code: Select all
PIDSTAT zmc : Reporting average of 12 readings at 5 seconds intervals
ZMC Process ID : 773 ==> ( 6.60 + 7.00 + 6.60 + 6.80 + 6.40 + 6.80 + 7.00 + 7.00 + 6.20 + 6.80 + 6.80 + 6.40 ) / 12
AVERAGE : 6.70
PIDSTAT zma : Reporting average of 12 readings at 5 seconds intervals
ZMA Process ID : 781 ==> ( 1.40 + 1.40 + 1.40 + 1.40 + 1.20 + 1.40 + 1.40 + 1.40 + 1.00 + 1.60 + 1.20 + 1.40 ) / 12
AVERAGE : 1.35
Code: Select all
PIDSTAT zmc : Reporting average of 12 readings at 5 seconds intervals
ZMC Process ID : 773 ==> ( 9.20 + 9.60 + 7.40 + 0.00 + 6.20 + 9.20 + 7.40 + 7.60 + 8.80 + 6.40 + 8.40 + 8.00 ) / 12
AVERAGE : 8.18
PIDSTAT zma : Reporting average of 12 readings at 5 seconds intervals
ZMA Process ID : 24781 ==> ( 4.80 + 3.60 + 3.80 + 3.80 + 3.40 + 4.80 + 3.40 + 3.20 + 2.80 + 2.00 + 3.20 + 3.20 ) / 12
AVERAGE : 3.50
Code: Select all
PIDSTAT zmc : Reporting average of 12 readings at 5 seconds intervals
ZMC Process ID : 773 ==> ( 6.80 + 6.60 + 6.60 + 7.00 + 7.20 + 6.80 + 7.19 + 6.60 + 6.80 + 7.20 + 6.60 + 7.20 ) / 12
AVERAGE : 6.88
PIDSTAT zma : Reporting average of 12 readings at 5 seconds intervals
ZMA Process ID : 16633 ==> ( 5.60 + 5.40 + 5.20 + 5.40 + 5.59 + 5.20 + 5.40 + 5.20 + 5.40 + 5.20 + 5.00 + 5.40 ) / 12
AVERAGE : 5.33
Thanks,
Chris