Frame Acquisition
Name | Description |
---|---|
getFrame() | Returns a DCEFrame object which contains the image data of the latest frame from the video input. |
singleFrameMode | Returns or sets whether to enable the single-frame mode. |
onSingleFrameAcquired | This event is triggered when a new frame / image is acquired under the single-frame mode. |
getFrame
Returns a DCEFrame
object which contains the image data of the latest frame from the video input.
getFrame(region?:Region): DCEFrame
Parameters
region
: optional parameter of the type Region
. It specifies a rectangular area on the image. If passed, the method only returns the frame cropped by the region.
Return value
A DCEFrame
object which contains the image data of the (cropped) frame and related information.
Code Snippet
// Returns only the 25% center area of the frame
let frameData = enhancer.getFrame({
regionBottom: 75,
regionRight: 75,
regionLeft: 25,
regionTop: 25,
regionMeasuredByPercentage: true
});
document.body.appendChild(frameData.canvas);
See also
singleFrameMode
Returns or sets whether to enable the singe-frame mode. When the single-frame mode is enabled, the video will not stream in the built-in UI of the library. Instead, the user can click the UI to invoke the system camera interface to catch a frame or select an existing image from the device storage.
singleFrameMode: boolean
Code Snippet
let pEnhancer = null;
(async () => {
let enhancer = await (pEnhancer = pEnhancer || Dynamsoft.DCE.CameraEnhancer.createInstance());
enhancer.singleFrameMode = true;
await enhancer.open();
})();
onSingleFrameAcquired
This event is triggered when a new frame / image is acquired under the single-frame mode.
onSingleFrameAcquired: (file: File) => {}
Arguments
file
: a File
object representing the image the user chose or a frame from the video input.
Code Snippet
let pEnhancer = null;
(async () => {
let enhancer = await (pEnhancer = pEnhancer || Dynamsoft.DCE.CameraEnhancer.createInstance());
enhancer.onSingleFrameAcquired = file => {
console.log(file.size);
};
await enhancer.open();
})();
See also