Avisynth vertical alignment correction script for Stereoscopic 3D video

This tool is of use for Nu-View and maybe 2xCamcorder users with synchronized zoom.

Problem:
A video is shot with minimal vertical misalignment between each respective left/right view when the camcorder's lens is set to wide angle. A zoom then starts at frame #250 and ends at frame #370. But by the end of the zoom the vertical alignment between left/right views is out by 10 lines due a minor misalignment being magnified by the zoom lens.

Solution:
  1. Hardware solution, have properly aligned cameras or Nu-View adaptor at the shooting stage. In the case of the Nu-View adaptor, horizontal misalignment can easily be adjusted with the convergence (ARRRGH!!! Puppet Kite Kid yells in Horror!) control knob while shooting. But vertical misalignment cannot be so easily be adjusted while shooting.
  2. Software solution, Gradually move one field vertically relative to the other over the period of the zoom, in this case 10 lines in 120 (370-250) frames, or 1 line per 12 frames over a period of 120 frames
This page describes the software solution by use of an Avisynth script, VirtualDub and Valentim Batista's Virtualdub plugin FieldShift


FieldShift

In Stereoscopic (3D) film/video it is imperative that an object in the left (eye) picture is on the exact horizontal plane as the Right (eye) picture. Otherwise eye strain can and usually occurs.

By use of Valentim's FieldShift filter it is very easy to adjust the left/right images so that they align on the horizontal plane.
FieldShift Filter


FieldAlign

There is another dimension to consider in Stereoscopic (3D) video. An image can not only move left/right, up/down as in conventional 2D video. But can also move into and out of the TV screen.

By use of the FieldAlign filter one image can be be moved left or right relative to the other. This has the effect of moving an object in or out the screen.
FieldAlign Filter



Introduction to the Nu-View Stereoscopic 3D Video Attachment

Photograph of Nu-View attached to a Sony Camcorder The Nu-View Adapter allows two distinct views (left eye and right eye) to enter the single lens (eye) of a camcorder in order to provide a true stereoscopic 3D image to be displayed and/or recorded. A threaded optical adapter is first attached to the camera's filter threads, which provides a stable optically aligned bayonet mount for the Nu-View. After the adapter is attached, the camcorder is used in a normal manner to view and record. To duplicate a true stereoscopic 3D experience the adapter provides the user with a simple single convergence control which allows you to converge on objects near and far.

Slowed down version of a field Sequential 3D video The Nu-View synchronizes with your camcorders field scanning. Standard PAL TV uses 50 (NTSC uses 60) fields per second (2 fields make 1 full frame). The left-eye view is recorded in Field one, followed by the right-eye view in Field 2. This method of recording stereoscopic 3D is called Field Sequential (FS). The image on the right is a slowed down (approx. 10Hz) demonstration of FS working.

Alternating between left-eye/right-eye views at only 50/60 fields per second can lead to perceptible flicker. But this can be eliminated completely if the video is watched on a standard PC monitor whose refresh rate is more akin to 120Hz.



Demonstration video of the script in use

Download video to see example of Avisynth Vertical Misalignment Zoom Correction working

Corrected video on left__________________________Uncorrected on right

Size:1.2MB Duration 6 seconds 25fps
720x288 MPEG1 interlaced

To download the video, RIGHT Click on the image and
"Save Target As" (Internet Explorer) or "Save Link As" (Netscape).




List of software required for the
Vertical alignment correction script

1. Virtual Dub

Virtual Dub Program IconClick on Virtual Dub icon to download the latest version. VirtualDub is a video capture/processing utility for 32-bit Windows platforms (98/NT/2000/XP), licensed under the GNU General Public License (GPL). It lacks the editing power of a general-purpose editor such as Adobe Premiere, but is streamlined for fast linear operations over video. It has batch-processing capabilities for processing large numbers of files and can be extended with third-party video filters. VirtualDub is mainly geared toward processing AVI files, although it can read (not write) MPEG-1 and also handle sets of BMP images.

2. Avisynth

Avisynth Logo Click on Avisynth Icon to download the latest version. AviSynth is a powerful tool for video post-production. It relies on simple scripts you can create using any text editor. It uses a simple yet powerful programming language, complex filters can be created from basic operations, thus developing into a sophisticated palette of useful and unique effects.

3. VirtualDub plugin filters useful for stereoscopic 3D video

Useful filters for stereoscopic 3D video, for use with Virtual Dub Click on zip icon to download the the filters.

Unzip the file into the 'plugins' directory of Virtualdub, eg.
C:\Program Files\VirtualDub\plugins

Filters Included in zip file:

Big thank you to the following people; Simon Walters, Valentim Batista, who have kindly written or modified existing VirtualDub filters to accommodate stereoscopic video. Go to their respective website for the latest filter updates.


METHOD

Once VirtualDub, Avisynth, and the Plugin pack are installed correctly, you will need to modify the following Avisynth script to your specific configuration.
  1. Copy and paste the following script into notepad or similar text editor.
    global plugin_directory = "C:\Program Files\VirtualDub\plugins"
    Function VShift (clip, int "Y") 
    {
    	LoadVirtualDubPlugin(plugin_directory+"\fieldshift.vdf", "VShift")
    	return clip.ConvertToRGB.VShift(Y)
    }
    DirectShowSource("D:\Video.avi")
    ConvertToRGB
    Animate(85,330, "VShift", last,0,last,-6)
    #eg. Above command will gradually displace one field vertically by 6 lines
    starting at frame #85 and finishing at frame #330
    
    
  2. Edit the script so the first line points to your Virtualdub 'plugins' folder. eg. "C:\Program Files\VirtualDub\plugins" in this case.
  3. Save the script and remember to change the extension from .TXT to .AVS
Example: A zoom starts at frame #250 and ends at frame #370. By the end of the zoom (120 frames worth) the vertical alignment is out by 10 lines.
Solution: Every 12 frames the script needs to move one field vertically by 1 for a period of 120 frames.

As each Animate command can only move fields by a maximum of +- 8 lines it is necessary to stack them.

Animate(250,346, "VShift", last,0,last,-8)
Animate(346,370, "VShift", last,0,last,-2)

Breakdown of the Animate command:
Animate(Start frame number, End frame number , "VShift", last,0,last, Number of lines to displace)
How frame numbers were derived: Start of zoom =250, 8(lines)x12(frames)+250=346, 2(lines)x12(frames)+346=370




e-mail gedburnell@yahoo.com
Subscribe to 3dtv
Powered by groups.yahoo.com