Made input_rgb_image_pyramid use multiple cores while building the pyramid.

This commit is contained in:
Davis King 2016-09-10 15:29:06 -04:00
parent 6168781ab9
commit 86fa427e26
1 changed files with 12 additions and 11 deletions

View File

@ -567,15 +567,21 @@ namespace dlib
} }
matrix<rgb_pixel> img; std::vector<matrix<rgb_pixel>> imgs(std::distance(ibegin,iend));
create_tiled_pyramid<pyramid_type>(*ibegin, img, data.annotation().get<std::vector<rectangle>>()); parallel_for(0, imgs.size(), [&](long i){
nr = img.nr(); std::vector<rectangle> rects;
nc = img.nc(); if (i == 0)
data.set_size(std::distance(ibegin,iend), 3, nr, nc); create_tiled_pyramid<pyramid_type>(ibegin[i], imgs[i], data.annotation().get<std::vector<rectangle>>());
else
create_tiled_pyramid<pyramid_type>(ibegin[i], imgs[i], rects);
});
nr = imgs[0].nr();
nc = imgs[0].nc();
data.set_size(imgs.size(), 3, nr, nc);
const size_t offset = nr*nc; const size_t offset = nr*nc;
auto ptr = data.host(); auto ptr = data.host();
while(true) for (auto&& img : imgs)
{ {
for (long r = 0; r < nr; ++r) for (long r = 0; r < nr; ++r)
{ {
@ -592,11 +598,6 @@ namespace dlib
} }
} }
ptr += offset*(data.k()-1); ptr += offset*(data.k()-1);
++ibegin;
if (ibegin == iend)
break;
create_tiled_pyramid<pyramid_type>(*ibegin, img, data.annotation().get<std::vector<rectangle>>());
} }
} }