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
void fpi_imgdev_image_captured(struct fp_img_dev *imgdev, struct fp_img *img)
{
	struct fp_print_data *print;
	int r;
	fp_dbg("");

	if (imgdev->action_state != IMG_ACQUIRE_STATE_AWAIT_IMAGE) {
		fp_dbg("ignoring due to current state %d", imgdev->action_state);
		return;
	}

	if (imgdev->action_result) {
		fp_dbg("not overwriting existing action result");
		return;
	}

	r = sanitize_image(imgdev, &img);
	if (r < 0) {
		imgdev->action_result = r;
		fp_img_free(img);
		goto next_state;
	}

	fp_img_standardize(img);
	imgdev->acquire_img = img;
	r = fpi_img_to_print_data(imgdev, img, &print);
	if (r < 0) {
		fp_dbg("image to print data conversion error: %d", r);
		imgdev->action_result = FP_ENROLL_RETRY;
		goto next_state;
	} else if (img->minutiae->num < MIN_ACCEPTABLE_MINUTIAE) {
		fp_dbg("not enough minutiae, %d/%d", img->minutiae->num,
			MIN_ACCEPTABLE_MINUTIAE);
		fp_print_data_free(print);
		/* depends on FP_ENROLL_RETRY == FP_VERIFY_RETRY */
		imgdev->action_result = FP_ENROLL_RETRY;
		goto next_state;
	}

	imgdev->acquire_data = print;
	switch (imgdev->action) {
	case IMG_ACTION_ENROLL:
		imgdev->action_result = FP_ENROLL_COMPLETE;
		break;
	case IMG_ACTION_VERIFY:
		verify_process_img(imgdev);
		break;
	case IMG_ACTION_IDENTIFY:
		identify_process_img(imgdev);
		break;
	default:
		BUG();
		break;
	}

next_state:
	imgdev->action_state = IMG_ACQUIRE_STATE_AWAIT_FINGER_OFF;
	dev_change_state(imgdev, IMGDEV_STATE_AWAIT_FINGER_OFF);
}
Beispiel #3
0
/**Capture an image, standardize and binarize it, and write it to a file*/
void image_save_binarized(char* filename){
    struct fp_img* img = image_get();
    fp_img_standardize(img);
    struct fp_img* img_binarized = fp_img_binarize(img);
    image_writefile(img_binarized, filename);
    fp_img_free(img); //free it
    fp_img_free(img_binarized);
}
Beispiel #4
0
void fpi_imgdev_image_captured(struct fp_img_dev *imgdev, struct fp_img *img)
{
	struct fp_print_data *print;
	int r;
	fp_dbg("");

	if (imgdev->action_state != IMG_ACQUIRE_STATE_AWAIT_IMAGE) {
		fp_dbg("ignoring due to current state %d", imgdev->action_state);
		return;
	}

	if (imgdev->action_result) {
		fp_dbg("not overwriting existing action result");
		return;
	}

	r = sanitize_image(imgdev, &img);
	if (r < 0) {
		imgdev->action_result = r;
		fp_img_free(img);
		goto next_state;
	}

	fp_img_standardize(img);
	imgdev->acquire_img = img;
	if (imgdev->action != IMG_ACTION_CAPTURE) {
		r = fpi_img_to_print_data(imgdev, img, &print);
		if (r < 0) {
			fp_dbg("image to print data conversion error: %d", r);
			imgdev->action_result = FP_ENROLL_RETRY;
			goto next_state;
		} else if (img->minutiae->num < MIN_ACCEPTABLE_MINUTIAE) {
			fp_dbg("not enough minutiae, %d/%d", img->minutiae->num,
				MIN_ACCEPTABLE_MINUTIAE);
			fp_print_data_free(print);
			/* depends on FP_ENROLL_RETRY == FP_VERIFY_RETRY */
			imgdev->action_result = FP_ENROLL_RETRY;
			goto next_state;
		}
	}

	imgdev->acquire_data = print;
	switch (imgdev->action) {
	case IMG_ACTION_ENROLL:
		if (!imgdev->enroll_data) {
			imgdev->enroll_data = fpi_print_data_new(imgdev->dev);
		}
		BUG_ON(g_slist_length(print->prints) != 1);
		/* Move print data from acquire data into enroll_data */
		imgdev->enroll_data->prints =
			g_slist_prepend(imgdev->enroll_data->prints, print->prints->data);
		print->prints = g_slist_remove(print->prints, print->prints->data);

		fp_print_data_free(imgdev->acquire_data);
		imgdev->acquire_data = NULL;
		imgdev->enroll_stage++;
		if (imgdev->enroll_stage == imgdev->dev->nr_enroll_stages)
			imgdev->action_result = FP_ENROLL_COMPLETE;
		else
			imgdev->action_result = FP_ENROLL_PASS;
		break;
	case IMG_ACTION_VERIFY:
		verify_process_img(imgdev);
		break;
	case IMG_ACTION_IDENTIFY:
		identify_process_img(imgdev);
		break;
	case IMG_ACTION_CAPTURE:
		imgdev->action_result = FP_CAPTURE_COMPLETE;
		break;
	default:
		BUG();
		break;
	}

next_state:
	imgdev->action_state = IMG_ACQUIRE_STATE_AWAIT_FINGER_OFF;
	dev_change_state(imgdev, IMGDEV_STATE_AWAIT_FINGER_OFF);
}
Beispiel #5
0
/**Capture an image, standardize it, and write it to a file*/
void image_save(char* filename){
    struct fp_img* img = image_get();
    fp_img_standardize(img);
    image_writefile(img, filename);
    fp_img_free(img); //free it
}