Search in sources :

Example 1 with KeyPoint

use of org.opencv.core.KeyPoint in project Relic_Main by TeamOverdrive.

the class MatOfKeyPoint method fromArray.

public void fromArray(KeyPoint... a) {
    if (a == null || a.length == 0)
        return;
    int num = a.length;
    alloc(num);
    float[] buff = new float[num * _channels];
    for (int i = 0; i < num; i++) {
        KeyPoint kp = a[i];
        buff[_channels * i + 0] = (float) kp.pt.x;
        buff[_channels * i + 1] = (float) kp.pt.y;
        buff[_channels * i + 2] = kp.size;
        buff[_channels * i + 3] = kp.angle;
        buff[_channels * i + 4] = kp.response;
        buff[_channels * i + 5] = kp.octave;
        buff[_channels * i + 6] = kp.class_id;
    }
    // TODO: check ret val!
    put(0, 0, buff);
}
Also used : KeyPoint(org.opencv.core.KeyPoint) KeyPoint(org.opencv.core.KeyPoint)

Example 2 with KeyPoint

use of org.opencv.core.KeyPoint in project Relic_Main by TeamOverdrive.

the class Converters method Mat_to_vector_KeyPoint.

public static void Mat_to_vector_KeyPoint(Mat m, List<KeyPoint> kps) {
    if (kps == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC(7) != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException("CvType.CV_64FC(7) != m.type() ||  m.cols()!=1\n" + m);
    kps.clear();
    double[] buff = new double[7 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        kps.add(new KeyPoint((float) buff[7 * i], (float) buff[7 * i + 1], (float) buff[7 * i + 2], (float) buff[7 * i + 3], (float) buff[7 * i + 4], (int) buff[7 * i + 5], (int) buff[7 * i + 6]));
    }
}
Also used : MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) Point(org.opencv.core.Point) MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) MatOfPoint(org.opencv.core.MatOfPoint)

Example 3 with KeyPoint

use of org.opencv.core.KeyPoint in project Relic_Main by TeamOverdrive.

the class Converters method vector_KeyPoint_to_Mat.

public static Mat vector_KeyPoint_to_Mat(List<KeyPoint> kps) {
    Mat res;
    int count = (kps != null) ? kps.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC(7));
        double[] buff = new double[count * 7];
        for (int i = 0; i < count; i++) {
            KeyPoint kp = kps.get(i);
            buff[7 * i] = kp.pt.x;
            buff[7 * i + 1] = kp.pt.y;
            buff[7 * i + 2] = kp.size;
            buff[7 * i + 3] = kp.angle;
            buff[7 * i + 4] = kp.response;
            buff[7 * i + 5] = kp.octave;
            buff[7 * i + 6] = kp.class_id;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
Also used : Mat(org.opencv.core.Mat) MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) Point(org.opencv.core.Point) MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) MatOfPoint(org.opencv.core.MatOfPoint)

Example 4 with KeyPoint

use of org.opencv.core.KeyPoint in project Relic_Main by TeamOverdrive.

the class MatOfKeyPoint method toArray.

public KeyPoint[] toArray() {
    int num = (int) total();
    KeyPoint[] a = new KeyPoint[num];
    if (num == 0)
        return a;
    float[] buff = new float[num * _channels];
    // TODO: check ret val!
    get(0, 0, buff);
    for (int i = 0; i < num; i++) a[i] = new KeyPoint(buff[_channels * i + 0], buff[_channels * i + 1], buff[_channels * i + 2], buff[_channels * i + 3], buff[_channels * i + 4], (int) buff[_channels * i + 5], (int) buff[_channels * i + 6]);
    return a;
}
Also used : KeyPoint(org.opencv.core.KeyPoint) KeyPoint(org.opencv.core.KeyPoint)

Aggregations

KeyPoint (org.opencv.core.KeyPoint)4 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)2 MatOfPoint (org.opencv.core.MatOfPoint)2 Point (org.opencv.core.Point)2 Mat (org.opencv.core.Mat)1