changed logic in ocr
This commit is contained in:
@@ -839,38 +839,30 @@ function cameraCapture() {
|
||||
// this.stopDetection();
|
||||
// },
|
||||
|
||||
async capturePhoto() {
|
||||
const video = this.$refs.video;
|
||||
const canvas = this.$refs.canvas;
|
||||
const snapshot = this.$refs.snapshot;
|
||||
const overlay = this.$refs.overlay;
|
||||
const ctx = canvas.getContext('2d');
|
||||
capturePhoto() {
|
||||
const video = this.$refs.video;
|
||||
const canvas = this.$refs.canvas;
|
||||
const snapshot = this.$refs.snapshot;
|
||||
const context = canvas.getContext('2d');
|
||||
|
||||
canvas.width = video.videoWidth;
|
||||
canvas.height = video.videoHeight;
|
||||
ctx.drawImage(video, 0, 0);
|
||||
canvas.width = video.videoWidth;
|
||||
canvas.height = video.videoHeight;
|
||||
|
||||
const snapshotData = canvas.toDataURL('image/png');
|
||||
this.$refs.hiddenInput.value = snapshotData;
|
||||
this.capturedPhoto = snapshotData;
|
||||
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
// ✅ Hide video and overlays immediately
|
||||
video.classList.add('hidden');
|
||||
overlay.classList.add('hidden');
|
||||
//const dataUrl = canvas.toDataURL('image/png');
|
||||
const dataUrl = canvas.toDataURL('image/jpeg', 0.95);
|
||||
|
||||
// ✅ Set snapshot image and display in same place
|
||||
snapshot.src = snapshotData;
|
||||
snapshot.classList.remove('hidden');
|
||||
|
||||
// ✅ Stop video stream (after hiding)
|
||||
if (this.stream) {
|
||||
this.stream.getTracks().forEach(track => track.stop());
|
||||
}
|
||||
|
||||
this.stopDetection();
|
||||
},
|
||||
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
|
||||
snapshot.src = dataUrl;
|
||||
snapshot.classList.remove('hidden');
|
||||
video.classList.add('hidden');
|
||||
this.photoTaken = true;
|
||||
|
||||
this.$refs.hiddenInput.value = dataUrl;
|
||||
console.log('Captured Image:', dataUrl);
|
||||
},
|
||||
|
||||
async verifyPhoto() {
|
||||
if (!this.capturedPhoto) {
|
||||
|
||||
Reference in New Issue
Block a user