Performance
Performance of VisionCamera​
VisionCamera is highly optimized to be as fast as a native Camera app, and is sometimes even faster than that. I am using highly efficient native GPU buffer formats (such as YUV 4:2:0, or lossy compressed YUV 4:2:0), running the video pipelines in parallel, using C++ for the Frame Processors implementation, and other tricks to make sure VisionCamera is as efficient as possible.
Making it faster​
There are a few things you can do to make your Camera faster which requires a core understanding of how Cameras work under the hood:
Simpler Camera Device​
Selecting a "simpler" Camera Device (i.e. a Camera Device with less physical cameras) allows the Camera to initialize faster as it does not have to start multiple devices at once.
You can prefer a simple wide-angle Camera (['wide-angle-camera']
) over a triple camera (['ultra-wide-angle-camera', 'wide-angle-camera', 'telephoto-camera']
) to significantly speed up initialization time.
- Hooks API
- Imperative API
const fasterDevice = useCameraDevice('back', {
physicalDevices: ['wide-angle-camera']
})
const slowerDevice = useCameraDevice('back', {
physicalDevices: ['ultra-wide-angle-camera', 'wide-angle-camera', 'telephoto-camera']
})
const devices = Camera.getAvailableCameraDevices()
const fasterDevice = getCameraDevice(devices, 'back', {
physicalDevices: ['wide-angle-camera']
})
const slowerDevice = getCameraDevice(devices, 'back', {
physicalDevices: ['ultra-wide-angle-camera', 'wide-angle-camera', 'telephoto-camera']
})
See "Camera Devices" for more information.
By default (when not passing the options object), a simpler device is already chosen.
No Video HDR​
Video HDR uses 10-bit formats and/or additional processing steps that come with additional computation overhead. Disable videoHdr
for higher efficiency.
Buffer Compression​
Enable Buffer Compression (enableBufferCompression
) to use lossy-compressed buffers for the Camera's video pipeline. These buffers can use less memory and are more efficient.
When not using a frameProcessor
, buffer compression is automatically enabled.
Video Stabilization​
Video Stabilization requires additional overhead to start the algorithm, so disabling videoStabilizationMode
can significantly speed up the Camera initialization time.