I've created a simple mobile application which shows the camera and decodes QRCodes with
Because my camera is blurry, this works for big QRCodes. Is there a way to focus the camera with Javascript? So this also works for smaller images or is there another solution?
EDIT I've noticed that if I use the Android App (instead of the HTML5 version), it can handle way more color difference and can scan my codes, while jsqrcode cannot. Am I using the wrong library?
Using ZXING
My working code:
public void scan() {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan();
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// On Scan result we get get to this part
try {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
// CODE
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Also needed to add the import .google.zxing.integration.android
package to my project.
I've created a simple mobile application which shows the camera and decodes QRCodes with https://github./LazarSoft/jsqrcode
Because my camera is blurry, this works for big QRCodes. Is there a way to focus the camera with Javascript? So this also works for smaller images or is there another solution?
EDIT I've noticed that if I use the Android App (instead of the HTML5 version), it can handle way more color difference and can scan my codes, while jsqrcode cannot. Am I using the wrong library?
Using ZXING
My working code:
public void scan() {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan();
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// On Scan result we get get to this part
try {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
// CODE
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Also needed to add the import .google.zxing.integration.android
package to my project.
- Did you get anywhere with this? I'm trying to access the rear camera with the 'environment' mand, however as you suggest, it won't focus and is no good for scanning? – andybarnes Commented Feb 28, 2014 at 8:30
- As far is I discovered it is not possible. Currently I am using the XZing scan app (there are multiple demos on the internet) and open that APP from my app and let it scan. That app has full scan positiblities. – Niels Commented Feb 28, 2014 at 10:04
- Thanks for that, I'll investigate! – andybarnes Commented Feb 28, 2014 at 11:12
- Added some of my code. GL – Niels Commented Feb 28, 2014 at 15:33
1 Answer
Reset to default 1Is the HTML5 version even working on your phone at all? CanIUse suggests that it shouldn't work on any mobile device except blackberry... but they are sometimes not up-to-date.
Either way - doubtful there's a one-size-fits-all solution with such a new API. Can you see about using the app (native code) version on phones and the flash-enabled version for desktops. You will have to perform your own device sniffing:
if( user_has_flash ) {
// Load an HTML5/Flash solution
} else if( is_mobile_device) {
// defer to the native code
// zxing has a phonegap plugin - https://github./wildabeast/BarcodeScanner
} else {
alert("Your device does not have scanning capabilities");
}