当前位置: 首页>>代码示例>>C++>>正文


C++ ofxCvColorImage::resetROI方法代码示例

本文整理汇总了C++中ofxCvColorImage::resetROI方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxCvColorImage::resetROI方法的具体用法?C++ ofxCvColorImage::resetROI怎么用?C++ ofxCvColorImage::resetROI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofxCvColorImage的用法示例。


在下文中一共展示了ofxCvColorImage::resetROI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: monoCmonoB


//.........这里部分代码省略.........
            if (targW < targW_inAspect) {
                left -= (targW_inAspect-targW)/2;
                targW = targW_inAspect;
            }
            else {
                int targH_inAspect = targW/inAspect;
                top -= (targH_inAspect-targH)/2;
                targH = targH_inAspect;
            }
        }
        else {
            targW = cropW;
            targH = cropH;
            // centroid of all blobs
            top = (float)(top+max_y)/2;
            top -= ((float)targH/2);
            left = (float)(left+max_x)/2;
            left -= ((float)targW/2);
        }
        int out_left = 0;
//        int out_H = outH;
        copyRegion( fullFrame, left, top, targW, targH,
                    outputImg, out_left, out_H_gap, outW, out_H_in_aspect);
    }
}

///*****************************************************************
///                            MULTICHANNEL
///******************************************************************/
void testApp::multiC(){
    int numBlobs = lastBlobs.size();
     if (numBlobs > 0) {
    // calculate number of rows & columns needeed
        float sqroot = sqrtf(numBlobs);

        float trun = truncf(sqroot);
        float rnd = roundf(sqroot);

        if (trun == rnd) rnd +=0.5;
        else trun += 0.5;

        int rows = (int)roundf(trun);
        if (rows <= 0) rows = 1;
        int cols = (int)roundf(rnd);
        if (cols <= 0) cols = 1;

    // calculate channel width and height
        int channelW = (float)outW/(float)cols;
        int channelH = channelW/outAspect;
        int comonGap = (outH-channelH*rows)/2;
        int channelGap = out_H_gap*((float)channelH/(float)outH); // letterbox black zones height
        // draw channels to output buffer image
        for (int i =0; i < numBlobs;i++) {
           int dx = (i%cols)*channelW;
           int dy = comonGap+(i/cols)*(channelH+channelGap);
            targW = cropW;
            targH = cropH;
            top = 0;
            left = 0;

            if (bZoomTarget) {
                 top = lastBlobs[i].boundingRect.y;
                 left = lastBlobs[i].boundingRect.x;
                 targW = lastBlobs[i].boundingRect.width;
                 targH = lastBlobs[i].boundingRect.height;
                 targW = MAX(targW, targH/inAspect);
                 targH = MAX(targH, targW*inAspect);

            }
            else {
                top = lastBlobs[i].centroid.y;
                left = lastBlobs[i].centroid.x;
            }
        // whithout the (float) casting a segmentation fault occurs
        top = in_out_scale*(float)top;
        top -= ((float)targH/2);
        left = in_out_scale*(float)left;
        left -= ((float)targW/2);

         copyRegion( fullFrame, left, top, targW, targH,
                     outputImg, dx, dy, channelW, channelH);
        }
     }
}
///*****************************************************************
///                            COPY REGION
///******************************************************************/
void testApp::copyRegion(ofxCvColorImage &src, int &sx, int &sy, int &sw, int &sh,
                         ofxCvColorImage &dst, int &dx, int &dy, int &dw, int &dh){
    if (sy < 0) sy = 0;
    else if (sy > src.height-sh) sy = src.height-sh;
    if (sx < 0) sx = 0;
    else if (sx > src.width-sw) sx = src.width-sw;

    src.setROI(sx, sy, sw, sh );
    dst.setROI(dx,dy,dw, dh);
    dst.scaleIntoMe(src, CV_INTER_NN);
    dst.resetROI();
    src.resetROI();
}
开发者ID:dasaki,项目名称:cvcinema,代码行数:101,代码来源:testApp.cpp


注:本文中的ofxCvColorImage::resetROI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。