CameraComponent class

Warning: This API is now obsolete.

Create a camera media source with MediaSourceManager.createCameraSource() and use that to create a component for display. To record a video from the camera use O3hMediaSource.createVideoRecorder()

A view of the camera input that can be recorded if needed for future playbacks.

Signature:

export declare class CameraComponent extends Component 

Extends: Component

Methods

MethodModifiersDescription
addHighlight(type, level)Associate a highlight of the given type at the current moment in the video capture
captureImage()Capture a still image from the camera.
getCaptureResolution()Gets the current capture resolution of the camera.
pause()Pause the functionality of the component
reset()Restore the component to it's original state to allow recording to be repeated.
restartCamera()Turn the camera back on again after turning it off with CameraComponent.stopCamera()
resume()Resume the functionality of the component after pausing it
setCameraType(cameraType)Change the camera of a running camera component
setRecordingSpeed(speed)Control the timing of adding frames to the video recording.
setRecordingVolume(volume)Set the volume of the recording audio input in real time.
setResolutionScale(resolutionScale)Changes the resolution of a running camera component.
startRecording()Start the recording of the camera data.
stopCamera()Turn the camera off, to allow for the camera to be temporarily disabled without having to switch to a new layout
stopRecording(delay)Finish recording of the camera data, after this is called no further recording is possible on this component

CameraComponent.addHighlight() method

Associate a highlight of the given type at the current moment in the video capture

Signature:

addHighlight(type: Enum<typeof HighlightType>, level: number): void;

Parameters

ParameterTypeDescription
typeEnum<typeof HighlightType>The classification of what makes this moment special
levelnumberA value between 1 and 100 that describes how strong the highlight moment is

Returns:

void

CameraComponent.getCaptureResolution() method

Gets the current capture resolution of the camera.

Signature:

getCaptureResolution(): Promise<Vector2>;

Returns:

Promise<Vector2>

A promise that resolves to a Vector2 whose x and y values are the width and height of the camera output in pixels.

Remarks

This is the size of the raw camera output that is used for video recording, face tracking, image segmentation etc. It is determined by the resolution scale you provide to CameraComponentConfig.resolutionScale or CameraComponent.setResolutionScale() and the resolutions available on the device, and does not take into account any cropping or scaling that is done to fit the component in its layout.

CameraComponent.captureImage() method

Capture a still image from the camera.

Signature:

captureImage(): Promise<ImageAsset>;

Returns:

Promise<ImageAsset>

A still capture as an image asset

Remarks

Note that images captured by taking a snapshot of a video source like this will naturally be lower quality than images taken as a photo with AssetManager.getImageFromPhoto(), but this method can be more tightly integrated into the module design.

This call can take up to half a second to run, avoid blocking the user interface when calling.

CameraComponent.pause() method

Pause the functionality of the component

Signature:

pause(): void;

Returns:

void

CameraComponent.reset() method

Restore the component to it's original state to allow recording to be repeated.

Signature:

reset(): Promise<void>;

Returns:

Promise<void>

CameraComponent.restartCamera() method

Turn the camera back on again after turning it off with CameraComponent.stopCamera()

Signature:

restartCamera(): Promise<void>;

Returns:

Promise<void>

A promise that resolves when the camera is turned back on

Remarks

This call can take more than half a second to run, try to perform this operation behind the scenes

CameraComponent.resume() method

Resume the functionality of the component after pausing it

Signature:

resume(): void;

Returns:

void

CameraComponent.setCameraType() method

Change the camera of a running camera component

Signature:

setCameraType(cameraType: Enum<typeof CameraType>): Promise<void>;

Parameters

ParameterTypeDescription
cameraTypeEnum<typeof CameraType>The type identifier of the camera to use

Returns:

Promise<void>

A promise that resolves when the switch of cameras is complete

CameraComponent.setRecordingSpeed() method

Control the timing of adding frames to the video recording.

Signature:

setRecordingSpeed(speed: number): void;

Parameters

ParameterTypeDescription
speednumberSlow motion capture for values between 0.5 and 1 or time lapse for values > 1

Returns:

void

Remarks

If this is not called recording defaults to a value of 1 which is real time.

For values other then 1 it's suggested you disable audio recording by setting CameraComponentConfig.recordMicrophone to false when creating the camera component, or by setting the recording volume to 0 on an existing component. Otherwise the audio is out of sync with slow mo recordings and chopping for time lapse ones.

CameraComponent.setRecordingVolume() method

Set the volume of the recording audio input in real time.

Signature:

setRecordingVolume(volume: number): void;

Parameters

ParameterTypeDescription
volumenumberThe desired audio input volume, with normal values between 0 and 1. Volume defaults to 1 if this isn't called.

Returns:

void

CameraComponent.setResolutionScale() method

Changes the resolution of a running camera component.

Signature:

setResolutionScale(resolutionScale: Enum<typeof CameraResolutionScale>): Promise<void>;

Parameters

ParameterTypeDescription
resolutionScaleEnum<typeof CameraResolutionScale>A value defined in CameraResolutionScale that determines the capture resolution of the camera.

Returns:

Promise<void>

A promise that resolves when the switch to the new resolution is complete.

CameraComponent.startRecording() method

Start the recording of the camera data.

Signature:

startRecording(): void;

Returns:

void

Remarks

If this component has a mask or transform applied with Component.setMask() or Component.transition(), that mask or transform will not be applied to the recorded video.

CameraComponent.stopCamera() method

Turn the camera off, to allow for the camera to be temporarily disabled without having to switch to a new layout

Signature:

stopCamera(): void;

Returns:

void

CameraComponent.stopRecording() method

Finish recording of the camera data, after this is called no further recording is possible on this component

Signature:

stopRecording(delay?: number): Promise<VideoAsset>;

Parameters

ParameterTypeDescription
delaynumber(Optional) Stop the recording after the given delay in seconds, the default value is 0 which stops immediately. Use this if you know the cut off time of your recording so the system recording indicator can alert the user when the recording time is near the end. A subsequent call to stopRecording or pause will causes this pending stop to be cancelled and the promise resolution will fail.

Returns:

Promise<VideoAsset>

A promise that resolves when the recording is finalized with a reference to it.

Remarks

This call can take up to half a second to run, avoid blocking the user interface when calling.