In the past few days, I created a small tool for recognizing QR codes using navigator.mediaDevices.getDisplayMedia()
and jsQR.js
. The specific idea is to use the navigator.mediaDevices.getDisplayMedia()
method to call the browser's screen sharing feature to capture a webpage or software interface, then draw it onto a canvas
, and finally call jsQR.js
to achieve the effect of parsing QR codes on the page. Since the screen sharing feature has an option to capture the entire screen, it theoretically can recognize QR codes from any location, but due to resolution limitations, some smaller QR codes may not be detected.
All modern desktop browsers support navigator.mediaDevices.getDisplayMedia()
, except for Internet Explorer. Currently, no mobile browser supports this method.
This article is synchronized and updated to xLog by Mix Space. The original link is https://www.vinking.top/posts/codes/qr-code-scanner-with-getDisplayMedia