的15×15像素的Andr​​oid Mat.get()区域 [英] Android Mat.get() area of 15x15 pixels

查看:196
本文介绍了的15×15像素的Andr​​oid Mat.get()区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助请求。
林能够得到使用OpenCV的摄像头preVIEW的特定点的像素信息

help is requested. Im able to get pixel information of a specific point in camera preview using openCV

    @Override
public void onPreviewFrame(Mat image) {
    if (image == null || image.empty() == true) return;

    int w = image.cols(); //640 columns
    int h = image.rows(); //480 rows
    double [] p = image.get(h/2, w/2); //dividing them getting 1 point = 1 pixel
    if (p == null || p.length < 3) return;
    overlay_view.setRGB((int)p[2], (int)p[1], (int)p[0]);
}

但我怎么会得到15×15像素的区域阵列将开始H / 2和W / 2点?

but how i would get the array from 15x15 pixels area that will start at h/2 and w/2 points?

推荐答案

事情是这样的:

@Override
public void onPreviewFrame(Mat image) {
    if (image == null || image.empty() == true) return;

    int w = image.cols(); //640 columns
    int h = image.rows(); //480 rows

    double[][][] array15x15 = new double[15][15][3];

    for (int row = 0; row < 15; row++) {
        for (int col = 0; col < 15; col++) {
            double[] p = image.get(w/2 + row, h/2 + col);
            if (p == null || p.length < 3) return;
            else {
                array15x15[row][col] = p;
            }
        }
    }
}

这篇关于的15×15像素的Andr​​oid Mat.get()区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