alantrrs / OpenTLD

:eyes: C++ implementation of TLD
GNU General Public License v3.0
225 stars 99 forks source link

one big bug in code #14

Open zttkkk opened 12 years ago

zttkkk commented 12 years ago

tracker.filterPts() It should be written this way:

//before using this function,points whose status is false has already been filted. bool LKTracker::filterPts(vec_POINT2F pts1,vec_POINT2F pts2) { short i,a; short n = pts2->size;

//计算FBerror和ncc的中值
medNCC = median(&similarity);
medFB = median(&FB_error);

//过滤掉相似度较低的那一半
for( i=a=0; i<n; ++i )
{
    if( vec_at(similarity,i) < medNCC || vec_at(FB_error,i) > medFB )
        continue;

    vec_at(*pts1,a) = vec_at(*pts1,i);
    vec_at(*pts2,a) = vec_at(*pts2,i);
    vec_at(FB_error,a) = vec_at(FB_error,i);
    a++;
}

vec_POINT2F_resize(pts1,a);
vec_POINT2F_resize(pts2,a);

if (a>0)
    return true;
else
    return false;

}

Check ZK's code,then you will know I'm right

arthurv commented 12 years ago

Hi, thanks for pointing this out. Can you open a push request in github for this patch? On Jul 17, 2012 9:56 AM, "zttkkk" < reply@reply.github.com> wrote:

tracker.filterPts() It should be written this way:

//before using this function,points whose status is false has already been filted. bool LKTracker::filterPts(vec_POINT2F pts1,vec_POINT2F pts2) { short i,a; short n = pts2->size;

    //计算FBerror和ncc的中值
    medNCC = median(&similarity);
    medFB = median(&FB_error);

    //过滤掉相似度较低的那一半
    for( i=a=0; i<n; ++i )
    {
    if(     vec_at(similarity,i) < medNCC || vec_at(FB_error,i) >

medFB ) continue;

            vec_at(*pts1,a) = vec_at(*pts1,i);
            vec_at(*pts2,a) = vec_at(*pts2,i);
            vec_at(FB_error,a) = vec_at(FB_error,i);
            a++;
}

    vec_POINT2F_resize(pts1,a);
    vec_POINT2F_resize(pts2,a);

    if (a>0)
            return true;
    else
            return false;

}

Check ZK's code,then you will know I'm right


Reply to this email directly or view it on GitHub: https://github.com/alantrrs/OpenTLD/issues/14

arthurv commented 12 years ago

I meant pull request, sorry On Jul 17, 2012 9:56 AM, "zttkkk" < reply@reply.github.com> wrote:

tracker.filterPts() It should be written this way:

//before using this function,points whose status is false has already been filted. bool LKTracker::filterPts(vec_POINT2F pts1,vec_POINT2F pts2) { short i,a; short n = pts2->size;

    //计算FBerror和ncc的中值
    medNCC = median(&similarity);
    medFB = median(&FB_error);

    //过滤掉相似度较低的那一半
    for( i=a=0; i<n; ++i )
    {
    if(     vec_at(similarity,i) < medNCC || vec_at(FB_error,i) >

medFB ) continue;

            vec_at(*pts1,a) = vec_at(*pts1,i);
            vec_at(*pts2,a) = vec_at(*pts2,i);
            vec_at(FB_error,a) = vec_at(FB_error,i);
            a++;
}

    vec_POINT2F_resize(pts1,a);
    vec_POINT2F_resize(pts2,a);

    if (a>0)
            return true;
    else
            return false;

}

Check ZK's code,then you will know I'm right


Reply to this email directly or view it on GitHub: https://github.com/alantrrs/OpenTLD/issues/14

zttkkk commented 12 years ago

arthurv,I am a new user of github,so I don't know how to "pull a request".I hope you to do that. By the way,my code is not easy to understand,for example I use vec_POINT2F instead of std::vectorcv::Point. That's because I translate your C++ code to pure C, in my work I use some trick to simulate the STL container vector. And vec_POINT2F is that thing,you can take it just like vector I believe you have already understand where the bug is,so let others know!