索尼智能眼镜的二维码 Reader
QR Code Reader for Sony SmartEyeglass
$ 您好,我正在使用我在 Github https://github.com/simsor/SmartEyeglassQRCode/blob/master/AndroidApp/app/src/main/java/com/example/sony/smarteyeglass/extension/helloworld/HelloWorldControl.java 上找到的应用程序,它是索尼 SmartEyeglass 的二维码 reader。但由于某种原因,它不起作用。当我扫描二维码时,它会显示 "QR code not found" 或 "please wait" 很长一段时间,而不会显示结果。我尝试了几件事,但没有任何改变。你们中有人知道发生了什么事吗?
public void processPicture(CameraEvent event) {
updateLayout("Please wait...");
if (event.getIndex() == 0) {
if (event.getData() != null && event.getData().length > 0) {
byte[] data = event.getData();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
//copy pixel data from the Bitmap into the 'intArray' array
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap bbmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new QRCodeReader();
int DelayTime = 5000;
boolean error = false;
try {
Result result = reader.decode(bbmap);
Log.d(Constants.LOG_TAG, result.getText());
doWebsiteCommunication(result.getText());
} catch (NotFoundException e) {
updateLayout("QR Code Not Found");
error = true;
e.printStackTrace();
} catch (ChecksumException e) {
e.printStackTrace();
updateLayout(new String[] {
"QR Code looks corrupted",
"Maybe try again?"
});
error = true;
} catch (FormatException e) {
e.printStackTrace();
updateLayout("That's not a QR Code");
error = true;
}
if (error) {
try {
Thread.sleep(DelayTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
currentlyTakingPicture = false;
updateLayout(DEFAULT_TEXT);
}
}
}
}
问题是
doWebsiteCommunication(result.getText());
直接换成
updateLayout(result.getText());
这应该可以正常工作
PS: doWebsiteCommunication 本来是用来用扫描数据更新外部网站的,但是因为你只想读二维码所以不需要它
$ 您好,我正在使用我在 Github https://github.com/simsor/SmartEyeglassQRCode/blob/master/AndroidApp/app/src/main/java/com/example/sony/smarteyeglass/extension/helloworld/HelloWorldControl.java 上找到的应用程序,它是索尼 SmartEyeglass 的二维码 reader。但由于某种原因,它不起作用。当我扫描二维码时,它会显示 "QR code not found" 或 "please wait" 很长一段时间,而不会显示结果。我尝试了几件事,但没有任何改变。你们中有人知道发生了什么事吗?
public void processPicture(CameraEvent event) {
updateLayout("Please wait...");
if (event.getIndex() == 0) {
if (event.getData() != null && event.getData().length > 0) {
byte[] data = event.getData();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
//copy pixel data from the Bitmap into the 'intArray' array
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
BinaryBitmap bbmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new QRCodeReader();
int DelayTime = 5000;
boolean error = false;
try {
Result result = reader.decode(bbmap);
Log.d(Constants.LOG_TAG, result.getText());
doWebsiteCommunication(result.getText());
} catch (NotFoundException e) {
updateLayout("QR Code Not Found");
error = true;
e.printStackTrace();
} catch (ChecksumException e) {
e.printStackTrace();
updateLayout(new String[] {
"QR Code looks corrupted",
"Maybe try again?"
});
error = true;
} catch (FormatException e) {
e.printStackTrace();
updateLayout("That's not a QR Code");
error = true;
}
if (error) {
try {
Thread.sleep(DelayTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
currentlyTakingPicture = false;
updateLayout(DEFAULT_TEXT);
}
}
}
}
问题是
doWebsiteCommunication(result.getText());
直接换成
updateLayout(result.getText());
这应该可以正常工作
PS: doWebsiteCommunication 本来是用来用扫描数据更新外部网站的,但是因为你只想读二维码所以不需要它