| 182 | } |
| 183 | |
| 184 | ImageRandomAreaCrop::ImageRandomAreaCrop( |
| 185 | const std::string& ikey, |
| 186 | std::pair<float, float> area_range, |
| 187 | std::pair<float, float> aspect_ratio_range, |
| 188 | int num_trial, |
| 189 | const std::string& okey) |
| 190 | : ImageTransformOp(ikey, okey), |
| 191 | areaRange_(area_range), |
| 192 | aspectRatioRange_(aspect_ratio_range), |
| 193 | numTrial_(num_trial) { |
| 194 | if ((area_range.first > area_range.second) || (area_range.first <= 0) || |
| 195 | (area_range.second > 1.0)) { |
| 196 | throw std::runtime_error("ImageRandomAreaCrop: invalid area range"); |
| 197 | } |
| 198 | if ((aspect_ratio_range.first > aspect_ratio_range.second) || |
| 199 | (aspect_ratio_range.first <= 0)) { |
| 200 | throw std::runtime_error("ImageRandomAreaCrop: invalid aspect ratio range"); |
| 201 | } |
| 202 | if ((area_range.first * aspect_ratio_range.first > 1) || |
| 203 | (area_range.first > aspect_ratio_range.second)) { |
| 204 | throw std::runtime_error( |
| 205 | "ImageRandomAreaCrop: provided area range and aspect ratio range cannot be fullfilled"); |
| 206 | } |
| 207 | if (numTrial_ <= 0) { |
| 208 | throw std::runtime_error( |
| 209 | "ImageRandomAreaCrop: number of trial must be positive"); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | ImageRandomAreaCrop::Parameters ImageRandomAreaCrop::generate_random_crop_( |
| 214 | int64_t w, |
nothing calls this directly
no outgoing calls
no test coverage detected