How to implement a simple Projection Masked project

Hi all

I’m brand new to coding and openFrameworks. I’ve been working on getting my Raspberry Pi 2 setup and operational (success!) and then going through the tutorials here and many of the examples and addon examples. I’ve learned a lot, and now I’m ready to focus on doing a specific project.

What I would like to do, is create random visualizations (using shaders or movies), and to have those play through a PNG mask. My thought is, to setup a very simple pseudo-projection mapping. I would create the PNG ahead of time based on the physical space / surfaces being used, import that into the project, and then run it. Given that, I have a few questions:

  1. Does something similar to this already exist, and if so can someone point me in the right direction?
  2. If not, what do I need to focus on to learn how to do this? I am thinking tutorials on creating your own shaders, probably open gles, and learning what is the best way to create a mask with a PNG image.
  3. Are there other tutorials / resources available online that people can recommend?

Thanks in advance for any help provided, :smile:

Check out our simple RPI2 projection mapping software called kibio

Its all OF.

It’s a work in progress, but might be a nice place to start. PNG and live drawn masks are already implemented. We just ran a workshop on it here in Chicago and it went quite well!

Hey, sorry to dredge this topic back up, but I finally got around to Kibio today. I’m having a few issues compiling it, can you offer any guidance?

int main()
ofGLWindowSettings windowSettings;

ofRunApp(new Kibio::SimpleApp());


The errors from the Pi when it tries to compile are:

src/main.cpp:31:5: error: ‘ofGLWindowSettings’ was not declared in this scope
ofGLWindowSettings windowSettings;
src/main.cpp:31:24: error: expected ‘;’ before ‘windowSettings’
ofGLWindowSettings windowSettings;
src/main.cpp:32:5: error: ‘windowSettings’ was not declared in this scope
src/main.cpp:33:34: error: ‘ofCreateWindow’ was not declared in this scope

What version of OF are you using to compile it?


Ah, it’s compiled against master. Window settings, etc is a 0.9+ feature.

Ok, I switched to the master branch and it does compile and run now, thanks!

That said, it doesn’t do anything other than start. Any attempt to interact with it causes a crash, but it’s progress.

@brannondorsey have you compiled Kibio on a RPI2 yet?

Hi there @dj0le! Unfortunately I have yet to compile and run Kibio on the RPI2 so I can’t speak to specific issues, but I do know that the way that it is currently written will pose problems if you are running it without a windowing system (i.e. launched without startx). Have you attempted to run Kibio from the desktop view? Does appear to behave normally (video loops, etc…) until you perform some action? If so, what is that action exactly?

Hi Brannon,

From the command line, it will launch:

You can see the initial square points but no video inside. You can modify it with the scale / rotation / hand icons on the screen. However, if you try to load a project file, or save a project, or add another layer, it crashes and the error is no X display:

** (kibio:2244): WARNING **: Could not open X display
Unable to init server

(kibio:2244): Gtk-WARNING **: cannot open display:
terminate called after throwing an instance of ‘Poco::SystemException’
what(): System exception
[verbose] ofSignalHandler: Aborted

If you launch Kibio from the desktop view, it is actually identical (looks the same, and crashes at the same point). However the error code from the desktop is:

** (kibio:3135): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
kibio: …/…/src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost’ failed.
[verbose] ofSignalHandler: Aborted
[notice ] ofAppEGLWindow: destroyNativeKeyboard()
[verbose] ofThread: - name: Thread 1 - Signaled to stop.
[verbose] ofThread: - name: Thread 1 - waiting to stop

(kibio:3135): Gdk-WARNING **: kibio: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.

@brannondorsey – is this because the native linux file-chooser is not implemented for RPi?

Ok, I have a new question if anyone can help.

Using parts of LPMT and pkmProjector, I have a working set of code that does the Projection Mapping that I need. I set up a PNG mask and the video plays behind it and can be resized / warped to fit the correct surface.

However, everywhere that is black is still being projected and you can still see the outline of the entire projector’s output as a result. Is there some code I can add in openframeworks that will make the projector only play the movie inside the mask for a true projection mapping?

I looked through Kibio and LPMT, but I couldn’t see what code (if any) is accomplishing that and I’m not sure what I need to do.