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


Java CvType類代碼示例

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


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

示例1: Mat_to_vector_Mat

import org.opencv.core.CvType; //導入依賴的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:Deeplocal,項目名稱:android-things-drawbot,代碼行數:17,代碼來源:Converters.java

示例2: loadResource

import org.opencv.core.CvType; //導入依賴的package包/類
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException
{
    InputStream is = context.getResources().openRawResource(resourceId);
    ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());

    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = is.read(buffer)) != -1) {
        os.write(buffer, 0, bytesRead);
    }
    is.close();

    Mat encoded = new Mat(1, os.size(), CvType.CV_8U);
    encoded.put(0, 0, os.toByteArray());
    os.close();

    Mat decoded = Imgcodecs.imdecode(encoded, flags);
    encoded.release();

    return decoded;
}
 
開發者ID:raulh82vlc,項目名稱:Image-Detection-Samples,代碼行數:22,代碼來源:Utils.java

示例3: Mat_to_vector_KeyPoint

import org.opencv.core.CvType; //導入依賴的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:hoangphuc3117,項目名稱:Android-Crop-Receipt,代碼行數:17,代碼來源:Converters.java

示例4: denoise

import org.opencv.core.CvType; //導入依賴的package包/類
public static void denoise() {
        String imgInPath = "captchaExample.jpg";
        imgInPath = "MyCaptcha.PNG";
        imgInPath = "blurredtext.jpg";
        String imgOutPath = "captchaNoiseRemovedExample.png";
        imgOutPath = "MyNoiseRemovedCaptcha.PNG";

        Mat image = Imgcodecs.imread(imgInPath);
        Mat out = new Mat();
        Mat tmp = new Mat();
        Mat kernel = new Mat(new Size(3, 3), CvType.CV_8UC1, new Scalar(255));
//        Mat kernel = new Mat(image.size(), CvType.CV_8UC1, new Scalar(255));
        Imgproc.morphologyEx(image, tmp, Imgproc.MORPH_OPEN, kernel);
        Imgproc.morphologyEx(tmp, out, Imgproc.MORPH_CLOSE, kernel);
        Imgcodecs.imwrite(imgOutPath, out);
    }
 
開發者ID:PacktPublishing,項目名稱:Machine-Learning-End-to-Endguide-for-Java-developers,代碼行數:17,代碼來源:OpenCVNonMavenExamples.java

示例5: LuminanceWeight

import org.opencv.core.CvType; //導入依賴的package包/類
public static Mat LuminanceWeight(Mat img, Mat L) {
	Mat bCnl = new Mat();
	Core.extractChannel(img, bCnl, 0);
	bCnl.convertTo(bCnl, CvType.CV_32F);
	Mat gCnl = new Mat();
	Core.extractChannel(img, gCnl, 1);
	gCnl.convertTo(gCnl, CvType.CV_32F);
	Mat rCnl = new Mat();
	Core.extractChannel(img, rCnl, 2);
	rCnl.convertTo(rCnl, CvType.CV_32F);
	Mat lum = new Mat(L.rows(), L.cols(), L.type());
	for (int i = 0; i < L.rows(); i++) {
		for (int j = 0; j < L.cols(); j++) {
			double data = Math.sqrt( ( Math.pow(bCnl.get(i, j)[0] / 255.0 - L.get(i, j)[0], 2.0) +
					Math.pow(gCnl.get(i, j)[0] / 255.0 - L.get(i, j)[0], 2.0) +
					Math.pow(rCnl.get(i, j)[0] / 255.0 - L.get(i, j)[0], 2.0) ) / 3 );
			lum.put(i, j, data);
		}
	}
	return lum;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:22,代碼來源:FeatureWeight.java

示例6: mat2Bitmap

import org.opencv.core.CvType; //導入依賴的package包/類
private Bitmap mat2Bitmap(Mat src, int code) {
    Mat rgbaMat = new Mat(src.width(), src.height(), CvType.CV_8UC4);
    Imgproc.cvtColor(src, rgbaMat, code, 4);
    Bitmap bmp = Bitmap.createBitmap(rgbaMat.cols(), rgbaMat.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(rgbaMat, bmp);
    return bmp;
}
 
開發者ID:jorenham,項目名稱:fingerblox,代碼行數:8,代碼來源:ImageProcessing.java

示例7: onPictureTaken

import org.opencv.core.CvType; //導入依賴的package包/類
@Override
public void onPictureTaken(byte[] data, Camera camera) {
    Log.i(TAG, "Saving a bitmap to file");
    // The camera preview was automatically stopped. Start it again.
    mCamera.startPreview();
    mCamera.setPreviewCallback(this);

    // Write the image in a file (in jpeg format)
    try {
        /*FileOutputStream fos = new FileOutputStream(mPictureFileName);

        fos.write(data);
        fos.close();*/

        Bitmap bmp = BitmapFactory.decodeByteArray(data , 0, data.length);
        Mat orig = new Mat(bmp.getHeight(),bmp.getWidth(),CvType.CV_8UC3);
        Bitmap myBitmap32 = bmp.copy(Bitmap.Config.ARGB_8888, true);
        Utils.bitmapToMat(myBitmap32, orig);
        mImage = new Mat();
        Imgproc.cvtColor(orig,mImage,Imgproc.COLOR_RGB2GRAY);
        /*Imgproc.cvtColor(orig, orig, Imgproc.COLOR_BGR2RGB,4);
        Mat frame = new Mat(mFrameHeight+mFrameHeight/2,mFrameWidth, CvType.CV_8UC1);
        frame.put(0,0,data);
        //Imgcodecs.imdecode(frame,0);
        Imgproc.cvtColor(frame,mImage,Imgproc.COLOR_YUV2RGBA_NV21);//frame.submat(0, mFrameHeight, 0, mFrameWidth);*/

    } catch (Exception e) {
        Log.e("PictureDemo", "Exception in photoCallback", e);
    }

}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:32,代碼來源:CameraView.java

示例8: loadResource

import org.opencv.core.CvType; //導入依賴的package包/類
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException
{
    InputStream is = context.getResources().openRawResource(resourceId);
    ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());

    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = is.read(buffer)) != -1) {
        os.write(buffer, 0, bytesRead);
    }
    is.close();

    Mat encoded = new Mat(1, os.size(), CvType.CV_8U);
    encoded.put(0, 0, os.toByteArray());
    os.close();

    Mat decoded = Highgui.imdecode(encoded, flags);
    encoded.release();

    return decoded;
}
 
開發者ID:Deeplocal,項目名稱:android-things-drawbot,代碼行數:22,代碼來源:Utils.java

示例9: Mat_to_vector_int

import org.opencv.core.CvType; //導入依賴的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:TheBigBombman,項目名稱:RobotIGS,代碼行數:16,代碼來源:Converters.java

示例10: Mat_to_vector_Rect

import org.opencv.core.CvType; //導入依賴的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:johnhany,項目名稱:MOAAP,代碼行數:16,代碼來源:Converters.java

示例11: Mat_to_vector_char

import org.opencv.core.CvType; //導入依賴的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:johnhany,項目名稱:MOAAP,代碼行數:16,代碼來源:Converters.java

示例12: Mat_to_vector_DMatch

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

示例13: Mat_to_vector_double

import org.opencv.core.CvType; //導入依賴的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:vulovicv23,項目名稱:opencv-documentscanner-android,代碼行數:16,代碼來源:Converters.java

示例14: main

import org.opencv.core.CvType; //導入依賴的package包/類
public static void main (String[] args) {
    String imgPath = "src/main/resources/underwater_images/underwater_scene.jpg";
    Mat image = Imgcodecs.imread(imgPath, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    new ImShow("original").showImage(image); // show image
    Mat fusion = RemoveBackScatter.enhance(image, blkSize, patchSize, lambda, gamma, r, eps, level);
    fusion.convertTo(fusion, CvType.CV_8UC1);
    new ImShow("fusion").showImage(fusion); // show fusion result
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:9,代碼來源:RemoveBackScatterExample.java

示例15: main

import org.opencv.core.CvType; //導入依賴的package包/類
public static void main (String[] args) {
    String imgPath = "src/main/resources/haze_images/canon_2.jpg";
    Mat image = Imgcodecs.imread(imgPath, Imgcodecs.CV_LOAD_IMAGE_COLOR);
    new ImShow("org-image").showImage(image);
    Mat result = OptimizedContrastEnhance.enhance(image, blkSize, patchSize, lambda, eps, krnlSize);
    result.convertTo(result, CvType.CV_8UC1);
    new ImShow("dehaze-image").showImage(result);
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:9,代碼來源:OptimizedContrastEnhanceExample.java


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