split ofvideograbber in 2?

alo.

I’m doing a project with 3 firewire cameras and on each one i’m doing openCV processing (ofxCvHaarFinder). CPU load is high. I need to lower it. in PureData what i do is initialize the camera at 320x240 and separate the feed in 2: ones goes directly to render; the other one is resized to 160x120 for openCV processing. How do I achieve this in OF?

Is the FBOtexture method the way to go? if so, how do I manage to use the resized FBOtexture for openCV processing?

I’m really new to coding so any details would help me a lot. I do everything intuitively and so far so good, but this is eating my head.

thanks.

ofxOpenCv images has a resizeIntoMe method, you just need to create the image and call that method to make a resized copy, it should be something like this:

  
grayImageSmall.resizeIntoMe( grayImageOriginal );  

or, colorImage depending on what you are using

hi. thanks for the reply.

i don’t think if i’m doing this correctly.

  
  
  
   colorImg.allocate(camWidth,camHeight);  
	colorImgSmall.allocate(camWidth/2, camHeight/2);  
  
if (bNewFrame){  
  
		colorImg.setFromPixels(vidGrabber.getPixels(), camWidth,camHeight);  
		colorImgSmall.scaleIntoMe( colorImg );  
...  
  

I get no results this way and when trying to draw colorImgSmall i get a black screen.

what am I doing wrong?

Hey adrian

At first sight that seems ok to me, where does the value of bNewFrame comes from, I suppose from the grabFrame or idleVideo, but is the only thing I can see there that can make your images not being updated, does the big image show something?

this would be a very basic example of this method. The colorImg is fine, while colorImgSmall shows a black rectangle. should this be working?

  
  
  
#include "testApp.h"  
  
  
void videoSettings();  
void listDevices();  
  
  
//--------------------------------------------------------------  
void testApp::setup(){  
  
	camWidth 		= 320;	// try to grab at this size.  
	camHeight 		= 240;  
  
	vidGrabber.setVerbose(true);  
	vidGrabber.setDeviceID(0);  
	vidGrabber.initGrabber(camWidth,camHeight,1);  
  
  
//---------------------------------pra cam 0:  
	colorImg.allocate(camWidth,camHeight);  
	colorImgSmall.allocate(camWidth/2, camHeight/2);  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
//------------------------------para cam 0:  
bool bNewFrame = false;  
  
       vidGrabber.grabFrame();  
	   bNewFrame = vidGrabber.isFrameNew();  
  
if (bNewFrame){  
  
		colorImg.setFromPixels(vidGrabber.getPixels(), camWidth,camHeight);  
  
		colorImgSmall.scaleIntoMe( colorImg );  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
	    colorImg.draw(0,0,camWidth,camHeight);  
	    colorImgSmall.draw(camWidth,0,camWidth/2,camHeight/2);  
  
	}  
  
  
//--------------------------------------------------------------  
void testApp::keyPressed  (int key){  
  
	switch (key){  
  
		case 's':  
            ofGetFrameRate();  
  
			vidGrabber.videoSettings();  
		break;  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased(int key){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y ){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(){  
  
}  
  

Haven’t actually test it but it seems ok to me. It should work just like that unless i’m missing something.