Example usage for org.opencv.core MatOfPoint3f create

List of usage examples for org.opencv.core MatOfPoint3f create

Introduction

In this page you can find the example usage for org.opencv.core MatOfPoint3f create.

Prototype

public void create(int rows, int cols, int type) 

Source Link

Usage

From source file:com.android.cts.verifier.sensors.RVCVXCheckAnalyzer.java

License:Apache License

/**
 * Generate pattern geometry like this one
 * http://docs.opencv.org/trunk/_downloads/acircles_pattern.png
 *
 * @return Array of 3D points//from  ww  w.j  a v  a 2s.c  om
 */
private MatOfPoint3f asymmetricalCircleGrid(Size size) {
    final int cn = 3;

    int n = (int) (size.width * size.height);
    float positions[] = new float[n * cn];
    float unit = 0.02f;
    MatOfPoint3f grid = new MatOfPoint3f();

    for (int i = 0; i < size.height; i++) {
        for (int j = 0; j < size.width * cn; j += cn) {
            positions[(int) (i * size.width * cn + j + 0)] = (2 * (j / cn) + i % 2) * (float) unit;
            positions[(int) (i * size.width * cn + j + 1)] = i * unit;
            positions[(int) (i * size.width * cn + j + 2)] = 0;
        }
    }
    grid.create(n, 1, CvType.CV_32FC3);
    grid.put(0, 0, positions);
    return grid;
}