Types
VIDEOCAPTURE

Handle of VideoCapture object

Used to handle pointer (void *) to VideoCapture object

VIDEOFRAME

Handle of VideoFrame object

Used to handle pointer (void *) to VideoFrame object

Enumerations
PIXFMT

Image buffer pixel formats

PIXFMT_GRAYSCALE

Grayscale 8 bpp format

PIXFMT_RGB24

RGB 24 bpp format

PIXFMT_BGR24

BGR 24 bpp format

PIXFMT_YUV420

YUV420 format

ERR_CAPTURE

Video capture error codes

ERR_CAPTURE_OPEN_VIDEO

Error opening video source

ERR_CAPTURE_READ_FRAME

Error reading frame

ERR_CAPTURE_EOF

End of file

TEXT_POSITION

Text position on video frame

TEXT_POSITION_LEFT_TOP

Text position in the left top corner of video frame

TEXT_POSITION_RIGHT_TOP

Text position in the right top corner of video frame

TEXT_POSITION_LEFT_BOTTOM

Text position in the left bottom corner of video frame

TEXT_POSITION_RIGHT_BOTTOM

Text position in the right bottom corner of video frame

Callbacks
FrameCapturedCallback

Invokes by VideoCapture object on new video frame capture

Parameters
hVideoCapture

Handle of VideoCapture object

hFrame

Handle of VideoFrame object

customObject

Pointer to custom object, defined in VideoCapture_Create function

Notes

After this event the receives VideoFrame object have reference count = 1 and you need to call VideoFrame_Release function to release it.

CaptureErrorCallback

Invokes by VideoCapture object on error

Parameters
hVideoCapture

Handle of VideoCapture object

errorCode

Error code (see ERR_CAPTURE enumeration values)

customObject

Pointer to custom object, defined in VideoCapture_Create function

Video Capture Functions
VideoCapture_Create
VIDEOCAPTURE DTKVIDAPI VideoCapture_Create(
frameCapturedCallback,
captureErrorCallback,
void
customObject
)

Create Video Capture object

Parameters
frameCapturedCallback

FrameCapturedCallback function

captureErrorCallback

CaptureErrorCallback function

customObject
void*

Pointer to custom object

VideoCapture_Destroy
void DTKVIDAPI VideoCapture_Destroy(
hVideoCapture
)

Destroy Video Capture object

Parameters
hVideoCapture

Handle of VideoCapture object

VideoCapture_StartCaptureFromFile
int DTKVIDAPI VideoCapture_StartCaptureFromFile(
hVideoCapture,
const 
char
fileName,
int 
repeat_count
)

Start video capture from video file

Parameters
hVideoCapture

Handle of VideoCapture object

fileName Video

file path

repeat_count
int

Repeat count, default 0 (always repeat)

Return

Value 0 on success, or one of ERR_CAPTURE enumeration values.

VideoCapture_StartCaptureFromIPCamera
int DTKVIDAPI VideoCapture_StartCaptureFromIPCamera(
hVideoCapture,
const 
char
ipCameraURL
)

Start video capture from IP camera

Parameters
hVideoCapture

Handle of VideoCapture object

ipCameraURL
const char*

IP camera URL (RTSP or HTTP). The URL must include user name and password if required.

Return

Value 0 on success, or one of ERR_CAPTURE enumeration values.

VideoCapture_StartCaptureFromDevice
int DTKVIDAPI VideoCapture_StartCaptureFromDevice(
hVideoCapture,
int 
deviceIndex,
int 
captureWidth,
int 
captureHeight
)

Start video capture from video device

Parameters
hVideoCapture

Handle of VideoCapture object

deviceIndex
int

Device index starting from 0 (0 - first video device)

captureWidth
int

Capture X-resolution in pixels

captureHeight
int

Capture Y-resolution in pixels

Return

Value 0 on success, or one of ERR_CAPTURE enumeration values.

Notes

If video device do not support defined resolution, then will be selected nearest resolution supported by this device.

VideoCapture_GetVideoWidth
int DTKVIDAPI VideoCapture_GetVideoWidth(
hVideoCapture
)

Gets the width of the video stream in pixels

Parameters
hVideoCapture

Handle of VideoCapture object

Return

Width of the video stream in pixels. If the video stream is not started, the return value is 0.

VideoCapture_GetVideoHeight
int DTKVIDAPI VideoCapture_GetVideoHeight(
hVideoCapture
)

Gets the height of the video stream in pixels

Parameters
hVideoCapture

Handle of VideoCapture object

Return

Height of the video stream in pixels. If the video stream is not started, the return value is 0.

VideoCapture_GetVideoFPS
int DTKVIDAPI VideoCapture_GetVideoFPS(
hVideoCapture
)

Gets the frames per second (FPS) of the video stream

Parameters
hVideoCapture

Handle of VideoCapture object

Return

Frames per second (FPS) of the video stream. If the video stream is not started, the return value is 0.

VideoCapture_GetVideoFOURCC
int DTKVIDAPI VideoCapture_GetVideoFOURCC(
hVideoCapture
)

