Skip to content
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

No barcode detected #21

Open
petertuharsky opened this issue Dec 2, 2022 · 15 comments
Open

No barcode detected #21

petertuharsky opened this issue Dec 2, 2022 · 15 comments
Labels
bug Something isn't working

Comments

@petertuharsky
Copy link

Hi!
I'm trying to use the Camerainput plugin. I have it installed under GLPI with no problem, the camera icon is present near search bar.
I log in to GLPI using a browser on mobile. When I tap the camera icon in GLPI, (after neccessarry camera access confirmation) a camera window opens that shows the correct camera input.
But it does nothing else; no barcode is ever detected or scanned. When I tap the camera window, it disappears as if nothing happened.
Am I doing something wrong?

@petertuharsky petertuharsky added the bug Something isn't working label Dec 2, 2022
@cconard96
Copy link
Owner

It could be a few things.
Do you know what type of barcode you are trying to scan (ex: code 39), and is it in the list in the plugin settings?

Is there any glare or imperfections on the barcode itself? The current library used for barcode detection is OK, but it doesn't do a lot to work around imperfect images.

It's also possible something broke this plugin. I'll try to test it on my end later today.

@petertuharsky
Copy link
Author

Wow, that was fast! :-)
As of plugin settings, I see none (in Super-Admin role). Under GLPI - Settings - Plugins, there is no setting available for any plugin. I only see plugin name, version and I'm only able to Activate/Deactivate or Uninstall the plugin.
I don't know the exact types of code - I used several from different goods. If needed, I could probably get the type info from some specialised barcode scanner app...
As of imperfections, well, I attempted to create very good light environment that other barcode scanners would rejoice to have :-)
I have a suspicion though. Using the camera plugin, I see no attepmts to focus the image. Maybe this is a sign it dosen't really work correctly?

@cconard96
Copy link
Owner

I've not been able to recreate the issue consistently. The only issue I've noticed is that it doesn't do well if there isn't high contrast between the barcode and the background. The webcam I was using to test with did appear to be auto-focusing, but that may have been something the camera was doing on its own and not the barcode library.

I suggest checking which formats are enabled in the plugin config (Setup > General > Camera input tab). Not all of the supported formats are enabled by default. The more formats that are enabled at once, the longer it could take to identify and the more likely there could be a misread.

@petertuharsky
Copy link
Author

Thank You for instructions. I had no idea that almost all code formats (but one) are disabled by default.

For curiosity, how long would the decoding take at most were all code formats enabled? Would it be 1 sec, 2 secs or 10? When I enabled all formats, it seemed I got no response at all.

Then I enabled and tested only UPC and EAN codes. Now the plugin gives some output, but incorrect so far.

I think the lack of focus may be part of the problem. Other barcode scanning software attempt continually to re-focus the camera in order to gain sharp picture of the code, but with the plugin the focus does not move at all.

I would also suggest the plugin to give some hint about its status, since I couldn't tell, whether it is even working - all I could see here was some camera preview window. Other scanners display some sort of hint of the zone it is actually considering, or showing where it is seeking to detect some scanning entry points etc, and when finally scans the code, stills the image, beeps and shows a green line across the code or frame around in order to show, which part of image did it scan (useful, since often there are several barcodes on one piece of hardware).

@cconard96
Copy link
Owner

Almost everything about the scanning part is done withing the library I'm using. I'm not sure what information I can get from it while it is working, but I can check. There are options that show a debug overlay that shows what it is currently trying to scan.

Ideally, I wanted to move away from this library and use the native Barcode Detection API if possible, but it isnt widely supported by browsers yet on the desktop side.

@cconard96
Copy link
Owner

There seems to be an issue with the initial config too. The Code 39 option looks like it is enabled by default, but it is just the default value that shows when the config is missing from the database. It doesn't seem like the config is created during the plugin install.

With all of the codes enabled when I first created the plugin, it seemed like it wasn't working at all or very rarely.

For forcing auto focus, I don't think browsers expose that kind of control but I can check.

@petertuharsky
Copy link
Author

I'm interested. Could it improve the capabilities of scanning (namely speed and reliability)? Is the API supported for now by ANY browser?

@cconard96
Copy link
Owner

Only some mobile browsers have full support.

https://developer.mozilla.org/en-US/docs/Web/API/Barcode_Detection_API#browser_compatibility

For desktop OS devices, none have full compatibility. Those that partially implement it only do so on less used operating systems like ChromeOS and MacOS it seems.

@cconard96
Copy link
Owner

Using it should be more reliable since the burden of maintaining and improving it would be on the browser developers rather than the maintainers of the library I'm using. There would be more eyes on the development and a wider range of people using it.

@petertuharsky
Copy link
Author

Do You plan on implementing this feature in some near future? E.q., giving the option in plugin config to choose the method?
I see no problem in using mobile Firefox, should it improve results.

And, just to be sure - isn't there some free, more capable library available around? The other folks for e-banking, ticketing, URL scanning etc... they all use some propietary code?
I guess that was there a better library, You would have probably already implemented it, but still... it is difficult for me to comprehend, since the barcode scanning is so abundant these days, that I thought the library must long be out there available for everybody...

@cconard96
Copy link
Owner

I just tagged a beta version of what will be the v2.1.0 release which has dropped the library the plugin was using before in favor of the native Barcode Detection API and a polyfill library for it on platforms where it is not available. From my testing using a webcam on my desktop (uses polyfill library) and my smartphone (native API), there seems to be a noticeable improvement in speed and reliability.

If you are able to, could you test the new functionality?
https://github.com/cconard96/glpi-camerainput-plugin/releases/tag/v2.1.0-beta

There is no release archive for the beta, but you can download the source and then run "npm install --omit=dev" in a terminal from within the plugin folder after you extract it to the correct location to install the polyfill dependency.

Also, this new version drops the configuration options as no issue was noticed by letting the barcode detector try and find all supported formats at once.

@petertuharsky
Copy link
Author

Thank You for this step. I have tested and result is excellent! I even didn't run the npm command.
The scanning works with Chrome mobile browser. In Firefox, the icon is absent; I don't know whether it is possible to enable it somehow in settings or no.

@petertuharsky
Copy link
Author

Hm, well, UPC and EAN codes are scanned in fraction of second, it's amazing, and it's great improvement indeed. However some other codes, used on hardware parts, are not scanned at all, under the same light conditions.

@cconard96
Copy link
Owner

The npm command is required for it to work on platforms that don't have the barcode detection API implemented like desktop browsers.

Do you know what type of barcodes aren't working?
The supported formats are Aztec, code_128, code_39, code_93, codabar, data_matrix, ean_13, ean_8, itf, pdf417, qr_code, upc_a, and upc_e.
If not, are they 1D barcodes or 2D (like qr codes) and are they very small?

@petertuharsky
Copy link
Author

petertuharsky commented Dec 29, 2022

Well, I did a snapshot of an example, but before sending, I tested scanning the picture from the monitor screen, and surprise - it is well scanned.
So it seems, that the problem is in focus again - the scanning screen still dosen't seem to focus, and while it dosen't prevent some codes to get scanned, others are more dense and possibly the software is unable to adjust to that degree of optical imperfection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants