本文整理汇总了C++中ofxCvColorImage::getROI方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxCvColorImage::getROI方法的具体用法?C++ ofxCvColorImage::getROI怎么用?C++ ofxCvColorImage::getROI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxCvColorImage
的用法示例。
在下文中一共展示了ofxCvColorImage::getROI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFromCvColorImage
//--------------------------------------------------------------------------------
void ofxCvGrayscaleImage::setFromCvColorImage( ofxCvColorImage& mom ) {
if( matchingROI(getROI(), mom.getROI()) ) {
cvCvtColor( mom.getCvImage(), cvImage, CV_RGB2GRAY );
flagImageChanged();
} else {
ofLog(OF_LOG_ERROR, "in =, ROI mismatch");
}
}
示例2: update
void ofxBackground::update(ofxCvColorImage& input){
float now = ofGetElapsedTimeMillis();
// get width/height disregarding ROI
IplImage* ipltemp = input.getCvImage();
_width = ipltemp->width;
_height = ipltemp->height;
if( inputCopy.getWidth() == 0 ) {
allocate( _width, _height );
} else if( inputCopy.getWidth() != _width || inputCopy.getHeight() != _height ) {
// reallocate to new size
clear();
allocate( _width, _height );
} else { //don't do anything unless we have allocated! (and therefore set timeStartedLearning to a safe, non zero value)
inputCopy = input;
inputCopy.setROI( input.getROI() );
yuvImage.setROI( input.getROI() ); //pass on ROI'ness
yuvImage.setFromPixels(inputCopy.getPixels(), _width, _height);
yuvImage.convertRgbToYuv();
if((now-timeStartedLearning) < LEARNING_TIME){
//then we should be learning
//LEARNING THE AVERAGE AND AVG DIFF BACKGROUND
accumulateBackground(inputCopy.getCvImage());
//LEARNING THE CODEBOOK BACKGROUND
pColor = (uchar *)((yuvImage.getCvImage())->imageData);
for(int c=0; c<imageLen; c++)
{
cvupdateCodeBook(pColor, cB[c], cbBounds, nChannels);
pColor += 3;
}
//TODO: clear stale entries
bStatsDone = false;
bLearning = true;
}else {
//its either time to do stats or not
bLearning = false;
if(!bStatsDone){
//do the stats, just the once
createModelsfromStats(); //create the background model
bStatsDone = true;
}else {
//learn as normal, find the foreground if any
//FIND FOREGROUND BY AVG METHOD:
backgroundDiff(inputCopy.getCvImage(),ImaskAVG);
cvCopy(ImaskAVG,ImaskAVGCC);
cvconnectedComponents(ImaskAVGCC);
//FIND FOREGROUND BY CODEBOOK METHOD
uchar maskPixelCodeBook;
pColor = (uchar *)((yuvImage.getCvImage())->imageData); //3 channel yuv image
uchar *pMask = (uchar *)((ImaskCodeBook)->imageData); //1 channel image
for(int c=0; c<imageLen; c++)
{
maskPixelCodeBook = cvbackgroundDiff(pColor, cB[c], nChannels, minMod, maxMod);
*pMask++ = maskPixelCodeBook;
pColor += 3;
}
//This part just to visualize bounding boxes and centers if desired
cvCopy(ImaskCodeBook,ImaskCodeBookCC);
cvconnectedComponents(ImaskCodeBookCC);
//TODO: update the learned background pixels....
//TODO: clear stale codebook entries on a much slower frequency
}
}
backgroundAverage = ImaskAVG;
backgroundAverageConnectedComponents = ImaskAVGCC;
backgroundCodebook = ImaskCodeBook;
backgroundCodeBookConnectedComponents = ImaskCodeBookCC;
}
}