GithubHelp home page GithubHelp logo

upcautolang / backgroundsplit-opencv Goto Github PK

View Code? Open in Web Editor NEW
278.0 278.0 158.0 11.64 MB

This repository is the C++ Source Code of several algorithms of Extracting Background, which are based on OpenCV libraries after I learn about the theory of these algorithms(including Frame-Difference, Gauss-Background-Difference, ViBe algorithms).

CMake 1.76% C++ 97.29% C 0.96%

backgroundsplit-opencv's People

Contributors

upcautolang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backgroundsplit-opencv's Issues

memory leak in ViBe+

we should delete as follows
void ViBePlus::deleteSamples()
{

for(int i = 0; i <Gray.rows; ++i)
{
    for(int j = 0; j<Gray.cols; ++j)
    {
        for (int k = 0; k < num_samples + 1; k++)
        {
            delete []samples_Frame[i][j][k];
            samples_Frame[i][j][k] = nullptr;
        }
        delete []samples_Frame[i][j];
        delete []samples[i][j];

        samples_Frame[i][j] = nullptr;
        samples[i][j] = nullptr;
    }
    delete []samples_Frame[i];
    delete []samples[i];
    delete []samples_ave[i];
    delete []samples_sumsqr[i];
    delete []samples_ForeNum[i];
    delete []samples_BGInner[i];
    delete []samples_InnerState[i];
    delete []samples_BlinkLevel[i];
    delete []samples_MaxInnerGrad[i];



    samples_Frame[i] = nullptr;
    samples[i] = nullptr;
    samples_ave[i] = nullptr;
    samples_sumsqr[i] = nullptr;
    samples_ForeNum[i] = nullptr;
    samples_BGInner[i] = nullptr;
    samples_InnerState[i] = nullptr;
    samples_BlinkLevel[i] = nullptr;
    samples_MaxInnerGrad[i] = nullptr;

}
delete []samples_Frame;
delete []samples;
delete []samples_ave;
delete []samples_sumsqr;
delete []samples_ForeNum;
delete []samples_BGInner;
delete []samples_InnerState;
delete []samples_BlinkLevel;
delete []samples_MaxInnerGrad;

samples_Frame = nullptr;
samples = nullptr;
samples_ave = nullptr;
samples_sumsqr = nullptr;
samples_ForeNum = nullptr;
samples_BGInner = nullptr;
samples_InnerState = nullptr;
samples_BlinkLevel = nullptr;
samples_MaxInnerGrad = nullptr;

}

the code which in vibe.cpp miss a "}" symbol

When using the developer's vibe project code, I found an error in the file which called "vibe.cpp". In line 53, “if” statement is missing "}" symbol, it will cause the compilation to fail. when i add "}" and it's ok. This question is too small, I will not pull request. You can close it ,when you see my issues. Any way , thank you very much.

How to make the release version?

When I cmake&make it,the test program just Time of Update ViBe+ Background: 256.704ms.
How can I make the release version to make it faster?

Line 274 Maybe should be changed.

原代码:samples[i][j][random]=img.at(i, j);

由于此处为了更改邻居点的样本值,所以也许应该改成:
samples[row][col][random] = img.at (i, j);

A mistake in ViBe destructor

In ViBe::init(), a 3d array is applied, but it's released in a wrong way.
void ViBe::deleteSamples() { delete samples; }
It doesn't matter if ViBe.init() is just used once. But in the case where background should be built for many times, the program will crash due to a lack of memory.

The right way is to release the pointers one by one with the opposite order of applying for arrays.

Useless loop

Hi! I have your implementation of ViBe+ reviewed and realized that in function

void ViBePlus::UpdatePixSampleSumSquare(int i, int j, int k, int val)
{
    double res = 0;
    UpdatePixSampleAve(i, j, k, val);
    for(int m = 0; m < num_samples; m++)
        res += pow(samples[i][j][m] - samples_ave[i][j], 2);
    res /= num_samples;
    samples_sumsqr[i][j] = res;
}

the loop is useless. Because it's adding to res a value of expression pow(samples[i][j][k] - samples_ave[i][j], 2) <num_samples> times. Then res is dividing by num_samples. So this loop and dividing are equals to res = pow(samples[i][j][k] - samples_ave[i][j], 2).

That is why I'm suggesting that there must be a samples[i][j][m] instead of samples[i][j][k]. Otherwise this loop is useless.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.