我使用的是 zxing core 1.7、zxing j2se 1.7 和网络摄像头捕获 0.3.11 库
可能IDE是netbeans 7.2,数据库是mysql
问题是线程....我似乎无法创建一个标识符来中断并将其跳转到另一个方法...而且我认为我做得非常错误... 有任何想法吗 ? T_T
public void run() {
do {
try {
Thread.sleep(300);
} catch (InterruptedException e) {}
Result result = null;
BufferedImage image = null;
if (webcam.isOpen()) {
if ((image = webcam.getImage()) == null) {
continue;
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = new MultiFormatReader().decode(bitmap);
} catch (NotFoundException e) {
}
}
int a;
a = (result.getText().length()); //thread error
if (result != null) {
txtID.setText(result.getText());
try {
QRLOAD();
} catch (Exception e) {} //method to load jtable
try {
Update_PIC();
} catch (Exception e) {} //method to load picture jlabel
try {
Time_inUP();
} //method to to update the time
catch (Exception e) {}
if (a > 1) {
OperatorQR(); //method to close the thread and call the main panel
} else {
}
}
} while (true);
}
最佳答案
我自己找到了答案..呵呵 将结果设置为 int 并获取长度将不起作用...... 您只会在 if 参数中指出它...T_T
public void run() {
do {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
}
Result result = null;
BufferedImage image = null;
if (webcam.isOpen()) {
if ((image = webcam.getImage()) == null) {
continue;
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = new MultiFormatReader().decode(bitmap);
} catch (NotFoundException e) {
}
}
if ( result != null ) {
txtID.setText(result.getText());
try{QRLOAD();} //method to load jtable
catch(Exception e){ }
try{Update_PIC();} //method to load picture jlabel
catch(Exception e){ }
try{Time_inUP();} //method to to update the time
catch(Exception e){ }
try{Update_PIC();}
catch(Exception e){ }
try{QRLOAD();}
catch(Exception e){ }
if (result.getText().length()>1 ) {// This is the solution
OperatorQR(); //method to close the thread,webcam and call the main panel
}
}
}while (true);
}
关于java - QR 扫描仪时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32934852/