Added OpenCv Utility class, with a method for resizing a giving Mat.

parent b02b610c
package com.aluxoft.earrecognition.utils;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
/**
* Created by josejuliomartinez on 08/10/15.
*/
public class OpenCvUtils {
public static void resizeMat(Mat image, double maxWidth, double maxHeight) {
if (image.width() <= maxWidth && image.height() <= maxHeight) {
return;
}
double ratio = (double)image.width() / (double)image.height();
double width, height;
if (ratio > 1) {
width = maxWidth;
height = maxWidth * ((double)image.height()/(double)image.width());
} else {
height = maxHeight;
width = maxHeight* ratio;
}
Imgproc.resize(image, image, new Size(width, height));
}
private OpenCvUtils() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment