Example usage for org.opencv.core CvType typeToString

List of usage examples for org.opencv.core CvType typeToString

Introduction

In this page you can find the example usage for org.opencv.core CvType typeToString.

Prototype

public static final String typeToString(int type) 

Source Link

Usage

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static byte getByte(final int row, final int col, final Mat mat) {
    if (CvType.CV_8UC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_8UC1, we found: " + CvType.typeToString(mat.type()));

    mat.get(row, col, _byteBuff1);//from  w  ww  .  j  av  a  2s.  co m
    return _byteBuff1[0];
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

/**
 * The corresponding Java primitive array type depends on the Mat type:
 * CV_8U and CV_8S -> byte[]//from www  .  j ava  2  s .  c om
 * CV_16U and CV_16S -> short[]
 * CV_32S -> int[]
 * CV_32F -> float[]
 * CV_64F-> double[]
 */
static byte[] getByteArray(final Mat mat) {
    if (CvType.CV_8UC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_8UC1, we found: " + CvType.typeToString(mat.type()));

    final int size = (int) (mat.total() * mat.channels());
    if (_byteBuff.length != size) {
        _byteBuff = new byte[size];
    }
    mat.get(0, 0, _byteBuff); // 0 for row and col means the WHOLE Matrix
    return _byteBuff;
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static int[] getIntArray(final Mat mat) {
    if (CvType.CV_32SC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_32SC1, we found: " + CvType.typeToString(mat.type()));

    final int size = (int) (mat.total() * mat.channels());
    if (_intBuff.length != size) {
        _intBuff = new int[size];
    }//from  w w  w . jav  a2 s  . c  o m
    mat.get(0, 0, _intBuff); // 0 for row and col means the WHOLE Matrix
    return _intBuff;
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static float[] getFloatArray(final Mat mat) {
    if (CvType.CV_32FC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_32FC1, we found: " + CvType.typeToString(mat.type()));

    final int size = (int) (mat.total() * mat.channels());
    if (_floatBuff.length != size) {
        _floatBuff = new float[size];
    }//from  w  w w .  j  a  v a  2 s .  co m
    mat.get(0, 0, _floatBuff); // 0 for row and col means the WHOLE Matrix
    return _floatBuff;
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static double[] getDoubleArray(final Mat mat) {
    if (CvType.CV_64F != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_64F, we found: " + CvType.typeToString(mat.type()));

    final int size = (int) (mat.total() * mat.channels());
    if (_doubleBuff.length != size) {
        _doubleBuff = new double[size];
    }//from www . ja  v  a  2  s. c o  m
    mat.get(0, 0, _doubleBuff); // 0 for row and col means the WHOLE Matrix
    return _doubleBuff;
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static int getInt(final int row, final int col, final Mat mat) {
    if (CvType.CV_32SC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_32SC1, we found: " + CvType.typeToString(mat.type()));

    mat.get(row, col, _intBuff1);//  w w w .  j av a2 s. c o  m
    return _intBuff1[0];
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static float getFloat(final int row, final int col, final Mat mat) {
    if (CvType.CV_32F != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_32F, we found: " + CvType.typeToString(mat.type()));

    mat.get(row, col, _floatBuff1);//from   ww  w .j  a  v a2s. c  o  m
    return _floatBuff1[0];
}

From source file:com.trandi.opentld.tld.Util.java

License:Apache License

static double getDouble(final int row, final int col, final Mat mat) {
    if (CvType.CV_64F != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_64F, we found: " + CvType.typeToString(mat.type()));

    mat.get(row, col, _doubleBuff1);/*from   w w  w.  j  a v  a 2s. c om*/
    return _doubleBuff1[0];
}

From source file:gab.opencv.OpenCV.java

License:Open Source License

public String matToS(Mat mat) {
    return CvType.typeToString(mat.type());
}

From source file:syncleus.dann.data.video.TLDUtil.java

License:Apache License

public static byte getByte(final int row, final int col, final Mat mat) {
    if (CvType.CV_8UC1 != mat.type())
        throw new IllegalArgumentException(
                "Expected type is CV_8UC1, we found: " + CvType.typeToString(mat.type()));

    mat.get(row, col, _byteBuff1);/*from w w w .j  av  a  2  s.  co m*/
    return _byteBuff1[0];
}