mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
improve qr reading by additionally scanning using boofcv
This commit is contained in:
parent
2cc02e38e6
commit
d3b0eac51a
3 changed files with 14 additions and 0 deletions
|
@ -124,6 +124,7 @@ dependencies {
|
||||||
exclude group: 'org.slf4j'
|
exclude group: 'org.slf4j'
|
||||||
}
|
}
|
||||||
implementation('com.sparrowwallet.nightjar:nightjar:0.2.40')
|
implementation('com.sparrowwallet.nightjar:nightjar:0.2.40')
|
||||||
|
implementation('com.sparrowwallet.bokmakierie:bokmakierie:1.0')
|
||||||
implementation('io.reactivex.rxjava2:rxjava:2.2.15')
|
implementation('io.reactivex.rxjava2:rxjava:2.2.15')
|
||||||
implementation('io.reactivex.rxjava2:rxjavafx:2.2.2')
|
implementation('io.reactivex.rxjava2:rxjavafx:2.2.2')
|
||||||
implementation('org.apache.commons:commons-lang3:3.7')
|
implementation('org.apache.commons:commons-lang3:3.7')
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.google.zxing.*;
|
||||||
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
|
||||||
import com.google.zxing.common.HybridBinarizer;
|
import com.google.zxing.common.HybridBinarizer;
|
||||||
import com.google.zxing.qrcode.QRCodeReader;
|
import com.google.zxing.qrcode.QRCodeReader;
|
||||||
|
import com.sparrowwallet.bokmakierie.Bokmakierie;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
@ -43,6 +44,7 @@ public class WebcamService extends ScheduledService<Image> {
|
||||||
private Webcam cam;
|
private Webcam cam;
|
||||||
private long lastQrSampleTime;
|
private long lastQrSampleTime;
|
||||||
private final Reader qrReader;
|
private final Reader qrReader;
|
||||||
|
private final Bokmakierie bokmakierie;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Webcam.setDriver(new WebcamScanDriver());
|
Webcam.setDriver(new WebcamScanDriver());
|
||||||
|
@ -55,6 +57,7 @@ public class WebcamService extends ScheduledService<Image> {
|
||||||
this.delayCalculator = delayCalculator;
|
this.delayCalculator = delayCalculator;
|
||||||
this.lastQrSampleTime = System.currentTimeMillis();
|
this.lastQrSampleTime = System.currentTimeMillis();
|
||||||
this.qrReader = new QRCodeReader();
|
this.qrReader = new QRCodeReader();
|
||||||
|
this.bokmakierie = new Bokmakierie();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,6 +159,15 @@ public class WebcamService extends ScheduledService<Image> {
|
||||||
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
|
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
|
||||||
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||||
|
|
||||||
|
try {
|
||||||
|
com.sparrowwallet.bokmakierie.Result result = bokmakierie.scan(bufferedImage);
|
||||||
|
if(result != null) {
|
||||||
|
return new Result(result.getMessage(), result.getRawBytes(), new ResultPoint[0], BarcodeFormat.QR_CODE);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.debug("Error scanning QR", e);
|
||||||
|
}
|
||||||
|
|
||||||
if(ZBar.isEnabled()) {
|
if(ZBar.isEnabled()) {
|
||||||
ZBar.Scan scan = ZBar.scan(bufferedImage);
|
ZBar.Scan scan = ZBar.scan(bufferedImage);
|
||||||
if(scan != null) {
|
if(scan != null) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ open module com.sparrowwallet.sparrow {
|
||||||
requires net.coobird.thumbnailator;
|
requires net.coobird.thumbnailator;
|
||||||
requires com.github.hervegirod;
|
requires com.github.hervegirod;
|
||||||
requires com.sparrowwallet.toucan;
|
requires com.sparrowwallet.toucan;
|
||||||
|
requires com.sparrowwallet.bokmakierie;
|
||||||
requires java.smartcardio;
|
requires java.smartcardio;
|
||||||
requires com.jcraft.jzlib;
|
requires com.jcraft.jzlib;
|
||||||
}
|
}
|
Loading…
Reference in a new issue