CameraFactory
interface CameraFactory extends HybridObjectThe CameraFactory allows creating various other
Camera related objects with arguments.
Properties
cameraPermissionStatus
readonly cameraPermissionStatus: PermissionStatusGet the current Camera PermissionStatus.
microphonePermissionStatus
readonly microphonePermissionStatus: PermissionStatusGet the current Microphone PermissionStatus.
supportsMultiCamSessions
readonly supportsMultiCamSessions: booleanGets whether the platform supports creating multi-cam
CameraSessions.
Older phones may not be able to support this.
See
createCameraSession(enableMultiCam)
Methods
createCameraSession()
createCameraSession(enableMultiCam: boolean): Promise<CameraSession>Creates a new CameraSession.
- If
enableMultiCamistrue, theCameraSessionsupports attaching multipleCameraDevices as inputs/connections at the same time. - If
enableMultiCamisfalse, theCameraSessiononly supports a singleCameraDeviceinput at a time.
Throws
If enableMultiCam is true, but supportsMultiCamSessions is false.
createDepthFrameOutput()
createDepthFrameOutput(options: DepthFrameOutputOptions): CameraDepthFrameOutputCreate a new CameraDepthFrameOutput
with the given DepthFrameOutputOptions.
createDeviceFactory()
createDeviceFactory(): Promise<CameraDeviceFactory>Asynchronously create a new CameraDeviceFactory.
createFrameOutput()
createFrameOutput(options: FrameOutputOptions): CameraFrameOutputCreate a new CameraFrameOutput
with the given FrameOutputOptions.
createFrameRenderer()
createFrameRenderer(): FrameRendererCreate a new FrameRenderer.
createNormalizedMeteringPoint()
createNormalizedMeteringPoint(
x: number,
y: number,
size?: number): MeteringPointCreates a normalized MeteringPoint, where x and y are
values in the normalized range from 0.0 to 1.0.
Your are responsible for handling orientation, cropping and scaling.
Parameters
x
The X coordinate ranging from 0.0 to 1.0
y
The Y coordinate ranging from 0.0 to 1.0
size
The size/radius of the MeteringPoint
createObjectOutput()
createObjectOutput(options: ObjectOutputOptions): CameraObjectOutputCreate a new CameraObjectOutput
with the given ObjectOutputOptions.
createOrientationManager()
createOrientationManager(orientationSource: OrientationSource): OrientationManagerCreates a new OrientationManager.
createOutputSynchronizer()
createOutputSynchronizer(outputs: CameraOutput[]): CameraOutputSynchronizerCreate a new CameraOutputSynchronizer that
synchronizes the given outputs.
createPhotoOutput()
createPhotoOutput(options: PhotoOutputOptions): CameraPhotoOutputCreate a new CameraPhotoOutput
with the given PhotoOutputOptions.
createPreviewOutput()
createPreviewOutput(): CameraPreviewOutputCreate a new CameraPreviewOutput.
createTapToFocusGestureController()
createTapToFocusGestureController(): TapToFocusGestureControllerCreates a new TapToFocusGestureController.
createVideoOutput()
createVideoOutput(options: VideoOutputOptions): CameraVideoOutputCreate a new CameraVideoOutput
with the given VideoOutputOptions.
createZoomGestureController()
createZoomGestureController(): ZoomGestureControllerCreates a new ZoomGestureController.
requestCameraPermission()
requestCameraPermission(): Promise<boolean>Request Camera permission.
Returns
true if Camera permission has now been granted, false otherwise.
requestMicrophonePermission()
requestMicrophonePermission(): Promise<boolean>Request Microphone permission.
Returns
true if Microphone permission has now been granted, false otherwise.
resolveConstraints()
resolveConstraints(
device: CameraDevice,
outputConfigurations: CameraOutputConfiguration[],
constraints: Constraint[],
requiresMultiCam?: boolean): Promise<CameraSessionConfig>Resolves the given constraints to a fully validated
CameraSessionConfig respecting the given device's
capabilities negotiated with the given outputConfigurations.
The given constraints are ranked by priority in their
order passed in the array, descending.
The first item (index 0) has highest priority, while the last item
has lowest priority.
Discussion
On a device that supports every possible combination of features,
the returned CameraSessionConfig features exactly what was
described in the given constraints.
Most devices however negotiate available features across the given
outputConfigurations because of bandwidth constraints or
simply feature compatibility - for example, 10-bit Video HDR is often
not supported when used in conjunction with 100+ FPS.
Also, maximum available video resolution is often only available when
using a lower photo resolution, and vice-versa.
Discussion
The resolutionPreference Constraint is optional, but
may rank the given CameraOutput's resolution above other
Constraints.
If a resolutionPreference Constraint is omitted, it is
treated as last priority - other Constraints shall be met
first, if possible.
Examples
For a Photo HDR session configuration, use this:
const device = ...
const photoOutput = ...
const config = await resolveConstraints(
device,
[photoOutput],
[
{ resolutionPreference: photoOutput },
{ photoHDR: true },
]
)To also enable Video HDR (if available), but still prefer Photo HDR if both are not supported concurrently, use this:
const device = ...
const photoOutput = ...
const videoOutput = ...
const config = await resolveConstraints(
device,
[photoOutput, videoOutput],
[
{ resolutionPreference: photoOutput },
{ resolutionPreference: videoOutput },
{ photoHDR: true },
{ videoDynamicRange: CommonDynamicRanges.ANY_HDR },
]
)