Java Code Examples for org.opencv.core.Mat#type()

The following examples show how to use org.opencv.core.Mat#type() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Converters.java    From SimpleDocumentScanner-Android with MIT License 6 votes vote down vote up
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]));
    }
}
 
Example 2
Source File: Converters.java    From SmartPaperScan with Apache License 2.0 6 votes vote down vote up
public static void Mat_to_vector_Mat(Mat m, List<Mat> mats) {
    if (mats == null)
        throw new java.lang.IllegalArgumentException("mats == null");
    int count = m.rows();
    if (CvType.CV_32SC2 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC2 != m.type() ||  m.cols()!=1\n" + m);

    mats.clear();
    int[] buff = new int[count * 2];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        long addr = (((long) buff[i * 2]) << 32) | (((long) buff[i * 2 + 1]) & 0xffffffffL);
        mats.add(new Mat(addr));
    }
}
 
Example 3
Source File: Converters.java    From OpenCV-android with Apache License 2.0 6 votes vote down vote up
public static void Mat_to_vector_Mat(Mat m, List<Mat> mats) {
    if (mats == null)
        throw new java.lang.IllegalArgumentException("mats == null");
    int count = m.rows();
    if (CvType.CV_32SC2 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC2 != m.type() ||  m.cols()!=1\n" + m);

    mats.clear();
    int[] buff = new int[count * 2];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        long addr = (((long) buff[i * 2]) << 32) | (((long) buff[i * 2 + 1]) & 0xffffffffL);
        mats.add(new Mat(addr));
    }
}
 
Example 4
Source File: Converters.java    From Android-Car-duino with GNU General Public License v2.0 6 votes vote down vote up
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]));
    }
}
 
Example 5
Source File: Converters.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void Mat_to_vector_uchar(Mat m, List<Byte> us) {
    if (us == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_8UC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_8UC1 != m.type() ||  m.cols()!=1\n" + m);

    us.clear();
    byte[] buff = new byte[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        us.add(buff[i]);
    }
}
 
Example 6
Source File: Converters.java    From OpenCV-Android-Object-Detection with MIT License 5 votes vote down vote up
public static void Mat_to_vector_char(Mat m, List<Byte> bs) {
    if (bs == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_8SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_8SC1 != m.type() ||  m.cols()!=1\n" + m);

    bs.clear();
    byte[] buff = new byte[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        bs.add(buff[i]);
    }
}
 
Example 7
Source File: Converters.java    From FTCVision with MIT 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 8
Source File: Converters.java    From Form-N-Fun with MIT License 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example 9
Source File: Converters.java    From MOAAP with MIT 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 10
Source File: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_int(Mat m, List<Integer> is) {
    if (is == null)
        throw new java.lang.IllegalArgumentException("is == null");
    int count = m.rows();
    if (CvType.CV_32SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC1 != m.type() ||  m.cols()!=1\n" + m);

    is.clear();
    int[] buff = new int[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        is.add(buff[i]);
    }
}
 
Example 11
Source File: Converters.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public static void Mat_to_vector_Rect2d(Mat m, List<Rect2d> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == 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.rows()!=1\n" + m);

    rs.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect2d(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example 12
Source File: Converters.java    From faceswap with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_char(Mat m, List<Byte> bs) {
    if (bs == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_8SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_8SC1 != m.type() ||  m.cols()!=1\n" + m);

    bs.clear();
    byte[] buff = new byte[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        bs.add(buff[i]);
    }
}
 
Example 13
Source File: Converters.java    From MOAAP with MIT 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 14
Source File: Converters.java    From sudokufx with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example 15
Source File: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_uchar(Mat m, List<Byte> us) {
    if (us == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_8UC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_8UC1 != m.type() ||  m.cols()!=1\n" + m);

    us.clear();
    byte[] buff = new byte[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        us.add(buff[i]);
    }
}
 
Example 16
Source File: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_int(Mat m, List<Integer> is) {
    if (is == null)
        throw new java.lang.IllegalArgumentException("is == null");
    int count = m.rows();
    if (CvType.CV_32SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC1 != m.type() ||  m.cols()!=1\n" + m);

    is.clear();
    int[] buff = new int[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        is.add(buff[i]);
    }
}
 
Example 17
Source File: Converters.java    From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" 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 18
Source File: Converters.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_int(Mat m, List<Integer> is) {
    if (is == null)
        throw new java.lang.IllegalArgumentException("is == null");
    int count = m.rows();
    if (CvType.CV_32SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC1 != m.type() ||  m.cols()!=1\n" + m);

    is.clear();
    int[] buff = new int[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        is.add(buff[i]);
    }
}
 
Example 19
Source File: Converters.java    From LPR with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_double(Mat m, List<Double> ds) {
    if (ds == null)
        throw new java.lang.IllegalArgumentException("ds == null");
    int count = m.rows();
    if (CvType.CV_64FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC1 != m.type() ||  m.cols()!=1\n" + m);

    ds.clear();
    double[] buff = new double[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        ds.add(buff[i]);
    }
}
 
Example 20
Source File: Converters.java    From OpenCvFaceDetect with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_int(Mat m, List<Integer> is) {
    if (is == null)
        throw new java.lang.IllegalArgumentException("is == null");
    int count = m.rows();
    if (CvType.CV_32SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC1 != m.type() ||  m.cols()!=1\n" + m);

    is.clear();
    int[] buff = new int[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        is.add(buff[i]);
    }
}