Code Monkey home page Code Monkey logo

stereoscopy's Introduction

StereoscoPy

This is a Python script/library for converting two images into a stereoscopic 3D image: anaglyph, side-by-side (cross-eye and parallel), over/under, wiggle GIF, interlaced and checkerboard.

Requirements

  • Python 3.4+ or Python 2.7+
  • Pillow
  • cv2 (optional for auto align)
  • numpy (optional for auto align)

Installation

From the Python Package Index:

pip install stereoscopy

With the optional requirements for the auto align feature:

pip install "stereoscopy[auto_align]"

Or download and run:

python setup.py install

Command-Line

Help

StereoscoPy --help

Cross-eyed (Right/Left)

With white 5px wide border and image division. Auto aligned, resized to be 450 pixels in width and shifted horizontally by 1 pixel.

StereoscoPy -A -R 400 0 -S 1 0 -x --div 5 --border 5 --bg 255 255 255 0 left.jpg right.jpg cross_eye.jpg

Anaglyph

For red-cyan glasses, there are various methods for creating anaglyphs available.

StereoscoPy -A -R 400 0 -S 1 0 -a left.jpg right.jpg anaglyph_wimmer.jpg
StereoscoPy -A -R 400 0 -S 1 0 -am dubois left.jpg right.jpg anaglyph_dubois.jpg
StereoscoPy -A -R 400 0 -S 1 0 -am gray left.jpg right.jpg anaglyph_gray.jpg
StereoscoPy -A -R 400 0 -S 1 0 -am color left.jpg right.jpg anaglyph_color.jpg
StereoscoPy -A -R 400 0 -S 1 0 -am half-color left.jpg right.jpg anaglyph_half_color.jpg

The Dubois anaglyph method for amber-blue glasses.

StereoscoPy -am dubois --cs amber-blue left.jpg right.jpg anaglyph_dubois_ab.jpg

Wiggle GIF

Without alignment

StereoscoPy -R 400 0 -wt 400 left.jpg right.jpg simple.gif

Shifting an image moves the right image in relation to the left image. An images can be shifted after the auto align to change its center.

StereoscoPy -A -R 400 0 -S 1 0 -wt 200 left.jpg right.jpg align_shift.gif

Squashed Parallel (Left/Right) and Top/Bottom for TVs

StereoscoPy -A -R 400 0 -S 1 0 -ps left.jpg right.jpg tv_left_right.jpg
StereoscoPy -A -R 400 0 -S 1 0 -os left.jpg right.jpg tv_over_under.jpg

Two separate image outputs

Before converting to the stereoscopic outputs, I find this (or a slow wiggle GIF) to be a nice way to check for the correct dimensions, shift and rotation by switching between the two output images in an image viewer.

StereoscoPy --shift 19 30 --crop 20% 0 0 0 --resize 1920 1080 --offset 100% --parallel left.jpg right.jpg out1.jpg out2.jpg

Misc

20% cropped from the top, resized to 1920x1080 and offset to the right by 100%.

StereoscoPy --crop 20% 0 0 0 --resize 1920 1080 --offset 100% --cross-eye left.jpg right.jpg out.jpg
StereoscoPy -C 20% 0 0 0 -R 1920 1080 -O 100% -x left.jpg right.jpg out.jpg

20% cropped from left and right and resized to be 1080 high and 0 width to preserve the aspect ratio.

StereoscoPy -R 0 1080 -C 0 20% 0 20% -o left.jpg right.jpg out.jpg

stereoscopy's People

Contributors

2sh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stereoscopy's Issues

Had to change Image.py

Got in working on Linux Mint 19.2, by changing in .local/lib/python2.7/site-packages/PIL/Image.py:

Line 1968: rotn_center = (int(w / 2.0), int(h / 2.0))
Line 2387: self.im.transform2(( int(box[0]),int(box[1]),int(box[2]),int(box[3]) ), image.im, method, data, resample, fill)
Line 2495: return Image()._new(core.new(mode, (int(size[0]),int(size[1])) ))

Provide all examples

Please add left.jpg and right.jpg to the example_images directory to be able to try out the provided examples from README.md directly.

Color scheme red-green not workin with method gray

Calling this:

stereoscopy.create_anaglyph((left, right), color_scheme="red-green", method="gray").save(rgAnagFileName)

Results in the following:
front-anaglyph-rg

Shouldn't the background be white / gray, like calling without the color_scheme param? That is just green where the are cyan parts without the color_scheme param.

After searching for example it seems that the orange tint is actually to be expected...
Can anyone confirm?

Doesn't work with latest OpenCV

I like this project. I used it to make a puzzle for a treasure hunt for my wife. I see that there has not been any activity for a while, so this may fall on deaf ears. However, I was working in an environment where OpenCV (4.2.0 I believe) was already installed. I pip installed StereoscoPy on a Windows machine. When I first tried to run the script, there was an error in the call to findTransformECC. It wanted an inputMask and a gaussian blur radius. I modified the code to pass None and 1 respectively, and it worked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.