changed logic in ocr related to init camera
This commit is contained in:
@@ -201,6 +201,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
// },
|
// },
|
||||||
async initCamera() {
|
async initCamera() {
|
||||||
try {
|
try {
|
||||||
|
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||||
this.stream = await navigator.mediaDevices.getUserMedia({
|
this.stream = await navigator.mediaDevices.getUserMedia({
|
||||||
video: {
|
video: {
|
||||||
facingMode: this.currentFacingMode, // 'user' or 'environment'
|
facingMode: this.currentFacingMode, // 'user' or 'environment'
|
||||||
@@ -212,6 +213,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
this.$refs.video.srcObject = this.stream;
|
this.$refs.video.srcObject = this.stream;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error accessing camera:', err);
|
console.error('Error accessing camera:', err);
|
||||||
|
alert("Cannot access camera. Enable permissions or use HTTPS.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user