chnage dlogic in ocr for camera crop
This commit is contained in:
@@ -298,8 +298,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest"></script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
@@ -311,21 +309,6 @@ function cameraCapture() {
|
||||
photo1: '',
|
||||
|
||||
|
||||
// async initCamera() {
|
||||
// try {
|
||||
// if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
|
||||
// this.stream = await navigator.mediaDevices.getUserMedia({
|
||||
// video: { facingMode: this.currentFacingMode }
|
||||
// });
|
||||
|
||||
// this.$refs.video.srcObject = this.stream;
|
||||
// } catch (err) {
|
||||
// console.error("Camera error:", err);
|
||||
// alert("Cannot access camera. Enable permissions or use HTTPS.");
|
||||
// }
|
||||
// },
|
||||
|
||||
async initCamera() {
|
||||
try {
|
||||
if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
@@ -334,21 +317,37 @@ function cameraCapture() {
|
||||
video: { facingMode: this.currentFacingMode }
|
||||
});
|
||||
|
||||
const video = this.$refs.video;
|
||||
video.srcObject = this.stream;
|
||||
await video.play();
|
||||
|
||||
const overlay = this.$refs.overlay;
|
||||
overlay.width = video.videoWidth;
|
||||
overlay.height = video.videoHeight;
|
||||
|
||||
this.startTextDetection(); //auto detection after camera start
|
||||
this.$refs.video.srcObject = this.stream;
|
||||
this.startDetection();
|
||||
} catch (err) {
|
||||
console.error("Camera error:", err);
|
||||
alert("Camera access failed!");
|
||||
alert("Cannot access camera. Enable permissions or use HTTPS.");
|
||||
}
|
||||
},
|
||||
|
||||
// async initCamera() {
|
||||
// try {
|
||||
// if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
||||
|
||||
// this.stream = await navigator.mediaDevices.getUserMedia({
|
||||
// video: { facingMode: this.currentFacingMode }
|
||||
// });
|
||||
|
||||
// const video = this.$refs.video;
|
||||
// video.srcObject = this.stream;
|
||||
// await video.play();
|
||||
|
||||
// const overlay = this.$refs.overlay;
|
||||
// overlay.width = video.videoWidth;
|
||||
// overlay.height = video.videoHeight;
|
||||
|
||||
// this.startTextDetection(); //auto detection after camera start
|
||||
// } catch (err) {
|
||||
// console.error("Camera error:", err);
|
||||
// alert("Camera access failed!");
|
||||
// }
|
||||
// },
|
||||
|
||||
async switchCamera() {
|
||||
this.currentFacingMode = this.currentFacingMode === 'user' ? 'environment' : 'user';
|
||||
await this.initCamera();
|
||||
|
||||
Reference in New Issue
Block a user