當前位置: 首頁>>代碼示例>>Java>>正文


Java Mat.type方法代碼示例

本文整理匯總了Java中org.opencv.core.Mat.type方法的典型用法代碼示例。如果您正苦於以下問題:Java Mat.type方法的具體用法?Java Mat.type怎麽用?Java Mat.type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.core.Mat的用法示例。


在下文中一共展示了Mat.type方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Mat_to_vector_Mat

import org.opencv.core.Mat; //導入方法依賴的package包/類
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));
    }
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:17,代碼來源:Converters.java

示例2: Mat_to_vector_KeyPoint

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]));
    }
}
 
開發者ID:linzuzeng,項目名稱:Microsphere,代碼行數:17,代碼來源:Converters.java

示例3: preprocess

import org.opencv.core.Mat; //導入方法依賴的package包/類
static Bitmap preprocess(Mat frame, int width, int height) {
    // convert to grayscale
    Mat frameGrey = new Mat(height, width, CvType.CV_8UC1);
    Imgproc.cvtColor(frame, frameGrey, Imgproc.COLOR_BGR2GRAY, 1);

    // rotate
    Mat rotatedFrame = new Mat(width, height, frameGrey.type());
    Core.transpose(frameGrey, rotatedFrame);
    Core.flip(rotatedFrame, rotatedFrame, Core.ROTATE_180);

    // resize to match the surface view
    Mat resizedFrame = new Mat(width, height, rotatedFrame.type());
    Imgproc.resize(rotatedFrame, resizedFrame, new Size(width, height));

    // crop
    Mat ellipseMask = getEllipseMask(width, height);
    Mat frameCropped = new Mat(resizedFrame.rows(), resizedFrame.cols(), resizedFrame.type(), new Scalar(0));
    resizedFrame.copyTo(frameCropped, ellipseMask);

    // histogram equalisation
    Mat frameHistEq = new Mat(frame.rows(), frameCropped.cols(), frameCropped.type());
    Imgproc.equalizeHist(frameCropped, frameHistEq);

    // convert back to rgba
    Mat frameRgba = new Mat(frameHistEq.rows(), frameHistEq.cols(), CvType.CV_8UC4);
    Imgproc.cvtColor(frameHistEq, frameRgba, Imgproc.COLOR_GRAY2RGBA);

    // crop again to correct alpha
    Mat frameAlpha = new Mat(frameRgba.rows(), frameRgba.cols(), CvType.CV_8UC4, new Scalar(0, 0, 0, 0));
    frameRgba.copyTo(frameAlpha, ellipseMask);

    // convert to bitmap
    Bitmap bmp = Bitmap.createBitmap(frameAlpha.cols(), frameAlpha.rows(), Bitmap.Config.ARGB_4444);
    Utils.matToBitmap(frameAlpha, bmp);

    return bmp;
}
 
開發者ID:jorenham,項目名稱:fingerblox,代碼行數:38,代碼來源:ImageProcessing.java

示例4: Mat_to_vector_char

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]);
    }
}
 
開發者ID:ravindu1024,項目名稱:android-imaging-utils,代碼行數:16,代碼來源:Converters.java

示例5: Mat_to_vector_Rect2d

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]));
    }
}
 
開發者ID:linzuzeng,項目名稱:Microsphere,代碼行數:16,代碼來源:Converters.java

示例6: Mat_to_vector_int

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]);
    }
}
 
開發者ID:wblgers,項目名稱:OpenCV_Android_Plus,代碼行數:16,代碼來源:Converters.java

示例7: Mat_to_vector_Rect

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]));
    }
}
 
開發者ID:jmpaaak,項目名稱:EyeShopping,代碼行數:16,代碼來源:Converters.java

示例8: Mat_to_vector_uchar

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]);
    }
}
 
開發者ID:KAlO2,項目名稱:OpenCV,代碼行數:16,代碼來源:Converters.java

示例9: Mat_to_vector_double

import org.opencv.core.Mat; //導入方法依賴的package包/類
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]);
    }
}
 
開發者ID:daquexian,項目名稱:DNNLibrary,代碼行數:16,代碼來源:Converters.java

示例10: Mat_to_vector_float

import org.opencv.core.Mat; //導入方法依賴的package包/類
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:16,代碼來源:Converters.java


注:本文中的org.opencv.core.Mat.type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。