Ejemplo n.º 1
0
void test_backremoval(){
	float max_value;
	float min_value;
	IplImage * rimage = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	IplImage * min_image = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	int values [] = {0,0,0,0,0,0,0,0,0};
	IplConvKernel * kernel = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_RECT,values);
	cvDilate(image,rimage,kernel);
	display_image("dilate",rimage);
	cvErode(rimage,rimage,kernel);
	display_image("erode",rimage);
	
	//cvDilate(max_image,max_image,kernel);
	//cvDilate(max_image,max_image,kernel);
	display_image("original",image);
	display_image("rimage",rimage);

	//rimage = test_background_subtraction(image,max_image);
	//display_image("back removed",rimage);

	//IplImage * otsu_image = otsu_algorithm(rimage);
	//otsu_image = invert_image(otsu_image);
	//display_image("otsu image",otsu_image);

}
static void display_image_charging(uint16_t soc, enum charge_level_t level)
{
	if (level == CHARGE_DISABLE) {
		display_image(IMAGE_CHARGE_NEEDED, soc);
	} else {
		display_image(IMAGE_CHARGING, soc);
	}
}
Ejemplo n.º 3
0
int main(void)
{
  SDL_Surface *img = load_image("visage");
  display_image(img);
  unsigned long **array = img_to_tab(img);
  parcours(array, img->w, img->h);
  img = tab_to_img(array, img->w, img->h);
  display_image(img);
  return 0;
}
Ejemplo n.º 4
0
void test_time_opencv_erode(){

	//image = cvLoadImage("C:\\Users\\ninao\\Documents\\images\\dibco_test_images\\H04.bmp",0);
	display_image("image",image);
	IplImage * rimage = cvCloneImage(image);
	int values [] = {0,0,0,0,0,0,0,0,0};
	IplConvKernel * kernel = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_RECT,values);
	tester->start_timer();
	cvErode(image,rimage,kernel);
	tester->stop_timer();
	display_image("erode",rimage);
}
int board_charging(void)
{
	enum charge_level_t charger;
	uint16_t batt_soc = 0;
	int ret;

	charger = charger_detect();

	ret = init_batt();
	
	if (ret && charger == CHARGE_DISABLE) {
		printf("failed to init battery: %d\n", ret);
		return ret;
	}

	ret = max17042_soc(&batt_soc);

	if (ret && charger == CHARGE_DISABLE) {
		printf("failed to read initial SOC: %d\n", ret);
		return ret;
	}

	if (batt_soc < SOC_THRESH_MIN) {
		display_image(IMAGE_CHARGE_NEEDED, batt_soc);
		if (ret) {
			printf("No battery detected, emergency charging!\n");
		}

		charge_loop(&batt_soc, ret ? 1 : 0);

		if (batt_soc < SOC_THRESH_MIN) {
			// Uh-oh, we exited the charge loop
			// before we passed the minimum
			// In this case we should power down
			if (batt_soc >= SOC_THRESH_DISPLAY_MIN) {
				display_image(IMAGE_CHARGE_NEEDED, batt_soc);
				udelay(1000 * 1000 * 2);
			}

			twl6030_power_off();
		}
	}

	/* Reconfigure MPU DPLL clock as it might have been set */
	/* to conservative values in x-loader, only do this in the
	 case where we are actually going to boot */
	set_mpu_dpll_max_opp();

	display_image(IMAGE_BOOT, batt_soc);
	printf("SOC %hu%%, booting.\n", batt_soc);
	return ret;
}
Ejemplo n.º 6
0
void test_normalization_min_max(){
	float max_value;
	float min_value;
	IplImage * max_image = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	IplImage * min_image = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	IplConvKernel * kernel = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_RECT);
	cvErode(image,min_image,kernel);
	cvDilate(image,max_image,kernel);
	display_image("dilate",min_image);
	display_image("erode",max_image);

	int kernel_radius = 1;
	test_get_normalization_parameters(image,min_image,max_image,kernel_radius,max_value,min_value);
	printf("max: %f, min: %f",max_value,min_value);
}
Ejemplo n.º 7
0
void test_su_algorithm_parts(){
	IplImage* edges_image = min_max_edge_detection(image);
	display_image("edges image",edges_image);
	IplImage * contrast_image = otsu_algorithm(edges_image);
	contrast_image = invert_image(contrast_image);
	display_image("otsu image",contrast_image);
	IplImage* peak_pixels_image = get_peak_pixels(contrast_image);
	display_image("peak_pixels_image",peak_pixels_image);
	int text_width = text_width_approximation(peak_pixels_image);
	printf("text width: %d",text_width);
	display_image("image before local thresholding",image);
	IplImage* rimage = perform_local_thresholding(image,contrast_image,text_width);
	display_image("resutl",rimage);

}
Ejemplo n.º 8
0
void test_performance_parts(){
	tester->start_timer();
	printf("edge detection\n");
	IplImage* edges_image = min_max_edge_detection(image);
	tester->stop_timer();
	tester->start_timer();
	printf("otsu\n");
	IplImage * contrast_image = otsu_algorithm(edges_image);
	tester->stop_timer();
	tester->start_timer();
	printf("invert image\n");
	contrast_image = invert_image(contrast_image);
	tester->stop_timer();
	tester->start_timer();
	printf("get peak pixels\n");
	IplImage* peak_pixels_image = get_peak_pixels(contrast_image);
	tester->stop_timer();
	tester->start_timer();
	printf("text width\n");
	int text_width = 3;//text_width_approximation(peak_pixels_image);
	printf("text width: %d \n",text_width);
	tester->stop_timer();
	tester->start_timer();
	printf("local thresholding\n");
	IplImage* rimage = perform_local_thresholding(image,contrast_image,text_width);
	tester->stop_timer();
	tester->get_total_testing_time();
	display_image("rimage",rimage);

}
Ejemplo n.º 9
0
int	event_mouse(int button, int x, int y, t_global *global)
{
  t_object	*tmp;
  double	vector[NB_DIMENSION];
  t_detail	detail;

  if (init_detail(&detail) || global == NULL || global->scene == NULL)
    return (EXIT_FAILURE);
  tmp = global->scene->object;
  if (button == CLICK_LEFT && !calc_direction_vector(global, vector, x, y))
    {
      while (tmp)
	{
	  if (inter_ray_box(global->scene->camera, vector, tmp))
	    tmp->inter(global->scene->camera, tmp, &detail, vector);
	  tmp = tmp->next;
	}
      global->object = detail.object;
    }
  if ((button == SCROLL_UP || button == SCROLL_DOWN))
    {
      if (global->scene->camera)
	global->scene->camera->fov += ((button == SCROLL_UP ? 1 : -1) * 10);
      display_image(global);
    }
  return (EXIT_SUCCESS);
}
Ejemplo n.º 10
0
int receive_mouse(char* ip, int port){
    //TODO: Change buffer size such that it's dynamic depending on the 
    //other person's screen size.
    #define BUFFER_SIZE 256
    #define NO_SPECIAL_PROTOCOL 0
    #define NO_FLAGS 0
    struct sockaddr_in server_address;
    char* server_name;
    char buffer[BUFFER_SIZE];
    socklen_t address_size;
    int socket_file_descriptor;
    //AF_INET is to specify that one wants
    //IPv4 as the domain.
    socket_file_descriptor = socket(AF_INET, SOCK_STREAM, NO_SPECIAL_PROTOCOL);
    memset(&server_address, 0, sizeof(server_address));
    server_address.sin_family = AF_INET;
    server_address.sin_port = htonl(port);
    server_name = (char*) gethostbyname("localhost");
    inet_pton(AF_INET, server_name, &server_address.sin_addr);
    address_size = sizeof(server_address);
    if(connect(socket_file_descriptor, (struct sockaddr *)&server_address, address_size) == -1){
        exit(21); 
    }
    while(recv(socket_file_descriptor, buffer, sizeof(buffer), NO_FLAGS) != -1){
        display_image(buffer,500,500);
    }
    return 1;
}
Ejemplo n.º 11
0
void test_min_max_edge_detection(){
	tester->start_timer();
	float max_value;
	float min_value;
	IplImage * max_image = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	IplImage * min_image = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	int values [] = {0,0,0,0,0,0,0,0,0};
	IplConvKernel * kernel = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_RECT,values);
	cvErode(image,min_image,kernel);
	cvDilate(image,max_image,kernel);
	//display_image("erode",min_image);
	//display_image("dilate",max_image);

	int kernel_radius = 1;
	//test_get_normalization_parameters(image,min_image,max_image,kernel_radius,max_value,min_value);

	IplImage * rimage = cvCloneImage(image);
	for(int y=0;y<image->height;y++){

		for(int x=0;x<image->width;x++){
			//int value = get_pixel(image,y,x);
			//printf("%d \n",value);
			float enhanced_value = test_min_max_enhancement(y,x,kernel_radius,image,min_image,max_image); 
			//int new_value = 255 * enhanced_value/max_value;
			int new_value = enhanced_value;
			set_pixel(rimage,y,x,new_value);
		}
	}

	tester->stop_timer();
	display_image("result",rimage);
	cvSaveImage("images/edges.png",rimage);

}
Ejemplo n.º 12
0
/**
 * Display invalid PIN message
 */
