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


Java MatOfInt.get方法代碼示例

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


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

示例1: filterContours

import org.opencv.core.MatOfInt; //導入方法依賴的package包/類
/**
 * Filters out contours that do not meet certain criteria.
 * 
 * @param inputContours
 *            is the input list of contours
 * @param output
 *            is the the output list of contours
 * @param minArea
 *            is the minimum area of a contour that will be kept
 * @param minPerimeter
 *            is the minimum perimeter of a contour that will be kept
 * @param minWidth
 *            minimum width of a contour
 * @param maxWidth
 *            maximum width
 * @param minHeight
 *            minimum height
 * @param maxHeight
 *            maximimum height
 * @param Solidity
 *            the minimum and maximum solidity of a contour
 * @param minVertexCount
 *            minimum vertex Count of the contours
 * @param maxVertexCount
 *            maximum vertex Count
 * @param minRatio
 *            minimum ratio of width to height
 * @param maxRatio
 *            maximum ratio of width to height
 */
private void filterContours(List<MatOfPoint> inputContours, double minArea, double minPerimeter, double minWidth,
		double maxWidth, double minHeight, double maxHeight, double[] solidity, double maxVertexCount,
		double minVertexCount, double minRatio, double maxRatio, List<MatOfPoint> output) {
	final MatOfInt hull = new MatOfInt();
	output.clear();
	// operation
	for (int i = 0; i < inputContours.size(); i++) {
		final MatOfPoint contour = inputContours.get(i);
		final Rect bb = Imgproc.boundingRect(contour);
		if (bb.width < minWidth || bb.width > maxWidth)
			continue;
		if (bb.height < minHeight || bb.height > maxHeight)
			continue;
		final double area = Imgproc.contourArea(contour);
		if (area < minArea)
			continue;
		if (Imgproc.arcLength(new MatOfPoint2f(contour.toArray()), true) < minPerimeter)
			continue;
		Imgproc.convexHull(contour, hull);
		MatOfPoint mopHull = new MatOfPoint();
		mopHull.create((int) hull.size().height, 1, CvType.CV_32SC2);
		for (int j = 0; j < hull.size().height; j++) {
			int index = (int) hull.get(j, 0)[0];
			double[] point = new double[] { contour.get(index, 0)[0], contour.get(index, 0)[1] };
			mopHull.put(j, 0, point);
		}
		final double solid = 100 * area / Imgproc.contourArea(mopHull);
		if (solid < solidity[0] || solid > solidity[1])
			continue;
		if (contour.rows() < minVertexCount || contour.rows() > maxVertexCount)
			continue;
		final double ratio = bb.width / (double) bb.height;
		if (ratio < minRatio || ratio > maxRatio)
			continue;
		output.add(contour);
	}
}
 
開發者ID:chopshop-166,項目名稱:frc-2017,代碼行數:68,代碼來源:Vision.java

示例2: filterContours

import org.opencv.core.MatOfInt; //導入方法依賴的package包/類
/**
 * Filters out contours that do not meet certain criteria.
 * @param inputContours is the input list of contours
 * @param output is the the output list of contours
 * @param minArea is the minimum area of a contour that will be kept
 * @param minPerimeter is the minimum perimeter of a contour that will be kept
 * @param minWidth minimum width of a contour
 * @param maxWidth maximum width
 * @param minHeight minimum height
 * @param maxHeight maximimum height
 * @param Solidity the minimum and maximum solidity of a contour
 * @param minVertexCount minimum vertex Count of the contours
 * @param maxVertexCount maximum vertex Count
 * @param minRatio minimum ratio of width to height
 * @param maxRatio maximum ratio of width to height
 */
private void filterContours(List<MatOfPoint> inputContours, double minArea,
	double minPerimeter, double minWidth, double maxWidth, double minHeight, double
	maxHeight, double[] solidity, double maxVertexCount, double minVertexCount, double
	minRatio, double maxRatio, List<MatOfPoint> output) {
	final MatOfInt hull = new MatOfInt();
	output.clear();
	//operation
	for (int i = 0; i < inputContours.size(); i++) {
		final MatOfPoint contour = inputContours.get(i);
		final Rect bb = Imgproc.boundingRect(contour);
		if (bb.width < minWidth || bb.width > maxWidth) continue;
		if (bb.height < minHeight || bb.height > maxHeight) continue;
		final double area = Imgproc.contourArea(contour);
		if (area < minArea) continue;
		if (Imgproc.arcLength(new MatOfPoint2f(contour.toArray()), true) < minPerimeter) continue;
		Imgproc.convexHull(contour, hull);
		MatOfPoint mopHull = new MatOfPoint();
		mopHull.create((int) hull.size().height, 1, CvType.CV_32SC2);
		for (int j = 0; j < hull.size().height; j++) {
			int index = (int)hull.get(j, 0)[0];
			double[] point = new double[] { contour.get(index, 0)[0], contour.get(index, 0)[1]};
			mopHull.put(j, 0, point);
		}
		final double solid = 100 * area / Imgproc.contourArea(mopHull);
		if (solid < solidity[0] || solid > solidity[1]) continue;
		if (contour.rows() < minVertexCount || contour.rows() > maxVertexCount)	continue;
		final double ratio = bb.width / (double)bb.height;
		if (ratio < minRatio || ratio > maxRatio) continue;
		output.add(contour);
	}
}
 
開發者ID:mustafamertunali,項目名稱:FRC-6416-frc2017,代碼行數:48,代碼來源:GripPipeline.java

示例3: scoreContour

import org.opencv.core.MatOfInt; //導入方法依賴的package包/類
/**
 * Score contour based on a variety of factors
 * @param mop contour to score
 * @return contour score (range from 0 to infinity?)
 */
private double scoreContour(MatOfPoint mop) {
	// Score on solidity -- ideally find 100% solid rectangle
	final MatOfInt hull = new MatOfInt(); // is this expensive?
	final double area = Imgproc.contourArea(mop);
	Imgproc.convexHull(mop, hull);
	MatOfPoint mopHull = new MatOfPoint();
	mopHull.create((int) hull.size().height, 1, CvType.CV_32SC2);
	for (int j = 0; j < hull.size().height; j++) {
		int index = (int)hull.get(j, 0)[0];
		double[] point = new double[] { mop.get(index, 0)[0], mop.get(index, 0)[1]};
		mopHull.put(j, 0, point);
	}
	final double solid = 100 * area / Imgproc.contourArea(mopHull);
	double scoreSolidity = solid;

	// Score aspect ratio -- exact ratio is 0.4
	final Rect bb = Imgproc.boundingRect(mop);
	final double ratio = bb.width / (double)bb.height;
	final double targetRatio = 0.4;
	final double minRatio = 0.0;
	final double maxRatio = 1.0;
	double scoreAspectRatio = 0;
	if (ratio < minRatio || ratio > maxRatio) {
		scoreAspectRatio = 0;
	} else {
		if (ratio > targetRatio) {
			scoreAspectRatio = 1 - (ratio - targetRatio) / (maxRatio - targetRatio);
		} else {
			scoreAspectRatio = 1 - (targetRatio - ratio) / (targetRatio - minRatio);
		}
		scoreAspectRatio *= 100;
	}

	// Compute final score
	double score = scoreSolidity + scoreAspectRatio;
	return score;
}
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:43,代碼來源:VisionTest.java

示例4: filterContours

import org.opencv.core.MatOfInt; //導入方法依賴的package包/類
/**
 * Filters out contours that do not meet certain criteria.
 * 
 * @param inputContours
 *            is the input list of contours
 * @param output
 *            is the the output list of contours
 * @param minArea
 *            is the minimum area of a contour that will be kept
 * @param minPerimeter
 *            is the minimum perimeter of a contour that will be kept
 * @param minWidth
 *            minimum width of a contour
 * @param maxWidth
 *            maximum width
 * @param minHeight
 *            minimum height
 * @param maxHeight
 *            maximimum height
 * @param Solidity
 *            the minimum and maximum solidity of a contour
 * @param minVertexCount
 *            minimum vertex Count of the contours
 * @param maxVertexCount
 *            maximum vertex Count
 * @param minRatio
 *            minimum ratio of width to height
 * @param maxRatio
 *            maximum ratio of width to height
 */
private void filterContours (List<MatOfPoint> inputContours,
        double minArea,
        double minPerimeter, double minWidth, double maxWidth,
        double minHeight, double maxHeight, double[] solidity,
        double maxVertexCount, double minVertexCount, double minRatio,
        double maxRatio, List<MatOfPoint> output)
{
    final MatOfInt hull = new MatOfInt();
    output.clear();
    // operation
    for (int i = 0; i < inputContours.size(); i++)
        {
        final MatOfPoint contour = inputContours.get(i);
        final Rect bb = Imgproc.boundingRect(contour);
        if (bb.width < minWidth || bb.width > maxWidth)
            continue;
        if (bb.height < minHeight || bb.height > maxHeight)
            continue;
        final double area = Imgproc.contourArea(contour);
        if (area < minArea)
            continue;
        if (Imgproc.arcLength(new MatOfPoint2f(contour.toArray()),
                true) < minPerimeter)
            continue;
        Imgproc.convexHull(contour, hull);
        MatOfPoint mopHull = new MatOfPoint();
        mopHull.create((int) hull.size().height, 1, CvType.CV_32SC2);
        for (int j = 0; j < hull.size().height; j++)
            {
            int index = (int) hull.get(j, 0)[0];
            double[] point = new double[]
                {contour.get(index, 0)[0], contour.get(index, 0)[1]};
            mopHull.put(j, 0, point);
            }
        final double solid = 100 * area / Imgproc.contourArea(mopHull);
        if (solid < solidity[0] || solid > solidity[1])
            continue;
        if (contour.rows() < minVertexCount
                || contour.rows() > maxVertexCount)
            continue;
        final double ratio = bb.width / (double) bb.height;
        if (ratio < minRatio || ratio > maxRatio)
            continue;
        output.add(contour);
        }
}
 
開發者ID:FIRST-Team-339,項目名稱:2017,代碼行數:77,代碼來源:GripPipeline.java

示例5: filterContours

import org.opencv.core.MatOfInt; //導入方法依賴的package包/類
/**
 * Filters out contours that do not meet certain criteria.
 *
 * @param inputContours
 *          is the input list of contours
 * @param output
 *          is the the output list of contours
 * @param minArea
 *          is the minimum area of a contour that will be kept
 * @param minPerimeter
 *          is the minimum perimeter of a contour that will be kept
 * @param minWidth
 *          minimum width of a contour
 * @param maxWidth
 *          maximum width
 * @param minHeight
 *          minimum height
 * @param maxHeight
 *          maximimum height
 * @param Solidity
 *          the minimum and maximum solidity of a contour
 * @param minVertexCount
 *          minimum vertex Count of the contours
 * @param maxVertexCount
 *          maximum vertex Count
 * @param minRatio
 *          minimum ratio of width to height
 * @param maxRatio
 *          maximum ratio of width to height
 */
private void filterContours(List<MatOfPoint> inputContours, double minArea, double minPerimeter, double minWidth,
    double maxWidth, double minHeight, double maxHeight, double[] solidity, double maxVertexCount,
    double minVertexCount, double minRatio, double maxRatio, List<MatOfPoint> output) {
  final MatOfInt hull = new MatOfInt();
  output.clear();
  // operation
  for (int i = 0; i < inputContours.size(); i++) {
    final MatOfPoint contour = inputContours.get(i);
    final Rect bb = Imgproc.boundingRect(contour);
    if (bb.width < minWidth || bb.width > maxWidth) {
      continue;
    }
    if (bb.height < minHeight || bb.height > maxHeight) {
      continue;
    }
    final double area = Imgproc.contourArea(contour);
    if (area < minArea) {
      continue;
    }
    if (Imgproc.arcLength(new MatOfPoint2f(contour.toArray()), true) < minPerimeter) {
      continue;
    }
    Imgproc.convexHull(contour, hull);
    MatOfPoint mopHull = new MatOfPoint();
    mopHull.create((int) hull.size().height, 1, CvType.CV_32SC2);
    for (int j = 0; j < hull.size().height; j++) {
      int index = (int) hull.get(j, 0)[0];
      double[] point = new double[] { contour.get(index, 0)[0], contour.get(index, 0)[1] };
      mopHull.put(j, 0, point);
    }
    final double solid = 100 * area / Imgproc.contourArea(mopHull);
    if (solid < solidity[0] || solid > solidity[1]) {
      continue;
    }
    if (contour.rows() < minVertexCount || contour.rows() > maxVertexCount) {
      continue;
    }
    final double ratio = bb.width / (double) bb.height;
    if (ratio < minRatio || ratio > maxRatio) {
      continue;
    }
    output.add(contour);
  }
}
 
開發者ID:cyborgs3335,項目名稱:STEAMworks,代碼行數:75,代碼來源:GripPipelineWithBlur.java


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