This commit is contained in:
ArifHilmi 2025-03-03 09:11:54 +08:00
parent 11e8e84064
commit f4125a09ed
2 changed files with 39 additions and 21 deletions

View File

@ -375,7 +375,15 @@
qrCodeResult: null, qrCodeResult: null,
debounceTimeout: null, debounceTimeout: null,
error: "", error: "",
selectedConstraints: { facingMode: "environment" }, selectedConstraints: {
video: {
facingMode: "environment", // Kamera belakang
width: { ideal: 1920 }, // Resolusi tinggi
height: { ideal: 1080 },
focusMode: "continuous", // Auto-focus
zoom: 2.0
}
},
trackFunctionSelected: { text: 'outline', value: null }, trackFunctionSelected: { text: 'outline', value: null },
barcodeFormats: { barcodeFormats: {
qr_code: true, // Hanya mendukung QR Code qr_code: true, // Hanya mendukung QR Code
@ -625,10 +633,12 @@
} }
this.error = message; this.error = message;
}, },
//Setting Camera //Setting Camera
async onCameraReady() { async onCameraReady() {
try { this.enableAutoFocus();
},
async enableAutoFocus() {
const devices = await navigator.mediaDevices.enumerateDevices(); const devices = await navigator.mediaDevices.enumerateDevices();
this.videoInputDevices = devices.filter(device => device.kind === 'videoinput'); this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
@ -642,11 +652,19 @@
} else { } else {
this.error = "No camera detected."; this.error = "No camera detected.";
} }
} catch (err) {
this.error = "Error accessing camera: " + err.message;
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
const track = stream.getVideoTracks()[0];
const capabilities = track.getCapabilities();
if(capabilities.focusMode) {
await track.applyConstraints({ focusMode: "continuous" }); // Auto-focus
} }
}, },
//Update Camera Category //Update Camera Category
updateCamera() { updateCamera() {
this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } }; this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };

View File

@ -13,7 +13,7 @@
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "http://localhost:5124", "applicationUrl": "http://192.168.0.20:5124",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@ -22,7 +22,7 @@
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "https://localhost:7036;http://localhost:5124", "applicationUrl": "https://192.168.0.20:7036;http://192.168.0.20:5124",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }