This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to generate LDC mesh table

Other Parts Discussed in Thread: TDA4VM, TDA4VH-Q1

Dear TI experts,

I follow "[FAQ] TDA4VM: How to create a LDC mesh LUT for fisheye distortion correction on TDA4?" to generate mesh table. While setting s=2; m=4, it has some many NaN in mesh table.

May I know how to decide suitable value for s and m?

  • 2112.mesh.txt

    7737.spec_file.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    0 0.000
    0.1 0.005
    0.2 0.010
    0.3 0.015
    0.4 0.020
    0.5 0.025
    0.6 0.030
    0.7 0.036
    0.8 0.041
    0.9 0.046
    1 0.051
    1.1 0.056
    1.2 0.061
    1.3 0.066
    1.4 0.071
    1.5 0.076
    1.6 0.081
    1.7 0.086
    1.8 0.091
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Dear TI experts,

    I upload spec_file.txt and mesh.txt that I use and generate. Could you help to check if there is anything wrong?

    Thanks

  • Most likely, it goes out of your input range of 75.6 degrees.

    You may add one more line at the end as below and try again.

    "180  3.442" or "90 3.442"

  • 8741.mesh.txt

    Hi Gang Hua,

    After adding 90 3.442 at the end of spec_file.txt, we can get mesh.txt as attachment. Coud you help to check if it is reasonable?

    Thank you

  • I don't find any NaN in the new file.

  • Yes, there is no NaN this time. But I don't know if the result is reasonable. Could you help to check it?

  • Dear TI

    I used cam_single.sh to capture two image

    img_msc_0000_1904x1072.YUV and img_viss_0000_1934x1096.YUV

    I have converted distortion table "spec_file.txt" to mesh.txt and my setting is W = 1904; H = 1072

    I used mesh.txt to convert mesh_lut.h ./convert.sh mesh.txt 1904 1072 16
    I used DCC tool to open the preview image "DCCOutPut.png"
    Seems the picture is wrong, I saw some error message
    Input Image DDR BW = 12124992, MESH LUT DDR BW = 433088, Total = 12558080
    output_image.yuv created in C:\work\Project\MD\TestProject\.plugoutdir\DC_Mesh_LDC2
    Input Image DDR BW = 12124992, MESH LUT DDR BW = 433088, Total = 12558080
    LDC error flags:
    bit0 = 1: out of input image frame bound or mesh frame bound (warning only: clipped back)
    bit1 = 0: out of pixel block bound (PIXPAD is too small; warning only: clipped back)
    bit2 = 0: internal pixel buffer overflow (input image block is too big)
    bit3 = 0: internal mesh buffer overflow (mesh down sampling is too small)
    bit4 = 0: affine/pwarp internal overflow
    bit5 = 0: out of mesh block bound (warning only: clipped back)

    Request to get YUV image from Target : Enter IP Address...

    Loaded communication DLL:itCommun.dll

    Request to get YUV image from Target : Enter IP Address...

    Loaded communication DLL:itCommun.dll


    Do I set any wrong?

    img_msc_0000_1904x1072.rar 6557.mesh.txt

    7356.spec_file.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    0 0.000
    0.1 0.005
    0.2 0.010
    0.3 0.015
    0.4 0.020
    0.5 0.025
    0.6 0.030
    0.7 0.036
    0.8 0.041
    0.9 0.046
    1 0.051
    1.1 0.056
    1.2 0.061
    1.3 0.066
    1.4 0.071
    1.5 0.076
    1.6 0.081
    1.7 0.086
    1.8 0.091
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Dear TI

    I modified output frame x, y to 1280x720

    and output starting x coodinate = 300 and y = 140

    seems OK but the top area have some dislocation, can you give me suggestion to modify it?

  • Do I set any wrong?

    Not really wrong, but your output view goes out of your input view by too much.

    You may use smaller "s" values for smaller output view and try again.

  • seems OK but the top area have some dislocation, can you give me suggestion to modify it?

    Same problem as above

    You output view on the top is going out of your input image boundary.
    LDC H/W repeats input image border pixels when it is getting out of boundary.
    You will need to plan your output view properly according to your lens distortion geometry.

  • Hi Gang

    OK, I will try smaller "s" values

    How could I build the new bin to camera module

    I copy xml to imaging\sensor_drv\src\imx390 and run the "generate_dcc.sh"

    Then, It generated some new bin, but i don't know how to use it.

    I built imaging and sdk and copy .out to sdk, but It still not work

    Thanks

  • If you are using PSDK RTOS, you may have to do below to copy everything to SD card.

    make linux_fs_install_sd

  • Dear Gang

    Could you give me more detail.

    I have downloaded pre-build RTOS and source code RTOS

    I copied pre-build RTOS and It's workful.

    Now, I modified imaging\sensor_drv\src\imx390 in source code RTOS and run the "generate_dcc.sh" and got new bin

    Could I just copied bin to sdcard? If yes, where is the path?

    Or what is the procedure I need to do?

    I made vision_app, sdk, and imaging, then copied all .out to sdcard, but nothing changed.

    Or I don't need to make anything, just after modifying then make linux_fs_install_sd?

    Thanks

  • Hi Gang

    We are successful to modify parameters.

    But I have some questions.

    1. I used vision_app script single_cam to take picture, then I only can get img_msc_0000_1904x1072.YUV and img_viss_0000_1934x1096.YUV

    But the imx390 config defines IMX390_1920x1080 to preview

    2. I used img_msc_0000_1904x1072.YUV to do LDC, DCC simulation is OK, but I push to SD card that the preview is not right, so I need to use 1920x1080 to preduce parameters

    How could I take 1920x1080 YUV or RAW?

    I need it to simulate LDC on DCC tool

    Thanks

     

  • Hi Will,

    I am not sure about these questions.

    IMX390 sensor output raw image and VISS output YUV should be both 1936x1096 if you have not changed the IMX390 sensor driver.

    LDC output in PSDK is configured to 1920x1080 in the single-cam app.

  • Hi Gang

    I understand IMX390 sensor output raw image and VISS output YUV should be both 1936x1096

    And LDC output in PSDK is configured to 1920x1080

    But I need to re-correction LDC, because the LDC is wrong now 

    So, I need to take 1920x1080 YUV, then I can use DCC tool to re-gen LDC table like this  "ldc_xml_IMX390_1920x1080_2.txt"

    If I use YUV 1936x1096 to gen 1920x1080 LDC table on DCC tool, the DCC output is wrong

    Thanks

  • I am confused about your LDC input and output image size on TDA4.

    For tuning tool, you can specify your input image size, output image size, and LUT image frame size separately.
    Please follow plugin guide for the details.

  • Hi Gang

    Let me explain my problem

    First of all, there is a sample code in TDA4VH-Q1 source code

    imaging\sensor_drv\src\imx390\dcc_xmls\wdr\ldc_xml_IMX390_1920x1080_3.txt

    I took a YUV image img_viss_0000_1934x1096 to simulate LDC parameter  

    I set input image size 1934x1096, and output image size 1280x720, then the DCC preview like that. 

    But If i put the parameter code to code base, modify IMX390_ldc.xml and ldc_xml_IMX390_1934x1096_1.txt

    The real preview is like this

    So the real resolution is not fitting 1934x1096.

    Then I ignored the input size 1934x1096, I used sample resolution 1920x1080 to simulate LDC, now the DCC preview is wrong but output parameter is right for code base.

    So, I suspect that I only can use 1920x1080 to simulate. So, I need to take 1920x1080 YUV, but I don't know how to take it

    Thanks

  • First of all, there is a sample code in TDA4VH-Q1 source code

    Do you use "app_single_cam" under "vision_apps"?

    The sensor output RAW and VISS output YUV should be both 1936x1096.
    I am not sure why you have 1934 instead.

    When I press "s" key at "app_single_cam", it saves the raw and yuv images with the size below.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    RAW file name .//img_0000.raw
    YUV file name .//img_viss_0000.yuv
    imgaddr_width = 1936
    imgaddr_height = 1096
    imgaddr_stride = 1936
    width = 1936
    height = 1096
    YUV file name .//img_ldc_0000.yuv
    imgaddr_width = 1920
    imgaddr_height = 1080
    imgaddr_stride = 1920
    width = 1920
    height = 1080
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I suppose LDC output size is decided by "app_single_cam" while creating the LDC openvx node.

    If you need to modify LDC output size, you may have to change the LDC node settings.

  • Hi Gang

    That's my mistake.

    RAW file name .//img_0000.raw
    YUV file name .//img_viss_0000.yuv
    imgaddr_width = 1936
    imgaddr_height = 1096
    imgaddr_stride = 1936
    width = 1936
    height = 1096

    This is what i got.

    Then, I need to get 1920x1080 YUV to simulate LDC,

    Because, as i mentioned before, I can't use 1936x1096 YUV to simulate LDC on DCC tool

    because If I use the output XML code base, I only can get wrong preview.

    Can you give me more specific infornation about where i need to modify.

    1. How to get 1920x1080 YUV?

    2. If i need to modify LDC output, I only need to get new XML or i need to modify source code

    Thanks

  • Then, I need to get 1920x1080 YUV to simulate LDC,

    Because, as i mentioned before, I can't use 1936x1096 YUV to simulate LDC on DCC tool

    Your LDC input is from VISS output and it should be 1936x1096.
    You should use 1936x1096 for LDC input in tuning tool as well.

    because If I use the output XML code base, I only can get wrong preview.

    I suppose you should be able set LDC output size to 1936x1096 in tuning tool.

    2. If i need to modify LDC output, I only need to get new XML or i need to modify source code

    If you use the single-cam app, please refer to "app_create_ldc(...)" in "app_single_cam_common.c".
    I believe "obj->ldc_out" is the LDC output image.

  • Hi Gang

    We saw some DCC XML parameters were written app_single_cam_common.h

    #define LDC_TABLE_WIDTH (1920)
    #define LDC_TABLE_HEIGHT (1080)
    #define LDC_DS_FACTOR (2)
    #define LDC_BLOCK_WIDTH (64)
    #define LDC_BLOCK_HEIGHT (32)
    #define LDC_PIXEL_PAD (1)

    I am confused, if i want use DCC XML config, which app i need to use?

    Thanks

  • For VPAC tuning, the single-cam app is the simplest to use.

  • Hi Gang

    We modified app_single_cam_common.c and app_single_cam_main.c 

    It is worked

    Thank you

  • Hi Will,

    Thanks for the update!

    Could you please confirm if the cause is the output image size?