Posts Tagged ‘projection mapping’

ProjectedQuads source code

Sunday, January 31st, 2010

ProjectedQuads
On request from several people I decided to finally release source code of my projection mapping projects. I wanted to make a Processing library from it anyway at some point but I delayed it so many times that it might never happen.

Features

- unlimited number of quads
- support for static images and dynamic generative animations
- loading and saving configuration to a text file

Download

ProjectedQuadsTest.zip [7kb]

How to use it?

Let’s say we want to display an image with perspective correction. First declare variables for our image and quad that will display it.

PImage img;
ProjectedQuads projectedQuads;

Then in setup() function load the image, create projectedQuads object, set number of quads and assign textures to them.

void setup() {
img = loadImage("checker.png");
projectedQuads = new ProjectedQuads();
projectedQuads->setNumQuads(1);
projectedQuads.getQuad(0).setTexture(img);
}

All we have to do in draw() function is just call projectedQuads.draw();

void draw() {
projectedQuads.draw();
}

Run the sketch and adjust corners of the quad using mouse or keyboard. Attached example source code explains how to use more quads and display dynamic graphic generated in processing.

Some other projects that I use this code for:

- “3xI” reactive projection mapping during Vivisesja festival. Read more about it on my blog.

3xI

- During Shiftcontrol’s end of they year meeting I did small projections to add some life to the globetrotters pub where it took place.

Projection mapping in 3d

Wednesday, December 9th, 2009

Encouraged by previous results I decided to try to play more. This time in 3D. By 3D I mean projecting on the object in such a way that it looks like you are actually projecting from different sides of it.

2D in 3D – Lets say we want to project a rectangle on one of the sides of a cube. It’s easy when the projector is exactly in front of the target side.

projectin2Din3Da

If not then we will quickly observe a keystone effect. Simply speaking the image will be distorted.

projectin2Din3Db

How to overcome that? We just have to project image that looks like the projector ’sees’ it.

projectin2Din3Dc

Ok. So now we know the theory let’s talk about how to apply it in practice. All I need is some way to distort an image so it looks like a ‘viewed from the side’. There is a Processing library for that, vvvv patch, or even specialized app called VPT (video projection tools) . Non of them allowed me to program my own visuals on arbitrary number of surfaces (and vvvv is Windows only..). So I made my own Processing sketch which for defined number of rectangles displays handles in each corner that can be dragged around to match target geometry.

corner pin mapping

Corner – As a first victim or my new projection I have chosen a corner in our studio.

Cube – After some time I noticed an empty box lying on a desk… guess what I did..

3D in 3D – is projecting 3D graphics on a 3D object. While it can be done it’s quite limited. The problem is that it looks good from only one point of view. As you can see on the image below in case ‘a’ when we are standing in front of the projected surface everything looks good. We can get the feeling of depth and so on. But immediately once we start moving more to the left or right and viewing angle increases the image becomes more and more flat – case ‘b’. The last case ‘c’ shows what would we expect

fake3d

I had one attempt to display something 3D but it wasn’t very successful to I decided to spend my time tweaking my 2D code.

IMG_0385_3d_in_3d

More examples? Look here or here.

Projection mapping in the office

Saturday, December 5th, 2009

Projection mapping is making projections in a way that they match the surface they are projected on. This way we can use projector for something much more interesting than flat powerpoint presentation like VJ projections. As I was invited for vivisesja this year I decided to play a bit with Processing and see what I can do during two weekends.

2D in 2D – This is how I call projecting 2D graphics on flat (or almost flat) surface. We have some cool pipes going across room and wall in our studio so I chose them as my projection target.

Equalizer – first test was simple. I have audio reactive bars and I want to project them so they match the pipes. How to do that? I made a sketch that displays 4 rectangles. I was doing it by hand in code so I spend some time to make them match the pipes perfectly. This gave me a mask that I could use for limiting projection only to the pipes. Having positions of the rectangles I programmed animated bars so they matched this positions. Results were super good, as expected :)

equalizer

The only trick here is to adjust projector brightness so the black is invisible on the wall.

Sunset – it’s time for some magic. What would happen if we invert the mask so we project everywhere beside the pipes?

sun

People usually say that’s the best one of my first tests. It’s somehow counter intuitive and surprising when watched for the first time.

The only issue with this one is that when observed from a side you get shadows from the pipes so it doesn’t look so good anymore.

sun_shadow

Sunset – this time I wanted to play with some more complex mask and couch next to the pipes looked like a perfect target. I took a photo of the couch, draw an outline of it, filled the shape with white and projected it back on the couch.

stars

Of course my shape wasn’t perfect so I had to retouch it a bit to remove all the gaps. I made a Processing sketch that was constantly reloading the image for projection so every time I pressed Cmd+S I was able to see the changes almost realtime.

Want more (especially large scale) projection mapping examples? Look at this, this, this and this.