本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}