Video stabilization using opencv

312 views
Skip to first unread message

Dilawar Singh

unread,
Oct 17, 2016, 2:34:31 AM10/17/16
to wncc_iitb
TL;DR;

Corrects for motions/shakes introduced by camera in recordings of neural signals. This process is known as video stabilization. See here  http://nghiaho.com/?p=2093

--

This application deals with video of neural recordings. In such recordings, feature sizes are small. On top of it, recordings are quite noisy. Animal head movements introduces sharp shakes. Out of the box video stabilizer (link above) do not work very well on such recordings. Though there are quite a lot of plugins for ImageJ to do such a work, I haven't compared their performance with this application. This application is hosted here https://github.com/dilawar/video_stabilizer and a demo video is available on youtube here  https://www.youtube.com/watch?v=vGjIFvzOOQ8 .

The summary of basic principle is following:

0. Collect all frames in a list/vector.
1. Use bilateral filter to smooth out each frame. Bilateral filter smoothens image without distorting the edges (well to a certain extent).
2.  Calculate optical flow between previous frame and current frame. This is a proxy for movement. Construct a transformation and store them in a vector. OpenCV function `goodFeatureToTrack` does almost all the work for us.
3. Take average of these transformations and apply it on each frame of original recording; that's correct motion.

Sometimes it is desirable to apply step 3 during recording i.e. we don't have the luxury of computing the average. In such cases Kalman filters are used to smooth-out the trajectory.

PS: Rudolf E. Kalman died recently. 

      Dilawar
      NCBS Bangalore

Kumar Ayush

unread,
Oct 18, 2016, 1:19:57 AM10/18/16
to wncc_iitb
Thank you for this wonderful post.

That is a real loss to the community, but I hope his work keeps inspiring us for years.

About the video stabilization module, it would be a good idea to convert it into an android app which can stabilize the videos we take on our phone.

Regards
Kumar Ayush

--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saket Choudhary

unread,
Oct 18, 2016, 1:26:48 AM10/18/16
to wncc...@googlegroups.com
Are those synapses? Pretty cool!

--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+unsubscribe@googlegroups.com.

Dilawar Singh

unread,
Oct 18, 2016, 2:09:04 AM10/18/16
to wncc...@googlegroups.com
@ Saket

No they are not synapses. We don't work at synaptic level. We usually record
from as many neurons as possible when animal does the behaviour (in addition to
single cell (patch) recordings from a single neuron).

Mike Housser (among many other people) works at synaptic level. His lab produces
lot of cool stuff at dendritic/synaptic level http://Onw.dendrites.org/ .

Dilawar

--
>> email to wncc_iitb+...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>--
>--
>The website for the club is http://wncc-iitb.org/
>To post to this group, send email to wncc...@googlegroups.com
>---
>You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.

Dilawar Singh

unread,
Oct 18, 2016, 2:20:46 AM10/18/16
to Web and Coding Club IIT Bombay
I think these app must be available. Image stabilization is quite a old trick - at least it has been applied on start trek https://www.youtube.com/watch?v=5nKDQBwpCJg  .
This will be very slow on normal videos where feature sizes are often large. Since it computes as many "good corners" as possible and applies quite a large bilateral filter on each frame.

    Dilawar
Reply all
Reply to author
Forward
0 new messages