EncodedFrame

The EncodedFrame message is an output of the VideoEncoder node. This message is used to represent a frame that has been encoded by the VideoEncoder. It provides various properties and methods for interacting with the encoded frame data.

Structure

The EncodedFrame class inherits from Buffer and includes several nested classes and methods for accessing and modifying frame properties. Here are the primary components of the EncodedFrame class:

  • FrameType: Enumerates the types of frames that can be encoded (I, P, B, Unknown).

  • Profile: Indicates the encoding profile used (AVC, HEVC, JPEG).

FrameType

The FrameType class identifies the type of the encoded frame. The available types are:

  • B: Represents a bi-directional predicted frame.

  • I: Represents an intra-coded frame.

  • P: Represents a predicted frame.

  • Unknown: Used when the frame type cannot be determined.

Profile

The Profile class specifies the encoding profile used for the frame. The supported profiles are:

  • AVC: H.264/AVC encoding profile.

  • HEVC: H.265/HEVC encoding profile.

  • JPEG: JPEG encoding profile.

Reference

class depthai.EncodedFrame
class FrameType

Members:

I

P

B

Unknown

property name
class Profile

Members:

JPEG

AVC

HEVC

property name
getBitrate(self: depthai.EncodedFrame)int

Retrieves the encoding bitrate

getColorTemperature(self: depthai.EncodedFrame)int

Retrieves white-balance color temperature of the light source, in kelvins

getData(self: object) → numpy.ndarray[numpy.uint8]

Get non-owning reference to internal buffer

Returns

Reference to internal buffer

getExposureTime(self: depthai.EncodedFrame)datetime.timedelta

Retrieves exposure time

getFrameType(self: depthai.EncodedFrame)depthai.RawEncodedFrame.FrameType

Retrieves frame type (H26x only)

getInstanceNum(self: depthai.EncodedFrame)int

Retrieves instance number

getLensPosition(self: depthai.EncodedFrame)int

Retrieves lens position, range 0..255. Returns -1 if not available

getLensPositionRaw(self: depthai.EncodedFrame)float

Retrieves lens position, range 0.0f..1.0f. Returns -1 if not available

getLossless(self: depthai.EncodedFrame)bool

Returns true if encoding is lossless (JPEG only)

getProfile(self: depthai.EncodedFrame)depthai.RawEncodedFrame.Profile

Retrieves the encoding profile (JPEG, AVC or HEVC)

getQuality(self: depthai.EncodedFrame)int

Retrieves the encoding quality

getRaw(self: depthai.ADatatype)depthai.RawBuffer
getSensitivity(self: depthai.EncodedFrame)int

Retrieves sensitivity, as an ISO value

getSequenceNum(self: depthai.EncodedFrame)int

Retrieves sequence number

getTimestamp(self: depthai.EncodedFrame)datetime.timedelta

Retrieves timestamp related to dai::Clock::now()

getTimestampDevice(self: depthai.EncodedFrame)datetime.timedelta

Retrieves timestamp directly captured from device’s monotonic clock, not synchronized to host time. Used mostly for debugging

setBitrate(self: depthai.EncodedFrame, arg0: int)depthai.EncodedFrame

Retrieves the encoding bitrate

setData(*args, **kwargs)

Overloaded function.

  1. setData(self: depthai.Buffer, arg0: List[int]) -> None

Parameter data:

Copies data to internal buffer

  1. setData(self: depthai.Buffer, arg0: numpy.ndarray[numpy.uint8]) -> None

Parameter data:

Copies data to internal buffer

setFrameType(self: depthai.EncodedFrame, arg0: depthai.RawEncodedFrame.FrameType)depthai.EncodedFrame

Retrieves frame type (H26x only)

setLossless(self: depthai.EncodedFrame, arg0: bool)depthai.EncodedFrame

Returns true if encoding is lossless (JPEG only)

setProfile(self: depthai.EncodedFrame, arg0: depthai.RawEncodedFrame.Profile)depthai.EncodedFrame

Retrieves the encoding profile (JPEG, AVC or HEVC)

setQuality(self: depthai.EncodedFrame, arg0: int)depthai.EncodedFrame

Retrieves the encoding quality

setSequenceNum(self: depthai.EncodedFrame, arg0: int)depthai.EncodedFrame

Specifies sequence number

Parameter seq:

Sequence number

setTimestamp(self: depthai.EncodedFrame, arg0: datetime.timedelta)depthai.EncodedFrame

Retrieves image timestamp related to dai::Clock::now()

setTimestampDevice(self: depthai.EncodedFrame, arg0: datetime.timedelta)depthai.EncodedFrame

Sets image timestamp related to dai::Clock::now()

class dai::EncodedFrame : public dai::Buffer

Public Types

using Profile = RawEncodedFrame::Profile
using FrameType = RawEncodedFrame::FrameType

Public Functions

EncodedFrame()

Construct EncodedFrame message. Timestamp is set to now

EncodedFrame(std::shared_ptr<RawEncodedFrame> ptr)
~EncodedFrame() = default
unsigned int getInstanceNum() const

Retrieves instance number

std::chrono::microseconds getExposureTime() const

Retrieves exposure time

int getSensitivity() const

Retrieves sensitivity, as an ISO value

int getColorTemperature() const

Retrieves white-balance color temperature of the light source, in kelvins

int getLensPosition() const

Retrieves lens position, range 0..255. Returns -1 if not available

float getLensPositionRaw() const

Retrieves lens position, range 0.0f..1.0f. Returns -1 if not available

unsigned int getQuality() const

Retrieves the encoding quality

unsigned int getBitrate() const

Retrieves the encoding bitrate

bool getLossless() const

Returns true if encoding is lossless (JPEG only)

FrameType getFrameType() const

Retrieves frame type (H26x only)

Profile getProfile() const

Retrieves the encoding profile (JPEG, AVC or HEVC)

EncodedFrame &setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp)

Retrieves image timestamp related to dai::Clock::now()

EncodedFrame &setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp)

Sets image timestamp related to dai::Clock::now()

EncodedFrame &setSequenceNum(int64_t seq)

Specifies sequence number

Parameters
  • seq: Sequence number

EncodedFrame &setInstanceNum(unsigned int instance)

Instance number relates to the origin of the frame (which camera)

Parameters
  • instance: Instance number

EncodedFrame &setQuality(unsigned int quality)

Specifies the encoding quality

Parameters
  • quality: Encoding quality

EncodedFrame &setBitrate(unsigned int bitrate)

Specifies the encoding quality

Parameters
  • quality: Encoding quality

EncodedFrame &setLossless(bool lossless)

Specifies if encoding is lossless (JPEG only)

Parameters
  • lossless: True if lossless

EncodedFrame &setFrameType(FrameType type)

Specifies the frame type (H26x only)

Parameters
  • type: Type of h26x frame (I, P, B)

EncodedFrame &setProfile(Profile profile)

Specifies the encoding profile

Parameters
  • profile: Encoding profile

Private Functions

std::shared_ptr<RawBuffer> serialize() const override

Private Members

RawEncodedFrame &frame

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.