static void display_invalid_pin()
{
    uint32_t x = CENTER_IMAGE_ON_X_AXIS(MDTP_MAIN_TEXT_WIDTH,fb_config->width);
	uint32_t y = (fb_config->height)*MAIN_TEXT_RELATIVE_Y_LOCATION;

	display_image(MDTP_INVALID_PIN_OFFSET, MDTP_MAIN_TEXT_WIDTH, MDTP_MAIN_TEXT_HEIGHT, x, y);
}
Ejemplo n.º 13
0
/* save file */
void save_file(const int fd, const char *filename, const int total)
{
    int w_bytes, chk;
    FILE *fp = NULL;
    static char buf[1500];

    assert(filename != NULL && total >= 0);

    fp = fopen(filename, "a+");
    if (NULL == fp)
    {
        printf("open file error!\r\n");
        return;
    }
    w_bytes = 0;
    while (w_bytes != total)
    {
        chk = recv(fd, buf, sizeof(buf), 0);
        fwrite(buf, chk, 1, fp);
        w_bytes += chk;
        fflush(fp);

        /* update progress bar */
        update_progress(&bar, chk);
        display_image(&bar);
    }
    putchar('\n');
    fflush(fp);
    fclose(fp);
    printf("%s: save!", filename);
}
Ejemplo n.º 14
0
void montage_channels(const Blob<Dtype> *image, const std::string &prefix,
                      bool show_diff) {

  cv::Mat *result = NULL;
  get_montage_channels_mat(image, show_diff, result);
  display_image(prefix, result);
}
Ejemplo n.º 15
0
void imshow(const Blob<Dtype> *image, int show_num, const std::string &prefix,
            bool show_diff) {
  const int channels = image->channels();
  const int height = image->height();
  const int width = image->width();
  const Dtype *data_ptr = show_diff ? image->cpu_diff() : image->cpu_data();
  int show_channels = channels == 3 ? channels : 1;

  int imsize = channels == 3 ? height * width * 3 : height * width;
  int type = channels == 3 ? CV_32FC3 : CV_32FC1;
  Dtype buffer[imsize];
  char name_buff[100];
  std::string window_name;
  for (int i = 0; i < show_num; ++i) {
    // std::copy(data_ptr + image->offset(i, 0, 0, 0),
    //           data_ptr + image->offset(i, 0, 0, 0) + imsize, buffer);
    // open cv does channels for each row
    int counter = 0;
    for (int h = 0; h < height; ++h) {
      for (int w = 0; w < width; ++w) {
        for (int c = 0; c < show_channels; ++c) {
          buffer[counter++] = data_ptr[image->offset(i, c, h, w)];
        }
      }
    }

    // between [0, 1]
    normalize(buffer, imsize);

    cv::Mat im(height, width, type, buffer, 0);

    snprintf(name_buff, 100, " %d", i);
    display_image(prefix + name_buff, &im);
  }
}
Ejemplo n.º 16
0
/**
 * Display the instructions for the OK button.
 */
