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

JSQR is using too much CPU #86

Open
alexolliveira opened this issue Jul 31, 2018 · 5 comments
Open

JSQR is using too much CPU #86

alexolliveira opened this issue Jul 31, 2018 · 5 comments

Comments

@alexolliveira
Copy link

JSQR is using a lot of CPU. When the cam is turned on, the use of cpu increases by 50%. How to solve this?

@cozmo
Copy link
Owner

cozmo commented Aug 15, 2018

So generally scanning images is going to use CPU. We've made strides to reduce the amount of CPU (and memory) that jsQR uses, especially in the v1 refactor. That said I certainly agree it could be better. #78 for example will cut down the CPU cycles per image by ~30% (when inverting is disabled) I think.

Going to keep this issue open to track general CPU improvements but we should probably try to define some metrics etc or we'll never be able to close it. Not sure if you have any ideas around that?

@adamreisnz
Copy link

Is it possible to move some of the processing to service workers somehow? We also find that especially from a live stream, it becomes almost impossible to scan a QR code on a phone.

@henrylearn2rock
Copy link

Check this out https://github.com/tigranbs/reactive-qr

@adamreisnz
Copy link

Thanks that looks good, I will try to refactor it for Vue.

@FPWombot
Copy link

So generally scanning images is going to use CPU. We've made strides to reduce the amount of CPU (and memory) that jsQR uses, especially in the v1 refactor. That said I certainly agree it could be better. #78 for example will cut down the CPU cycles per image by ~30% (when inverting is disabled) I think.

Going to keep this issue open to track general CPU improvements but we should probably try to define some metrics etc or we'll never be able to close it. Not sure if you have any ideas around that?

Is there a way to destroy the scanner when it has grabbed a code? So it only is running when called. similar to this example:

<script type="module"> const videoElem = document.getElementById('video'); // When you click a scan button, create the instance $('.scanner-btn').on('click', function () { const qrScanner = new QrScanner(videoElem, result => { $('#search_string').val(result); setTimeout(function () { $('#form').submit(); // After i submit the code for validation, destroy the instance ( since it uses alot of CPU) qrScanner.destroy(); }, 100); }); qrScanner.start(); }) </script>

any help appreciated thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants