[英]Android OpenCV Create Rect
Good evening, need some help with getting a square area of rgb pixels with openCV Im trying to get the pixels from a 50x50 area on the center of the screen, but i didnt get any success. 晚上好,需要一些帮助来通过openCV获得正方形的rgb像素。我试图从屏幕中心的50x50区域获得像素,但是我没有获得任何成功。 if i use the output i dont get any pixel else if using original mat(image) its getting the top corner Please someone help 如果我使用输出,如果使用原始mat(image),则不会得到任何其他像素,它会到达顶角。请有人帮助
@Override
public void onPreviewFrame(Mat image) {
int w = image.cols();
int h = image.rows();
Mat roi=new Mat(image, new Rect(h/2 , w/2 , 50, 50));
Mat output = roi.clone();
int rw=output.cols();
int rh=output.rows();
//double [] arrp = output.get(rh, rw);//if i use the output i dont get any pixel
double [] arrp = image.get(rh, rw);//if use original mat its getting the top corner
Log.i("",+(int)arrp[2]+" "+ (int)arrp[1]+" "+(int)arrp[0]);
}
I assume you can use copyTo
: 我假设您可以使用copyTo
:
Mat output(50, 50, image.type());
image(Rect(h/2 , w/2 , output.size())).copyTo(output);
The matrix class has an operator (const Rect &roi), that returns a submatrix (without deep data copy). 矩阵类具有一个运算符(const Rect&roi),该运算符返回一个子矩阵(不包含深层数据副本)。 : http://docs.opencv.org/modules/core/doc/basic_structures.html#id6 : http : //docs.opencv.org/modules/core/doc/basic_structures.html#id6
EDIT: 编辑:
Didn't see it was for android. 没有看到它是为Android。 I think there is no operator, so you have to use the submat
function : 我认为没有运算符,因此您必须使用submat
函数:
image.submat(Rect(h/2 , w/2 , output.size())).copyTo(output)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.