Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate a shaky cam with opencv?

Tags:

opencv

I'm trying to simulate a shaky cam in a static video. I could choose a couple of points randomly and then pan/zoom/warp using easing, but I was wondering if there's a better, more standard way.

like image 383
John Bartost Avatar asked Nov 03 '22 21:11

John Bartost


1 Answers

A shaky camera will usually not include zooming. The image rotation component would also be very small, and can probably be ignored. You can probably get sufficient results with 2D translation only.

What you should probably do is define your shake path in time - the amount of image motion from the original static video for each frame - and then shift each frame by this amount.
You might want to crop your video a bit to hide any blank parts near the image border, remaining blank regions may be filled using in-painting. This path should be relatively smooth and not completely random jitter since you are simulating physical hand motion.

To make the effect more convincing, you should also add motion-blur.
The direction of this blur is the same as the shake-path, and the amount is based on the current shake speed.

like image 156
Adi Shavit Avatar answered Nov 08 '22 09:11

Adi Shavit