static void display_pin_instructions()
{
    uint32_t x = CENTER_IMAGE_ON_X_AXIS(MDTP_PIN_INSTRUCTIONS_WIDTH,fb_config->width);
	uint32_t y = (fb_config->height)*OK_TEXT_RELATIVE_Y_LOCATION;

	display_image(MDTP_PIN_INSTRUCTIONS_OFFSET, MDTP_PIN_INSTRUCTIONS_WIDTH, MDTP_PIN_INSTRUCTIONS_HEIGHT, x, y);
}
Ejemplo n.º 17
0
void display_page(book * b, page * p)
{
	char ** l;
	int i;
	char str[20];
	
	if(!p)
		return;
	
	set_font(2);
	if(p->image) {
		display_image(p->image);
	}

	for(i=0, l=p->lines; *l; i++,l++){
		glColor3f(0.34f,0.25f, 0.16f);
		draw_string_zoomed(10,i*18*0.9f,(unsigned char*)*l,0,1.0f);
	}
	
	glColor3f(0.385f,0.285f, 0.19f);
	
	safe_snprintf(str,sizeof(str),"%d",p->page_no);
	if(b->type==1)
		draw_string_zoomed(140,b->max_lines*18*0.9f+2,(unsigned char*)str,0,1.0);
	else if(b->type==2)
		draw_string_zoomed(110,b->max_lines*18*0.9f+2,(unsigned char*)str,0,1.0);
	set_font(0);
}
Ejemplo n.º 18
0
int main() {

  /* Provides a user interface for the fill algorithm. */

  char filename[BUFSIZ] ;
  int x, y, old_color, new_color ;

  printf( "Enter image file name. " ) ;
  scanf( "%s", filename ) ;
  if( init_image( filename ) == - 1 ) {
    printf( "Error initializing the image.\n" ) ;
    exit( 1 ) ;
  }

  while( TRUE ) {
    display_image() ;
    printf( "Enter the point at which the fill should start ( x, y ) : " ) ;
    scanf( "%d, %d", &x, &y ) ;
    if( ( x == -1 ) && ( y == -1 ) ) break ;

    old_color = read_pixel( x, y ) ;
    
    do {
      printf( "Pixel color is %d. Enter the new color: ", old_color ) ;
      scanf( "%d", &new_color ) ;
    
    } while( old_color == new_color || new_color < 0 || new_color > 9 ) ;
   
    fill( x, y, old_color, new_color ) ;
  }

  printf( "All done.\n" ) ;
  return 0 ;
}
Ejemplo n.º 19
0
/**
 * Display initial delay message
 */
