Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhshams committed Dec 30, 2021
2 parents cca5423 + 15fad43 commit b439032
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 23 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build
run: mvn --batch-mode --update-snapshots verify
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# JNBIS
Java Implementation of NIST Biometric Image Software (NBIS)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)

* master [![Build Status](https://travis-ci.org/kareez/jnbis.svg?branch=master)](https://travis-ci.org/kareez/jnbis)
* develop [![Build Status](https://travis-ci.org/kareez/jnbis.svg?branch=develop)](https://travis-ci.org/kareez/jnbis)
![CI](https://github.com/mhshams/jnbis/actions/workflows/ci.yaml/badge.svg)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mhshams/jnbis/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.mhshams/jnbis)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)


### About JNBIS
Expand All @@ -21,7 +21,7 @@ if you are using maven, add it to project dependencies.

```xml
<dependency>
<groupId>jnbis</groupId>
<groupId>com.github.mhshams</groupId>
<artifactId>jnbis</artifactId>
<version>2.x.x</version>
</dependency>
Expand Down Expand Up @@ -80,7 +80,7 @@ Nist nist = Jnbis.nist().decode("/path/to/nist/file"));

Decode a NIST file with given **File** instance
```Java
Nist nist = Jnbis.nist().decode(new File("/path/to/nist/file")));
Nist nist = Jnbis.nist().decode(new File("/path/to/nist/file"));
```

Decode a NIST file with given **InputStream** instance
Expand All @@ -91,7 +91,7 @@ Nist nist = Jnbis.nist().decode(nistInputStream));
**Nist** instance contains different types of data, depending on file type.
Here is a sample code that extract all fingerprints and save them in individual files.
```Java
Nist nist = Jnbis.nist().decode(new File("/path/to/nist/file")));
Nist nist = Jnbis.nist().decode(new File("/path/to/nist/file"));

for (HighResolutionGrayscaleFingerprint fp : nist.getHiResGrayscaleFingerprints()) {
Jnbis.wsq()
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>com.github.mhshams</groupId>
<artifactId>jnbis</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
<packaging>jar</packaging>

<name>JNBIS</name>
Expand Down Expand Up @@ -45,8 +45,8 @@

<properties>
<jdk.version>1.8</jdk.version>
<junit.version>4.12</junit.version>
<jackson.version>2.5.4</jackson.version>
<junit.version>4.13.2</junit.version>
<jackson.version>2.13.1</jackson.version>
<maven.compiler.verison>3.3</maven.compiler.verison>
<maven.source.verison>2.4</maven.source.verison>
<maven.javadoc.verison>2.10.3</maven.javadoc.verison>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jnbis/api/model/Nist.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ public abstract class Nist {

public abstract List<VariableResolutionPalmprint> getVariableResPalmprints();

public abstract List<UserDefinedTestingImage> getUserDefinedTestingImages();

public abstract List<IrisImage> getIrisImages();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.jnbis.api.model.record;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.jnbis.internal.record.BaseImageRecord;

import java.util.HashMap;
import java.util.Map;

/**
* @author TeeSofteis
*/
public class UserDefinedTestingImage extends BaseImageRecord {

// 16.003 - 16.005 and 16.013 - 16.998
@JsonProperty("user_defined_fields")
private Map<Integer, String> userDefinedFields;

public Map<Integer, String> getUserDefinedFields() {
return userDefinedFields;
}

public void setUserDefinedFields(Map<Integer, String> userDefinedFields) {
this.userDefinedFields = userDefinedFields;
}

public void addUserDefinedField(int key, String value) {
if (userDefinedFields == null) {
userDefinedFields = new HashMap<>();
}
userDefinedFields.put(key, value);
}

// 16.008 - SLC
@JsonProperty("scale_units")
private String scaleUnits;

// 16.009 - HPS
@JsonProperty("horizontal_pixel_scale")
private String horizontalPixelScale;

// 16.010 - VPS
@JsonProperty("vertical_pixel_scale")
private String verticalPixelScale;

// 16.012 - BPX
@JsonProperty("bits_per_pixel")
private String bitsPerPixel;

public String getScaleUnits() {
return scaleUnits;
}

public void setScaleUnits(String scaleUnits) {
this.scaleUnits = scaleUnits;
}

public String getHorizontalPixelScale() {
return horizontalPixelScale;
}

public void setHorizontalPixelScale(String horizontalPixelScale) {
this.horizontalPixelScale = horizontalPixelScale;
}

public String getVerticalPixelScale() {
return verticalPixelScale;
}

public void setVerticalPixelScale(String verticalPixelScale) {
this.verticalPixelScale = verticalPixelScale;
}

public String getBitsPerPixel() {
return bitsPerPixel;
}

public void setBitsPerPixel(String bitsPerPixel) {
this.bitsPerPixel = bitsPerPixel;
}

}
9 changes: 9 additions & 0 deletions src/main/java/org/jnbis/internal/InternalNist.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class InternalNist extends Nist {
private final List<VariableResolutionLatentImage> variableResolutionLatentImages;
private final List<VariableResolutionFingerprint> variableResolutionFingerprints;
private final List<VariableResolutionPalmprint> variableResolutionPalmprints;
private final List<UserDefinedTestingImage> userDefinedTestingImages;
private final List<IrisImage> irisImages;

public InternalNist() {
Expand All @@ -41,6 +42,7 @@ public InternalNist() {
variableResolutionLatentImages = new ArrayList<>();
variableResolutionFingerprints = new ArrayList<>();
variableResolutionPalmprints = new ArrayList<>();
userDefinedTestingImages = new ArrayList<>();
irisImages = new ArrayList<>();
}

Expand Down Expand Up @@ -96,6 +98,9 @@ void addVariableResPalmprint(VariableResolutionPalmprint palmprint) {
variableResolutionPalmprints.add(palmprint);
}

void addUserDefinedTestingImage(UserDefinedTestingImage image) {
userDefinedTestingImages.add(image);
}
void addIrisImage(IrisImage image) {
irisImages.add(image);
}
Expand Down Expand Up @@ -152,6 +157,10 @@ public List<VariableResolutionPalmprint> getVariableResPalmprints() {
return variableResolutionPalmprints;
}

public List<UserDefinedTestingImage> getUserDefinedTestingImages() {
return userDefinedTestingImages;
}

public List<IrisImage> getIrisImages() {
return irisImages;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jnbis/internal/NistDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ record = readerFactory.read(token);
} else if (record instanceof VariableResolutionPalmprint) {
decoded.addVariableResPalmprint((VariableResolutionPalmprint) record);

} else if (record instanceof UserDefinedTestingImage) {
decoded.addUserDefinedTestingImage((UserDefinedTestingImage) record);

} else if (record instanceof IrisImage) {
decoded.addIrisImage((IrisImage) record);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jnbis/internal/NistHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class NistHelper {
public static final int RT_VR_LATENT_IMAGE = 13;
public static final int RT_VR_FINGERPRINT = 14;
public static final int RT_VR_PALMPRINT = 15;
public static final int RT_USER_DEFINED_TESTING_IMAGE = 16;
public static final int RT_IRIS_IMAGE = 17;

// Information separators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jnbis.internal.record.reader;


import org.jnbis.api.model.record.UserDefinedTestingImage;
import org.jnbis.internal.NistHelper;
import org.jnbis.internal.record.BaseRecord;

Expand Down Expand Up @@ -34,7 +35,7 @@ public BaseRecord read(NistHelper.Token token) {
READERS[NistHelper.RT_VR_LATENT_IMAGE] = new VariableResolutionLatentImageReader();
READERS[NistHelper.RT_VR_FINGERPRINT] = new VariableResolutionFingerprintReader();
READERS[NistHelper.RT_VR_PALMPRINT] = new VariableResolutionPalmprintReader();
READERS[16] = NOT_SUPPORTED;
READERS[NistHelper.RT_USER_DEFINED_TESTING_IMAGE] = new UserDefinedTestingImageReader();
READERS[NistHelper.RT_IRIS_IMAGE] = new IrisImageReader();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.jnbis.internal.record.reader;

import org.jnbis.internal.NistHelper;
import org.jnbis.api.model.record.UserDefinedTestingImage;

import java.util.ArrayList;
import java.util.Arrays;

/**
* @author TeeSofteis
*/
public class UserDefinedTestingImageReader extends RecordReader {
@Override
public UserDefinedTestingImage read(NistHelper.Token token) {
if (token.pos >= token.buffer.length) {
throw new RuntimeException("T16::NULL pointer to T16 record");
}

UserDefinedTestingImage userDefinedTestingImage = new UserDefinedTestingImage();

int start = token.pos;

NistHelper.Tag tag = getTagInfo(token);
if (tag.field != 1) {
throw new RuntimeException("T16::Invalid Record type = " + tag.type);
}

Integer length = Integer.parseInt(nextWord(token, NistHelper.TAG_SEP_GSFS, NistHelper.FIELD_MAX_LENGTH - 1, false));
userDefinedTestingImage.setLogicalRecordLength(length.toString());

while (true) {
token.pos++;
tag = getTagInfo(token);

if (tag.field == 999) {
byte[] data = new byte[length - (token.pos - start)];
System.arraycopy(token.buffer, token.pos, data, 0, data.length);
token.pos = token.pos + data.length;
userDefinedTestingImage.setImageData(data);
break;
}

String word = nextWord(token, NistHelper.TAG_SEP_GSFS, NistHelper.FIELD_MAX_LENGTH - 1, false);
switch (tag.field) {
case 1:
userDefinedTestingImage.setLogicalRecordLength(word);
break;
case 2:
userDefinedTestingImage.setImageDesignationCharacter(word);
break;
case 6:
userDefinedTestingImage.setHorizontalLineLength(word);
break;
case 7:
userDefinedTestingImage.setVerticalLineLength(word);
break;
case 8:
userDefinedTestingImage.setScaleUnits(word);
break;
case 9:
userDefinedTestingImage.setHorizontalPixelScale(word);
break;
case 10:
userDefinedTestingImage.setVerticalPixelScale(word);
break;
case 11:
userDefinedTestingImage.setCompressionAlgorithm(word);
break;
case 12:
userDefinedTestingImage.setBitsPerPixel(word);
break;
default:
if ((2 < tag.field && tag.field < 6) || (12 < tag.field && tag.field < 999)) {
// User defined fields could be found at tag 3-5 and 13-998. As the name implies,
// it is not obvious which format the data has. From my point of view, the best
// solution is to handle the data as an array of text, therefore split data into
// sub fields and items as you need.
userDefinedTestingImage.addUserDefinedField(tag.field, word);
}
break;
}
}
return userDefinedTestingImage;
}
}
Loading

0 comments on commit b439032

Please sign in to comment.