Search code examples
opencvbackground-imagegaussiansubtractionbackground-subtraction

How does opencv store matrix value in Gaussian mixture? In which order?


I've searched the "bgfg_gaussmix2.cpp" code, it says in gaussian mixture model, it stores mixture weight (w), mean ( nchannels values ) and covariance for each gaussian mixture of each pixel background model. I want to know the order of its storage, for instance, is it "weight, mean, covariance", or " mean, covariance, weight", or something else? Thanks in advance.


Solution

  • If you are speeking about the gaussian mixture structure CvPBGMMGaussian, the storing order is

    1. Weight
    2. mean dimension 1
    3. mean dimension 2
    4. mean dimension 3
    5. Variance

    The three dimensions are packed in a float array. Here is the definition of this structure :

    #define CV_BGFG_MOG2_NDMAX 3
    typedef struct CvPBGMMGaussian
    {
        float weight;
        float mean[CV_BGFG_MOG2_NDMAX];
        float variance;
    }CvPBGMMGaussian
    

    If you are not speeking about this structure, please be more precise in your question.