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