-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting TypeError when opening the scan page #27
Comments
Hi @jaca420. Thanks for your feedback. As far as I can see, the function In order to make it work you need:
See the README section here https://github.com/PiotrFLEURY/camcode#add-a-javascript-file-for-barcode-scan You can also see a working example here https://github.com/PiotrFLEURY/camcode/blob/main/example/ With the javascript function: function detectBarcode(dataUrl, callback) {
Quagga.decodeSingle({
decoder: {
readers: [
"code_128_reader",
"ean_reader",
"ean_8_reader",
"code_39_reader",
"code_39_vin_reader",
"code_93_reader"
] // List of active readers
},
locate: true, // try to locate the barcode in the image
src: dataUrl // or 'data:image/jpg;base64,' + data
}, function (result) {
if (result && result.codeResult) {
console.log("result", result.codeResult.code);
callback(result.codeResult.code);
} else {
console.log("not detected");
}
});
} The javascript lib import (In this example I choosed QuaggaJs) camcode/example/web/index.html Line 44 in a48c333
And the imported javascript file camcode/example/web/index.html Line 45 in a48c333
The documentation should be improved I guess. Thanks again for this feedback |
I've just tested it on my side and all works well. I cannot figure out what's going on on your version. Can you please provide me the full code via a Github link maybe ? |
How can I do that? Github link? I made the changes. I didn't understand 100% before and got it to work a bit. I got it to scan a barcode by moving the phone close and away from the barcode. It read it once ... and that's it. I wasn't able to read it again. I tried a barcode from a can of RedBull and nothing ... Code is just as above. Just added the javascript scripts. While testing, it activated the selfie camera which worked better then the main camera. Camera doesn't seem to focus too well when scanning. |
This is so weird ... I'll share my code again here. Edited it to be like in your example. web/index.html
web/js/barcode.js
home_screen.dart
cam_code_scanner_page.dart
|
Does your phone have multiple camera lens ? I know that the autofocus can be improved on some camera like wide angle camera |
Yeah ... it does. How would I improve the autofocus? |
I think the problem is directly inside the camcode plugin itself. If you look at this code Line 181 in a48c333
We are searching cameras regarding some options in order to filter them. In my opinion, we should find the correct option to find only "standard" camera lens and exclude wide angle ones on order to get better scan performance. |
You might be right ... When I was testing the app using |
We can filter medias using some characteristics according to the documentation here : But the fact is that for multi lens camera on phones, each brand uses its own way to classify the camera lens list. I don't want to implement one code for each brand. It will be to fastidious to maintain. If anyone have an idea how to do that I would be pleased to put this improvement in the camcode plugin. |
Hmm ... what about switching between cameras while scanning the barcode? |
In fact this feature is already implemented but seems to not working 100% well. I looked at the device selection code but for the moment I can't figure out why it is not working on every devices. This is a hard part because this is working on every device I have and it is not working so well on some user devices. As this project is open source, I can only hope that some ones make some enhancement proposition for they own device in a pull request. If you can make it work on your device I'll be pleased to review your pull request and publish it on pub.dev |
I'll see ... Don't have so much experience with Flutter |
Just an update ... I tried with another phone (Samsung A52)... but still doesn't work. And FYI the app running on an iPhone 6 doesn't even open the camera. |
Using this in a web app and when tapping on a button
I'm getting the below error over and over
The text was updated successfully, but these errors were encountered: