changed init camera logic in ocr
This commit is contained in:
@@ -185,20 +185,35 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
photoTaken: false,
|
||||
photo1: '',
|
||||
|
||||
// async initCamera() {
|
||||
// try {
|
||||
// if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
|
||||
// this.stream = await navigator.mediaDevices.getUserMedia({
|
||||
// video: { facingMode: this.currentFacingMode }
|
||||
// });
|
||||
|
||||
// this.$refs.video.srcObject = this.stream;
|
||||
// } catch (err) {
|
||||
// console.error("Camera error:", err);
|
||||
// alert("Cannot access camera. Enable permissions or use HTTPS.");
|
||||
// }
|
||||
// },
|
||||
async initCamera() {
|
||||
try {
|
||||
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: { facingMode: this.currentFacingMode }
|
||||
video: {
|
||||
width: { ideal: 1920 },
|
||||
height: { ideal: 1080 },
|
||||
},
|
||||
audio: false
|
||||
});
|
||||
|
||||
this.$refs.video.srcObject = this.stream;
|
||||
} catch (err) {
|
||||
console.error("Camera error:", err);
|
||||
alert("Cannot access camera. Enable permissions or use HTTPS.");
|
||||
console.error('Error accessing camera:', err);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
async switchCamera() {
|
||||
this.currentFacingMode = this.currentFacingMode === 'user' ? 'environment' : 'user';
|
||||
|
||||
Reference in New Issue
Block a user