mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
replace jni-based zbar wrapper with ffm-based jzbar
* Replace ZBar JNI library implementation with jzbar * Move ZBar.java to com.sparrowwallet.sparrow.control package * Move ZBar.java to the com.sparrowwallet.sparrow.io package * Switch to jzbar from Maven Central and update module/package imports accordingly * Remove jzbar entry from extraJavaModuleInfo to avoid module patching error
This commit is contained in:
parent
6c9a0d14cd
commit
2a2be2617c
12 changed files with 12 additions and 926 deletions
|
|
@ -109,6 +109,7 @@ dependencies {
|
||||||
implementation('com.github.hervegirod:fxsvgimage:1.1')
|
implementation('com.github.hervegirod:fxsvgimage:1.1')
|
||||||
implementation('com.sparrowwallet:toucan:0.9.0')
|
implementation('com.sparrowwallet:toucan:0.9.0')
|
||||||
implementation('com.jcraft:jzlib:1.1.3')
|
implementation('com.jcraft:jzlib:1.1.3')
|
||||||
|
implementation('io.github.doblon8:jzbar:0.0.1')
|
||||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0')
|
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.0')
|
||||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.10.0')
|
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.10.0')
|
||||||
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
|
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.google.zxing.qrcode.QRCodeReader;
|
||||||
import com.sparrowwallet.bokmakierie.Bokmakierie;
|
import com.sparrowwallet.bokmakierie.Bokmakierie;
|
||||||
import com.sparrowwallet.drongo.OsType;
|
import com.sparrowwallet.drongo.OsType;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
|
import com.sparrowwallet.sparrow.io.ZBar;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
|
@ -15,7 +16,6 @@ import javafx.concurrent.ScheduledService;
|
||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import javafx.embed.swing.SwingFXUtils;
|
import javafx.embed.swing.SwingFXUtils;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import net.sourceforge.zbar.ZBar;
|
|
||||||
import org.openpnp.capture.*;
|
import org.openpnp.capture.*;
|
||||||
import org.openpnp.capture.library.OpenpnpCaptureLibrary;
|
import org.openpnp.capture.library.OpenpnpCaptureLibrary;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package net.sourceforge.zbar;
|
package com.sparrowwallet.sparrow.io;
|
||||||
|
|
||||||
|
import io.github.doblon8.jzbar.Config;
|
||||||
|
import io.github.doblon8.jzbar.Image;
|
||||||
|
import io.github.doblon8.jzbar.ImageScanner;
|
||||||
|
import io.github.doblon8.jzbar.SymbolType;
|
||||||
import com.sparrowwallet.sparrow.net.NativeUtils;
|
import com.sparrowwallet.sparrow.net.NativeUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -7,7 +11,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class ZBar {
|
public class ZBar {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ZBar.class);
|
private static final Logger log = LoggerFactory.getLogger(ZBar.class);
|
||||||
|
|
@ -41,19 +44,12 @@ public class ZBar {
|
||||||
image.setData(data);
|
image.setData(data);
|
||||||
|
|
||||||
try(ImageScanner scanner = new ImageScanner()) {
|
try(ImageScanner scanner = new ImageScanner()) {
|
||||||
scanner.setConfig(Symbol.NONE, Config.ENABLE, 0);
|
scanner.setConfig(SymbolType.NONE, Config.ENABLE, 0);
|
||||||
scanner.setConfig(Symbol.QRCODE, Config.ENABLE, 1);
|
scanner.setConfig(SymbolType.QRCODE, Config.ENABLE, 1);
|
||||||
int result = scanner.scanImage(image);
|
int result = scanner.scanImage(image);
|
||||||
if(result != 0) {
|
if(result != 0) {
|
||||||
try(SymbolSet results = scanner.getResults()) {
|
String symbolData = image.getFirstSymbol().getData();
|
||||||
Scan scan = null;
|
return new Scan(getRawBytes(symbolData), symbolData);
|
||||||
for(Iterator<Symbol> iter = results.iterator(); iter.hasNext(); ) {
|
|
||||||
try(Symbol symbol = iter.next()) {
|
|
||||||
scan = new Scan(getRawBytes(symbol.getData()), symbol.getData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return scan;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,4 +56,5 @@ open module com.sparrowwallet.sparrow {
|
||||||
requires com.sparrowwallet.tern;
|
requires com.sparrowwallet.tern;
|
||||||
requires com.sparrowwallet.lark;
|
requires com.sparrowwallet.lark;
|
||||||
requires com.sun.jna;
|
requires com.sun.jna;
|
||||||
|
requires io.github.doblon8.jzbar;
|
||||||
}
|
}
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* Config
|
|
||||||
*
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoder configuration options.
|
|
||||||
*/
|
|
||||||
public class Config {
|
|
||||||
/**
|
|
||||||
* Enable symbology/feature.
|
|
||||||
*/
|
|
||||||
public static final int ENABLE = 0;
|
|
||||||
/**
|
|
||||||
* Enable check digit when optional.
|
|
||||||
*/
|
|
||||||
public static final int ADD_CHECK = 1;
|
|
||||||
/**
|
|
||||||
* Return check digit when present.
|
|
||||||
*/
|
|
||||||
public static final int EMIT_CHECK = 2;
|
|
||||||
/**
|
|
||||||
* Enable full ASCII character set.
|
|
||||||
*/
|
|
||||||
public static final int ASCII = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Minimum data length for valid decode.
|
|
||||||
*/
|
|
||||||
public static final int MIN_LEN = 0x20;
|
|
||||||
/**
|
|
||||||
* Maximum data length for valid decode.
|
|
||||||
*/
|
|
||||||
public static final int MAX_LEN = 0x21;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required video consistency frames.
|
|
||||||
*/
|
|
||||||
public static final int UNCERTAINTY = 0x40;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable scanner to collect position data.
|
|
||||||
*/
|
|
||||||
public static final int POSITION = 0x80;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Image scanner vertical scan density.
|
|
||||||
*/
|
|
||||||
public static final int X_DENSITY = 0x100;
|
|
||||||
/**
|
|
||||||
* Image scanner horizontal scan density.
|
|
||||||
*/
|
|
||||||
public static final int Y_DENSITY = 0x101;
|
|
||||||
}
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* Image
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stores image data samples along with associated format and size
|
|
||||||
* metadata.
|
|
||||||
*/
|
|
||||||
public class Image implements Closeable {
|
|
||||||
static {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C pointer to a zbar_symbol_t.
|
|
||||||
*/
|
|
||||||
private long peer;
|
|
||||||
private Object data;
|
|
||||||
|
|
||||||
public Image() {
|
|
||||||
peer = create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image(int width, int height) {
|
|
||||||
this();
|
|
||||||
setSize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image(int width, int height, String format) {
|
|
||||||
this();
|
|
||||||
setSize(width, height);
|
|
||||||
setFormat(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image(String format) {
|
|
||||||
this();
|
|
||||||
setFormat(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
Image(long peer) {
|
|
||||||
this.peer = peer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an associated peer instance.
|
|
||||||
*/
|
|
||||||
private native long create();
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up native data associated with an instance.
|
|
||||||
*/
|
|
||||||
public synchronized void destroy() {
|
|
||||||
if(peer != 0) {
|
|
||||||
destroy(peer);
|
|
||||||
peer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy the associated peer instance.
|
|
||||||
*/
|
|
||||||
private native void destroy(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Image format conversion.
|
|
||||||
*
|
|
||||||
* @returns a @em new image with the sample data from the original
|
|
||||||
* image converted to the requested format fourcc. the original
|
|
||||||
* image is unaffected.
|
|
||||||
*/
|
|
||||||
public Image convert(String format) {
|
|
||||||
long newpeer = convert(peer, format);
|
|
||||||
if(newpeer == 0) {
|
|
||||||
return (null);
|
|
||||||
}
|
|
||||||
return (new Image(newpeer));
|
|
||||||
}
|
|
||||||
|
|
||||||
private native long convert(long peer, String format);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the image format fourcc.
|
|
||||||
*/
|
|
||||||
public native String getFormat();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify the fourcc image format code for image sample data.
|
|
||||||
*/
|
|
||||||
public native void setFormat(String format);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a "sequence" (page/frame) number associated with this
|
|
||||||
* image.
|
|
||||||
*/
|
|
||||||
public native int getSequence();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Associate a "sequence" (page/frame) number with this image.
|
|
||||||
*/
|
|
||||||
public native void setSequence(int seq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the width of the image.
|
|
||||||
*/
|
|
||||||
public native int getWidth();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the height of the image.
|
|
||||||
*/
|
|
||||||
public native int getHeight();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the size of the image.
|
|
||||||
*/
|
|
||||||
public native int[] getSize();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify the pixel size of the image.
|
|
||||||
*/
|
|
||||||
public native void setSize(int[] size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify the pixel size of the image.
|
|
||||||
*/
|
|
||||||
public native void setSize(int width, int height);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the crop region of the image.
|
|
||||||
*/
|
|
||||||
public native int[] getCrop();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify the crop region of the image.
|
|
||||||
*/
|
|
||||||
public native void setCrop(int[] crop);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify the crop region of the image.
|
|
||||||
*/
|
|
||||||
public native void setCrop(int x, int y, int width, int height);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the image sample data.
|
|
||||||
*/
|
|
||||||
public native byte[] getData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify image sample data.
|
|
||||||
*/
|
|
||||||
public native void setData(byte[] data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify image sample data.
|
|
||||||
*/
|
|
||||||
public native void setData(int[] data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the decoded results associated with this image.
|
|
||||||
*/
|
|
||||||
public SymbolSet getSymbols() {
|
|
||||||
return (new SymbolSet(getSymbols(peer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private native long getSymbols(long peer);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* ImageScanner
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read barcodes from 2-D images.
|
|
||||||
*/
|
|
||||||
public class ImageScanner implements Closeable {
|
|
||||||
static {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C pointer to a zbar_image_scanner_t.
|
|
||||||
*/
|
|
||||||
private long peer;
|
|
||||||
|
|
||||||
public ImageScanner() {
|
|
||||||
peer = create();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an associated peer instance.
|
|
||||||
*/
|
|
||||||
private native long create();
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up native data associated with an instance.
|
|
||||||
*/
|
|
||||||
public synchronized void destroy() {
|
|
||||||
if(peer != 0) {
|
|
||||||
destroy(peer);
|
|
||||||
peer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy the associated peer instance.
|
|
||||||
*/
|
|
||||||
private native void destroy(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set config for indicated symbology (0 for all) to specified value.
|
|
||||||
*/
|
|
||||||
public native void setConfig(int symbology, int config, int value) throws IllegalArgumentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse configuration string and apply to image scanner.
|
|
||||||
*/
|
|
||||||
public native void parseConfig(String config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable the inter-image result cache (default disabled).
|
|
||||||
* Mostly useful for scanning video frames, the cache filters duplicate
|
|
||||||
* results from consecutive images, while adding some consistency
|
|
||||||
* checking and hysteresis to the results. Invoking this method also
|
|
||||||
* clears the cache.
|
|
||||||
*/
|
|
||||||
public native void enableCache(boolean enable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve decode results for last scanned image.
|
|
||||||
*
|
|
||||||
* @returns the SymbolSet result container
|
|
||||||
*/
|
|
||||||
public SymbolSet getResults() {
|
|
||||||
return (new SymbolSet(getResults(peer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private native long getResults(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scan for symbols in provided Image.
|
|
||||||
* The image format must currently be "Y800" or "GRAY".
|
|
||||||
*
|
|
||||||
* @returns the number of symbols successfully decoded from the image.
|
|
||||||
*/
|
|
||||||
public native int scanImage(Image image);
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* Modifier
|
|
||||||
*
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoder symbology modifiers.
|
|
||||||
*/
|
|
||||||
public class Modifier {
|
|
||||||
/**
|
|
||||||
* barcode tagged as GS1 (EAN.UCC) reserved
|
|
||||||
* (eg, FNC1 before first data character).
|
|
||||||
* data may be parsed as a sequence of GS1 AIs
|
|
||||||
*/
|
|
||||||
public static final int GS1 = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* barcode tagged as AIM reserved
|
|
||||||
* (eg, FNC1 after first character or digit pair)
|
|
||||||
*/
|
|
||||||
public static final int AIM = 1;
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* Orientation
|
|
||||||
*
|
|
||||||
* Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoded symbol coarse orientation.
|
|
||||||
*/
|
|
||||||
public class Orientation {
|
|
||||||
/**
|
|
||||||
* Unable to determine orientation.
|
|
||||||
*/
|
|
||||||
public static final int UNKNOWN = -1;
|
|
||||||
/**
|
|
||||||
* Upright, read left to right.
|
|
||||||
*/
|
|
||||||
public static final int UP = 0;
|
|
||||||
/**
|
|
||||||
* sideways, read top to bottom
|
|
||||||
*/
|
|
||||||
public static final int RIGHT = 1;
|
|
||||||
/**
|
|
||||||
* upside-down, read right to left
|
|
||||||
*/
|
|
||||||
public static final int DOWN = 2;
|
|
||||||
/**
|
|
||||||
* sideways, read bottom to top
|
|
||||||
*/
|
|
||||||
public static final int LEFT = 3;
|
|
||||||
}
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* Symbol
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Immutable container for decoded result symbols associated with an image
|
|
||||||
* or a composite symbol.
|
|
||||||
*/
|
|
||||||
public class Symbol implements Closeable {
|
|
||||||
/**
|
|
||||||
* No symbol decoded.
|
|
||||||
*/
|
|
||||||
public static final int NONE = 0;
|
|
||||||
/**
|
|
||||||
* Symbol detected but not decoded.
|
|
||||||
*/
|
|
||||||
public static final int PARTIAL = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-8.
|
|
||||||
*/
|
|
||||||
public static final int EAN8 = 8;
|
|
||||||
/**
|
|
||||||
* UPC-E.
|
|
||||||
*/
|
|
||||||
public static final int UPCE = 9;
|
|
||||||
/**
|
|
||||||
* ISBN-10 (from EAN-13).
|
|
||||||
*/
|
|
||||||
public static final int ISBN10 = 10;
|
|
||||||
/**
|
|
||||||
* UPC-A.
|
|
||||||
*/
|
|
||||||
public static final int UPCA = 12;
|
|
||||||
/**
|
|
||||||
* EAN-13.
|
|
||||||
*/
|
|
||||||
public static final int EAN13 = 13;
|
|
||||||
/**
|
|
||||||
* ISBN-13 (from EAN-13).
|
|
||||||
*/
|
|
||||||
public static final int ISBN13 = 14;
|
|
||||||
/**
|
|
||||||
* Interleaved 2 of 5.
|
|
||||||
*/
|
|
||||||
public static final int I25 = 25;
|
|
||||||
/**
|
|
||||||
* DataBar (RSS-14).
|
|
||||||
*/
|
|
||||||
public static final int DATABAR = 34;
|
|
||||||
/**
|
|
||||||
* DataBar Expanded.
|
|
||||||
*/
|
|
||||||
public static final int DATABAR_EXP = 35;
|
|
||||||
/**
|
|
||||||
* Codabar.
|
|
||||||
*/
|
|
||||||
public static final int CODABAR = 38;
|
|
||||||
/**
|
|
||||||
* Code 39.
|
|
||||||
*/
|
|
||||||
public static final int CODE39 = 39;
|
|
||||||
/**
|
|
||||||
* PDF417.
|
|
||||||
*/
|
|
||||||
public static final int PDF417 = 57;
|
|
||||||
/**
|
|
||||||
* QR Code.
|
|
||||||
*/
|
|
||||||
public static final int QRCODE = 64;
|
|
||||||
/**
|
|
||||||
* Code 93.
|
|
||||||
*/
|
|
||||||
public static final int CODE93 = 93;
|
|
||||||
/**
|
|
||||||
* Code 128.
|
|
||||||
*/
|
|
||||||
public static final int CODE128 = 128;
|
|
||||||
|
|
||||||
static {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C pointer to a zbar_symbol_t.
|
|
||||||
*/
|
|
||||||
private long peer;
|
|
||||||
/**
|
|
||||||
* Cached attributes.
|
|
||||||
*/
|
|
||||||
private int type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Symbols are only created by other package methods.
|
|
||||||
*/
|
|
||||||
Symbol(long peer) {
|
|
||||||
this.peer = peer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native void init();
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up native data associated with an instance.
|
|
||||||
*/
|
|
||||||
public synchronized void destroy() {
|
|
||||||
if(peer != 0) {
|
|
||||||
destroy(peer);
|
|
||||||
peer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release the associated peer instance.
|
|
||||||
*/
|
|
||||||
private native void destroy(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve type of decoded symbol.
|
|
||||||
*/
|
|
||||||
public int getType() {
|
|
||||||
if(type == 0) {
|
|
||||||
type = getType(peer);
|
|
||||||
}
|
|
||||||
return (type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private native int getType(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve symbology boolean configs settings used during decode.
|
|
||||||
*/
|
|
||||||
public native int getConfigMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve symbology characteristics detected during decode.
|
|
||||||
*/
|
|
||||||
public native int getModifierMask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve data decoded from symbol as a String.
|
|
||||||
*/
|
|
||||||
public native String getData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve raw data bytes decoded from symbol.
|
|
||||||
*/
|
|
||||||
public native byte[] getDataBytes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a symbol confidence metric. Quality is an unscaled,
|
|
||||||
* relative quantity: larger values are better than smaller
|
|
||||||
* values, where "large" and "small" are application dependent.
|
|
||||||
*/
|
|
||||||
public native int getQuality();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve current cache count. When the cache is enabled for
|
|
||||||
* the image_scanner this provides inter-frame reliability and
|
|
||||||
* redundancy information for video streams.
|
|
||||||
*
|
|
||||||
* @returns < 0 if symbol is still uncertain
|
|
||||||
* @returns 0 if symbol is newly verified
|
|
||||||
* @returns > 0 for duplicate symbols
|
|
||||||
*/
|
|
||||||
public native int getCount();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an approximate, axis-aligned bounding box for the
|
|
||||||
* symbol.
|
|
||||||
*/
|
|
||||||
public int[] getBounds() {
|
|
||||||
int n = getLocationSize(peer);
|
|
||||||
if(n <= 0) {
|
|
||||||
return (null);
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] bounds = new int[4];
|
|
||||||
int xmin = Integer.MAX_VALUE;
|
|
||||||
int xmax = Integer.MIN_VALUE;
|
|
||||||
int ymin = Integer.MAX_VALUE;
|
|
||||||
int ymax = Integer.MIN_VALUE;
|
|
||||||
|
|
||||||
for(int i = 0; i < n; i++) {
|
|
||||||
int x = getLocationX(peer, i);
|
|
||||||
if(xmin > x) {
|
|
||||||
xmin = x;
|
|
||||||
}
|
|
||||||
if(xmax < x) {
|
|
||||||
xmax = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
int y = getLocationY(peer, i);
|
|
||||||
if(ymin > y) {
|
|
||||||
ymin = y;
|
|
||||||
}
|
|
||||||
if(ymax < y) {
|
|
||||||
ymax = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bounds[0] = xmin;
|
|
||||||
bounds[1] = ymin;
|
|
||||||
bounds[2] = xmax - xmin;
|
|
||||||
bounds[3] = ymax - ymin;
|
|
||||||
return (bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private native int getLocationSize(long peer);
|
|
||||||
|
|
||||||
private native int getLocationX(long peer, int idx);
|
|
||||||
|
|
||||||
private native int getLocationY(long peer, int idx);
|
|
||||||
|
|
||||||
public int[] getLocationPoint(int idx) {
|
|
||||||
int[] p = new int[2];
|
|
||||||
p[0] = getLocationX(peer, idx);
|
|
||||||
p[1] = getLocationY(peer, idx);
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve general axis-aligned, orientation of decoded
|
|
||||||
* symbol.
|
|
||||||
*/
|
|
||||||
public native int getOrientation();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve components of a composite result.
|
|
||||||
*/
|
|
||||||
public SymbolSet getComponents() {
|
|
||||||
return (new SymbolSet(getComponents(peer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private native long getComponents(long peer);
|
|
||||||
|
|
||||||
native long next();
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* SymbolIterator
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterator over a SymbolSet.
|
|
||||||
*/
|
|
||||||
public class SymbolIterator implements java.util.Iterator<Symbol> {
|
|
||||||
/**
|
|
||||||
* Next symbol to be returned by the iterator.
|
|
||||||
*/
|
|
||||||
private Symbol current;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SymbolIterators are only created by internal interface methods.
|
|
||||||
*/
|
|
||||||
SymbolIterator(Symbol first) {
|
|
||||||
current = first;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the iteration has more elements.
|
|
||||||
*/
|
|
||||||
public boolean hasNext() {
|
|
||||||
return (current != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the next element in the iteration.
|
|
||||||
*/
|
|
||||||
public Symbol next() {
|
|
||||||
if(current == null) {
|
|
||||||
throw (new java.util.NoSuchElementException("access past end of SymbolIterator"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol result = current;
|
|
||||||
long sym = current.next();
|
|
||||||
if(sym != 0) {
|
|
||||||
current = new Symbol(sym);
|
|
||||||
} else {
|
|
||||||
current = null;
|
|
||||||
}
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Raises UnsupportedOperationException.
|
|
||||||
*/
|
|
||||||
public void remove() {
|
|
||||||
throw (new UnsupportedOperationException("SymbolIterator is immutable"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/*------------------------------------------------------------------------
|
|
||||||
* SymbolSet
|
|
||||||
*
|
|
||||||
* Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This file is part of the ZBar Bar Code Reader.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is free software; you can redistribute it
|
|
||||||
* and/or modify it under the terms of the GNU Lesser Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2.1 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* The ZBar Bar Code Reader is distributed in the hope that it will be
|
|
||||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
||||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser Public License
|
|
||||||
* along with the ZBar Bar Code Reader; if not, write to the Free
|
|
||||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* http://sourceforge.net/projects/zbar
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
package net.sourceforge.zbar;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Immutable container for decoded result symbols associated with an image
|
|
||||||
* or a composite symbol.
|
|
||||||
*/
|
|
||||||
public class SymbolSet extends java.util.AbstractCollection<Symbol> implements Closeable {
|
|
||||||
static {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C pointer to a zbar_symbol_set_t.
|
|
||||||
*/
|
|
||||||
private long peer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SymbolSets are only created by other package methods.
|
|
||||||
*/
|
|
||||||
SymbolSet(long peer) {
|
|
||||||
this.peer = peer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native void init();
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up native data associated with an instance.
|
|
||||||
*/
|
|
||||||
public synchronized void destroy() {
|
|
||||||
if(peer != 0) {
|
|
||||||
destroy(peer);
|
|
||||||
peer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release the associated peer instance.
|
|
||||||
*/
|
|
||||||
private native void destroy(long peer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve an iterator over the Symbol elements in this collection.
|
|
||||||
*/
|
|
||||||
public java.util.Iterator<Symbol> iterator() {
|
|
||||||
long sym = firstSymbol(peer);
|
|
||||||
if(sym == 0) {
|
|
||||||
return (new SymbolIterator(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new SymbolIterator(new Symbol(sym)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the number of elements in the collection.
|
|
||||||
*/
|
|
||||||
public native int size();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve C pointer to first symbol in the set.
|
|
||||||
*/
|
|
||||||
private native long firstSymbol(long peer);
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue