Thursday, May 24, 2012

Make a movie with your kid!

I will demonstrate how to put your kid into a virtually created environment. First you need to record your kid and capture an AVI file using the program "dvgrab". It is possible that you will need to install dvgrab. Then connect your camera with the computer using a Firewire cable and issue a command:

dvgrab film.avi

Next we will split the file film.avi into separate frames. This can be done with the program ffmpeg from

ffmpeg -i film.avi image_%06d.png

This will create a number of frame files. Now we need to define what "background" means. Use gimp or any similar program to cut off the background from one of the frames.

Store it in the file background.png. Then unzip the archive  movie_maker_scripts.tar.gz to the directory PERL and type:

perl -I../PERL -f ../PERL/ background.png

As a result you will obtain the HVS parameters of your background. Now open the in an editor and edit the line:

if ($h>=156 && $h<=167 && $v<=162 && $v>=54)

The values should reflect the minimum and maximum for H and V, respectively. Once this is done we are ready to remove the background from all the frames. Go to the directory with the frames, create a directory RESULT and then run:

perl -I../../PERL ../../PERL/ . RESULT

After a while the directory RESULT will contain a number of frames without the background, like the one below:

Now is a good time to learn Blender, or a similar program to build a virtual 3D environment. It can look like:

Note that in this case we used one of the frames to create the wizard's picture hanging on the wall. Next step will be to paste the virtual environment into the frames without background. I will describe how to do it next time.

No comments:

Post a Comment