Class ImgFrame

Nested Relationships

Nested Types

Inheritance Relationships

Base Types

Class Documentation

class ImgFrame : public dai::Buffer, public dai::ProtoSerializable

ImgFrame message. Carries image data and metadata.

Public Types

enum class Type

Values:

enumerator YUV422i
enumerator YUV444p
enumerator YUV420p
enumerator YUV422p
enumerator YUV400p
enumerator RGBA8888
enumerator RGB161616
enumerator RGB888p
enumerator BGR888p
enumerator RGB888i
enumerator BGR888i
enumerator LUT2
enumerator LUT4
enumerator LUT16
enumerator RAW16
enumerator RAW14
enumerator RAW12
enumerator RAW10
enumerator RAW8
enumerator PACK10
enumerator PACK12
enumerator YUV444i
enumerator NV12
enumerator NV21
enumerator BITSTREAM
enumerator HDR
enumerator RGBF16F16F16p
enumerator BGRF16F16F16p
enumerator RGBF16F16F16i
enumerator BGRF16F16F16i
enumerator GRAY8
enumerator GRAYF16
enumerator RAW32
enumerator NONE

Public Functions

ImgFrame()

Construct ImgFrame message. Timestamp is set to now

ImgFrame(long fd)
ImgFrame(size_t size)
ImgFrame(long fd, size_t size)
virtual ~ImgFrame()
virtual void serialize(std::vector<std::uint8_t> &metadata, DatatypeEnum &datatype) const override
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 getStride() const

Retrieves image line stride in bytes

unsigned int getPlaneStride(int planeIndex = 0) const

Retrieves image plane stride (offset to next plane) in bytes

Parameters:

current – plane index, 0 or 1

unsigned int getHeight() const

Retrieves image height in pixels

unsigned int getPlaneHeight() const

Retrieves image plane height in lines

unsigned int getSourceWidth() const

Retrieves source image width in pixels

unsigned int getSourceHeight() const

Retrieves source image height in pixels

Type getType() const

Retrieves image type

float getBytesPerPixel() const

Retrieves image bytes per pixel

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 &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 &setWidth(unsigned int width)

Specifies frame width

Parameters:

width – frame width

ImgFrame &setStride(unsigned int stride)

Specifies frame stride

Parameters:

stride – frame stride

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 &setSourceSize(unsigned int width, unsigned int height)

Specifies source frame size

Parameters:
  • height – frame height

  • width – frame width

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

Specifies source frame size

Parameters:

size – frame size

ImgFrame &setType(Type type)

Specifies frame type, RGB, BGR, …

Parameters:

type – Type of image

Point2f remapPointFromSource(const Point2f &point) const

Remap a point from the current frame to the source frame

Parameters:

point – point to remap

Returns:

remapped point

Point2f remapPointToSource(const Point2f &point) const

Remap a point from the source frame to the current frame

Parameters:

point – point to remap

Returns:

remapped point

Rect remapRectFromSource(const Rect &rect) const

Remap a rectangle from the source frame to the current frame

Parameters:

rect – rectangle to remap

Returns:

remapped rectangle

Rect remapRectToSource(const Rect &rect) const

Remap a rectangle from the current frame to the source frame

Parameters:

rect – rectangle to remap

Returns:

remapped rectangle

ImgFrame &setMetadata(const ImgFrame &sourceFrame)

Convenience function to initialize meta data from another frame Copies over timestamps, transformations done on the image, etc.

Parameters:

sourceFrame – source frame from which the metadata is taken from

ImgFrame &setMetadata(const std::shared_ptr<ImgFrame> &sourceFrame)

Convenience function to initialize meta data from another frame Copies over timestamps, transformations done on the image, etc.

Parameters:

sourceFrame – shared pointer to source frame from which the metadata is taken from

ImgFrame &copyDataFrom(const ImgFrame &sourceFrame)

Convenience function to set the data of the ImgFrame

Parameters:

data – data to set

ImgFrame &copyDataFrom(const std::shared_ptr<ImgFrame> &sourceFrame)

Convenience function to set the data of the ImgFrame

Parameters:

data – data to set

std::shared_ptr<ImgFrame> clone() const

Create a clone of the ImgFrame with metadata and data copied

Returns:

cloned ImgFrame

float getSourceDFov() const

Note

Fov API works correctly only on rectilinear frames Get the source diagonal field of view in degrees

Returns:

field of view in degrees

float getSourceHFov() const

Note

Fov API works correctly only on rectilinear frames Get the source horizontal field of view

Parameters:

degrees – field of view in degrees

float getSourceVFov() const

Note

Fov API works correctly only on rectilinear frames Get the source vertical field of view

Parameters:

degrees – field of view in degrees

bool validateTransformations() const

Check that the image transformation match the image size

Returns:

true if the transformations are valid

template<typename ...T>
inline ImgFrame &setFrame(T...)
template<typename ...T>
inline void getFrame(T...)
template<typename ...T>
inline void getCvFrame(T...)
template<typename ...T>
inline ImgFrame &setCvFrame(T...)
DEPTHAI_SERIALIZE(ImgFrame, Buffer::ts, Buffer::tsDevice, Buffer::sequenceNum, fb, sourceFb, cam, category, instanceNum, transformation)
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

Public Members

Specs fb = {}
Specs sourceFb = {}
CameraSettings cam
uint32_t category = 0
uint32_t instanceNum = 0
dai::FrameEvent event = dai::FrameEvent::NONE
ImgTransformation transformation

Public Static Functions

static Point2f remapPointBetweenFrames(const Point2f &originPoint, const ImgFrame &originFrame, const ImgFrame &destFrame)

Remap point between two frames

Parameters:
  • originPoint – point to remap

  • originFrame – origin frame

  • destFrame – destination frame

Returns:

remapped point

static Rect remapRectBetweenFrames(const Rect &originRect, const ImgFrame &originFrame, const ImgFrame &destFrame)

Remap rectangle between two frames

Parameters:
  • originRect – rectangle to remap

  • originFrame – origin frame

  • destFrame – destination frame

Returns:

remapped rectangle

static inline constexpr int typeToBpp(Type type)
static inline constexpr bool isInterleaved(Type type)
static inline constexpr Type toPlanar(Type type)
static inline constexpr Type toInterleaved(Type type)
struct CameraSettings

Public Members

int32_t exposureTimeUs
int32_t sensitivityIso
int32_t lensPosition
int32_t wbColorTemp
float lensPositionRaw
template<typename ...T>
struct dependent_false

Public Static Attributes

static constexpr bool value = false
struct Specs

Public Functions

DEPTHAI_SERIALIZE(Specs, type, width, height, stride, bytesPP, p1Offset, p2Offset, p3Offset)

Public Members

Type type = Type::NONE
unsigned int width
unsigned int height
unsigned int stride
unsigned int bytesPP
unsigned int p1Offset
unsigned int p2Offset
unsigned int p3Offset