Gets the FOURCC code of the video stream

Parameters
hVideoCapture

Handle of VideoCapture object

Return

FOURCC code (32 bit integer) of the video stream. If the video stream is not started, the return value is 0.

VideoCapture_StopCapture
int DTKVIDAPI VideoCapture_StopCapture(
hVideoCapture
)

Stop video capture

Parameters
hVideoCapture

Handle of VideoCapture object

Return

Value 0 on success, or one of ERR_CAPTURE enumeration values.

VideoCapture_IsStarted
bool DTKVIDAPI VideoCapture_IsStarted(
hVideoCapture
)

Check if video capture is started

Parameters
hVideoCapture

Handle of VideoCapture object

Return

Value True if video capture is started, otherwise False.

VideoCapture_GetLibraryVersion
int DTKVIDAPI VideoCapture_GetLibraryVersion(
char
buffer,
int 
buff_size
)

Return library version

Parameters
buffer
char*

Pointer to string buffer which receives library version

buff_size
int

Size of string buffer

Returns

Number of bytes copied to buffer. If buffer = NULL or buff_size = 0, then function return number of bytes required for store result string

VideoCapture_SetRtspOverTcp
void DTKVIDAPI VideoCapture_SetRtspOverTcp(
hVideoCapture,
bool 
rtsp_transport_tcp
)

Sets a value indicating whether the VideoCapture will use TCP transport for RTSP stream

Parameters
hVideoCapture

Handle of VideoCapture object

rtsp_transport_tcp
bool

true - use TCP transport, false - use UDP transport

VideoCapture_GetRtspOverTcp
bool DTKVIDAPI VideoCapture_GetRtspOverTcp(
hVideoCapture
)

Gets a value indicating whether the VideoCapture will use TCP transport for RTSP stream

Parameters
hVideoCapture

Handle of VideoCapture object

Returns

Boolean value

VideoCapture_SetRenderingWindow
void DTKVIDAPI VideoCapture_SetRenderingWindow(
hVideoCapture,
void
nativeWindow
)

Sets the rendering window for the video stream

Parameters
hVideoCapture

Handle of VideoCapture object

nativeWindow
void*

Pointer to native window handle (HWND on Windows or X11 window handle on Linux)

VideoCapture_PolygonsClear
void DTKVIDAPI VideoCapture_PolygonsClear(
hVideoCapture
)

Clears all polygons defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

Notes

This function can be used to clear all polygons defined in the video capture object.

VideoCapture_AddPolygon
int DTKVIDAPI VideoCapture_AddPolygon(
hVideoCapture,
const 
char
name
)

Adds a new polygon to the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

name
const char*

Name of the polygon

Returns

Index of the new polygon

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_AddPolygonPoint
int DTKVIDAPI VideoCapture_AddPolygonPoint(
hVideoCapture,
int 
polygonIndex,
int 
x,
int 
y
)

Adds a new point to the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

x
int

X coordinate of the point

y
int

Y coordinate of the point

Returns

Index of the new point

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_DeletePolygonPoint
int DTKVIDAPI VideoCapture_DeletePolygonPoint(
hVideoCapture,
int 
polygonIndex,
int 
pointIndex
)

Deletes a point from the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

pointIndex
int

Index of the point

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_SetPolygonName
int DTKVIDAPI VideoCapture_SetPolygonName(
hVideoCapture,
int 
polygonIndex,
const 
char
name
)

Sets the name of the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

name
const char*

Name of the polygon

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_SetPolygonPoint
int DTKVIDAPI VideoCapture_SetPolygonPoint(
hVideoCapture,
int 
polygonIndex,
int 
pointIndex,
int 
x,
int 
y
)

Sets the coordinates of the point of the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

pointIndex
int

Index of the point

x
int

X coordinate of the point

y
int

Y coordinate of the point

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_GetPolygonPoint
int DTKVIDAPI VideoCapture_GetPolygonPoint(
hVideoCapture,
int 
polygonIndex,
int 
pointIndex,
int
x,
int
y
)

Gets the coordinates of the point of the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

pointIndex
int

Index of the point

x
int*

Pointer to X coordinate of the point

y
int*

Pointer to Y coordinate of the point

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_GetPolygonName
int DTKVIDAPI VideoCapture_GetPolygonName(
hVideoCapture,
int 
polygonIndex,
char
name,
int 
nameSize
)

Gets the name of the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

name
char*

Pointer to string buffer to receive name of the polygon

nameSize
int

Size of string buffer

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_GetPolygonPointCount
int DTKVIDAPI VideoCapture_GetPolygonPointCount(
hVideoCapture,
int 
polygonIndex
)

Gets the number of points of the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoCapture_DeletePolygon
int DTKVIDAPI VideoCapture_DeletePolygon(
hVideoCapture,
int 
polygonIndex
)

Deletes the polygon defined in the video capture object

Parameters
hVideoCapture

Handle of VideoCapture object

polygonIndex
int

Index of the polygon

Returns

Value 0 on success, otherwise -1

Notes

