added retake photo functionality and improved capture logic in camera capture component

This commit is contained in:
dhanabalan
2025-10-27 16:24:05 +05:30
parent 39eedf1fe9
commit a9421963a7

View File

@@ -734,17 +734,13 @@ function cameraCapture() {
<x-filament::button color="primary" @click="switchCamera">Switch Camera</x-filament::button>
<x-filament::button color="success" @click="capturePhoto">Capture Photo</x-filament::button>
<x-filament::button color="warning" @click="verifyPhoto">Verify</x-filament::button>
<x-filament::button color="primary" @click="retakePhoto">Retake</x-filament::button>
</div>
<input type="hidden" x-ref="hiddenInput" name="camera_capture_file">
{{-- <input type="hidden" x-ref="serialInput" name="serialNumbers"> --}}
{{-- <input type="hidden" x-model="serialNumbers" name="serialNumbers"> --}}
<input type="hidden" x-model="serialNumbers" name="serialNumbers">
</div>
<!-- Scripts -->
@@ -825,7 +821,6 @@ function cameraCapture() {
// this.stopDetection();
// },
async capturePhoto() {
const video = this.$refs.video;
const canvas = this.$refs.canvas;
@@ -885,7 +880,6 @@ function cameraCapture() {
//this.$refs.serialInput.value = JSON.stringify(this.serialNumbers);
alert("Serial numbers stored in hidden input:\n" + this.$refs.serialInput.value);
}
} catch (err) {
console.error("OCR verify error:", err);
@@ -924,6 +918,14 @@ function cameraCapture() {
}
},
async retakePhoto() {
this.photoTaken = false;
this.$refs.snapshot.classList.add('hidden');
this.$refs.video.classList.remove('hidden');
await this.initCamera();
},
startDetection() {
if (this.textDetectionInterval) clearInterval(this.textDetectionInterval);
this.textDetectionInterval = setInterval(() => this.detectText(), 1000);
@@ -946,3 +948,6 @@ function cameraCapture() {