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.

running encode app

Hello I posted this in the DaVinci™ Video Processors  but that forum seems pretty dead, :(

I'm running the encode program on the DM368 using the MT9P031 camera but when I capture the image using this command

./encode -v codec.264 -w -I 4 -y 5

image looks like this:

 

 

, any ideas what happen to the colors? or how can it be fix?

  • I think it's just color saturation is not enough. I used to crank the saturation all the way up to 2.0. You can use IPIPE driver to change color correction matrix.

  • Thanks Hongfeng for answering, can you give me the location of the driver? and line of code to adjust,please :)

    I been looking on this drivers dm365_ipipe.c, dm365_ipipe_hw.c,  but I can't find the adjustment for saturation there.

  • The driver is already there, you dont need to modify those drivers.

    #include <media/davinci/imp_previewer.h>
    #include <media/davinci/dm365_ipipe.h>

    #define IPIPE_DEVICE  "/dev/davinci_previewer"

    void set_color_saturation(float saturation)
    {
      int ret;
      struct prev_module_param mod_param;
      struct prev_rgb2rgb rgb2rgb;
      struct prev_cap cap;
      int  preview_fd = -1,result;
      float rr,gr,br,rg,gg,bb;
      unsigned long op_mode;   
     

      preview_fd = open(IPIPE_DEVICE, O_RDWR);
      if(preview_fd <= 0) {
        printf("AEW:Cannot open ipipe device\n");
        return;
      }
       
      result=ioctl(preview_fd, PREV_G_OPER_MODE, &op_mode);
      if ( result < 0) {
        printf("Can't get operation mode\n");
        goto EXIT;
      }

      result=ioctl(preview_fd, PREV_S_OPER_MODE, &op_mode);
      if ( result < 0) {
        printf("Can't set operation mode\n");
        goto EXIT;
      }

      cap.index =0 ;
      while(1){
        ret = ioctl(preview_fd , PREV_ENUM_CAP, &cap);
        if(cap.module_id == PREV_RGB2RGB_1)break;
        if(ret<0){
        printf("IPIPE Module not found: PREV_RGB2RGB_1\n");   
        return;
        }
        cap.index++;
      }

      strcpy(mod_param.version,cap.version);
      mod_param.module_id = cap.module_id;
       
      rr=(0.299f+0.701f*saturation);
      rgb2rgb.coef_rr.integer = S12Q8_INTEGER(rr);
      rgb2rgb.coef_rr.decimal = S12Q8_DECIMAL(rr);
      printf("%02x%02x,",rgb2rgb.coef_rr.integer,rgb2rgb.coef_rr.decimal);
       
      gr=0.587f*(1-saturation);
      rgb2rgb.coef_gr.integer = S12Q8_INTEGER(gr);
      rgb2rgb.coef_gr.decimal = S12Q8_DECIMAL(gr);
      printf("%02x%02x,",rgb2rgb.coef_gr.integer,rgb2rgb.coef_gr.decimal);

      br=0.114f*(1-saturation);
      rgb2rgb.coef_br.integer = S12Q8_INTEGER(br);
      rgb2rgb.coef_br.decimal = S12Q8_DECIMAL(br);
      printf("%02x%02x\n",rgb2rgb.coef_br.integer,rgb2rgb.coef_br.decimal);

      rg=0.299f*(1-saturation);
      rgb2rgb.coef_rg.integer = S12Q8_INTEGER(rg);
      rgb2rgb.coef_rg.decimal = S12Q8_DECIMAL(rg);
      printf("%02x%02x,",rgb2rgb.coef_rg.integer,rgb2rgb.coef_rg.decimal);

      gg=0.587f+0.413f*saturation;
      rgb2rgb.coef_gg.integer = S12Q8_INTEGER(gg);
      rgb2rgb.coef_gg.decimal = S12Q8_DECIMAL(gg);
      printf("%02x%02x,",rgb2rgb.coef_gg.integer,rgb2rgb.coef_gg.decimal);

      rgb2rgb.coef_bg.integer = S12Q8_INTEGER(br);
      rgb2rgb.coef_bg.decimal = S12Q8_DECIMAL(br);
      printf("%02x%02x\n",rgb2rgb.coef_bg.integer,rgb2rgb.coef_bg.decimal);

      rgb2rgb.coef_rb.integer = S12Q8_INTEGER(rg);
      rgb2rgb.coef_rb.decimal = S12Q8_DECIMAL(rg);
      printf("%02x%02x,",rgb2rgb.coef_rb.integer,rgb2rgb.coef_rb.decimal);

      rgb2rgb.coef_gb.integer = S12Q8_INTEGER(gr);
      rgb2rgb.coef_gb.decimal = S12Q8_DECIMAL(gr);
      printf("%02x%02x,",rgb2rgb.coef_gb.integer,rgb2rgb.coef_gb.decimal);

      bb=0.114f+0.886f*saturation;
      rgb2rgb.coef_bb.integer = S12Q8_INTEGER(bb);
      rgb2rgb.coef_bb.decimal = S12Q8_DECIMAL(bb);
      printf("%02x%02x\n",rgb2rgb.coef_bb.integer,rgb2rgb.coef_bb.decimal);

      rgb2rgb.out_ofst_r = 0;
      rgb2rgb.out_ofst_g = 0;
      rgb2rgb.out_ofst_b = 0;

      mod_param.len = sizeof(struct prev_rgb2rgb);
      mod_param.param = &rgb2rgb;
       
      result=ioctl(preview_fd, PREV_S_PARAM, &mod_param);   

    EXIT:
      if ( result< 0) {
        printf("Error %d in Setting %s params from driver\n", result, cap.module_name);
      }
      else
        printf("Color Saturation Set to: %.1f\n",saturation);
      close(preview_fd);
     
      return ;
    }

  • thanks for the code, I put the code in this directory ti-dvsdk_dm365-evm_4_02_00_06/psp/linux-driver-examples-psp03.01.01.38/imp-prev-rsz/dm365

    and modified the make file and I get this error

    /home/icemetal/CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/lib/crt1.o: In function `_start':
    init.c:(.text+0x30): undefined reference to `main'
    collect2: ld returned 1 exit status
    make[2]: *** [color] Error 1
    make[2]: Leaving directory `/home/icemetal/ti-dvsdk_dm365-evm_4_02_00_06/psp/linux-driver-examples-psp03.01.01.38/imp-prev-rsz/dm365'
    make[1]: *** [build_dm365] Error 2
    make[1]: Leaving directory `/home/icemetal/ti-dvsdk_dm365-evm_4_02_00_06/psp/linux-driver-examples-psp03.01.01.38'
    make: *** [psp_examples] Error 2

    thats after adding some missing header files.

  • I thought you were running the encode demo.

    You only need to save this piece of code as another c file, add it to your makefile, then call the function somewhere, for example: catpure.c

  • Thanks Hongfeng, but where is the "Main" part of the code? is does not want to compile with out that.

  • didn't anyone else had the same problem running the encode application?

  • I think it's very straight forward already. If you still feel it challenging, you can modify drivers/char/dm365_def_para.c, line 69

    /* Defaults for rgb2rgb, saturation=1.6*/
    struct prev_rgb2rgb dm365_rgb2rgb_defaults = {
        .coef_rr = {1, 0x5a},   
        .coef_gr = {0xf, 0xb5},
        .coef_br = {0xf, 0xf2},
        .coef_rg = {0xf, 0xda},
        .coef_gg = {1, 0x34},   
        .coef_bg = {0xf, 0xf2},
        .coef_rb = {0xf, 0xda},
        .coef_gb = {0xf, 0xb5},
        .coef_bb = {1, 0x72},   
        .out_ofst_r = 0,
        .out_ofst_g = 0,
        .out_ofst_b = 0
    };

    Then rebuild your kernel.

  • Thank you Hongfeng!!!!, that really helped to bring the colors!!!! :), where did you found documentation on that driver? I want to do more adjustment on the brightness :)

  • Hi Andre,

    I am also running the same demo application using LI-5M02 Camera board with the below command

    1.  ./encode -I 4 -v test.mpeg2 -r 1280x720 -w

    2.  also trying your command (./encode -v codec.mpeg2 -w -I 4 -y 5) but getting video look like dark shadow.

    Please suggest me how to resolve this issue..

    Regards,

    Anil

  • Hi Andre,

    Image looks like:

  • looks like the image is out of focus, but I'm still having the same problem, I been emailing TI for over 2 months, and posting many times in the forum with no solution yet.

  • Hi Anil,

    I'm not sure of your configuration but if you are using the LI-5M02 camera board, you should try to adjust the manual focus on the lens.  You will still need to adjust the white balance and color gain/saturation.

    -Chuck