changed logic in ocr
This commit is contained in:
@@ -86,58 +86,27 @@ function cameraCapture() {
|
||||
await this.initCamera();
|
||||
},
|
||||
|
||||
// capturePhoto() {
|
||||
// const video = this.$refs.video;
|
||||
// const canvas = this.$refs.canvas;
|
||||
// const snapshot = this.$refs.snapshot;
|
||||
// const context = canvas.getContext('2d');
|
||||
|
||||
// context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
// const dataUrl = canvas.toDataURL('image/png');
|
||||
|
||||
// // stop camera stream after capture
|
||||
// if (this.stream) {
|
||||
// this.stream.getTracks().forEach(track => track.stop());
|
||||
// }
|
||||
|
||||
// snapshot.src = dataUrl;
|
||||
// snapshot.classList.remove('hidden');
|
||||
// this.photoTaken = true;
|
||||
|
||||
// // this.$refs.hiddenInput.value = dataUrl;
|
||||
// @this.set('photo1', dataUrl);
|
||||
// },
|
||||
capturePhoto() {
|
||||
const video = this.$refs.video;
|
||||
const canvas = this.$refs.canvas;
|
||||
const snapshot = this.$refs.snapshot;
|
||||
const context = canvas.getContext('2d');
|
||||
|
||||
// Draw current video frame to canvas
|
||||
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Get base64 image
|
||||
const dataUrl = canvas.toDataURL('image/png');
|
||||
|
||||
// Show captured image
|
||||
snapshot.src = dataUrl;
|
||||
snapshot.classList.remove('hidden');
|
||||
|
||||
// Hide video so snapshot is visible
|
||||
video.classList.add('hidden');
|
||||
|
||||
// Stop the camera stream AFTER snapshot is captured
|
||||
// stop camera stream after capture
|
||||
if (this.stream) {
|
||||
this.stream.getTracks().forEach(track => track.stop());
|
||||
this.stream = null;
|
||||
}
|
||||
|
||||
snapshot.src = dataUrl;
|
||||
snapshot.classList.remove('hidden');
|
||||
this.photoTaken = true;
|
||||
|
||||
// Update Livewire property
|
||||
@this.set('photo1', dataUrl);
|
||||
}
|
||||
|
||||
this.$refs.hiddenInput.value = dataUrl;
|
||||
//@this.set('photo1', dataUrl);
|
||||
},
|
||||
|
||||
async retakePhoto() {
|
||||
this.photoTaken = false;
|
||||
|
||||
Reference in New Issue
Block a user