Toybrick EN

中文 / EN
Toybrick EN Wiki TB-96AI System Software Packages
System Software Packages

ISP System Library

ISP Install And Compile

1、Install ISP Lib:

sudo dnf install librockchip_isp

2、Compiling And linking:

LDDFLAGS: = -lcam_engine_cifisp -lcam_ia

3、Include Header Files

#include <rockchip/rockchip_isp.h>

ISP Interfaces Description

rkisp_start: Create  ISP engine instance

int rkisp_start(void* &engine, int vidFd, const char* ispNode, const char* tuningFile);

Parameter Description:

1)、Engine:The ISP engine instance address, which returns the instance address after rkisp_start creates the engine instance.

2)、vidFd:Video stream fd,The video node handle that the user uses when capturing an image.

3)、ispNode:ISP node name,for example: ”/dev/video1”,This node is different from the node where the user captured the image.

4)、tuningFile:IQ xml file. for example:”/etc/cam_iq_ov9750.xml”,It  records the parameters required for camera 3A (auto white balance, auto  exposure, auto focus) operation.

5)、Return value: Return 0 on success and Engine is not NULL.


1、For the built-in camera, n cameras will enumerate 4 video nodes。

video(4*(n-1)+2)node is the video node that captures the image operation for the user,such as video2video6

video(4*(n-1)+1)node is the video node that performs 3A operations for the ISP library,such as video1video5

2、After use, you must use rkisp_stop to stop the ISP engine and free up the occupied resources.

3、You must select tuningFile that matches the camera, or your ISP engine won't work.

4、Image format currently captured by ISP cameras is: V4L2_PIX_FMT_NV12

rkisp_stop:Stop and destroy the ISP engine instance, freeing up resources

int rkisp_stop(void* &engine)

Parameters   Description:

engine: ISP engine instance address,create by rkisp_start

Return value: Return 0 on success

rkisp_setFocusMode:Set the focus mode

int rkisp_setFocusMode(void* &engine, enum HAL_AF_MODE fcMode);

Parameters   Description

     1)engine: ISP engine instance addresscreate by rkisp_start

     2)fcMode:Focus mode Settings

     HAL_AF_MODE_NOT_SET:Turn off the focus function

     HAL_AF_MODE_CONTINUOUS_VIDE:Set the continuous focus

Return value: Returns 0 on success

Attention:OV9750 can't support Autofocus ,and setting focus mode is not allowed (should turn off by default),otherwise an error will occur.

MPP System Library

MPP Install And Compile

1、Install MPP Lib

sudo dnf install librockchip_mpp-devel

2、Compiling And linking:

LDDFLAGS: = -lrockchip_mpp

3、Include Header Files:

#include <rockchip/rockchip_mpp.h>

MPP Interfaces Description

1、Create an instance of the MPP decoder:MppDecoderCreate, if create sucessfully,it returns the MPP structure pointer .

MppDecoder *dec = MppDecoderCreate(DECODE_TYPE_H264);

2、Destroy the MPP instance:MppDecoderDestroy


3、Decoding image enqueue operation:enqueue

dec->ops->enqueue(dec, data, size)

Parameters   Description

     1)data:Store H264 image data

     2)size:Image size

4、Decoding image dequeue operation:dequeue;Block until the MPP decodes successfully, and the function returns.

DecFrame *frame = dec->ops->dequeue(dec);

DecFrame structural members Description

1)v4l2Format:The decoded image format,Only support V4L2_FIX_FMT_NV12 currently

2)width:Image width

3)height:Image height

5、free  DecFrame Pointer:freeFrame;After successfully decoding and processing  the image, you must call this function to free memory.


RGA System Library

RGA Install And Compile

1、Install RGA Lib

sudo dnf install librockchip_rga-devel

2、Compiling And linking:

LDDFLAGS: = -lrockchip_rga -ldrm

3、Include Header Files:

extern “c” {#include <rockchip/rockchip_rga.h>}

RGA Interfaces Description

1、RgaCreate:Create an instance of the RGA if create sucessfully,it returns the RGA structure pointer .

RockchipRga *rga = rgaCreate();

2、RgaDestory:Destroy the RGA instance


3、initCtx:Clear the RGA context.


attention:If the context is not cleared, the image parameters are set as before for the next RGA operation.

4、setRotate: Set the selected rotation Angle

rga->ops->setRotate(rga, rotate);

Parameters   Description

1)rotate: Rotation Angle

RGA_ROTATE_NONE:Not rotating

RGA_ROTATE_90:Rotate 90 degrees counterclockwise

RGA_ROTATE_180:Rotate 180 degrees counterclockwise

RGA_ROTATE_270:Rotate 270 degrees counterclockwise

RGA_ROTATE_VFLIP:Mirror Vertically

RGA_ROTATE_HFLIP:Mirror Horizontally

5、setFillColor:Set color fill

rga->ops->setFillColor(rga, color);

Parameters   Description

Color:Color value




6、setCrops:Set clipping window

Set the source image clipping window:

rga->ops->setSrcCrop(rga, cropX, cropY, cropW, cropH);

Set the target image clipping window:

rga->ops->setSrcCrop(rga, cropX, cropY, cropW, cropH);

Parameters   Description

     1)、cropX:Origin abscissa

     2)、cropY:Origin ordinate

     3)、cropW:Window width

     4)、cropH:Window height

7、 setFormat:Set Image format

Set the format of the source image:

rga->ops->setSrcFormat(rga, v4l2Format, width, height);

Set the format of the target image

rga->ops->setDstFormat(rga, v4l2Format, width, height);

Parameters   Description

     1)、V4l2Format:v4l2 image format,you can find the support format in /usr/include/rockchip/rockchip_rga.h

     2)、Width:image width

     3)、Height:image height

8、setBuffer:set image Buffer

Set the file descriptor of the source image's Buffer (DMA memory fd):

rga->ops->setSrcBufferFd(rga, fd);

Set the source image Buffer pointer (user-space memory pointer):

rga->ops->setSrcBufferPtr(rga, ptr);

Set the file descriptor of the target image's Buffer (DMA memory fd)

rga->ops->setDstBufferFd(rga, fd);

Set the target image Buffer pointer (user-space memory pointer)

rga->ops->setDstBufferPtr(rga, ptr);

9、Perform image processing operations

Perform operations:


Rtspclient System Library

Rtspclient Install And Compile

1、Install RTSP Lib

sudo dnf install librockchip_rtsp-devel crul-devel

2、Compiling And linking

LDDFLAGS: = -lrockchip_rtsp

3、 Include Header Files:

#include <rockchip/rockchip_rtsp.h>

Rtspclient Interfaces Description

1、Constructor Function:

RtspClient(std::string url, std::string username = "", std::string password = "");
Rtsplcient client(“rtsp://”, “username”, “password”);

Parameters   Description

     1)、Url:RTSP network address of IPC camera 

     2)、Username:The username of the IPC camera , blank by default

     3)、Password:The password of the IPC camera , blank by default

2、Set the callback function:

setDataCallback(FRtspCallBack callBack);

client.setDataCallback(std::bind(&priv_class::onRstpHandle, priv_point,std::placeholders::_1, std::placeholders:_2));

Parameters   Description

1)、priv_class callback function:void onRtspHandle(unsigned char *buf, size_t len)

explain:The Rtspclient callback to this function every time when it receives a frame;

And buf stores H264 image data and len is the size of the image.

2)、priv_point:Pointer to the class.

3)、 _1&&_2:placeholder

3、Start fetching the RTSP stream:


4、Stop fetching the RTSP stream


Products Store Community Wiki Download About TB

To Top