![]() |
VOOZH | about |
Prerequisite: Addition and Blending of images using OpenCV in Python
In this article, we will be showing you how to effectively blend two videos together. But for that, we will first see what is Alpha Blending.
Alpha blending is a curved mix of two tones taking into consideration transparency impacts in computer illustrations. The estimation of alpha in the color code goes from 0.0 to 1.0, where 0.0 addresses a completely transparent tone, and 1.0 addresses a completely dark tone. The estimation of the subsequent color when color Value1 with an alpha value of Alpha is drawn over a foundation of color Value0 is given by:
Value = Value0(1.0 - Alpha) + Value1(Alpha)
The alpha part might be utilized to mix to red, green and blue segments similarly, as in 32-bit RGBA, or, then again, there might be three alpha qualities determined relating to every one of the essential tones for spectral tone shifting.
Now, the second thing we will be using is OpenCV which is a library of programming functions that focuses on real-time computer vision. But, before moving forward we will keep a note of a few things.
In order for our program to work perfectly, you've to make sure:
We will be taking two videos as input, one will be our background video and the second one will be our foreground video. The main work is to remove the solid color background of this foreground video so that we're left with the subject only (of foreground video) with its transparent background. After making this change, the foreground video will then be put on the background video, which will give an illusion of a single video with some effect on it but actually, there will be two videos blended together. This magic is done with the help of OpenCV and Python.
Input:
Foreground Video
Background Video
Notice that the foreground video contains only the particles with a solid black background, thus for better results, it is preferable to take foreground videos and background videos like these.
Output:
Notice that in this output video we can see that the sand is moving in the air in a hot desert area, which in reality is the blended output of the particle video(used as foreground) and desert video(used as background). Also, you can always press "q" from your keyboard to break the loop and quit the program.
So in this way, you can blend two videos and if done correctly, this method can also provide a professional edit look as well.