The polygons will be drown on video frames displayed in the rendering window defined by VideoCapture_SetRenderingWindow function.

VideoFrame Functions
VideoFrame_CreateFromImageBuffer
VIDEOFRAME DTKVIDAPI VideoFrame_CreateFromImageBuffer(
void
pBuffer,
int 
width,
int 
height,
int 
stride,
pixelFormat,
int64 
timestamp
)

Create VideoFrame object from image buffer

Parameters
pBuffer
void*

Pointer to buffer of image pixels data

width
int

Width of image in pixels

height
int

Height of image in pixel

stride
int

Size of one image row in bytes

pixelFormat

Pixel format, PIXFMT enumeration

timestamp
int64

Frame timestamp received from camera (optional). If you have not this value, then use -1

Return

Handle of VideoFrame object

Notes

After creating the VideoFrame object the reference count is set to 1 and need to call VideoFrame_Release function when you do not need this object anymore.

VideoFrame_AddRef
int DTKVIDAPI VideoFrame_AddRef(
hFrame
)

Increments the reference count of the VideoFrame object

Parameters
hFrame

Handle of VideoFrame object

Return

Reference count of the VideoFrame object

VideoFrame_Release
int DTKVIDAPI VideoFrame_Release(
hFrame
)

Decrements the reference count of the VideoFrame object

Parameters
hFrame

Handle of VideoFrame object

Return

Reference count of the VideoFrame object

Notes

When the reference count reaches zero, the VideoFrame object is destroyed.

VideoFrame_GetWidth
int DTKVIDAPI VideoFrame_GetWidth(
hFrame
)

Gets frame width in pixels

Parameters
hFrame

Handle of VideoFrame object

VideoFrame_GetHeight
int DTKVIDAPI VideoFrame_GetHeight(
hFrame
)

Gets frame height in pixels

Parameters
hFrame

Handle of VideoFrame object

VideoFrame_Timestamp
int64 DTKVIDAPI VideoFrame_Timestamp(
hFrame
)

Gets the timestamp of a video frame

Parameters
hFrame

Handle of VideoFrame object

VideoFrame_GetImageBuffer
int DTKVIDAPI VideoFrame_GetImageBuffer(
hFrame,
format,
void** 
pImageBuffer,
int
width,
int
height,
int
stride
)

Gets the image buffer of frame in specified pixel format

Parameters
hFrame

Handle of VideoFrame object

format

pixel format

pImageBuffer
void**

Pointer to a pointer which receives the image buffer containing pixel data of the image

width
int*

Pointer to integer variable which receives width of image

height
int*

Pointer to integer variable which receives height of image

stride
int*

Pointer to integer variable which receives size of one image row in bytes

Notes

You need to call VideoFrame_FreeImageBuffer with received pointer to free memory.

VideoFrame_GetObjectImageBuffer
int DTKVIDAPI VideoFrame_GetObjectImageBuffer(
hFrame,
int 
x,
int 
y,
int 
w,
int 
h,
format,
void** 
pImageBuffer,
int
width,
int
height,
int
stride
)

Gets an image buffer of the cropped rectangle (object bounding box) of the frame in the specified pixel format.

Parameters
hFrame

Handle of VideoFrame object

x
int

X coordinate of the top-left corner of the rectangle

y
int

Y coordinate of the top-left corner of the rectangle

w
int

Width of the rectangle

h
int

Height of the rectangle

format

pixel format

pImageBuffer
void**

Pointer to a pointer which receives the image buffer containing pixel data of the image

width
int*

Pointer to integer variable which receives width of image

height
int*

Pointer to integer variable which receives height of image

stride
int*

Pointer to integer variable which receives size of one image row in bytes

Notes

You need to call VideoFrame_FreeImageBuffer with received pointer to free memory.

VideoFrame_FreeImageBuffer
void DTKVIDAPI VideoFrame_FreeImageBuffer(
void
pImageBuffer
)

Deletes image buffer

Parameters
pImageBuffer
void*

Pointer to image buffer received using VideoFrame_GetImageBuffer function.

VideoFrame_DrawText
void DTKVIDAPI VideoFrame_DrawText(
hFrame,
const 
char
text,
position
)

Draws text on video frame

Parameters
hFrame

Handle of VideoFrame object

text
const char*

Text to draw

position

Position of text on video frame, TEXT_POSITION enumeration

Notes

This function draws text on video frame in the specified position.  The text will be drawn using default font and color.

VideoFrame_DrawBox
void DTKVIDAPI VideoFrame_DrawBox(
hFrame,
int 
x,
int 
y,
int 
w,
int 
h,
int 
color,
int 
thickness
)

Draws a box on video frame

Parameters
hFrame

Handle of VideoFrame object

x
int

X coordinate of the top-left corner of the box

y
int

Y coordinate of the top-left corner of the box

w
int

Width of the box

h
int

Height of the box

color
int

Color of the box in RGB format (0xRRGGBB)

thickness
int

Thickness of the box border in pixels

Notes

This function draws a box on video frame with specified position, size, color and border thickness.