Does OpenCV blobFromImage preserve the aspect ratio of the input image?

asked 2018-06-12 11:12:56 -0500

mhaghighat gravatar image

updated 2018-06-12 11:44:40 -0500

berak gravatar image

I wonder if the cv::blobFromImage() preserves the aspect ratio of the input image when it applies a resize or it stretches the image to the target size.

The documentation says "If crop is false, direct resize without cropping and preserving aspect ratio is performed". The word "and" makes the sentence a bit vague raising the question if "without" applies to the "preserving aspect ratio".

edit retag flag offensive close merge delete

Comments

2

here's what it does

and maybe, one should say: it's preserving the train image ratio , not the aspect ratio of your input image

berak gravatar imageberak ( 2018-06-12 11:24:52 -0500 )edit

So, it does not preserve the aspect ratio. Thanks a lot.

mhaghighat gravatar imagemhaghighat ( 2018-06-12 11:34:14 -0500 )edit

yea, it's a bit backwards. in fact, setting crop to false would preserve your input ratio, but in most cases, this is not desirable, as your image could be one of a dog, 1024x256,with a 128x128 dog somewhere in the middle.

berak gravatar imageberak ( 2018-06-12 11:41:12 -0500 )edit