Skip to content

Commit 1d68808

Browse files
committed
Merge pull request #3 from lazy-ants/bug_crop
fix bug with crop
2 parents 45e8f61 + 0403748 commit 1d68808

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

project/src/main.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ impl TransformationTrait for Transformation {
193193
}
194194
},
195195
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+
196200
let rect: cv::Rect;
197201
let resized: cv::Mat;
198-
if width > height {
202+
if crop_proportions > original_proportions {
199203
resized = relative_resize_width(&mat, width);
200204
rect = cv::Rect {
201205
x: 0,

0 commit comments

Comments
 (0)