At last nights meeting there was a lot of discussion about centralising
motion detection instead of doing it on the camera itself.
Here is how I did motion detection using vlc
First I created a log file using vlc to detect motion
# Create the log file using vlc
def create_log(path)
# Use Xvfb which opens up a virtual desktop to dump a GUI screen
we don't want to see.
# -a = select the next available display
`xvfb-run -a cvlc --no-loop --play-and-exit
--video-filter=motiondetect -vvv #{path}.mjpeg > #{path}.log 2>&1`
end
Then I just read through that log file and look for the number of changes
# Read in the log file and return the motiondetect lines
def read_log(path)
results = []
if File.exists?(path)
File.readlines(path).each do |line|
results.push line.chomp if line =~ /motiondetect filter/
end
end
results
end
This code is from my electric_eye recording tool
https://github.com/map7/electric_eye
I would love to change this program so that it uses something more
robust, faster and not as hacky. The vlc solution has to work in
realtime, uses a lot of resources and it's that good at motion
detection. I also found myself splitting each of my video streams into
1minute lengths so that I could process them in the background and
either keep or discard. It's all very messy.
It would be nice to have a tool which could detect motion much faster
than real time, do it in the background, automated through scripts on
the server and properly edit the videos. For instance I could record in
1hr lots and pass that file over to be processed and then the 'tool'
could remove the parts which are not needed, ie: nothing is moving.
from
Michael