Toggling an addon function on and off (Raspberry Pi BEGINNER)

I’m new to OpenFrameworks so apologies in advance for the simple question, or simple thinking.
I am trying to play a list of videos but then on keyboard press toggle the Raspberry Pi camera on and off to show some live streamed footage.
I’m using these addons:
ofxOMXPlayer
ofxRPiCameraVideoGrabber
I was pointed to them from this thread: Interactive video using Raspberry Pi GPIO pins [BEGINNER]

I have created an addons.make folder which calls both of these addons and have copied the ‘example-playlist’ code from ofxOMXPlayer but I can’t get my head around how to call the ofxRPiCameraVideoGrabber addon to toggle the camera on and off as in all of its examples the camera defaults to display as soon as you run the app.

Any help would be GREATLY appreciated!

Thanks in advance!

Hey @YagmanX

One quick thing is that until the other day the addons may have issues working with each other. However if you already have created an app where they are compiling together you may be ok.

I have never actually used both addons in one app myself but here is how I think it could work.

You will want both the camera and video player to be in texture mode. Once you start the camera just leave it running. You can then set a variable that toggles back and forth between the camera and video in your app

some pseudocode

void setup
{
 cameraSettings.enableTexture = true;
 camera.setup(cameraSettings);
 
 videoplayerSettings.enableTexture = true;
 videoplayer.setup(videoplayerSettings);

 doShowCamera = false;
}

void draw()
{
 if(doShowCamera)
 {
 camera.draw();
 }
 else
 {
  videoplayer.draw()
 }
}

void onKey()
{
doShowCamera=!doShowCamera;
}

Thank you so much for this, very useful! However I had noticed that the apps with multiple addons weren’t compiling… I thought it was just me trying out the wrong code!

Do you have any idea if this will be fixed any time soon?

should work on master branches as of yesterday

1 Like