How to use frame rate adjust function on NVIDIA Jetson Board

From wiki_veye
Jump to navigation Jump to search

查看中文

1 Problem description

The CS series cameras support flexible frame rate control and can be configured using I2C scripts.

However, if you use the default driver we provide and use gstreamer to make application layer calls, each gstreamer call will override the frame rate mode already written by the i2C script.


The following example and solution are given by taking CS-MIPI-IMX307 as an example.

For example, we use the following command to configure the mode of CS-MIPI-IMX307 to 1920 *1080@10fps:

./cs_mipi_i2c.sh -w -f videofmt -p1 1920 -p2 1080 -p3 10

Then preview using the following command:

gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvoverlaysink sync=false

The camera will be reconfigured to 1920*1080@30fps by the gstreamer command.

2 Solution method

Since our driver mode is V4L2 mode, the temporary solution is to modify the source code of the camera driver and remove the configuration of the camera stream mode in the driver.

Take CS-MIPI-IMX307 as an example. In the cs_imx307.h file, make the following modifications:

static cs307_reg cs307_reg_1920x1080_30fps[] = {

/*    {FMT_WIDTH_L,0x80},

    {FMT_WIDTH_H,0x7},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_HEIGHT_L,0x38},

    {FMT_HEIGHT_H,0x4},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_FRAMRAT_L,0x1E},

    {FMT_FRAMRAT_H,0x00},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_STREAM},*/

{CS307_TABLE_END, 0x00}

};

static cs307_reg cs307_reg_1280x720_crop_60fps[] = {

/*    {FMT_WIDTH_L,0x00},

    {FMT_WIDTH_H,0x5},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_HEIGHT_L,0xD0},

    {FMT_HEIGHT_H,0x2},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_FRAMRAT_L,0x3C},

    {FMT_FRAMRAT_H,0x00},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_STREAM},*/

{CS307_TABLE_END, 0x00}

};

static cs307_reg cs307_reg_640x480_crop_130fps[] = {

/*    {FMT_WIDTH_L,0x80},

    {FMT_WIDTH_H,0x2},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_HEIGHT_L,0xE0},

    {FMT_HEIGHT_H,0x1},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_CMD},

    {FMT_FRAMRAT_L,0x82},

    {FMT_FRAMRAT_H,0x00},

    {CS307_TABLE_WAIT_MS, CS307_WAIT_MS_STREAM},*/

{CS307_TABLE_END, 0x00}

};


Then recompile the driver according to the source code compilation guide for VEYE and CS camera drivers on the Nvidia Jetson platform.

After making the above changes, remember to use the i2C script to configure the stream mode.