Beispiel #1
0
static void ewin_cb_export_clicked(GtkWidget *widget, gpointer data)
{
	struct fp_img *scan = NULL;
	int finger = GPOINTER_TO_INT(data);
	int r;
	char path[2048];
	sprintf(path,"captured_%d.pgm",finger);
	if (!fp_dev_supports_imaging(fpdev)) {
	  fprintf(stderr, "this device does not have imaging capabilities.\n");
	  return; 
	} 
	r = fp_dev_img_capture(fpdev,0,&scan);
	if (r != 0) {
	  fprintf(stderr,"Image Capture Failed: %d\n",r);
	  fp_img_free(scan);
	  return;
	}
	fp_img_standardize(scan);
	r = fp_img_save_to_file(scan,path);
	fp_img_free(scan);
	if (r != 0) {
	  fprintf(stderr,"Image Save Failed: %d\n",r);
	}
	return;

}
Beispiel #2
0
int main(){

    //initialize
    if (fp_init()){
        printf("libfprint patladi!\n");
        exit(1); //failure
    }

    //dev discovery
    struct fp_dscv_dev** ddevicelist;
    struct fp_dscv_dev* ddevice;

    if (!(ddevicelist = fp_discover_devs())){ //listeyi al
        printf("Device discovery calismadi!\n");
        exit(1); //failure
    }

    if(!(ddevice = ddevicelist[0])){ //bos? TODO: 2 alet varsa nolacak?
        printf("Alet nerde?\n");
        exit(1); //failure
    }

    print_driver_info(ddevice);

    //open dev
    struct fp_dev* device;

    if(!(device = fp_dev_open(ddevice))){
        printf("Okuyucu baslamadi!\n");
        exit(1); //failure
    }

    //get image
    fp_img_save_to_file(get_image(device), "./parmak.pgm"); //TODO: nasi freelenir lan bu?

    //cleanup
    fp_dev_close(device);
    fp_exit();

    return 0;
}
Beispiel #3
0
int verify(struct fp_dev *dev, struct fp_print_data *data)
{
	int r;

	do {
		struct fp_img *img = NULL;

		sleep(1);
		printf("\nScan your finger now.\n");
		r = fp_verify_finger_img(dev, data, &img);
		if (img) {
			fp_img_save_to_file(img, "verify.pgm");
			printf("Wrote scanned image to verify.pgm\n");
			fp_img_free(img);
		}
		if (r < 0) {
			printf("verification failed\n");
			return r;
		}
	} while (1);
}
Beispiel #4
0
int verify(struct fp_dev *dev, struct fp_print_data *data)
{
	do {
		struct fp_img *img = NULL;

		sleep(1);
		printf("\nScan your finger now.\n");
		int r = fp_verify_finger_img(dev, data, &img);
		if (img) {
			fp_img_save_to_file(img, "verify.pgm");
			printf("Wrote scanned image to verify.pgm\n");
			fp_img_free(img);
		}
		if (r < 0) {
			printf("verification failed with error %d :(\n", r);
			return r;
		}
		switch (r) {
		case FP_VERIFY_NO_MATCH:
			printf("NO MATCH!\n");
			return 0;
		case FP_VERIFY_MATCH:
			printf("MATCH!\n");
			return 0;
		case FP_VERIFY_RETRY:
			printf("Scan didn't quite work. Please try again.\n");
			break;
		case FP_VERIFY_RETRY_TOO_SHORT:
			printf("Swipe was too short, please try again.\n");
			break;
		case FP_VERIFY_RETRY_CENTER_FINGER:
			printf("Please center your finger on the sensor and try again.\n");
			break;
		case FP_VERIFY_RETRY_REMOVE_FINGER:
			printf("Please remove finger from the sensor and try again.\n");
			break;
		}
	} while (1);
}
Beispiel #5
0
struct fp_print_data *
enroll (struct fp_dev *dev)
{
  struct fp_print_data *enrolled_print = NULL;
  int r;

  printf ("You will need to successfully scan your finger %d times to "
	  "complete the process.\n", fp_dev_get_nr_enroll_stages (dev));

  do
    {
      struct fp_img *img = NULL;

      sleep (1);
      printf ("\nScan your finger now.\n");

      r = fp_enroll_finger_img (dev, &enrolled_print, &img);
      if (img)
	{
	  fp_img_save_to_file (img, "enrolled.pgm");
	  printf ("Wrote scanned image to enrolled.pgm\n");
	  fp_img_free (img);
	}
      if (r < 0)
	{
	  printf ("Enroll failed with error %d\n", r);
	  return NULL;
	}

      switch (r)
	{
	case FP_ENROLL_COMPLETE:
	  printf ("Enroll complete!\n");
	  break;
	case FP_ENROLL_FAIL:
	  printf ("Enroll failed, something wen't wrong :(\n");
	  return NULL;
	case FP_ENROLL_PASS:
	  printf ("Enroll stage passed. Yay!\n");
	  break;
	case FP_ENROLL_RETRY:
	  printf ("Didn't quite catch that. Please try again.\n");
	  break;
	case FP_ENROLL_RETRY_TOO_SHORT:
	  printf ("Your swipe was too short, please try again.\n");
	  break;
	case FP_ENROLL_RETRY_CENTER_FINGER:
	  printf ("Didn't catch that, please center your finger on the "
		  "sensor and try again.\n");
	  break;
	case FP_ENROLL_RETRY_REMOVE_FINGER:
	  printf ("Scan failed, please remove your finger and then try "
		  "again.\n");
	  break;
	}
    }
  while (r != FP_ENROLL_COMPLETE);

  if (!enrolled_print)
    {
      fprintf (stderr, "Enroll complete but no print?\n");
      return NULL;
    }

  printf ("Enrollment completed!\n\n");
  return enrolled_print;
}
Beispiel #6
0
/**Helper: Write an image to a file*/
int image_writefile(struct fp_img* image, char* filename){
    return fp_img_save_to_file(image, filename); // 0 on sucess
}