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