Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The aspect ratio is preserved when both width and height are scaled by the same factor.

To resize an image to a fixed width (similar logic for fixed height), scale both the width and height by a scale factor given by:

double scale = float(width)/input.size().width;

cv::resize(inputArray, outputArray, cv::Size(0, 0), scale, scale);