Commit a215c494 authored by Davis King's avatar Davis King

Added missing requires clauses and asserts.

parent d41613d7
...@@ -135,6 +135,7 @@ namespace dlib ...@@ -135,6 +135,7 @@ namespace dlib
std::vector<mmod_rect>& crop_rects std::vector<mmod_rect>& crop_rects
) )
{ {
DLIB_CASSERT(num_rows(img)*num_columns(img) != 0);
chip_details crop_plan; chip_details crop_plan;
bool should_flip_crop; bool should_flip_crop;
make_crop_plan(img, rects, crop_plan, should_flip_crop); make_crop_plan(img, rects, crop_plan, should_flip_crop);
...@@ -233,9 +234,10 @@ namespace dlib ...@@ -233,9 +234,10 @@ namespace dlib
template <typename image_type> template <typename image_type>
rectangle make_random_cropping_rect_resnet( rectangle make_random_cropping_rect_resnet(
const image_type& img const image_type& img_
) )
{ {
const_image_view<image_type> img(img_);
// figure out what rectangle we want to crop from the image // figure out what rectangle we want to crop from the image
double mins = 0.1, maxs = 0.95; double mins = 0.1, maxs = 0.95;
auto scale = rnd.get_double_in_range(mins, maxs); auto scale = rnd.get_double_in_range(mins, maxs);
......
...@@ -174,6 +174,11 @@ namespace dlib ...@@ -174,6 +174,11 @@ namespace dlib
/*! /*!
requires requires
- images.size() == rects.size() - images.size() == 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 ensures
- Randomly extracts num_crops chips from images. We also copy the object - Randomly extracts num_crops chips from images. We also copy the object
metadata for each extracted crop and store it into #crop_rects. In metadata for each extracted crop and store it into #crop_rects. In
...@@ -195,6 +200,13 @@ namespace dlib ...@@ -195,6 +200,13 @@ namespace dlib
/*! /*!
requires requires
- images.size() == rects.size() - images.size() == rects.size()
- for all valid i:
- images[i].size() != 0
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
- 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 ensures
- Selects a random image and creates a random crop from it. Specifically, - Selects a random image and creates a random crop from it. Specifically,
we pick a random index IDX < images.size() and then execute we pick a random index IDX < images.size() and then execute
...@@ -212,6 +224,12 @@ namespace dlib ...@@ -212,6 +224,12 @@ namespace dlib
std::vector<mmod_rect>& crop_rects std::vector<mmod_rect>& crop_rects
); );
/*! /*!
requires
- img.size() != 0
- image_type1 == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
- image_type2 == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures ensures
- Extracts a random crop from img and copies over the mmod_rect objects in - Extracts a random crop from img and copies over the mmod_rect objects in
rects to #crop_rects if they are contained inside the crop. Moreover, rects to #crop_rects if they are contained inside the crop. Moreover,
......
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