OF_ERROR: in setFromPixels, size mismatch

Hey everybody,

I’m trying to get some information out of a videostream for a project. I basically used the Color Tracking example from the wiki as a base
http://wiki.openframeworks.cc/index.php-…-r-Tracking
This worked perfectly. Ran without a problem.

However, my version does not. It compiles without errors but when I run it, I get a big “OF_ERROR: in setFromPixels, size mismatch” after the setup-part.

Anybody able to help me? Thanks already

  
#include "testApp.h"  
//--------------------------------------------------------------  
void testApp::setup(){  
  
one.pos = ofxVec2f(0,0);  
  
    camWidth 		= 320;	  
    camHeight 		= 240;  
  
    tresholdOne = 64;  
    selectionWidth = 10;  
    channelCount = 128;  
  
    channelArray [channelCount];  
  
    channelHeight = camHeight / channelCount;  
  
    colorImg.allocate(camWidth,camHeight);       
  
    colorImgHSV.allocate(camWidth,camHeight);    
  
    hueImg.allocate(camWidth,camHeight);         
    satImg.allocate(camWidth,camHeight);         
    briImg.allocate(camWidth,camHeight);         
  
    vidGrabber.setVerbose(true);                 
    vidGrabber.initGrabber(camWidth,camHeight);  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
    for (int h = 0; h < channelCount; h++) {  
            channelArray[h] = 0;  
    }  
  
    vidGrabber.grabFrame();                                                   
  
    colorImg.setFromPixels(vidGrabber.getPixels(), camWidth, camHeight);      
  
    colorImgHSV = colorImg;                                                   
    colorImgHSV.convertRgbToHsv();                                            
  
    colorImgHSV.convertToGrayscalePlanarImages(hueImg, satImg, briImg);       
  
    hueImg.flagImageChanged();  
    satImg.flagImageChanged();  
    briImg.flagImageChanged();  
  
    unsigned char * briPixels = briImg.getPixels();  
    int nPixels = camWidth * camHeight;                                       
                                                                              
    for (int i = 0; i < camHeight; i++) {  
        for (int j = 0; j < camWidth; j++) {  
            if ( ABS(camWidth/2 - j) < selectionWidth ) {  
                if ( briPixels[j+i*camWidth] < tresholdOne ) {  
                    int currentChannel = i / channelHeight;  
                    channelArray[currentChannel] += 255 - briPixels[j+i*camWidth];  
                }  
            }  
        }  
    }  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
	 ofBackground(100,100,100);        
  
    ofSetColor(0xffffff);                  
    vidGrabber.draw(0,0);                  
	colorImgHSV.draw(340, 0);  
  
    for (int k = 0; k < channelCount; k++) {  
        string fpsStr = "Channel "+ofToString(k)+": "+ofToString(channelArray[k]);  
        ofDrawBitmapString(fpsStr, 800,20*k);  
    }  
  
  
}  

Nobody with even a vague idea on how to solve this?

The error comes from the line

  
colorImg.setFromPixels(vidGrabber.getPixels(), camWidth, camHeight);     
  

But that’s exactly the same as in the sample right?

Could really use some help, thanks.