Exemplo n.º 1
0
extern "C" int plugPrefs(gpointer data)
{
	plugData*	plugdata=(plugData*)data;
	GtkWidget*	dialog;
	GtkWidget*	dialogbox;
	GtkWidget*	showinvis;
	GtkWidget*	vbox;
	int			response;

	vbox=createNewBox(NEWVBOX,false,0);
	setTextDomain(true,plugdata);

	dialog=gtk_dialog_new_with_buttons(gettext("File Browser Plug In Prefs"),NULL,GTK_DIALOG_MODAL,GTK_STOCK_APPLY,GTK_RESPONSE_APPLY,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,NULL);
	dialogbox=gtk_dialog_get_content_area((GtkDialog*)dialog);
	gtk_container_add(GTK_CONTAINER(dialogbox),vbox);

	showinvis=gtk_check_button_new_with_label(gettext("Show Invisible File/Folders"));
	gtk_toggle_button_set_active((GtkToggleButton*)showinvis,showInvisible);
	gtk_box_pack_start((GtkBox*)vbox,showinvis,true,true,4);

	gtk_dialog_set_default_response((GtkDialog*)dialog,GTK_RESPONSE_APPLY);
	gtk_widget_show_all(dialog);
	response=gtk_dialog_run(GTK_DIALOG(dialog));
	if(response==GTK_RESPONSE_APPLY)
		{
			showInvisible=gtk_toggle_button_get_active((GtkToggleButton*)showinvis);
			showHideInvisibles(plugdata);
		}
	gtk_widget_destroy((GtkWidget*)dialog);
	setTextDomain(false,plugdata);
	return(0);
}
Exemplo n.º 2
0
int blobDetectionOmp(frame_t *frame){
    //detect blobs in the current frame and fill out the box struct
    //      --- look into segmentation of images (blur the image first then segment)
    // don't add a blob smaller than a certain size.
    unsigned long largestLabel;
    
    printf("at blobDetection, about to segment Image\n");
    if (segmentImage(frame, frame, &largestLabel) != 0) {
        printf("blobDetection: segmentImage failed\n");
        return 1;
    }
    printf("at blobDetection, segmentImage finished\n");

    box_t *box = frame->boxes;

    if (box != NULL) {
        printf("blobDetection: frame already has bounding boxes filled in!!\n");
        printf("                free boxes before calling this function\n");
        return 1;
    }

    int i, j;
    int left, right, up, down; 
    int x=0,y=0,count=0;
    int tag=1;
    int w, h, cx, cy;
    int centerx,centery;
    int done = 0;
    //detect blobs based on size - mean of pixels connected together
    // Check the segmented pixels and create a bounding box for each segment
    while(done == 0) {
        // Add blobs based on the segment - we're done when we've looked 
        //  through the whole list of segmentations
        // Based on segmentation, decide what the centroid, width, height        
        //      We're going to go through the image by each tag to find the 
        //          corresponding left, right, up, and down of the box.
        //      THIS IS COMPUTATIONALLY EXPENSIVE
        // TODO: change this operation to look around the area instead of
        //          the entire image.

        left = frame->image->width;
        right = 0;
        up = frame->image->height;
        down = 0;
        tag++;       
        count = 0;
        x = 0;
        y = 0;

        if (frame->image->data == NULL) {
            printf("ERROR: data is null\n");
        }

        #pragma omp parallel for
        for (i = 0; i < frame->image->height; i++){
            for (j = 0; j < frame->image->width; j++){
                
                pixel_t p;
                p = frame->image->data[i*frame->image->width+j];

                if (p.label == tag) {
                    // The pixel has label we're looking for, so we include it
                    //  Find the left, right, up, and down most values for the label

                    if (j < left) {
                        #pragma omp critical
                        left = j;
                    }
                    if (j > right) {
                        #pragma omp critical
                        right = j;
                    }
                    if (i < up) {
                        #pragma omp critical
                        up = i;
                    }
                    if (i > down) {
                        #pragma omp critical
                        down = i;
                    }
                    #pragma omp atomic
                    x+=j;
                    #pragma omp atomic
                    y+=i;
                    #pragma omp atomic
                    count++;
                }
                if (tag > largestLabel) {
                    // If we looked through the largest tag value, then we're done
                    done = 1;
                }
            }
        }
        
        #pragma omp barrier

        if (count == 0) {
            continue;
        }        
        printf("loop done, tag = %d, count = %d\n",tag, count);

        // update the corresponding values for the blob
        cx = x/count;
        cy = y/count;
        centerx = (right-left)/2 + left;
        centery = (up - down)/2 + down;
        w = abs(right - left);
        h = abs(up - down);

/*
        // Remove all blobs which do not fit within the constraints. 
        // Update the centroid and get min and max width and height of blob
        if (minBlob(w,h,centerx,centery) != 0) {
            LOG_ERR("Blob too small, Removing blob at (cx, cy) -> (%d, %d)\n", centerx, centery);
        } else if (maxBlob(w,h,centerx,centery) != 0) {
            LOG_ERR("Blob too large, Splitting blob at (cx,cy) -> (%d, %d)\n", centerx, centery);
            // TODO: Check if we can split the blob into multiple boxes or not
            //  for now, we'll just add the box to the list
            createNewBox(frame, cx, cy, centerx, centery, h, w);         
        } else {
            createNewBox(frame, cx, cy, centerx, centery, h, w);
        }
*/        
        if (count > 30) {
            printf("adding new box at (%d,%d) centroid = (%d,%d) (w,h) = (%d,%d)\n",
                left,up, centerx,centery, w, h);
            createNewBox(frame, cx, cy, left, up, w, h);
        }
    }

    return 0;
}
int blobDetection(frame_t *frame){
    //detect blobs in the current frame and fill out the box struct
    //      --- look into segmentation of images (blur the image first then segment)
    // don't add a blob smaller than a certain size.
    int largestLabel;
    if (segmentImage(frame, frame, &largestLabel) != 0) {
        printf("blobDetection: segmentImage failed\n");
        return 1;
    }

    box_t *box = frame->boxes;

    if (box != NULL) {
        printf("blobDetection: frame already has bounding boxes filled in!!\n");
        printf("                free boxes before calling this function\n");
        return 1;
    }

    int i, j;
    int left, right, up, down; 
    int tag=1;
    pixel_t p;
    int w, h, cx, cy;
    int done = 0;
    //detect blobs based on size - mean of pixels connected together
    // Check the segmented pixels and create a bounding box for each segment
    while(done == 0) {
        // Add blobs based on the segment - we're done when we've looked 
        //  through the whole list of segmentations
        // Based on segmentation, decide what the centroid, width, height        
        //      We're going to go through the image by each tag to find the 
        //          corresponding left, right, up, and down of the box.
        //      THIS IS COMPUTATIONALLY EXPENSIVE
        // TODO: change this operation to look around the area instead of
        //          the entire image.

        left = frame->image->width;
        right = 0;
        up = frame->image->height;
        down = 0;
        tag++;       
 
        for (i = 0; i < frame->image->height; i++){
            for (j = 0; j < frame->image->width; j++){
                p = frame->image->data[i*frame->image->width+j];
                if (p.L == tag) {
                    // The pixel has label we're looking for, so we include it
                    //  Find the left, right, up, and down most values for the label
                    if (j < left) {
                        left = j;
                    }
                    if (j > right) {
                        right = j;
                    }
                    if (i < up) {
                        up = i;
                    }
                    if (i > down) {
                        down = i;
                    }
                }
                if (tag > largestLabel) {
                    // If we looked through the largest tag value, then we're done
                    done = 1;
                }
            }
        }

        // update the corresponding values for the blob
        cx = (right-left)/2 + left;
        cy = (up - down)/2 - up;
        w = abs(right - left);
        h = abs(up - down);

        // Remove all blobs which do not fit within the constraints. 
        // Update the centroid and get min and max width and height of blob
        if (minBlob(w,h,cx,cy) != 0) {
            LOG_ERR("Blob too small, Removing blob at (cx, cy) -> (%d, %d)\n", cx, cy);
        } else if (maxBlob(w,h,cx,cy) != 0) {
            LOG_ERR("Blob too large, Splitting blob at (cx,cy) -> (%d, %d)\n", cx, cy);
            // TODO: Check if we can split the blob into multiple boxes or not
            //  for now, we'll just add the box to the list
            createNewBox(frame, cx, cy, h, w);         
        } else {
            createNewBox(frame, cx, cy, h, w);
        }
    }

    return 0;
}