We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 45e8f61 + 0403748 commit 1d68808Copy full SHA for 1d68808
project/src/main.rs
@@ -193,9 +193,13 @@ impl TransformationTrait for Transformation {
193
}
194
},
195
Transformation::Crop { height, width } => {
196
+ let original_size = mat.size().unwrap();
197
+ let original_proportions = (original_size.width as f32) / (original_size.height as f32);
198
+ let crop_proportions = (width as f32 / height as f32);
199
+
200
let rect: cv::Rect;
201
let resized: cv::Mat;
- if width > height {
202
+ if crop_proportions > original_proportions {
203
resized = relative_resize_width(&mat, width);
204
rect = cv::Rect {
205
x: 0,
0 commit comments