Sequence Frame Source

Defined under the namespace Scandit.Datacapture.Core

SequenceFrameSource
class SequenceFrameSource : FrameSource

Added in version 8.6.0

Emits frames added via addFrame().

This class can be used if the camera is not handled by Scandit Data Capture SDK (i.e., when using another framework handling the camera, like ARKit). Register an instance of this class as the data source via DataCaptureContext.frameSource and then add frames coming from the camera via addFrame().

Note

Register the frame source and switch it on once, outside of your frame loop, and then call addFrame() for each frame. Do not create a frame source per frame, and do not set one on the DataCaptureContext from inside the frame loop. In particular, do not feed a continuous camera stream through ImageFrameSource — it is meant for single images and turns off after each one.

On this platform both mistakes are expensive rather than merely wasteful: setting a frame source re-serializes the whole DataCaptureContext, and ImageFrameSource encodes every image it is given to pass it over the bridge. Measured on a Flutter sample at 720p, the per-frame variant cost 520 ms per frame against 21 ms for the loop below.

create(position, lensPosition)
static create(position: CameraPosition,
        lensPosition?: number): SequenceFrameSource

Added in version 8.6.0

Constructs a new SequenceFrameSource for the given CameraPosition. The lens position (0.0-1.0) sets the capture device lens position on iOS and is ignored on Android.

desiredState
get desiredState(): FrameSourceState

Added in version 8.6.0

Implemented from FrameSource. See FrameSource.desiredState.

getCurrentState()
getCurrentState(): Promise<FrameSourceState>

Added in version 8.6.0

Implemented from FrameSource. See FrameSource.getCurrentState.

addListener(listener)
addListener(listener: FrameSourceListener): void

Added in version 8.6.0

Implemented from FrameSource. See FrameSource.addListener().

removeListener(listener)
removeListener(listener: FrameSourceListener): void

Added in version 8.6.0

Implemented from FrameSource. See FrameSource.removeListener().

switchToDesiredState(state)
switchToDesiredState(state: FrameSourceState): Promise<void>

Added in version 8.6.0

Convenience method for FrameSource.switchToDesiredState(): it is same as calling FrameSource.switchToDesiredState() with the second argument set to null.

addFrame(width, height, frameData)
addFrame(width: number,
        height: number,
        frameData: string): Promise<void>

Added in version 8.6.0

Adds a frame with the given width and height. The frame data must be the Base64 encoding of the raw NV21 bytes of the frame. If this frame source is On and connected to a DataCaptureContext this is the next frame that will be processed.