static void display_initial_delay()
{
    uint32_t x = CENTER_IMAGE_ON_X_AXIS(MDTP_MAIN_TEXT_WIDTH,fb_config->width);
	uint32_t y = (fb_config->height)*MAIN_TEXT_RELATIVE_Y_LOCATION;

	display_image(MDTP_INITIAL_DELAY_OFFSET, MDTP_MAIN_TEXT_WIDTH, MDTP_MAIN_TEXT_HEIGHT, x, y);
}
Ejemplo n.º 20
0
/* This function is called repetitively from the main program */
void labwork( void )
{
  delay( 1000 );

  time2string( textstring, mytime );
  display_string( 3, textstring );
  display_update();

  getbtns();

  if (getbtns() == 1)
    mytime += (getsw() << 4);
  
  if (getbtns() == 2)
    mytime += (getsw() << 8);

  if (getbtns() == 4)
    mytime += (getsw() << 12);


  volatile int* porte = (volatile int*) 0xbf886110;
  tick( &mytime );
  *porte += 1;
  display_image(96, icon);
}
Ejemplo n.º 21
0
/**
 * Display OK button as selected.
 */
static void display_selected_ok_button()
{
    uint32_t ok_x = CENTER_IMAGE_ON_X_AXIS(MDTP_OK_BUTTON_WIDTH,fb_config->width);
	uint32_t ok_y = (fb_config->height)*OK_BUTTON_RELATIVE_Y_LOCATION;

	display_image(MDTP_SELECTED_OK_BUTTON_OFFSET, MDTP_OK_BUTTON_WIDTH, MDTP_OK_BUTTON_HEIGHT,  ok_x, ok_y);
}
Ejemplo n.º 22
0
void test_otsu_step(){
	//IplImage * edge_image = min_max_edge_detection(image);
	//display_image("edge_image",edge_image);
	IplImage * edge_image = cvLoadImage("images/edges.png",0);
	display_image("edges image",edge_image);
	IplImage * otsu_image = otsu_algorithm(edge_image);
	otsu_image = invert_image(otsu_image);
	display_image("otsu image",otsu_image);
	IplImage * segmented_pixels = get_pixels_on_template(image,otsu_image);
	display_image("segmented pixs",segmented_pixels);
	int threshold = otsu_thresholding_no_white(segmented_pixels);
	IplImage* fimage = apply_threshold(segmented_pixels,threshold);
	display_image("fimage", fimage);
	cvSaveImage("images/otsu_edges.png",otsu_image);

	
}
Ejemplo n.º 23
0
void test_su_algorithm(){ 
	tester->start_timer();
	IplImage* rimage = su_algorithm(image);
	tester->stop_timer();
	display_image("result",rimage);
	cvSaveImage("image2-T.png",rimage);

}
Ejemplo n.º 24
0
void test_peak_image_values_from_otsu(){
	IplImage * edge_image = cvLoadImage("images/otsu_edges.png",0);
	display_image("edge_images",edge_image);
	//int peak_value = get_max_value(edge_image);
	//printf("peak_val: %d",peak_value);
	//IplImage* rimage = cvCreateImage(cvGetSize(edge_image),edge_image->depth,edge_image->nChannels);
	//cvZero(rimage);
	IplImage * rimage = create_white_image(image->width,image->height,1);
	int kernel_radius = 1;
	for(int x=0;x<rimage->width;x=x+1){
		for(int y=0;y<rimage->height;y++){
			int center_value = get_pixel(edge_image,y,x);
			bool center_is_peak = false;
			/*for(int i=x-kernel_radius;i<=x+kernel_radius;i++){
				if(is_coordinate_inside_boundaries(y,i,image)){
					int pixel = get_pixel(edge_image,y,i);
					if(pixel>center_value){
						center_is_peak = false;
					}
				}
			}*/
			if(center_value ==0)
			if(is_coordinate_inside_boundaries(y,x-kernel_radius,image)&&is_coordinate_inside_boundaries(y,x+kernel_radius,image))
			{
				int left_pixel = get_pixel(edge_image,y,x-kernel_radius);
				int right_pixel = get_pixel(edge_image,y,x+kernel_radius);
				int threshold = 20;
				if(left_pixel == 255 || right_pixel== 255)
					center_is_peak= true;
			}

			if(center_is_peak){
				//set_pixel(rimage,y,x,center_value);
				set_pixel(rimage,y,x,0);
			//if(pixel==255){
				//set_pixel(rimage,y,x,255);
			//}
			}
		}
	}
	//rimage = invert_image(rimage);
	display_image("peak values ",rimage);
	cvSaveImage("images/peakvalues.png",rimage);

}
Ejemplo n.º 25
0
void test_local_thresholding(){
	int text_width = 3;
	IplImage* edges_image = cvLoadImage("images/otsu_edges.png",0);
	display_image("edges image",edges_image);
	IplImage* original_image = image;
	//IplImage* local_thresholding(IplImage * compensate_img, IplImage * edges_img,int text_width){
    int window_size = text_width * 2;
    if(window_size%2==0) // to make it odd
        window_size++;
    
    int radius = floor((float)window_size /2);
    
    int Nmin = window_size;
    IplImage * rimage = cvCloneImage(image);
	int height_limit  = image->height-radius;
	int width_limit = image->width-radius;

	for(int j=0; j< image->height ;j++){ //change radius to 130 ie to debug windows size
		for(int i=0 ; i < image->width;i++){
			if(j <radius || i < radius || j>= height_limit ||i >= width_limit){ //This is to make whie the borders, we assume there is no text in the borders
					set_pixel(rimage,j,i,255);
					continue;
			}

            int Ne = get_number_edge_pixels(edges_image,i,j,radius);
            float Emean = get_edges_mean(edges_image,image,i,j,radius);
			float Estd = get_edges_std(edges_image,image,Emean,i,j,radius);
			int pixel = get_pixel(image,j,i);
			if( Ne >= Nmin && pixel <= (Emean+Estd/2)){
				set_pixel(rimage,j,i,0);
			}
			else{
				set_pixel(rimage,j,i,255);
			}
		}
	}
    
    //return rimage;

	display_image("local thresholding",rimage);
	cvSaveImage("images/localt.png",rimage);

	
}
Ejemplo n.º 26
0
void test_stable(){

	//image = cvLoadImage("C:\\Users\\ninao\\Documents\\images\\testimages\\bigimage.bmp",0);
	tester->start_timer();
	test_min_max_edge_detection();
	IplImage * edges_image = cvLoadImage("images/edges.png",0);
	display_image("edges",edges_image);
	IplImage * rimage = cvCreateImage(cvGetSize(image),image->depth,image->nChannels); 
	int values [] = {0,0,0,0,0,0,0,0,0};
	IplConvKernel * kernel = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_RECT,values);
	//cvDilate(edges_image,rimage,kernel);
	//display_image("dilate",rimage);
	IplImage * otsu_image = otsu_algorithm(edges_image);
	otsu_image = invert_image(otsu_image);
	tester->stop_timer();
	cvSaveImage("images/fasterver.png",otsu_image);
	display_image("otsu image",otsu_image);

}
Ejemplo n.º 27
0
	virtual int on_image(const cv::Mat& image)
	{
		cv::Mat display_image(image);

		cv::putText(
			display_image, opts()[0], {10,70}, cv::FONT_HERSHEY_SIMPLEX, 2, {0,0,255});

		add_display_image("image", display_image);
		return 0;
	}
