1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Facial } from './libvbar-m-dxfacial.so'; // Placeholder for native module import
 
const dxCamera = {};
 
// --- Constants & Enums ---
 
 
// Instantiate the native object immediately.
// Thanks to ES module caching, this will only run once.
const _native = new Facial();
 
 
// --- Public API ---
 
/**
 * Set camera preview enable/disable
 * @param {number} channel - Camera channel (0: RGB, 1: NIR)
 * @param {number} enable - Switch state (0: disable, 1: enable)
 */
dxCamera.capPreviewEnable = function (channel, enable) {
    _native.capPreviewEnable(channel, enable); // Throws on error
};
 
/**
 * Capture and save a screenshot from the camera.
 * @param {string} savePath - The file path where the screenshot will be saved. If not provided, a default path will be used.
 * Throws an error if the operation fails.
 */
dxCamera.capPrintscreen = function (savePath = "/test.jpg") {
    _native.capPrintscreen(savePath);
};
 
 
export default dxCamera;