From 40448e64bd27a8d6e8dbd3071707eb7659cc4938 Mon Sep 17 00:00:00 2001 From: Davis King <davis@dlib.net> Date: Sat, 7 Oct 2017 14:09:09 -0400 Subject: [PATCH] Made add_image_left_right_flips() and add_image_rotations() work with mmod_rects in addition to rectangles and full_object_detections. --- dlib/image_transforms/interpolation.h | 15 ++++++++++++--- dlib/image_transforms/interpolation_abstract.h | 12 ++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/dlib/image_transforms/interpolation.h b/dlib/image_transforms/interpolation.h index ac988a12..c46ea7d6 100644 --- a/dlib/image_transforms/interpolation.h +++ b/dlib/image_transforms/interpolation.h @@ -1163,6 +1163,15 @@ namespace dlib return centered_rect(tran(center(rect)), rect.width(), rect.height()); } + inline mmod_rect tform_object ( + const point_transform_affine& tran, + mmod_rect rect + ) + { + rect.rect = tform_object(tran, rect.rect); + return rect; + } + inline full_object_detection tform_object( const point_transform_affine& tran, const full_object_detection& obj @@ -1209,7 +1218,7 @@ namespace dlib for (unsigned long i = 0; i < objects[j].size(); ++i) rects.push_back(impl::tform_object(tran, objects[j][i])); - images.push_back(temp); + images.push_back(std::move(temp)); objects.push_back(rects); } } @@ -1245,7 +1254,7 @@ namespace dlib for (unsigned long j = 0; j < num; ++j) { const point_transform_affine tran = flip_image_left_right(images[j], temp); - images.push_back(temp); + images.push_back(std::move(temp)); rects.clear(); for (unsigned long i = 0; i < objects[j].size(); ++i) @@ -1544,7 +1553,7 @@ namespace dlib for (unsigned long j = 0; j < images.size(); ++j) { const point_transform_affine tran = rotate_image(images[j], temp, angles(i)); - new_images.push_back(temp); + new_images.push_back(std::move(temp)); objtemp.clear(); for (unsigned long k = 0; k < objects[j].size(); ++k) diff --git a/dlib/image_transforms/interpolation_abstract.h b/dlib/image_transforms/interpolation_abstract.h index 869d3e03..a31520bc 100644 --- a/dlib/image_transforms/interpolation_abstract.h +++ b/dlib/image_transforms/interpolation_abstract.h @@ -499,7 +499,7 @@ namespace dlib requires - image_array_type == a dlib::array or std::vector of image objects that each implement the interface defined in dlib/image_processing/generic_image.h - - T == rectangle or full_object_detection + - T == rectangle, full_object_detection, or mmod_rect - images.size() == objects.size() ensures - This function computes all the left/right flips of the contents of images and @@ -532,8 +532,8 @@ namespace dlib implement the interface defined in dlib/image_processing/generic_image.h - images.size() == objects.size() - images.size() == objects2.size() - - T == rectangle or full_object_detection - - U == rectangle or full_object_detection + - T == rectangle, full_object_detection, or mmod_rect + - U == rectangle, full_object_detection, or mmod_rect ensures - This function computes all the left/right flips of the contents of images and then appends them onto the end of the images array. It also finds the @@ -571,8 +571,8 @@ namespace dlib - angles.size() > 0 - images.size() == objects.size() - images.size() == objects2.size() - - T == rectangle or full_object_detection - - U == rectangle or full_object_detection + - T == rectangle, full_object_detection, or mmod_rect + - U == rectangle, full_object_detection, or mmod_rect ensures - This function computes angles.size() different rotations of all the given images and then replaces the contents of images with those rotations of the @@ -608,7 +608,7 @@ namespace dlib - is_vector(angles) == true - angles.size() > 0 - images.size() == objects.size() - - T == rectangle or full_object_detection + - T == rectangle, full_object_detection, or mmod_rect ensures - This function is identical to the add_image_rotations() define above except that it doesn't have objects2 as an argument. -- 2.18.0