Ejemplo n.º 28
0
	void display_frame(ClFrame &frame) {
		if(m_crop) {
			PERF_START("display_image_crop");
			display_image_ocl_crop(frame);
			PERF_END("display_image_crop");
		} else {
			PERF_START("display_image");
			display_image(frame);
			PERF_END("display_image");
		}
	}
Ejemplo n.º 29
0
void test_performance(){
	
	//image = cvLoadImage("C:\\Users\\ninao\\Documents\\images\\testimages\\bigimage.bmp",0);
	tester->start_timer();
	IplImage* rimage = su_algorithm(image);
	tester->stop_timer();
	display_image("result",rimage);
	cvSaveImage("images/bigimage-su.png",rimage);


}
Ejemplo n.º 30
0
void display_a_card_by_animation(SDL_Renderer *pRenderer, SDL_Texture *card_back_face_texture, Vector animation_coords) {

  /** Distribute or gathering cards animation card display function. **/

  if ( (int16_t) round(animation_coords.x) == 0 || (int16_t) round(animation_coords.x) == 0) {
    return ;
  }

  display_image(pRenderer,card_back_face_texture, (int16_t) round(animation_coords.x), (int16_t) round(animation_coords.y), CARD_WIDTH, CARD_HEIGHT ) ;

  return ;
}