ofxFakam is an Open Frameworks addon that streams screen data to a fake camera driver. It relies on a QuickTime component that actually stream the screens to any program enabled to read from a camera source.
Works with OpenFrameworks, a cross platform open source toolkit for creative coding in C . http://www.openframeworks.cc/
Also woks with Cinder (sources pending) http://www.cinderlib.org/
The component is a stripped-down version of macam, and the component-src folder is basically a copy of the macam repository at the time I adapted it, and has not been updated until then.
Fakam works only on Mac OSX.
Fakam uses UNIX shared memory. Maybe you'll need to increase the available ammount on your system.
Check your current shared memory:
sysctl -A | grep shm
These params should be, AT LEAST:
kern.sysv.shmmax: 33554432 kern.sysv.shmmin: 1 kern.sysv.shmmni: 256 kern.sysv.shmseg: 64 kern.sysv.shmall: 8192
If not, edit /etc/sysctl.conf
sudo vi /etc/sysctl.conf
And add this:
kern.sysv.shmmax=33554432 kern.sysv.shmmin=1 kern.sysv.shmmni=256 kern.sysv.shmseg=64 kern.sysv.shmall=8192
Then REBOOT!
The Fakam QuickTime component is based on macam, an open-source generic webcam driver for mac osx. http://webcam-osx.sourceforge.net/
To install the component, copy the file coponent/fakam.component to /Library/QuickTime
If you're using macam, please delete the macam.component from the QuickTime folder for a while. Using both will cause conflicts. (See issues below)
To use ofxFakam, first you need to download and install OpenFrameworks. http://www.openframeworks.cc/
Then download ofxFakam sources from http://github.com/rsodre/ofxFakam/zipball/master or, alternatively, you can use git clone:
git clone git://github.com/rsodre/ofxFakam.git
The addon should sit in openFrameworks/addons/ofxFakam/
There's an example in ofxFakam/example/, just open and hit "Build and Run". You might want to chosoe "Release" instead of "Debug" for faster performance.
You can use oponent/FakamClient.app to test a Fakam stream. Just open it, press Play and then run your app.
Make sure your app is being rendered at resolution 640 x 480. Fakam is currently fixed at this resolution, any other will surely break it or render crap.
So on main.cpp, there sould be something like this:
ofSetupOpenGL(&window, 640, 480, OF_WINDOW);
Add the ofxFakam/src folder to your XCode project.
On your main app header, include the following in the header includes:
#include "ofxFakam.h"
In your base App class, add the following:
ofxFakam fakam;
Render your OpenGL screen normally and then do the magic:
fakam.copyScreen();
That's it!!
Fakam is a stripped-down version of macam, and is currently conflicting with it. If you're using macam, please delete the macam.component from the QuickTime components folder. There must be a way to eliminate this conflict, but I did not discover it yet.
You should see a lot of warnings on the Console, please ignore them.
Being "always on", I don't really know if Fakam is eternally consuming CPU or looping endlessly trying to connect to a stream. Maybe the warnings come from there.