Qr
This commit is contained in:
parent
11e8e84064
commit
f4125a09ed
@ -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,28 +633,38 @@
|
|||||||
}
|
}
|
||||||
this.error = message;
|
this.error = message;
|
||||||
},
|
},
|
||||||
|
|
||||||
//Setting Camera
|
//Setting Camera
|
||||||
async onCameraReady() {
|
async onCameraReady() {
|
||||||
try {
|
this.enableAutoFocus();
|
||||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
||||||
this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
|
|
||||||
|
|
||||||
if (this.videoInputDevices.length > 0) {
|
|
||||||
// Keep the selected camera if already chosen
|
|
||||||
if (!this.selectedCameraId) {
|
|
||||||
this.selectedCameraId = this.videoInputDevices[0].deviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
|
|
||||||
} else {
|
|
||||||
this.error = "No camera detected.";
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
this.error = "Error accessing camera: " + err.message;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async enableAutoFocus() {
|
||||||
|
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||||
|
this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
|
||||||
|
|
||||||
|
if (this.videoInputDevices.length > 0) {
|
||||||
|
// Keep the selected camera if already chosen
|
||||||
|
if (!this.selectedCameraId) {
|
||||||
|
this.selectedCameraId = this.videoInputDevices[0].deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedConstraints = { deviceId: { exact: this.selectedCameraId } };
|
||||||
|
} else {
|
||||||
|
this.error = "No camera detected.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 } };
|
||||||
|
|||||||
@ -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"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user