Commit 93f3a09f authored by Davis King's avatar Davis King

Added append() to random_cropper.

parent 8dece3ff
......@@ -110,13 +110,33 @@ namespace dlib
)
{
DLIB_CASSERT(images.size() == rects.size());
crops.resize(num_crops);
crop_rects.resize(num_crops);
parallel_for(0, num_crops, [&](long i) {
crops.clear();
crop_rects.clear();
append(num_crops, images, rects, crops, crop_rects);
}
template <
typename array_type
>
void append (
size_t num_crops,
const array_type& images,
const std::vector<std::vector<mmod_rect>>& rects,
array_type& crops,
std::vector<std::vector<mmod_rect>>& crop_rects
)
{
DLIB_CASSERT(images.size() == rects.size());
DLIB_CASSERT(crops.size() == crop_rects.size());
auto original_size = crops.size();
crops.resize(crops.size()+num_crops);
crop_rects.resize(crop_rects.size()+num_crops);
parallel_for(original_size, original_size+num_crops, [&](long i) {
(*this)(images, rects, crops[i], crop_rects[i]);
});
}
template <
typename array_type,
typename image_type
......
......@@ -181,6 +181,36 @@ namespace dlib
- #get_max_object_height() == value
!*/
template <
typename array_type
>
void append (
size_t num_crops,
const array_type& images,
const std::vector<std::vector<mmod_rect>>& rects,
array_type& crops,
std::vector<std::vector<mmod_rect>>& crop_rects
);
/*!
requires
- images.size() == rects.size()
- crops.size() == crop_rects.size()
- for all valid i:
- images[i].size() != 0
- array_type is a type with an interface compatible with dlib::array or
std::vector and it must in turn contain image objects that implement the
interface defined in dlib/image_processing/generic_image.h
ensures
- Randomly extracts num_crops chips from images and appends them to the end
of crops. We also copy the object metadata for each extracted crop and
store it into #crop_rects. In particular, calling this function is the
same as making multiple calls to the version of operator() below that
outputs a single crop, except that append() will use multiple CPU cores
to do the processing and is therefore faster.
- #crops.size() == crops.size()+num_crops
- #crop_rects.size() == crop_rects.size()+num_crops
!*/
template <
typename array_type
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment