本文整理汇总了Java中org.opencv.core.Rect.area方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.area方法的具体用法?Java Rect.area怎么用?Java Rect.area使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.core.Rect
的用法示例。
在下文中一共展示了Rect.area方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParticleReports
import org.opencv.core.Rect; //导入方法依赖的package包/类
/**
* Takes the base OpenCV list of contours and changes the output to be easier to
* work with.
*
* @param contours
* The input from the base OpenCV contours output
*/
private void createParticleReports (List<MatOfPoint> contours)
{
ParticleReport[] reports = new ParticleReport[contours.size()];
for (int i = 0; i < reports.length; i++)
{
reports[i] = new ParticleReport();
Rect r = Imgproc.boundingRect(contours.get(i));
reports[i].area = r.area();
reports[i].center = new Point(r.x + (r.width / 2),
r.y + (r.height / 2));
reports[i].boundingRect = r;
}
this.particleReports = reports;
}
示例2: filterContours
import org.opencv.core.Rect; //导入方法依赖的package包/类
@Override
public List<MatOfPoint> filterContours(List<MatOfPoint> contours) {
List<MatOfPoint> output = new ArrayList<>();
for (MatOfPoint contour : contours) {
final Rect boundingRect = Imgproc.boundingRect(contour);
final double rectArea = boundingRect.area();
final double targetAreaPercent = rectArea / imageArea * 100;
if (!area.inRangeInclusive(targetAreaPercent)) {
continue;
}
final double targetAspect = boundingRect.width / boundingRect.height;
if (!aspectRatio.inRangeInclusive(targetAspect)) {
continue;
}
final double targetArea = Imgproc.contourArea(contour);
final double targetFullness = targetArea / rectArea * 100;
if (!fullness.inRangeInclusive(targetFullness)) {
continue;
}
output.add(contour);
}
return output;
}