CameraFactory

interface CameraFactory extends HybridObject

The CameraFactory allows creating various other Camera related objects with arguments.

Properties

cameraPermissionStatus

readonly cameraPermissionStatus: PermissionStatus

Get the current Camera PermissionStatus.


microphonePermissionStatus

readonly microphonePermissionStatus: PermissionStatus

Get the current Microphone PermissionStatus.


supportsMultiCamSessions

readonly supportsMultiCamSessions: boolean

Gets 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.

Throws

If enableMultiCam is true, but supportsMultiCamSessions is false.


createDepthFrameOutput()

createDepthFrameOutput(options: DepthFrameOutputOptions): CameraDepthFrameOutput

Create a new CameraDepthFrameOutput with the given DepthFrameOutputOptions.


createDeviceFactory()

createDeviceFactory(): Promise<CameraDeviceFactory>

Asynchronously create a new CameraDeviceFactory.


createFrameOutput()

createFrameOutput(options: FrameOutputOptions): CameraFrameOutput

Create a new CameraFrameOutput with the given FrameOutputOptions.


createFrameRenderer()

createFrameRenderer(): FrameRenderer

Create a new FrameRenderer.


createNormalizedMeteringPoint()

createNormalizedMeteringPoint(
   x: number, 
   y: number, 
   size?: number): MeteringPoint

Creates 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()

iOS
createObjectOutput(options: ObjectOutputOptions): CameraObjectOutput

Create a new CameraObjectOutput with the given ObjectOutputOptions.


createOrientationManager()

createOrientationManager(orientationSource: OrientationSource): OrientationManager

Creates a new OrientationManager.


createOutputSynchronizer()

iOS
createOutputSynchronizer(outputs: CameraOutput[]): CameraOutputSynchronizer

Create a new CameraOutputSynchronizer that synchronizes the given outputs.


createPhotoOutput()

createPhotoOutput(options: PhotoOutputOptions): CameraPhotoOutput

Create a new CameraPhotoOutput with the given PhotoOutputOptions.


createPreviewOutput()

createPreviewOutput(): CameraPreviewOutput

Create a new CameraPreviewOutput.


createTapToFocusGestureController()

createTapToFocusGestureController(): TapToFocusGestureController

Creates a new TapToFocusGestureController.


createVideoOutput()

createVideoOutput(options: VideoOutputOptions): CameraVideoOutput

Create a new CameraVideoOutput with the given VideoOutputOptions.


createZoomGestureController()

createZoomGestureController(): ZoomGestureController

Creates 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 },
  ]
)