Time-saving preview of surveillance videos
Me-Too Algorithm
The algorithm borrowed from OpenCV Essentials [2] uses the move_test()
function (lines 9-45) to call the OpenCV goodFeaturesToTrack()
function (line 12) to detect points of interest in the old frame (oframe
); the maximum number points of interest is limited to 500 by the constant MAX_FEATURES
(line 6). Line 27 then calls calcOpticalFlowPyrLK()
and returns a number of areas in the new_features
variable that have apparently shifted, compared with ofeatures
in the last frame.
The for
loop (lines 34-43) iterates across the areas and finds the range that covered the longest path. If one of them exceeds the value of 100, line 44 returns the value 1
from move_test()
, thus indicating that movement must have occurred.
Spice It Up and Show Me!
Listing 1 thus outputs lines of integer values that represent the values in seconds for times at which something in the video moved from one frame to the next. It's now time for the code in Listing 3 to spice up this raw data, generate thumbnails for the appropriate scenes, and summarize the whole thing in an overview, as shown in Figure 4.
Listing 3
motion-meta
It uses the good old, all-around mplayer
tool for the thumbnails, fast forwarding to the specified video second with the -ss
option and storing the frame in a temporary directory $tmpdir
. The -frames 1
option stipulates that mplayer
terminates right after reading a single frame. The move()
function from the CPAN File::Copy module then renames the file in the temporary directory to one in the current directory and uses the CPAN DateTime::Format::Duration module to convert movie seconds to the hh:mm:ss
format. The frame at second 64 thus becomes the file 00:01:04.jpg
.
The Ubuntu perlmagick
package adds the CPAN Image::Magick module to the system, which you can use to create montages from multiple image files (i.e., virtual contact sheets) in the format shown in Figure 4. The call
$ max-movement-lk test.mp4 | ./motion-meta test.mp4
glues the two parts of the pipeline together and produces the contact sheet in motion-meta.jpg
.
The first part analyzes the frames in the video and prints the values (in seconds) during which movement has occurred. The second part grabs the movie second values, deduplicates them, looks up the associated thumbnail in the video, and mounts all of them to create a contact sheet – using nothing but the raw still image file names, conveniently chosen to reflect the time in the video in minutes and seconds.
10 Million for a Specialist
Detecting moving objects in video streams is used not only with surveillance videos, but with self-driving cars to distinguish endangered pedestrians from stationary road signs. Learning these techniques could pay off in terms of your career: According to ex-Googler Sebastian Thrun, companies in this field are currently outdoing each other and paying about $10 million for specialists [5]. Now who could afford it to say no to that?
Infos
- Arlo Security System: https://www.amazon.com/dp/B00P7EVST6
- Deniz Suarez, O., M. del Milagro Fernandez Carrobles, N. Vallez Enano, G. Bueno Garcia, and I. Serrano Gracia. OpenCV Essentials. Packt Publishing, 2014. https://www.amazon.com/OpenCV-Essentials-Oscar-Suarez-2014-08-25/dp/B017YC0EHA
- Lucas-Kanade method: https://en.wikipedia.org/wiki/Lucas%E2%80%93Kanade_method
- Listings for this article: ftp://ftp.linux-magazine.com/pub/listings/magazine/195/
- Post by Sebastian Thrun: http://www.recode.net/2016/9/17/12943214/sebastian-thrun-self-driving-talent-pool
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.