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
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.