我使用zxing核心1.7,zxing j2se 1.7和网络摄像头捕获0.3.11库
IDE可能是netbeans 7.2和数据库的myqsl
问题是线程....我似乎无法打破标识符并将其跳转到另一种方法......我认为我做错了... 有任何想法吗 ? 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);
}
答案 0 :(得分:0)
我自己想出了答案......他 将结果设置为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);
}