Java Code Examples for org.opencv.features2d.DMatch

The following are top voted examples for showing how to use org.opencv.features2d.DMatch. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MemeVision   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 2
Project: RectangleDetection   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 3
Project: cardboardAR-lib   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 4
Project: Aruco-Marker-Tracking-Android   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 5
Project: ColorDetector   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 6
Project: MIME   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 7
Project: scene-recon-android   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 8
Project: Android-Car-duino   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 9
Project: dynamic-perspective-on-android   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 10
Project: ros-tms-perception   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 11
Project: CompCellScopeAndroid_Development   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 12
Project: FourierFilterCam   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 13
Project: ResistorScanner   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 14
Project: MapEver   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 15
Project: HelloOpenCVInAndroidStudioWithGradle   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 16
Project: mobile-tanker   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 17
Project: rastertheque   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 18
Project: cvRecognition   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 19
Project: android-opencv-template   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 20
Project: persontracker   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 21
Project: Poke-A-Droid   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 22
Project: LgdxOcv   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 23
Project: effective_android_sample   File: Converters.java   Source Code and License 6 votes vote down vote up
public static Mat vector_DMatch_to_Mat(List<DMatch> matches) {
    Mat res;
    int count = (matches != null) ? matches.size() : 0;
    if (count > 0) {
        res = new Mat(count, 1, CvType.CV_64FC4);
        double[] buff = new double[count * 4];
        for (int i = 0; i < count; i++) {
            DMatch m = matches.get(i);
            buff[4 * i] = m.queryIdx;
            buff[4 * i + 1] = m.trainIdx;
            buff[4 * i + 2] = m.imgIdx;
            buff[4 * i + 3] = m.distance;
        }
        res.put(0, 0, buff);
    } else {
        res = new Mat();
    }
    return res;
}
 
Example 24
Project: TinyPlanetMaker   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 25
Project: TinyPlanetMaker   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}
 
Example 26
Project: TinyPlanetMaker   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public DMatch[] toArray() {
    int num = (int) total();
    DMatch[] a = new DMatch[num];
    if(num == 0)
        return a;
    float buff[] = new float[num * _channels];
    get(0, 0, buff); //TODO: check ret val!
    for(int i=0; i<num; i++)
        a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
    return a;
}
 
Example 27
Project: android-things-drawbot   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 28
Project: android-things-drawbot   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}
 
Example 29
Project: android-things-drawbot   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public DMatch[] toArray() {
    int num = (int) total();
    DMatch[] a = new DMatch[num];
    if(num == 0)
        return a;
    float buff[] = new float[num * _channels];
    get(0, 0, buff); //TODO: check ret val!
    for(int i=0; i<num; i++)
        a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
    return a;
}
 
Example 30
Project: Android-Crop-Receipt   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 31
Project: Android-Crop-Receipt   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}
 
Example 32
Project: Android-Crop-Receipt   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public DMatch[] toArray() {
    int num = (int) total();
    DMatch[] a = new DMatch[num];
    if(num == 0)
        return a;
    float buff[] = new float[num * _channels];
    get(0, 0, buff); //TODO: check ret val!
    for(int i=0; i<num; i++)
        a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
    return a;
}
 
Example 33
Project: AndroidCameraSudokuSolver   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 34
Project: AndroidCameraSudokuSolver   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}
 
Example 35
Project: AndroidCameraSudokuSolver   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public DMatch[] toArray() {
    int num = (int) total();
    DMatch[] a = new DMatch[num];
    if(num == 0)
        return a;
    float buff[] = new float[num * _channels];
    get(0, 0, buff); //TODO: check ret val!
    for(int i=0; i<num; i++)
        a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
    return a;
}
 
Example 36
Project: OpenCV_Android_Plus   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 37
Project: OpenCV_Android_Plus   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}
 
Example 38
Project: OpenCV_Android_Plus   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public DMatch[] toArray() {
    int num = (int) total();
    DMatch[] a = new DMatch[num];
    if(num == 0)
        return a;
    float buff[] = new float[num * _channels];
    get(0, 0, buff); //TODO: check ret val!
    for(int i=0; i<num; i++)
        a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
    return a;
}
 
Example 39
Project: MemeVision   File: Converters.java   Source Code and License 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 40
Project: MemeVision   File: MatOfDMatch.java   Source Code and License 5 votes vote down vote up
public void fromArray(DMatch...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++) {
        DMatch m = a[i];
        buff[_channels*i+0] = m.queryIdx;
        buff[_channels*i+1] = m.trainIdx;
        buff[_channels*i+2] = m.imgIdx;
        buff[_channels*i+3] = m.distance;
    }
    put(0, 0, buff); //TODO: check ret val!
}