使用opencv在Android中裁剪图像 [英] Cropping image in Android using opencv
本文介绍了使用opencv在Android中裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Android中使用OpenCV 2.3.1.我需要将图像裁剪成一半. 我正在做的是:
I am using OpenCV 2.3.1 in Android. I need to crop the image into half. What I am doing is:
Mat mIntermediateMat2 = new Mat(frame_height,frame_width,rgba.type);
mIntermediateMat2 = rgba.clone();
mIntermediateMat2 = mIntermediateMat2.rowRange(0,frame_height/2);
第三步将完成这项工作,还是我还要添加更多内容? 我在opencv 2.3文档中看到了Mat :: operator(),但不幸的是无法在opencv Android程序包中找到.
Will the third step do the job or I have to add something more? I saw Mat::operator() in opencv 2.3 documentation but unfortunately not able to find in the opencv Android package.
推荐答案
Mat类有一些构造函数,其中一个构造函数包含Mat和ROI(感兴趣的区域).
There are a few constructors for the Mat class, one of which takes a Mat and an ROI (region of interest).
以下是在Android/Java中执行此操作的方法:
Here's how to do it in Android/Java:
Mat uncropped = getUncroppedImage();
Rect roi = new Rect(x, y, width, height);
Mat cropped = new Mat(uncropped, roi);
这篇关于使用opencv在Android中裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文