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.

VLIB

I am usimg DM6437 and CCSV3.3. I am working on PAL system with resolution 720x576.

I want to do background subtraction using VLIB3_2_1_0.It required  initialize and update variance.initialisation kernel is 

int32_t  VLIB_initVarWithConstS16 (int16_t *restrict runningVar, const int16_t constVar, const uint32_t pixelCount)

now what should be value of constVar?

Statistical background subtraction kernel is

int32_t  VLIB_subtractBackgroundS16 (uint32_t *restrict mask32packed, const uint8_t *restrict newLuma, const int16_t *restrict runningMean, const int16_t *restrict runningVar, const int16_t thresholdGlobal, const int16_t thresholdFactor, const uint32_t PixelCount)

i have allocated for different variable as follows:

uint8_t newLuma[414720];                                                 //        720*570=414720
int16_t runningMean[414720];
int16_t runningVar[414720];
uint32_t mask32packed[12960];                                     //     414720/32=12960                                  Is size of buffer right?

i have taken values of thresholdGlobal,thresholdFactor,PixelCount from  VLIB_prototypes.h.

Can you tell me what is 32bitpacked mean?what output  should i expect from mask32packed?

if i want to display background subtraction output on monitor what should i do?

  • This does not appear to be a TI-RTOS issue.

    I will see about getting your question forwarded to the right place.

    Steve
  • I moved your thread to the device forum.

    todd
  • There is a standalone CCS project under vlib_c64Px_3_2_1_0\packages\ti\vlib\src\VLIB_initVarWithConstS16\c64P. I stepped through the code: it has test 6 cases with different pix count up to 4096 bytes:

    static initVarWithConstS16_testParams_t    testParams[]=
    {
        /********************************************
            {
               testPattern,
               *staticOut, constVar, pixelCount
            },
        *********************************************/
        {
            STATIC,
            refOut32, 0x0A00, 32
        },
        {
            STATIC,
            NULL, 0xAAAA, 64
        },
        {
            STATIC,
            NULL, 0, 128
        },
        {
            STATIC,
            NULL, 0x7FFF, 512
        },
        {
            STATIC,
            NULL, 0x1234, 1024
        },
        {
            STATIC,
            NULL, 0xfffe, 4096
        }
    };

    As for the intialized constVar value, I didn't see any relation to pix count, and it looks random. So I think you can use any value for your 720*570 PAL system, it is intial variance estimate.

    Regarding to the buffer size allocated, you can refer to:

      uint8_t    *newLuma         =  (uint8_t *) VLIB_malloc(prm[tpi].PixelCount * sizeof(uint8_t));
            uint8_t    *prevLuma        =  (uint8_t *) malloc(prm[tpi].PixelCount * sizeof(uint8_t));
            int16_t    *runningMean     =  (int16_t *) VLIB_malloc(prm[tpi].PixelCount * sizeof(int16_t));
            int16_t    *runningVar      =  (int16_t *) VLIB_malloc(prm[tpi].PixelCount * sizeof(int16_t));
            uint32_t   *mask32packed    =  (uint32_t *) VLIB_malloc(packed_size * 4);
            uint32_t   *mask32packed_cn =  (uint32_t *) malloc(packed_size * 4);

    The code uses pointer, you use static array. You PixelCount  = 720*570

    uint32_t    packed_size =   (prm[tpi].PixelCount + 31) / 32;

    I don't think you do the math right.

    For the meaning of mask32packed, see below:

    /**

    * @par Description:

    * The function VLIB_subtractBackgroundS16() implements a statistical background

    * segmentation algorithm. For each pixel, the running mean and variance statistics

    * are available. Given a novel luma observation, we test whether its squared

    * distance from the mean is larger than a multiplicative factor of its variance.

    * For a pixel to pass the test, its distance should also be greater than a

    * predefined global threshold, designed to capture inherent camera noise. When

    * these conditions are satisfied, the observation is deemed to stem from a

    * foreground object (and not from the modeled background), and the corresponding

    * mask pixel value is set to 1.

    *

    * @par

    * @param [out] mask32packed Binary mask to be computed (32-bit packed)

    * @param [in] newLuma Most recent Luma buffer (UQ8.0)

    * @param [in] runningMean Exponentially weighted running mean buffer (SQ8.7)

    * @param [in] runningVar Exponentially weighted running variance buffer (SQ12.3)

    * @param [in] thresholdGlobal Global threshold value (SQ12.3)

    * @param [in] thresholdFactor Multiplicative factor for threshold (SQ4.11)

    * @param [in] PixelCount Number of pixels to process (UQ32.0)

    Regards, Eric