# ImgFrame

These are all the images (regardless of their encoding/format), as well as the depth/disparity "image".
[Camera](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/camera.md) is the source of the image frame
messages.

## Examples of functionality

 * [Camera Previews](https://docs.luxonis.com/software-v3/depthai/examples/camera/camera_multiple_outputs.md)
 * [Depth Preview](https://docs.luxonis.com/software-v3/depthai/examples/stereo_depth/stereo_depth.md)

## Reference

### dai::ImgFrame

Kind: class

ImgFrame message. Carries image data and metadata.

#### dai::ImgFrame::CameraSettings

Kind: struct

##### int32_t exposureTimeUs

Kind: variable

##### int32_t sensitivityIso

Kind: variable

##### int32_t lensPosition

Kind: variable

##### int32_t wbColorTemp

Kind: variable

##### float lensPositionRaw

Kind: variable

##### Fsync fsync

Kind: variable

##### int32_t sensorMode

Kind: variable

##### float fps

Kind: variable

##### DEPTHAI_SERIALIZE(CameraSettings, exposureTimeUs, sensitivityIso, lensPosition, wbColorTemp, lensPositionRaw, fsync,
sensorMode, fps)

Kind: function

#### dai::ImgFrame::Specs

Kind: struct

##### Type type

Kind: variable

##### unsigned int width

Kind: variable

##### unsigned int height

Kind: variable

##### unsigned int stride

Kind: variable

##### unsigned int bytesPP

Kind: variable

##### unsigned int p1Offset

Kind: variable

##### unsigned int p2Offset

Kind: variable

##### unsigned int p3Offset

Kind: variable

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

Kind: function

#### int32_t Fsync

Kind: enum

##### NONE

Kind: enum_value

##### INPUT

Kind: enum_value

##### OUTPUT

Kind: enum_value

##### PTP

Kind: enum_value

#### Type

Kind: enum

##### YUV422i

Kind: enum_value

##### YUV444p

Kind: enum_value

##### YUV420p

Kind: enum_value

##### YUV422p

Kind: enum_value

##### YUV400p

Kind: enum_value

##### RGBA8888

Kind: enum_value

##### RGB161616

Kind: enum_value

##### RGB888p

Kind: enum_value

##### BGR888p

Kind: enum_value

##### RGB888i

Kind: enum_value

##### BGR888i

Kind: enum_value

##### LUT2

Kind: enum_value

##### LUT4

Kind: enum_value

##### LUT16

Kind: enum_value

##### RAW16

Kind: enum_value

##### RAW14

Kind: enum_value

##### RAW12

Kind: enum_value

##### RAW10

Kind: enum_value

##### RAW8

Kind: enum_value

##### PACK10

Kind: enum_value

##### PACK12

Kind: enum_value

##### YUV444i

Kind: enum_value

##### NV12

Kind: enum_value

##### NV21

Kind: enum_value

##### BITSTREAM

Kind: enum_value

##### HDR

Kind: enum_value

##### RGBF16F16F16p

Kind: enum_value

##### BGRF16F16F16p

Kind: enum_value

##### RGBF16F16F16i

Kind: enum_value

##### BGRF16F16F16i

Kind: enum_value

##### GRAY8

Kind: enum_value

##### GRAYF16

Kind: enum_value

##### RAW32

Kind: enum_value

##### NONE

Kind: enum_value

#### Specs fb

Kind: variable

#### Specs sourceFb

Kind: variable

#### CameraSettings cam

Kind: variable

#### uint32_t category

Kind: variable

#### uint32_t instanceNum

Kind: variable

#### dai::FrameEvent event

Kind: variable

#### ImgTransformation transformation

Kind: variable

#### ImgFrame()

Kind: function

Construct ImgFrame message. Timestamp is set to now

#### ImgFrame(long fd)

Kind: function

#### ImgFrame(size_t size)

Kind: function

#### ImgFrame(long fd, size_t size)

Kind: function

#### ~ImgFrame()

Kind: function

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### std::chrono::time_point< std::chrono::steady_clock, std::chrono::steady_clock::duration > getTimestamp(CameraExposureOffset
offset)

Kind: function

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)

Kind: function

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()

Kind: function

Retrieves instance number

#### unsigned int getCategory()

Kind: function

Retrieves image category

#### unsigned int getWidth()

Kind: function

Retrieves image width in pixels

#### unsigned int getStride()

Kind: function

Retrieves image line stride in bytes

#### unsigned int getPlaneStride(int planeIndex)

Kind: function

Retrieves image plane stride (offset to next plane) in bytes parameters: current: plane index, 0 or 1

#### unsigned int getHeight()

Kind: function

Retrieves image height in pixels

#### unsigned int getPlaneHeight()

Kind: function

Retrieves image plane height in lines

