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.

VPFE + Previewer pipleline - yellowish YUV output (6437 platform)

I have a 6437 based customized board capturing raw image from CMOS imaging sensor. I am trying to convert the raw bayer image into YUV by feeding it to previewer engine through DDR2 approach shown in TI samples (C:\dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\system\dm6437\bios\dm6437_evm\src\video\sample\previewer). The raw capture + previewer pipeline works fine and I see clear image but it's very yellowish. I tried changing the RGB pattern in cfa_coef but no luck. I see many previewer parameters - while balancing, RGB2RGB blending, RGB2YCbCr parameters, which may take many iterations.

Please reply to this post if you have any idea on correcting the yellowish image.

 

Regards,

Amit

  • I have not done that much work with the previewer, but I see no reason it would generate a yellowish image unless it had some configuration issue or the incoming Bayer image happened to have a yellow tint. How yellowish is the image you are seeing, is this something you could post a picture of? I assume by your description of yellowish, that if you have the camera looking at a white object that the object shows up as yellow after conversion?

  • I have attached both raw image and previewer output image. I am using the same previewer configuration used in TI sample except frame width and height (1280x720).

  •  

    When you go through DDR, CCDC driver dont use Data formatter block and bit selector.

    Maybe because of that you have less bits than number of bits sensor gives, and bad picture.

     

     

     

  • I dumped the raw 10-bit image captured through VPFE driver into file and attached the snapshot in the earlier post (larger one). It looks perfectly fine. As per my understanding, the previewer takes raw-bayer image so I feed the same raw image to previewer without formatting the data. Are you saying I need to format the raw image before feeding it to previewer? Can you elaborate about the data format?

  • More info on the previewer configuration I use:

    The imaging sensor outputs the raw image GR format. The RGB pixels would look like:

    Gr R Gr R ....

    B Gb B Gb ....

     

        /* down sample rate */
        prevParams.downSampleRate = PSP_PREVIEWER_DOWN_SAMPLE_RATE1;
        /* Set size and pitch parameters */
        /* start horizontal pixel */
        prevParams.sizeParam.sph = 0u;
        /* end horizontal pixel */
        prevParams.sizeParam.eph = PREV_IMAGE_WIDTH - 1;
        /* start vertical pixel */
        prevParams.sizeParam.slv = 0u;
        /* end vertical pixel */
        prevParams.sizeParam.elv = PREV_IMAGE_HEIGHT - 1;
        /* pixel size */
        prevParams.sizeParam.pixelSize = PSP_PREVIEWER_INWIDTH_10BIT;
        /* offset distance between two raws in input image - should be 32 bytes
         * aligned */
        prevParams.sizeParam.inPitch = PREV_IMAGE_WIDTH * 2;
        /* offset distance between two raws in output image - should be 32 bytes
         * aligned */
        prevParams.sizeParam.outPitch = (PREV_IMAGE_WIDTH * 2u);

        /* Set white balancing parameters */
        prevParams.whiteBalanceParam.wbDgain = 0x100;
        prevParams.whiteBalanceParam.wbGain[0] = 0x40;
        prevParams.whiteBalanceParam.wbGain[1] = 0x40;
        prevParams.whiteBalanceParam.wbGain[2] = 0x40;
        prevParams.whiteBalanceParam.wbGain[3] = 0x40;

        prevParams.whiteBalanceParam.position[0][0] = 0;
        prevParams.whiteBalanceParam.position[0][1] = 1;
        prevParams.whiteBalanceParam.position[0][2] = 0;
        prevParams.whiteBalanceParam.position[0][3] = 1;

        prevParams.whiteBalanceParam.position[1][0] = 2;
        prevParams.whiteBalanceParam.position[1][1] = 3;
        prevParams.whiteBalanceParam.position[1][2] = 2;
        prevParams.whiteBalanceParam.position[1][3] = 3;

        prevParams.whiteBalanceParam.position[2][0] = 0;
        prevParams.whiteBalanceParam.position[2][1] = 1;
        prevParams.whiteBalanceParam.position[2][2] = 0;
        prevParams.whiteBalanceParam.position[2][3] = 1;

        prevParams.whiteBalanceParam.position[3][0] = 2;
        prevParams.whiteBalanceParam.position[3][1] = 3;
        prevParams.whiteBalanceParam.position[3][2] = 2;
        prevParams.whiteBalanceParam.position[3][3] = 3;

        /* Set RGB2RGB blending parameters */
        prevParams.rgbBlendingParam.blending[0][0] = 0x1a1;
        prevParams.rgbBlendingParam.blending[0][1] = 0xf8a;
        prevParams.rgbBlendingParam.blending[0][2] = 0xfd5;
        prevParams.rgbBlendingParam.blending[1][0] = 0xfa1;
        prevParams.rgbBlendingParam.blending[1][1] = 0x1c4;
        prevParams.rgbBlendingParam.blending[1][2] = 0xf9b;
        prevParams.rgbBlendingParam.blending[2][0] = 0xfbd;
        prevParams.rgbBlendingParam.blending[2][1] = 0xfb1;
        prevParams.rgbBlendingParam.blending[2][2] = 0x192;

        prevParams.rgbBlendingParam.offset[0] = 0u;
        prevParams.rgbBlendingParam.offset[1] = 0u;
        prevParams.rgbBlendingParam.offset[2] = 0u;

        /* Set RGB2YCBCR parameters */
        prevParams.rgb2ycbcrParam.coeff[0][0] = 0x4Cu;
        prevParams.rgb2ycbcrParam.coeff[0][1] = 0x96u;
        prevParams.rgb2ycbcrParam.coeff[0][2] = 0x1Du;
        prevParams.rgb2ycbcrParam.coeff[1][0] = 0x3d4u;
        prevParams.rgb2ycbcrParam.coeff[1][1] = 0x3acu;
        prevParams.rgb2ycbcrParam.coeff[1][2] = 0x80u;
        prevParams.rgb2ycbcrParam.coeff[2][0] = 0x80u;
        prevParams.rgb2ycbcrParam.coeff[2][1] = 0x395u;
        prevParams.rgb2ycbcrParam.coeff[2][2] = 0x3ebu;

        prevParams.rgb2ycbcrParam.yOffset = 0u;
        prevParams.rgb2ycbcrParam.cbOffset = 0u;
        prevParams.rgb2ycbcrParam.crOffset = 0u;

        /* Set Black adjustment parameters */
        prevParams.blackAdjParam.blueAdj = 0;
        prevParams.blackAdjParam.redAdj = 0;
        prevParams.blackAdjParam.greenAdj =  0;

        prevParams.brightness = 0x20;
        prevParams.contrast =  0x10;

        /*CFA*/
        prevParams.features = PSP_PREVIEWER_CFA;

        for(prevFillParamsIndex1 = 0;
            prevFillParamsIndex1 < PSP_PREVIEWER_CFA_COEFF_TABLE_SIZE;
            prevFillParamsIndex1++)
        {
            prevParams.cfaCoeffsParam.coeffs[prevFillParamsIndex1]
                = cfa_coef[prevFillParamsIndex1];
        }

        prevParams.cfaCoeffsParam.vThreshold = 0x28;
        prevParams.cfaCoeffsParam.hThreshold = 0x28;

        /* output format */
        prevParams.outPixelOrderParam = PSP_PREVIEWER_PIXELORDER_YCBYCR;

  • which sensor is this? I had similar issue with MT9V022 sensor that was fixed with tunes parameters. I have my own driver for previewer. If it helps, below are the parameters I used to get the correct image out:

    /* Tuned parameters for MT9V022 sensor */

    /* Tuned parameters for MT9V022 sensor */
    PREV_Params PREVDrv_params = {
        IMG_WIDTH,
        IMG_HEIGHT,
        0x00000100,
        0x004B2A2B,
        0x11661166,
        PREV_PCR_CFAEN_ENABLE,
        PREV_PCR_WIDTH_10_BITWIDE,
        NULL,
        NULL,
        NULL,
        0xFF3001B0,
        0xFF94001E,
        0xFFFE016D,
        0xFEE9FFFF,
        0x00000216,
        0x03E703E7,
        0x03Ef    ,
        0x04C, 0x098, 0x01C,
        0x3D0, 0x3A4, 0x08C,
        0x08C, 0x32B, 0x38C,
        0,0,0,
        0x30, 0x30,
        0x0, 0xff,
        0x0, 0xff,
    };

    typedef struct PREV_Params {
        Uint32  width;  /* Number of columns for the video frames */
        Uint32  height; /* Number of rows for the video frames */
        Uint32  wbDGain;
        Uint32  wbGain;
        Uint32  wbSel;
        Uint32  enableCFA;
        Uint32  dataWidth;
        Uint32  gradVerCFA;
        Uint32  gradHorCFA;
        Uint32  tblCFA;
        Uint32  rgbMat1;
        Uint32  rgbMat2;
        Uint32  rgbMat3;
        Uint32  rgbMat4;
        Uint32  rgbMat5;
        Uint32  rgbOff1;
        Uint32  rgbOff2;
        Uint32  cscRY;
        Uint32  cscGY;
        Uint32  cscBY;
        Uint32  cscRCB;
        Uint32  cscGCB;
        Uint32  cscBCB;
        Uint32  cscRCR;
        Uint32  cscGCR;
        Uint32  cscBCR;
        Uint32  ofstY;
        Uint32  ofstCR;
        Uint32  ofstCB;
        Uint32  contrast;
        Uint32  brightness;
        Uint32  minC;
        Uint32  maxC;
        Uint32  minY;
        Uint32  maxY;

    } PREV_Params;

    Gagan

  • Its alta sensor - next generation high definition cmos sensor - A3372E2-4T. Thanks for your inputs. Will try this out.

  • No luck Gagan. It's now greenish. Though, I tried contrast, brightness and Rgb2YCbCr blending params from your configuration. Couldn't translate others. You mentioned you had your own previewer driver. Do you see changing the ti driver in such cases become mandatory? Thanks for your help.

    Guys, pls help me if any one tweaked the previewer params for alta HD sensor - 3372.

    Thanks,

    Amit

     

  • No. TI driver should be just fine.. I did my own driver for some other reasons. Do you have a raw dump of one frame of your sensor data (Bayer pattern)? Can you provide that? Also, it will be nice if you can provide a reference picture for the same scene so that some expert can suggest tuning parameters.

    Thanks,

    Gagan

  • Gagan, Yes, I have raw bayer pattern image and verified the image using raw image viewer. It looks good. Can you send me your email so I can send you the raw image? seems I can only attach the media file here.

    my email id: amistry@objectvideo.com

     

    -Amit

  • Dropping 4-bit on the floor from 12-bit captured image and feeding 10-bit image to previewer has improved the previewer output quite a bit. It still has some artifacts as its just a workaround but reasonably well for our demo. Thanks to all who supported.

    Please email me if you find something to fix this issue completely.

    -Amit

     

  • Hi Gagan,

    I am working with Aptina MT9022 color sensor too, and I have doubt about some preview parameters. What SPH and SLV values are you using?

    Thank you for your help

    Fabrizio Beltrandi

     

  • I am working with Aptina MT9p031 color senso, 12bit, DM365+DM6437, I use TI samples

    E:\dvsdk_1_11_00_00\pspdrivers_1_10_00\packages\ti\sdo\pspdrivers\system\dm6437\bios\evmDM6437\video\sample\build\previewer_on_the_fly

    to change RGB Bayer pattern format to YCbCr4:2:2

    But I get green image

    void GetPreviewerParams(PSP_previewerParams * PrevParams)
    {
        Uint32 i = 0;

        PrevParams->downSampleRate =  PSP_PREVIEWER_DOWN_SAMPLE_RATE1;

        PrevParams->features       =  PSP_PREVIEWER_CFA;

        for(i = 0; i < PSP_PREVIEWER_CFA_COEFF_TABLE_SIZE; i++)
        {
            PrevParams->cfaCoeffsParam.coeffs[i] = cfa_coef[i];
        }

        PrevParams->cfaCoeffsParam.vThreshold = 0x28;
        PrevParams->cfaCoeffsParam.hThreshold = 0x28;

        PrevParams->sizeParam.sph   = 2;
        PrevParams->sizeParam.eph   = (FRAME_WIDTH - 2 - 1);
        PrevParams->sizeParam.slv   = 0;
        PrevParams->sizeParam.elv   = (FRAME_HEIGHT - 1);
        PrevParams->sizeParam.pixelSize = PSP_PREVIEWER_INWIDTH_8BIT;
        PrevParams->sizeParam.outPitch = (FRAME_WIDTH) * (16/8u);

        PrevParams->whiteBalanceParam.wbDgain   = 0x100;
        PrevParams->whiteBalanceParam.wbGain[0] = 0x40;
        PrevParams->whiteBalanceParam.wbGain[1] = 0x40;
        PrevParams->whiteBalanceParam.wbGain[2] = 0x40;
        PrevParams->whiteBalanceParam.wbGain[3] = 0x40;

        PrevParams->whiteBalanceParam.position[0][0] = 0;
        PrevParams->whiteBalanceParam.position[0][1] = 1;
        PrevParams->whiteBalanceParam.position[0][2] = 0;
        PrevParams->whiteBalanceParam.position[0][3] = 1;

        PrevParams->whiteBalanceParam.position[1][0] = 2;
        PrevParams->whiteBalanceParam.position[1][1] = 3;
        PrevParams->whiteBalanceParam.position[1][2] = 2;
        PrevParams->whiteBalanceParam.position[1][3] = 3;

        PrevParams->whiteBalanceParam.position[2][0] = 0;
        PrevParams->whiteBalanceParam.position[2][1] = 1;
        PrevParams->whiteBalanceParam.position[2][2] = 0;
        PrevParams->whiteBalanceParam.position[2][3] = 1;

        PrevParams->whiteBalanceParam.position[3][0] = 2;
        PrevParams->whiteBalanceParam.position[3][1] = 3;
        PrevParams->whiteBalanceParam.position[3][2] = 2;
        PrevParams->whiteBalanceParam.position[3][3] = 3;

        PrevParams->rgbBlendingParam.blending[0][0] = 0x1a1;
        PrevParams->rgbBlendingParam.blending[0][1] = 0xf8a;
        PrevParams->rgbBlendingParam.blending[0][2] = 0xfd5;
        PrevParams->rgbBlendingParam.blending[1][0] = 0xfa1;
        PrevParams->rgbBlendingParam.blending[1][1] = 0x1c4;
        PrevParams->rgbBlendingParam.blending[1][2] = 0xf9b;
        PrevParams->rgbBlendingParam.blending[2][0] = 0xfbd;
        PrevParams->rgbBlendingParam.blending[2][1] = 0xfb1;
        PrevParams->rgbBlendingParam.blending[2][2] = 0x192;

        PrevParams->rgbBlendingParam.offset[0] = 0;
        PrevParams->rgbBlendingParam.offset[1] = 0;
        PrevParams->rgbBlendingParam.offset[2] = 0;

        PrevParams->rgb2ycbcrParam.coeff[0][0] = 0x4C;
        PrevParams->rgb2ycbcrParam.coeff[0][1] = 0x96;
        PrevParams->rgb2ycbcrParam.coeff[0][2] = 0x1D;
        PrevParams->rgb2ycbcrParam.coeff[1][0] = 0x3d4;
        PrevParams->rgb2ycbcrParam.coeff[1][1] = 0x3ac;
        PrevParams->rgb2ycbcrParam.coeff[1][2] = 0x82;
        PrevParams->rgb2ycbcrParam.coeff[2][0] = 0x82;
        PrevParams->rgb2ycbcrParam.coeff[2][1] = 0x395;
        PrevParams->rgb2ycbcrParam.coeff[2][2] = 0x3eb;
        PrevParams->rgb2ycbcrParam.yOffset     = 0;
        PrevParams->rgb2ycbcrParam.cbOffset    = 0;
        PrevParams->rgb2ycbcrParam.crOffset    = 0;

        PrevParams->blackAdjParam.blueAdj      = 0;
        PrevParams->blackAdjParam.redAdj       = 0;
        PrevParams->blackAdjParam.greenAdj     = 0;

        PrevParams->brightness = 0x20u;
        PrevParams->contrast   = 0x10u;

        PrevParams->outPixelOrderParam = PSP_PREVIEWER_PIXELORDER_YCRYCB;
    }

    Can anyone help me?


  • Hi Liying,

    I am not working with mt9p031, but some keys are general. First be sure that first pixel identified by SPH and SLV is a RED pixel. If you use sample parameters your colors would be correct, but I am using mt9v032 color sensor and I have some problems too. About white balance parameters I can not tell nothing, because I have not understand completely key role of this parameters. Blending is a mix of color out of CFA interpolation to give real coloro for human eye. I have a question for you: how do you visualize greenish image? If you apply a transform YcbCr to RGB , be sure to apply trasnformation with coefficient corresponding to primary transform, otherwise you can have color distortion.

    I hope this will be useful

    Fabrizio 

  • Hi Fabrizio,

    Thank you,I  try to modify the preview  parameters

  • Hi,I have the same problem,how to solve it?  thanks  a lot!