当前位置: 首页>>代码示例>>Java>>正文


Java MatOfPoint.put方法代码示例

本文整理汇总了Java中org.opencv.core.MatOfPoint.put方法的典型用法代码示例。如果您正苦于以下问题:Java MatOfPoint.put方法的具体用法?Java MatOfPoint.put怎么用?Java MatOfPoint.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opencv.core.MatOfPoint的用法示例。


在下文中一共展示了MatOfPoint.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterContours

import org.opencv.core.MatOfPoint; //导入方法依赖的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.MatOfPoint; //导入方法依赖的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.MatOfPoint; //导入方法依赖的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.MatOfPoint; //导入方法依赖的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.MatOfPoint; //导入方法依赖的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.MatOfPoint.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。