#### unsigned int getSourceWidth()

Kind: function

Retrieves source image width in pixels

#### unsigned int getSourceHeight()

Kind: function

Retrieves source image height in pixels

#### Type getType()

Kind: function

Retrieves image type

#### float getBytesPerPixel()

Kind: function

Retrieves image bytes per pixel

#### std::chrono::microseconds getExposureTime()

Kind: function

Retrieves exposure time

#### int getSensitivity()

Kind: function

Retrieves sensitivity, as an ISO value

#### int getColorTemperature()

Kind: function

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

#### int getLensPosition()

Kind: function

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

#### float getLensPositionRaw()

Kind: function

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

#### Fsync getFsync()

Kind: function

Retrieves effective frame sync mode for this frame.

#### int getSensorMode()

Kind: function

Retrieves selected sensor mode index for this frame.

#### float getFps()

Kind: function

Retrieves sensor FPS for this frame.

#### ImgTransformation & getTransformation()

Kind: function

Retrieves image transformation data

#### ImgFrame & setInstanceNum(unsigned int instance)

Kind: function

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

#### ImgFrame & setCategory(unsigned int category)

Kind: function

parameters: category: Image category

#### ImgFrame & setWidth(unsigned int width)

Kind: function

Specifies frame width parameters: width: frame width

#### ImgFrame & setStride(unsigned int stride)

Kind: function

Specifies frame stride parameters: stride: frame stride

#### ImgFrame & setHeight(unsigned int height)

Kind: function

Specifies frame height parameters: height: frame height

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

Kind: function

Specifies frame size parameters: height: frame height; width: frame width

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

Kind: function

Specifies frame size parameters: size: frame size

#### ImgFrame & setSourceSize(unsigned int width, unsigned int height)

Kind: function

Specifies source frame size parameters: height: frame height; width: frame width

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

Kind: function

Specifies source frame size parameters: size: frame size

#### ImgFrame & setType(Type type)

Kind: function

Specifies frame type, RGB, BGR, ... parameters: type: Type of image

#### ImgFrame & setTransformation(const ImgTransformation & transformation)

Kind: function

Specifies image transformation data parameters: transformation: transformation data

#### Point2f remapPointFromSource(const Point2f & point)

Kind: function

Remap a point from the current frame to the source frame parameters: point: point to remap return: remapped point

#### Point2f remapPointToSource(const Point2f & point)

Kind: function

Remap a point from the source frame to the current frame parameters: point: point to remap return: remapped point

#### Rect remapRectFromSource(const Rect & rect)

Kind: function

Remap a rectangle from the source frame to the current frame parameters: rect: rectangle to remap return: remapped rectangle

#### Rect remapRectToSource(const Rect & rect)

Kind: function

Remap a rectangle from the current frame to the source frame parameters: rect: rectangle to remap return: remapped rectangle

#### ImgFrame & setMetadata(const ImgFrame & sourceFrame)

Kind: function

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)

Kind: function

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)

Kind: function

Convenience function to set the data of the ImgFrame parameters: data: data to set

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

Kind: function

Convenience function to set the data of the ImgFrame parameters: data: data to set

#### std::shared_ptr< ImgFrame > clone()

Kind: function

Create a clone of the ImgFrame with metadata and data copied return: cloned ImgFrame

#### float getSourceDFov()

Kind: function

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

#### float getSourceHFov()

Kind: function

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()

Kind: function

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()

Kind: function

Check that the image transformation match the image size return: true if the transformations are valid

#### ImgFrame & setFrame(cv::Mat frame)

Kind: function

note: This API only available if OpenCV support is enabled ImgFrame buffer parameters: frame: Input cv::Mat frame from which to
copy the data

#### cv::Mat getFrame(bool copy)

Kind: function

note: This API only available if OpenCV support is enabled parameters: copy: If false only a reference to data is made, otherwise
a copy return: cv::Mat with corresponding to ImgFrame parameters

#### cv::Mat getCvFrame(cv::MatAllocator * allocator)

Kind: function

note: This API only available if OpenCV support is enabled ImgFrame is converted to color BGR interleaved or grayscale depending
on type. A copy is always made return: cv::Mat for use in opencv functions

#### ImgFrame & setCvFrame(cv::Mat frame, Type type)

Kind: function

note: This API only available if OpenCV support is enabled ImgFrame buffer and converts to a specific type. parameters: frame:
Input cv::Mat BGR frame or single channel frame from which to copy the data from.; type: Specifies the target image format for the
internal buffer, including color space, layout, and bit depth.

#### DEPTHAI_SERIALIZE(ImgFrame, Buffer::ts, Buffer::tsDevice, Buffer::sequenceNum, fb, sourceFb, cam, category, instanceNum,
transformation)

Kind: function

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

Kind: function

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

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

Kind: function

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

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
