Skip to content

aagsolutions/nbis

Repository files navigation

NIST Library

Build&Test Maven Central GitHub license CodeQL Scan Status

A Kotlin implementation of NIST Biometric Image Software (NBIS) for reading, writing, and building NIST records. Compatible with any JVM language.

Getting started:

About

NBIS is a library implemented in Kotlin to extract, decode, build and write NIST compressed files. For more information about NIST Biometric Image Software, visit the official NIST page.

Features

  • Read NIST files from various input sources
  • Write NIST files to output streams
  • Build NIST files programmatically
  • ✅ Support for record types 1-17
  • ✅ JVM language compatibility (Java, Kotlin, Scala, etc.)
  • ✅ Comprehensive field access and manipulation

NIST Record Types Support

Record Type Description Read Write Build
1 Transaction Information Record
2 User-defined descriptive text
3 Low-resolution grayscale fingerprint image
4 High-resolution grayscale fingerprint image
5 Low-resolution binary fingerprint image
6 High-resolution binary fingerprint image
7 User-defined image
8 Signature image
9 Minutiae data (for fingerprints)
10 Facial and SMT image
11 Forensic and investigatory voice data
12 Forensic dental and oral data
13 Variable-resolution latent friction ridge image
14 Variable-resolution fingerprint image
15 Palm print image
16 User-defined variable-resolution test image
17 Iris image
18 DNA data
19 Plantar (footprint) image
20 Original image record

Installation

Maven

<dependency>
    <groupId>eu.aagsolutions.img</groupId>
    <artifactId>nbis</artifactId>
    <version>0.7.1</version>
</dependency>

Gradle (Groovy DSL)

implementation 'eu.aagsolutions.img:nbis:0.7.1'

Gradle (Kotlin DSL)

implementation("eu.aagsolutions.img:nbis:0.7.1")

Quick Start

Reading a NIST File

From an input stream

Kotlin
val nistFile = NistFileReader(inputStream).use { reader -> reader.read() }
val transactionInformationRecord = nistFile.getTransactionInformationRecord()
Java
try (NistFileReader reader = new NistFileReader(inputStream)) {
    NistFile nistFile = reader.read();
    TransactionInformationRecord transactionInformationRecord = nistFile.getTransactionInformationRecord();
}

From a byte array

Kotlin
val nistFile = NistFileReader.Companion.decode(byteArray)
val transactionInformationRecord = nistFile.getTransactionInformationRecord()
Java
NistFile nistFile = NistFileReader.Companion.decode(byteArray);
TransactionInformationRecord transactionInformationRecord = nistFile.getTransactionInformationRecord();

Writing a NIST File

Kotlin

NistFileWriter(FileOutputStream("output.nist")).use { writer -> writer.write(nistFile) }

Java

NistFile nistFile = new NistFileBuilder()
        .withTransactionInformationRecord(transactionInformationRecord)
        .withUserDefinedDescriptionTextRecords(userDefinedTextRecord)
        .withFacialAndSmtImageRecords(facialAndSMTImageRecord)
        .build();
try (NistFileWriter writer = new NistFileWriter(new FileOutputStream("output.nist"))) {
    writer.write(nistFile);
}

API Documentation

Core Classes

NistFile

The main container for NIST records.

Key Methods:

  • getTransactionInformationRecord() - Get the required Type 1 record
  • getRecordsByType(RecordType) - Get all records of a specific type
  • getRecordByTypeAndIdc(RecordType, Int) - Get a specific record by type and IDC
  • getAllRecords() - Get all records in the file

NistFileReader

Reads NIST files from input streams.

NistFileWriter

Writes NIST files to output streams.

NistFileBuilder

Programmatically builds NIST files.

Working with Records

Accessing Field Data

// Get field as text 
val idcValue = record.getFieldText(DefaultFields.IDC)
// Get binary data (for image records) 
val imageData = record.getBinaryData()
// Get specific field object 
val field = record.getField(DefaultFields.LEN)

Record Types

All record types extend BaseRecord and provide type-specific functionality:

  • TransactionInformationRecord - Type 1 records
  • UserDefinedTextRecord - Type 2 records
  • HighResolutionGrayscaleFingerprintRecord - Type 4 records
  • MinutiaeDataRecord - Type 9 records
  • And more...

Field Types

The library supports different field types:

  • TextField - Text-based fields
  • ImageField - Binary image data fields

Requirements

  • Java: 17 or higher
  • Kotlin: 2.1 or higher

Inspiration and Credits

This project was inspired by the need for a robust and efficient library for handling NIST biometric image files. The inspiration comes from the original NBIS library, which is written in C and has been widely used in the biometric community. The goal of this project is to provide a modern, Kotlin-based alternative that is easier to use and maintain.

The project also draws inspiration from the work of other developers who have contributed to the open-source community with similar libraries. By leveraging their work and building upon it, we aim to create a high-quality, reliable, and efficient library for working with NIST biometric image files:

Packages

No packages published

Contributors 2

  •  
  •