Fixed area filtering of contours

This commit is contained in:
Banks Troutman
2019-09-16 11:45:56 -04:00
parent 86b811a36d
commit 99c32e1d18
4 changed files with 13 additions and 4 deletions

View File

@@ -52,12 +52,12 @@ public class VisionProcess {
}
private List<MatOfPoint> FilteredContours = new ArrayList<MatOfPoint>();
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Integer> area, List<Integer> ratio, List<Integer> extent, String SortMode, String TargetIntersection, String TargetGrouping){
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Integer> area, List<Integer> ratio, List<Integer> extent, String SortMode, String TargetIntersection, String TargetGrouping) {
for (MatOfPoint Contour : InputContours){
try{
var contourArea = Imgproc.contourArea(Contour);
double targetArea = (contourArea / CamVals.ImageArea) * 100;
if (targetArea >= area.get(0) || targetArea <= area.get(1)){
if (targetArea <= area.get(0) || targetArea >= area.get(1)){
continue;
}
var rect = Imgproc.minAreaRect(new MatOfPoint2f(Contour.toArray()));