如何使用OpenCV for Android修改图片大小?

时间:2014-12-12 12:10:39

标签: android opencv

有人知道如何使用OpenCV for Android修改图片大小吗?

似乎将尺寸设置为最大值,我没有设法改变。 使用基于JavaCameraView的ImageManipulations教程,以下是我可以获得的最大分辨率: 相机预览尺寸。宽度:960高度:720 相机图片尺寸。宽度:640高度:480

问题在于我需要更高分辨率的照片(我不关心预览尺寸)。

也许在opencv论坛上有一个答案但是我无法访问这个答案,因为那里似乎有作品(OpenCVForum

1 个答案:

答案 0 :(得分:0)

您可以按如下方式调整Mat的大小:

    Size szSource = new Size(640,480);
    Size szResized = new Size(2592,1944);
    Mat mSource= new Mat(szSource, CvType.CV_8U);// Read or Fill Something in your mSource
    Mat mResised = new Mat();
    Imgproc.resize( mSource, mResised, szResized,0,0,INTER_NEAREST);//mSource-> Your Source image

interpolation – interpolation method can be any of the above
INTER_NEAREST - a nearest-neighbor interpolation
INTER_LINEAR - a bilinear interpolation (used by default)
INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

进一步参考please see this