Fortunately, there's an API for that:
MediaDevices.getUserMedia() - Web APIs | MDN
It has fairly broad support, but you will need to make sure your site is served via HTTPS to use it.
And before you ask, no, there is no way to bypass the permission prompt.
Once you have the image, you will need to scan it for a barcode. You can either send the image to the server to do that, or use a client-side library. Google will find several examples - eg: QuaggaJS