本文整理匯總了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;
}