Skip to content

Java Anaglyph & Polarization 3d Library 🕶️ for Images and Movies

License

Notifications You must be signed in to change notification settings

OrbiterToad/movie-fleur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

movie-fleur 🌻

Convert 3D movies with split frames to Anaglyph 3D movies for viewing with red (blue/cyan/green) 3D glasses.

Convert from Video File with Frame Position

If a 3D video is available, frames can be extracted by specifying the frame position. 3D video files can be found here.

BufferedImage frame = FleurVideo.extract(new File("3dVideo.mp4"), 6000);

List<BufferedImage> splited = Fleur3dUtil.split(frame);
BufferedImage frameCombined = FleurFilter.additive(
        FleurFilter.color(splited.get(0), ColorMask.RED),
        FleurFilter.color(splited.get(1), ColorMask.CYAN));

ImageHelper.saveImage(frameCombined, "frame_combined.png");

Steps to Convert

1. Extract Frames from Video File

Extract Frames

FleurVideo.extract(new File("3dVideo.mp4"), 6000);

2. Split and Stretch Frames

Left Frame Right Frame
Left Frame Right Frame
List<BufferedImage> splited = Fleur3dUtil.split(frame);

3. Combine Frames without Color Filtering

Combined Frame

BufferedImage combined = FleurFilter.alphaCombine(frame1, frame2);

4. Apply Color Filters

Left Frame with Red Filter Right Frame with Cyan Filter
Red Filter Cyan Filter
BufferedImage redFilterImg = FleurFilter.color(splited.get(0), FilterColor.RED);
BufferedImage greenBlueFilterImg = FleurFilter.color(splited.get(1), FilterColor.CYAN);

5. Combine Frames with Additive Filtering

Filtered Combined Frame

BufferedImage additiveCombinedFrame = FleurFilter.additive(
        FleurFilter.color(splited.get(0), FilterColor.RED),
        FleurFilter.color(splited.get(1), FilterColor.CYAN)
);

6. Compile to Video

Compiled Video

List<BufferedImage> images = FleurVideo.extract(new File("3dVideo.mp4"), 6000, 6010);
List<BufferedImage> videoImages = new ArrayList<>();

for (BufferedImage image : images) {
    List<BufferedImage> splits = Fleur3dUtil.split(image);

    videoImages.add(FleurFilter.additive(
            FleurFilter.color(splits.get(0), ColorMask.RED),
            FleurFilter.color(splits.get(1), ColorMask.CYAN)
    ));
}

FleurVideo.create(videoImages, "3dVideoOut.mp4");

7. Compile to Polarized 3D Video (Left/Right)

Left Video Right Video
Left Video Right Video
List<BufferedImage> images = FleurVideo.extract(new File("3dVideo.mp4"), 6000, 6100);
List<BufferedImage> leftArray = new ArrayList<>();
List<BufferedImage> rightArray = new ArrayList<>();

for (BufferedImage image : images) {
    List<BufferedImage> splits = Fleur3dUtil.split(image);
    leftArray.add(splits.get(0));
    rightArray.add(splits.get(1));
}

FleurVideo.create(leftArray, "left.mp4");
FleurVideo.create(rightArray, "right.mp4");

To view: play both videos on separate projectors or use active shutter 3D glasses on a 60Hz monitor.

Further Filters

Filter Name Example Code Snippet
Default Default Default rendering
Additive Blue Yellow Blue Yellow FleurFilter.additive(FleurFilter.color(splits.get(0), ColorMask.BLUE), FleurFilter.color(splits.get(1), ColorMask.YELLOW));
Additive Green Magenta Green Magenta FleurFilter.additive(FleurFilter.color(splits.get(0), ColorMask.GREEN), FleurFilter.color(splits.get(1), ColorMask.MAGENTA));
Indexed Indexed ImageHelper.convertToType(frame, BufferedImage.TYPE_BYTE_INDEXED)
Red Red FleurFilter.color(frame, ColorMask.RED)
Green Green FleurFilter.color(frame, ColorMask.GREEN)
Blue Blue FleurFilter.color(frame, ColorMask.BLUE)
Cyan Cyan FleurFilter.color(frame, ColorMask.CYAN)
Gray Gray FleurFilter.gray(frame)
Binary Binary ImageHelper.convertToType(frame, BufferedImage.TYPE_BYTE_BINARY)
Transparent (0.5) Transparent FleurFilter.transparent(frame, 0.5)
Invert Invert FleurFilter.invert(frame)

About

Java Anaglyph & Polarization 3d Library 🕶️ for Images and Movies

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages