changed logic in ocr
This commit is contained in:
@@ -787,40 +787,68 @@ function cameraCapture() {
|
|||||||
await this.initCamera();
|
await this.initCamera();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// async capturePhoto() {
|
||||||
|
// const video = this.$refs.video;
|
||||||
|
// const canvas = this.$refs.canvas;
|
||||||
|
// const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// canvas.width = video.videoWidth;
|
||||||
|
// canvas.height = video.videoHeight;
|
||||||
|
// ctx.drawImage(video, 0, 0);
|
||||||
|
|
||||||
|
// // const snapshotData = canvas.toDataURL('image/png');
|
||||||
|
// // this.$refs.hiddenInput.value = snapshotData;
|
||||||
|
// // this.capturedPhoto = snapshotData; // store for verification
|
||||||
|
// const snapshotData = canvas.toDataURL('image/png');
|
||||||
|
// this.$refs.hiddenInput.value = snapshotData;
|
||||||
|
// this.capturedPhoto = snapshotData;
|
||||||
|
|
||||||
|
// // Stop camera stream
|
||||||
|
// if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||||
|
|
||||||
|
// // snapshot.src = dataUrl;
|
||||||
|
// // snapshot.classList.remove('hidden');
|
||||||
|
// // video.classList.add('hidden');
|
||||||
|
// // const snapshot = this.$refs.snapshot;
|
||||||
|
// // snapshot.src = snapshotData;
|
||||||
|
// // snapshot.classList.remove('hidden');
|
||||||
|
// // video.classList.add('hidden');
|
||||||
|
// // overlay.classList.add('hidden');
|
||||||
|
// snapshot.src = dataUrl;
|
||||||
|
// snapshot.classList.remove('hidden');
|
||||||
|
// video.classList.add('hidden');
|
||||||
|
|
||||||
|
// alert("Photo captured!");
|
||||||
|
// this.stopDetection();
|
||||||
|
// },
|
||||||
|
|
||||||
async capturePhoto() {
|
async capturePhoto() {
|
||||||
const video = this.$refs.video;
|
const video = this.$refs.video;
|
||||||
const canvas = this.$refs.canvas;
|
const canvas = this.$refs.canvas;
|
||||||
|
const overlay = this.$refs.overlay;
|
||||||
|
const snapshot = this.$refs.snapshot;
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
canvas.width = video.videoWidth;
|
canvas.width = video.videoWidth;
|
||||||
canvas.height = video.videoHeight;
|
canvas.height = video.videoHeight;
|
||||||
ctx.drawImage(video, 0, 0);
|
ctx.drawImage(video, 0, 0);
|
||||||
|
|
||||||
// const snapshotData = canvas.toDataURL('image/png');
|
|
||||||
// this.$refs.hiddenInput.value = snapshotData;
|
|
||||||
// this.capturedPhoto = snapshotData; // store for verification
|
|
||||||
const snapshotData = canvas.toDataURL('image/png');
|
const snapshotData = canvas.toDataURL('image/png');
|
||||||
this.$refs.hiddenInput.value = snapshotData;
|
this.$refs.hiddenInput.value = snapshotData;
|
||||||
this.capturedPhoto = snapshotData;
|
this.capturedPhoto = snapshotData;
|
||||||
|
|
||||||
// Stop camera stream
|
// Stop the camera stream
|
||||||
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||||
|
|
||||||
// snapshot.src = dataUrl;
|
// ✅ Hide video + overlay, show captured snapshot
|
||||||
// snapshot.classList.remove('hidden');
|
|
||||||
// video.classList.add('hidden');
|
|
||||||
// const snapshot = this.$refs.snapshot;
|
|
||||||
// snapshot.src = snapshotData;
|
|
||||||
// snapshot.classList.remove('hidden');
|
|
||||||
// video.classList.add('hidden');
|
|
||||||
// overlay.classList.add('hidden');
|
|
||||||
snapshot.src = dataUrl;
|
|
||||||
snapshot.classList.remove('hidden');
|
|
||||||
video.classList.add('hidden');
|
video.classList.add('hidden');
|
||||||
|
overlay.classList.add('hidden');
|
||||||
|
snapshot.src = snapshotData;
|
||||||
|
snapshot.classList.remove('hidden');
|
||||||
|
|
||||||
alert("Photo captured!");
|
|
||||||
this.stopDetection();
|
this.stopDetection();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
async verifyPhoto() {
|
async verifyPhoto() {
|
||||||
if (!this.capturedPhoto) {
|
if (!this.capturedPhoto) {
|
||||||
|
|||||||
Reference in New Issue
Block a user