ofVideoGrabber and ofFbo - Capturing and and drawing only part of the video

Hi, I’m using a webcam and would like to capture and draw only the left part of the image captured (WindowWidth/2, WindowHeight) whilst the programme is running fullscreen. However, with my code below, it does draw the left part of half of the screen but my image would be narrowed at the same time as well.

Is there a way or addon for me to obtain my desire result please?

In my ofApp.h, I have:

	ofVideoGrabber		simpleCam;
	ofFbo				cameraFbo;

In my ofApp.cpp, I have:

void ofApp::setup(){

	simpleCam.setup(ofGetWindowWidth(), ofGetWindowHeight(), true);
	cameraFbo.allocate(ofGetWindowWidth(), ofGetWindowHeight());
}

void ofApp::update(){

	simpleCam.update();
	if (simpleCam.isFrameNew()) {
		cameraFbo.begin();
        simpleCam.draw(cameraFbo.getWidth()/2, 0, -cameraFbo.getWidth()/2, cameraFbo.getHeight());  // draw flipped
		cameraFbo.end();
		
		opticalFlow.setInput(cameraFbo.getTexture());
	}
}

Cheers,
Karen

Hi Karen,
I think you could use the ofTexture of the ofVideoGrabber, and draw a subsection of that, like:
v.getTexture().drawSubsection()

1 Like