void Vision_Processor::process_and_send(const TimerEvent& event){
		if(_timer.isValid()){
			if(image_processing() == 0){
				send_msg();
				clear_msg();
			}else {
				ROS_INFO("[VISION PROCESSING]: Message without data sent.");
				_log_file << "Message without data sent due to error in image processing.";
				clear_msg();
				_ic.get_out_pub().publish(_msg);
			}
		}
	}
Example #2
0
int		main(int argc, char **argv)
{
    InitializeMagick("/");
    #ifndef DEBUG
    if (argc != 4) {
        printf("\n************************************************************************\n");
        printf("Please provide paramter and TWO file locations for image reconstruction!\n");
        printf("For example: ./TissueReconstruction restacking file_name file_output    \n");
        printf("************************************************************************\n");
        return 0;
    }
    else{
        char *f_imagePath = strdup(argv[2]);
        char *s_imagePath = strdup(argv[3]);
        char *f_ptr, *s_ptr;
        int  ch = '/';
        
        f_ptr = strrchr(f_imagePath, ch);
        s_ptr = strrchr(s_imagePath, ch);
        
        char *cht = "/";
        
        if (f_ptr != cht || s_ptr != cht ) {
            if(f_ptr != cht)
                asprintf(&f_imagePath, "%s/", f_imagePath);
            if(s_ptr != cht){
                struct stat st = {0};
                asprintf(&s_imagePath, "%s/Restacking/", s_imagePath);
                
                if (stat(s_imagePath, &st) == -1)
                    mkdir(s_imagePath, 0700);
            }
        }

        if (strcmp(argv[1], "processing") == 0)
            image_processing(f_imagePath, s_imagePath);
        else if (strcmp(argv[1], "restacking") == 0)
            restacking(f_imagePath, 0, 1000, s_imagePath);
        else if (strcmp(argv[1], "raw") == 0){
            asprintf(&s_imagePath, "%stissue.raw\n", s_imagePath);
            printf("Create a new RAW file in : %s\n", s_imagePath);
            dumpStackIntoRawFile(f_imagePath, s_imagePath);
        }
        
        free(f_imagePath);
        free(s_imagePath);
    }
    #endif
    
    #ifdef DEBUG

        /*
         ** image processing before restacking - max contrast, otsu-throsholding, cross correlation, image deconvolution
         */
        
        //image_processing(FILE_PATH, FILE_MAX_OUTPUT);
        //image_correction("/Users/adam/Documents/blockface_allbrains/3DOutput/y/", FILE_MAX_OUTPUT);
        //image_processing("/Users/adam/Desktop/image/JPG_CROP/", "/Users/adam/Desktop/image/JPG_CROP_GRAY");
        //check_raw(FILE_OUT_RAW);  
        
        /*
         ** restack images - Parameters:(source dir, start slide, end slide, output dir)
         */
    
        //restacking(FILE_PATH,0, 1000, FILE_MAX_OUTPUT);
        
        /*
        ** final - dump three planes to RAW file for Tissuestack used!
        */

        //dumpStackIntoRawFile("/Users/adam/Desktop/image/Reconstruction/", FILE_OUT_RAW);
    
     #endif
    DestroyMagick();
    return (0);
}