frame-msg
    Preparing search index...

    Class RxPhoto

    RxPhoto class handles JPEG image data streaming and processing. It can process JPEG images with or without a header ("raw" mode), although at least one compatible JPEG header must be cached before using raw mode. It can also rotate images 90 degrees counter-clockwise to upright (default behavior). Different JPEG qualities and resolutions can be specified.

    Index

    Constructors

    Properties

    queue: null | AsyncQueue<Uint8Array<ArrayBufferLike>>

    Asynchronous queue for received photo data (Uint8Array). Null if not attached.

    Methods

    • Attaches this RxPhoto instance to a FrameMsg object to receive photo data. It initializes the photo data queue and registers a handler for incoming data chunks.

      Parameters

      • frame: FrameMsg

        The FrameMsg instance to attach to.

      Returns Promise<AsyncQueue<Uint8Array<ArrayBufferLike>>>

      A Promise that resolves to the AsyncQueue where complete photo data (Uint8Array) will be placed.

    • Detaches this RxPhoto instance from a FrameMsg object. It unregisters the data handler and clears the photo data queue and any pending chunks.

      Parameters

      • frame: FrameMsg

        The FrameMsg instance to detach from.

      Returns void

    • Handles incoming raw photo data chunks. This method is typically called by a FrameMsg instance when new photo data is received. It accumulates chunks and, upon receiving the final chunk, processes the complete image. The processed image (as a Uint8Array) is then placed onto the queue.

      Parameters

      • data: Uint8Array

        A Uint8Array containing the raw photo data chunk, prefixed with a msgCode byte.

      Returns void

    • Rotates a JPEG image 90 degrees counter-clockwise using an offscreen canvas.

      Parameters

      • inputBytes: Uint8Array

        The input JPEG image as a Uint8Array.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      the rotated JPEG image as a Uint8Array.

    • Checks if a JPEG header is cached for the given quality and resolution.

      Parameters

      • quality: JpegQuality

        The JPEG quality.

      • resolution: number

        The photo resolution.

      Returns boolean

      True if a header is cached, false otherwise.