In the past two 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 invoke the screen sharing feature of the browser 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, theoretically, it can recognize QR codes from anywhere, 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 browsers support 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