Repository navigation
Quick Start
dilshan edited this page Nov 22, 2026
·
1 revision
A complete program that finds a sensor, waits for a finger, saves the fingerprint image as a BMP, and prints the first bytes of the template.
#include <stdio.h>
#include "openlru.h"
int main(void)
{
static uint8_t image[OLRU_IMAGE_SIZE];
uint8_t tpl[OLRU_TEMPLATE_SIZE];
olru_device_info list[OLRU_MAX_DEVICES];
olru_device *dev;
int rc;
/* 1. find sensors */
int count = olru_probe(list, OLRU_MAX_DEVICES);
if (count <= 0) {
fprintf(stderr, "no sensor found\n");
return 1;
}
printf("using %s (%04x:%04x)\n", list[0].name, list[0].vid, list[0].pid);
/* 2. open the first one */
rc = olru_open(&list[0], &dev);
if (rc != OLRU_OK) {
fprintf(stderr, "open: %s\n", olru_strerror(rc));
return 1;
}
/* 3. wait up to 10 s for a finger, then download the image */
printf("place a finger on the sensor...\n");
rc = olru_wait_for_finger(dev, 10000);
if (rc == OLRU_OK)
rc = olru_read_image(dev, image, sizeof image);
if (rc == OLRU_OK)
rc = olru_image_save_bmp(image, "finger.bmp");
/* 4. ask the sensor for a template */
if (rc == OLRU_OK)
rc = olru_read_template(dev, tpl);
if (rc == OLRU_OK)
for (int i = 0; i < 16; i++)
printf("%02x ", tpl[i]);
else
fprintf(stderr, "failed: %s\n", olru_strerror(rc));
olru_close(dev);
return rc != OLRU_OK;
}Build and run:
make lib
gcc quick.c -Iinclude build/libopenlru.a -o quick
./quick-
Probe -
olru_probereturns the sensors plugged in. -
Open -
olru_openclaims the sensor and checks it answers. -
Capture -
olru_wait_for_fingerthenolru_read_image. -
Template -
olru_read_template(call after a successful capture).
Always finish with olru_close.
olru_probe ─> olru_open ─> olru_capture_image / olru_wait_for_finger
│
├─> olru_read_image ─> olru_image_to_bmp / olru_image_save_bmp
└─> olru_read_template
... repeat per finger ...
olru_close
olru_read_image and olru_read_template both work on the image the sensor captured last, so call them after a successful capture. They can be called in either order.
openlru-lib - Open LRU Fingerprint Library · Home