ImgFrame

These are all the images (regardless of their encoding/format), as well as the depth/disparity “image”. ColorCamera and MonoCamera are the source of the image frame messages.

Examples of functionality

Reference

class depthai.ImgFrame
class Type

Members:

YUV422i

YUV444p

YUV420p

YUV422p

YUV400p

RGBA8888

RGB161616

RGB888p

BGR888p

RGB888i

BGR888i

RGBF16F16F16p

BGRF16F16F16p

RGBF16F16F16i

BGRF16F16F16i

GRAY8

GRAYF16

LUT2

LUT4

LUT16

RAW16

RAW14

RAW12

RAW10

RAW8

PACK10

PACK12

YUV444i

NV12

NV21

BITSTREAM

HDR

NONE

property name
getCategory(self: depthai.ImgFrame)int
getColorTemperature(self: depthai.ImgFrame)int
getCvFrame(self: object)object

Returns BGR or grayscale frame compatible with use in other opencv functions

getData(self: object) → numpy.ndarray[numpy.uint8]
getExposureTime(self: depthai.ImgFrame)datetime.timedelta
getFrame(self: object, copy: bool = False) → numpy.ndarray

Returns numpy array with shape as specified by width, height and type

getHeight(self: depthai.ImgFrame)int
getInstanceNum(self: depthai.ImgFrame)int
getLensPosition(self: depthai.ImgFrame)int
getLensPositionRaw(self: depthai.ImgFrame)float
getRaw(self: depthai.ADatatype)depthai.RawBuffer
getSensitivity(self: depthai.ImgFrame)int
getSequenceNum(self: depthai.ImgFrame)int
getTimestamp(*args, **kwargs)

Overloaded function.

  1. getTimestamp(self: depthai.ImgFrame) -> datetime.timedelta

  2. getTimestamp(self: depthai.ImgFrame, offset: depthai.CameraExposureOffset) -> datetime.timedelta

getTimestampDevice(*args, **kwargs)

Overloaded function.

  1. getTimestampDevice(self: depthai.ImgFrame) -> datetime.timedelta

  2. getTimestampDevice(self: depthai.ImgFrame, offset: depthai.CameraExposureOffset) -> datetime.timedelta

getType(self: depthai.ImgFrame)depthai.RawImgFrame.Type
getWidth(self: depthai.ImgFrame)int
setCategory(self: depthai.ImgFrame, category: int)depthai.ImgFrame
setData(*args, **kwargs)

Overloaded function.

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

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

setFrame(self: depthai.ImgFrame, array: numpy.ndarray)None

Copies array bytes to ImgFrame buffer

setHeight(self: depthai.ImgFrame, height: int)depthai.ImgFrame
setInstanceNum(self: depthai.ImgFrame, instance: int)depthai.ImgFrame
setSequenceNum(self: depthai.ImgFrame, seq: int)depthai.ImgFrame
setSize(*args, **kwargs)

Overloaded function.

  1. setSize(self: depthai.ImgFrame, width: int, height: int) -> depthai.ImgFrame

  2. setSize(self: depthai.ImgFrame, sizer: tuple[int, int]) -> depthai.ImgFrame

setTimestamp(self: depthai.ImgFrame, timestamp: datetime.timedelta)depthai.ImgFrame
setTimestampDevice(self: depthai.ImgFrame, arg0: datetime.timedelta)depthai.ImgFrame
setType(self: depthai.ImgFrame, type: depthai.RawImgFrame.Type)depthai.ImgFrame
setWidth(self: depthai.ImgFrame, width: int)depthai.ImgFrame
class dai::ImgFrame : public dai::Buffer

ImgFrame message. Carries image data and metadata.

Public Types

using Type = RawImgFrame::Type
using Specs = RawImgFrame::Specs
using CameraSettings = RawImgFrame::CameraSettings

Public Functions

ImgFrame()

Construct ImgFrame message. Timestamp is set to now

ImgFrame(std::shared_ptr<RawImgFrame> ptr)
~ImgFrame() = default
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp(CameraExposureOffset offset) const

Retrieves image timestamp (at the specified offset of exposure) related to dai::Clock::now()

std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice(CameraExposureOffset offset) const

Retrieves image timestamp (at the specified offset of exposure) directly captured from device’s monotonic clock, not synchronized to host time. Used when monotonicity is required.

unsigned int getInstanceNum() const

Retrieves instance number

unsigned int getCategory() const

Retrieves image category

unsigned int getWidth() const

Retrieves image width in pixels

unsigned int getHeight() const

Retrieves image height in pixels

Type getType() const

Retrieves image type

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

ImgFrame &setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp)

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

ImgFrame &setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp)

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

ImgFrame &setInstanceNum(unsigned int instance)

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

Parameters
  • instance: Instance number

ImgFrame &setCategory(unsigned int category)

Parameters
  • category: Image category

ImgFrame &setSequenceNum(int64_t seq)

Specifies sequence number

Parameters
  • seq: Sequence number

ImgFrame &setWidth(unsigned int width)

Specifies frame width

Parameters
  • width: frame width

ImgFrame &setHeight(unsigned int height)

Specifies frame height

Parameters
  • height: frame height

ImgFrame &setSize(unsigned int width, unsigned int height)

Specifies frame size

Parameters
  • height: frame height

  • width: frame width

ImgFrame &setSize(std::tuple<unsigned int, unsigned int> size)

Specifies frame size

Parameters
  • size: frame size

ImgFrame &setType(Type type)

Specifies frame type, RGB, BGR, …

Parameters
  • type: Type of image

ImgFrame &setFrame(cv::Mat frame)

Copies cv::Mat data to

ImgFrame buffer
Note

This API only available if OpenCV support is enabled

Parameters
  • frame: Input cv::Mat frame from which to copy the data

cv::Mat getFrame(bool copy = false)

Retrieves data as cv::Mat with specified width, height and type

Note

This API only available if OpenCV support is enabled

Return

cv::Mat with corresponding to ImgFrame parameters

Parameters
  • copy: If false only a reference to data is made, otherwise a copy

cv::Mat getCvFrame()

Retrieves cv::Mat suitable for use in common opencv functions.

ImgFrame is converted to color BGR interleaved or grayscale depending on type.
Note

This API only available if OpenCV support is enabled

A copy is always made

Return

cv::Mat for use in opencv functions

std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp() const

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

std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice() const

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

Private Functions

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

Private Members

RawImgFrame &img

Got questions?

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