elucideye / acf

Aggregated Channel Feature object detection in C++ and OpenGL ES 2.0 based on https://github.com/pdollar/toolbox
BSD 3-Clause "New" or "Revised" License
49 stars 20 forks source link

convTri is not correctly called when calculating the pyramid #69

Closed JN-Jones closed 6 years ago

JN-Jones commented 6 years ago

This is the matlab variant:

% compute image pyramid [approximated scales]
for i=isA
  iR=isN(i); sz1=round(sz*scales(i)/shrink);
  for j=1:nTypes, ratio=(scales(i)/scales(iR)).^-lambdas(j);
    data{i,j}=imResampleMex(data{iR,j},sz1(1),sz1(2),ratio); end
end

% smooth channels, optionally pad and concatenate channels
for i=1:nScales*nTypes, data{i}=convTri(data{i},smooth); end

and this is yours:

    util::ParallelHomogeneousLambda harness = [&](int j) {
        const int i = isA[j];

        int iR = isN[i - 1];
        cv::Size sz1 = round(cv::Size2d(sz) * scales[i - 1] / double(shrink));
        for (int j = 0; j < nTypes; j++)
        {
            double ratio = std::pow(scales[i - 1] / scales[iR - 1], -lambdas[j]);
            imResample(data[iR - 1][j], data[i - 1][j], sz1, ratio);
        }
        for (auto& img : data[i - 1])
        {
            convTri(img, img, smooth, 1);
        }
    };

cv::parallel_for_({ 0, int(isA.size()) }, harness);

However isA may be empty (it was in my case) which results in convTri not called at all. However the matlab code always applies convTri to all channels. So the convTri needs to be outside of the parallel_for call, maybe in it's own.

headupinclouds commented 6 years ago

Thanks. Fix applied in #70 , testing ...

I'll make an issue to add some kind of pixel level pyramid tests in place for c++ vs matlab. I think we can store ACF output from matlab, possibly in *.mat format, and load it via cvmatio for comparisons.

headupinclouds commented 6 years ago

Added https://github.com/elucideye/acf/issues/71