Exemplo n.º 1
0
        /*ipWidth = ipGrabber[i]->getWidth();
        ipHeight = ipGrabber[i]->getHeight();
        if ((ipWidth > 0) && (ipHeight >0) ) {
           if ((ipWidth != ipImg[i].getWidth()) || (ipHeight != ipImg[i].getHeight())) {
                if (ipImg[i].bAllocated) ipImg[i].resize(ipWidth, ipHeight);
                else ipImg[i].allocate(ipWidth, ipHeight);
           }
            if ((ipWidth != outW) || (ipHeight != outH)) {
                ofxCvColorImage tempIpImg;
                tempIpImg.allocate(ipWidth, ipHeight);
                tempIpImg.setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
                ipImg[i].scaleIntoMe(tempIpImg, OF_INTERPOLATE_NEAREST_NEIGHBOR);
            }
            else {
                ipImg[i].setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
            }
        }*/
    }
}
///*****************************************************************
///                            MONOCHANNEL MONOBLOB
///******************************************************************/
void testApp::monoCmonoB(){
    int numBlobs = lastBlobs.size();
    if (numBlobs > 0) {
        if (bZoomTarget) {
            left = lastBlobs[0].boundingRect.x * in_analysis_scale;
            top = lastBlobs[0].boundingRect.y  * in_analysis_scale;
            targW = lastBlobs[0].boundingRect.width * in_analysis_scale;
            targH = lastBlobs[0].boundingRect.height * in_analysis_scale;
            // adjust to mantain inAspect ratio
            int targW_inAspect = targH*inAspect;
            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;
            top = lastBlobs[0].centroid.y*in_analysis_scale-targH/2;
            left = lastBlobs[0].centroid.x*in_analysis_scale-targW/2;
        }
        // copyRegion needs variables as argumets
        int out_left = 0;

        copyRegion( fullFrame, left, top, targW, targH,
                    outputImg, out_left, out_H_gap, outW, out_H_in_aspect);
    }
}
Exemplo n.º 2
0
        /*ipWidth = ipGrabber[i]->getWidth();
        ipHeight = ipGrabber[i]->getHeight();
        if ((ipWidth > 0) && (ipHeight >0) ) {
           if ((ipWidth != ipImg[i].getWidth()) || (ipHeight != ipImg[i].getHeight())) {
                if (ipImg[i].bAllocated) ipImg[i].resize(ipWidth, ipHeight);
                else ipImg[i].allocate(ipWidth, ipHeight);
           }
            if ((ipWidth != outW) || (ipHeight != outH)) {
                ofxCvColorImage tempIpImg;
                tempIpImg.allocate(ipWidth, ipHeight);
                tempIpImg.setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
                ipImg[i].scaleIntoMe(tempIpImg, OF_INTERPOLATE_NEAREST_NEIGHBOR);
            }
            else {
                ipImg[i].setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
            }
        }*/
    }
}
///*****************************************************************
///                            MONOCHANNEL MONOBLOB
///******************************************************************/
void testApp::monoCmonoB(){
    int numBlobs = lastBlobs.size();
    if (numBlobs > 0) {
        if (bZoomTarget) {
            left = lastBlobs[0].boundingRect.x * in_analysis_scale;
            top = lastBlobs[0].boundingRect.y  * in_analysis_scale;
            targW = lastBlobs[0].boundingRect.width * in_analysis_scale;
            targH = lastBlobs[0].boundingRect.height * in_analysis_scale;
            // adjust to mantain inAspect ratio
            int targW_inAspect = targH*inAspect;
            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;
            top = lastBlobs[0].centroid.y*in_analysis_scale-targH/2;
            left = lastBlobs[0].centroid.x*in_analysis_scale-targW/2;
        }
        // copyRegion needs variables as argumets
        int out_left = 0;

        copyRegion( fullFrame, left, top, targW, targH,
                    outputImg, out_left, out_H_gap, outW, out_H_in_aspect);
    }
}
///*****************************************************************
///                            MONOCHANNEL MULTIBLOB
///******************************************************************/
void testApp::monoCmultiB(){
    int numBlobs = lastBlobs.size();
    if (numBlobs == 1) monoCmonoB();
    else if (numBlobs > 1) {
        int max_x = 0;
        int max_y = 0;
        for (unsigned int i = 0; i < lastBlobs.size(); i++) {

            left = MIN( left, lastBlobs[i].boundingRect.x) ;
            top  = MIN( top,  lastBlobs[i].boundingRect.y) ;
            max_x = MAX( max_x, lastBlobs[i].boundingRect.x+
                                lastBlobs[i].boundingRect.width );
            max_y = MAX( max_y, lastBlobs[i].boundingRect.y+
                                lastBlobs[i].boundingRect.height );
        }
        left *= in_analysis_scale;
        top *= in_analysis_scale;
        max_x *= in_analysis_scale;
        max_y *= in_analysis_scale;
        if (bZoomTarget) {
            targW = (max_x-left);
            targH = (max_y-top);
            // adjust to mantain inAspect ratio
            int targW_inAspect = targH*inAspect;
            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);
        }
     }
}
Exemplo n.º 3
0
void initializeHeap(Heap *h, uintptr_t *sp, uintptr_t *exnPtr, size_t exnCnt, serverstate ss)
{
  int i;
  Ro *r0, *r2, *r3, *r4, *r5, *r6; 

  if ( h->status != HSTAT_UNINITIALIZED )
    (*ss->report) (DIE, "initializeHeap: status <> HSTAT_UNINITIALIZED",ss->aux);

  r0 = clearStatusBits(*(Ro**)(h->ds));    // r0 is a pointer to a region description on the stack
  r2 = r0+1;                               // r2 is a pointer to the next region description on the stack
  r3 = r0+2;
  r4 = r0+3;
  r5 = r0+4;
  r6 = r0+5;
  
  h->sp = sp;
  h->exnPtr = exnPtr;
  h->exnCnt = exnCnt;

  //  printf("r0 = %x, r2 = %x, r3=%x, h=%x, ds=%x\n", r0,r2,r3,h,h->ds);

  h->r0copy = copyRegion(r0);
  h->r2copy = copyRegion(r2);
  h->r3copy = copyRegion(r3);
  h->r4copy = copyRegion(r4);
  h->r5copy = copyRegion(r5);
  h->r6copy = copyRegion(r6);

  for ( i = 0 ; i < LOWSTACK_COPY_SZ ; i++ )
    {
      h->lowStack[i] = *(sp - i - 1);
    }

  h->status = HSTAT_CLEAN;
}
Exemplo n.º 4
0
        /*ipWidth = ipGrabber[i]->getWidth();
        ipHeight = ipGrabber[i]->getHeight();
        if ((ipWidth > 0) && (ipHeight >0) ) {
           if ((ipWidth != ipImg[i].getWidth()) || (ipHeight != ipImg[i].getHeight())) {
                if (ipImg[i].bAllocated) ipImg[i].resize(ipWidth, ipHeight);
                else ipImg[i].allocate(ipWidth, ipHeight);
           }
            if ((ipWidth != outW) || (ipHeight != outH)) {
                ofxCvColorImage tempIpImg;
                tempIpImg.allocate(ipWidth, ipHeight);
                tempIpImg.setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
                ipImg[i].scaleIntoMe(tempIpImg, OF_INTERPOLATE_NEAREST_NEIGHBOR);
            }
            else {
                ipImg[i].setFromPixels(ipGrabber[i]->getPixels(), ipWidth, ipHeight);
            }
        }*/
    }
}
///*****************************************************************
///                            MONOCHANNEL MONOBLOB
///******************************************************************/
void testApp::monoCmonoB(){
    int numBlobs = lastBlobs.size();
    if (numBlobs > 0) {
        if (bZoomTarget) {
            left = lastBlobs[0].boundingRect.x * in_analysis_scale;
            top = lastBlobs[0].boundingRect.y  * in_analysis_scale;
            targW = lastBlobs[0].boundingRect.width * in_analysis_scale;
            targH = lastBlobs[0].boundingRect.height * in_analysis_scale;
            // adjust to mantain inAspect ratio
            int targW_inAspect = targH*inAspect;
            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;
            top = lastBlobs[0].centroid.y*in_analysis_scale-targH/2;
            left = lastBlobs[0].centroid.x*in_analysis_scale-targW/2;
        }
        // copyRegion needs variables as argumets
        int out_left = 0;

        copyRegion( fullFrame, left, top, targW, targH,
                    outputImg, out_left, out_H_gap, outW, out_H_in_aspect);
    }
}
///*****************************************************************
///                            MONOCHANNEL MULTIBLOB
///******************************************************************/
void testApp::monoCmultiB(){
    int numBlobs = lastBlobs.size();
    if (numBlobs == 1) monoCmonoB();
    else if (numBlobs > 1) {
        int max_x = 0;
        int max_y = 0;
        for (unsigned int i = 0; i < lastBlobs.size(); i++) {

            left = MIN( left, lastBlobs[i].boundingRect.x) ;
            top  = MIN( top,  lastBlobs[i].boundingRect.y) ;
            max_x = MAX( max_x, lastBlobs[i].boundingRect.x+
                                lastBlobs[i].boundingRect.width );
            max_y = MAX( max_y, lastBlobs[i].boundingRect.y+
                                lastBlobs[i].boundingRect.height );
        }
        left *= in_analysis_scale;
        top *= in_analysis_scale;
        max_x *= in_analysis_scale;
        max_y *= in_analysis_scale;
        if (bZoomTarget) {
            targW = (max_x-left);
            targH = (max_y-top);
            // adjust to mantain inAspect ratio
            int targW_inAspect = targH*inAspect;
            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);
    }
}