コード例 #1
0
ファイル: livin.c プロジェクト: Gargaj/livin_in_a_box-w32
void FreeLivin(){
   int i;

   closeDepthVideo(head);
   closeDepthVideo(matat);

   closeOutline(knock);
   closeOutline(jump);
   closeOutline(run);
   closeOutline(hang);
   closeOutline(falling);
   closeOutline(tiger);
   closeOutline(hop);
   closeOutline(flip);
   closeOutline(run2);
   closeOutline(tbill);
   closeOutline(catwheel);
   closeOutline(katf);
   closeOutline(door);
   closeOutline(trap);
   closeOutline(fractalme);

   for(i = 0; i < LETTERNUM; i++){
      freeMesh3D(letters[i]);
   }

   freeMesh3D(cube);

   deleteBox();
   deleteBackground();
   deleteGreetings();
   freeBigCube(bigcube);

   deleteProgram(background_shader, 5, background_src);
   deleteProgram(title_shader, 5, title_src);
   deleteProgram(credits_shader, 5, credits_src);
   deleteProgram(letter_shader, 2, letter_src);
   deleteProgram(scroll_shader, 5, scroll_src);
   deleteProgram(cube_shader, 3, cube_src);
   deleteProgram(gr_shader, 2, gr_src);
   deleteProgram(bigcube_shader, 2, bigcube_src);

   freeExplosion();
   looseFace(face);
   looseFace(armface);
}
コード例 #2
0
//TODO: testing and writing
int mergeBlobs(frame_t *frame){
    // given the image and the bounding boxes, merge close by ones
    //      update bounding box structure in img.
    if (frame == NULL) {
        printf("mergeBlobs: frame does not exist\n");
        return 1;
    }
    int tolX = 10;// tolerance is 10 pixels
    int tolY = 10;// tolerance is 10 pixels
    box_t *temp = frame->boxes;
    box_t *temp2 = frame->boxes;
    while(temp != NULL) {
        // TODO: Algorithm in O(n^2) because each box looks at every other box
        //   to see if should merge - should update this to become more efficient
        while (temp2 != NULL) {
            temp2 = temp2->next;
            // if the current box is within some tolerance of another, merge boxes
            // TODO: fix the data in which to merge blobs together
            if (tolX <= abs(temp->centroid_x - temp2->centroid_x)){
                if (tolY <= abs(temp->centroid_y - temp2->centroid_y)){
                    LOG_ERR("mergeBlobs: merging blobs within tolerance\n");   
                    // Create bounding box with new data
                    temp->centroid_x = (temp->centroid_x + temp2->centroid_x)/2;
                    temp->centroid_y = (temp->centroid_y + temp2->centroid_y)/2;
                    
                        //TODO: update the height and width of the box
                    // Remove old bounding box
                    if(deleteBox(frame, temp2)!= 0) {
                        printf("mergeBlobs: Could not delete box from frame\n");
                        return 1;
                    }
                }
            }
        }
        temp = temp->next;
        temp2 = frame->boxes;
    }
    return 0;
}
コード例 #3
0
//
// mergeBoxes - merge overlapping boxes
//
// return 0 on success
//
int mergeBoxes(frame_t *frame)
{
    if (frame == NULL) {
        printf("ERROR: mergeBoxes called with frame == NULL\n");
        return 1;
    }
    
    box_t *temp1 = frame->boxes;
    box_t *temp2;
    box_t *temp3;
    int boxUpdated;
    boxUpdated = 1;

    while (boxUpdated) {    
        temp1 = frame->boxes;
        boxUpdated = 0;
        while (temp1 != NULL) {
            temp2 = temp1->next;
            while (temp2 != NULL) {
                if (boxesIntersect(temp1, temp2, 10)) {
                    // boxes intersect, merge them
                    int endy, endy1, endy2;
                    int endx, endx1, endx2;
                    endx1 = temp1->startx + temp1->width;
                    endx2 = temp2->startx + temp2->width;
                    endy1 = temp1->starty + temp1->height;
                    endy2 = temp2->starty + temp2->height;
                    
                    endx = MAX(endx1, endx2);
                    endy = MAX(endy1, endy2);
                    
                    int startx, starty;
                    startx = MIN(temp1->startx, temp2->startx);
                    starty = MIN(temp1->starty, temp2->starty);
                    
                    // expand the first box
                    temp1->startx = startx;
                    temp1->starty = starty;
                    temp1->width = endx - startx;
                    temp1->height = endy - starty;

                    // get the next pointer first before we delete it
                    temp3 = temp2->next;
                    
                    // delete the 2nd box
                    if (deleteBox(frame, temp2) != 0) {
                        printf("mergeBoxes: ERROR - could not delete box from frame\n");
                        return 1;
                    }
                    // update the temp2
                    temp2 = temp3;
                    // set the update flag so we rescan the boxes
                    boxUpdated = 1;
                } else {
                    temp2 = temp2->next;
                }
            }
            temp1 = temp1->next;
        }
    }
    return 0;
}