mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Clear lists in Pipes
This commit is contained in:
@@ -41,6 +41,8 @@ public class Collect2dTargetsPipe implements Pipe<List<RotatedRect>, List<CVPipe
|
||||
public Pair<List<CVPipeline2d.Target2d>, Long> run(List<RotatedRect> input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
targets.clear();
|
||||
|
||||
input.forEach(r -> {
|
||||
CVPipeline2d.Target2d t = new CVPipeline2d.Target2d();
|
||||
t.rawPoint = r;
|
||||
|
||||
@@ -38,6 +38,8 @@ public class FilterContoursPipe implements Pipe<List<MatOfPoint>, List<MatOfPoin
|
||||
public Pair<List<MatOfPoint>, Long> run(List<MatOfPoint> input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
filteredContours.clear();
|
||||
|
||||
for (MatOfPoint Contour : input) {
|
||||
try {
|
||||
double contourArea = Imgproc.contourArea(Contour);
|
||||
|
||||
@@ -18,6 +18,8 @@ public class FindContoursPipe implements Pipe<Mat, List<MatOfPoint>> {
|
||||
public Pair<List<MatOfPoint>, Long> run(Mat input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
foundContours.clear();
|
||||
|
||||
Imgproc.findContours(input, foundContours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_TC89_L1);
|
||||
|
||||
long processTime = System.nanoTime() - processStartNanos;
|
||||
|
||||
@@ -39,6 +39,8 @@ public class GroupContoursPipe implements Pipe<List<MatOfPoint>, List<RotatedRec
|
||||
public Pair<List<RotatedRect>, Long> run(List<MatOfPoint> input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
groupedContours.clear();
|
||||
|
||||
List<MatOfPoint> sorted = new ArrayList<>(input);
|
||||
sorted.sort(sortByMomentsX);
|
||||
|
||||
|
||||
@@ -43,27 +43,30 @@ public class SortContoursPipe implements Pipe<List<RotatedRect>, List<RotatedRec
|
||||
public Pair<List<RotatedRect>, Long> run(List<RotatedRect> input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
sortedContours.clear();
|
||||
sortedContours.addAll(input);
|
||||
|
||||
switch (sort) {
|
||||
case Largest:
|
||||
input.sort(SortByLargestComparator);
|
||||
sortedContours.sort(SortByLargestComparator);
|
||||
break;
|
||||
case Smallest:
|
||||
input.sort(SortBySmallestComparator);
|
||||
sortedContours.sort(SortBySmallestComparator);
|
||||
break;
|
||||
case Highest:
|
||||
input.sort(SortByHighestComparator);
|
||||
sortedContours.sort(SortByHighestComparator);
|
||||
break;
|
||||
case Lowest:
|
||||
input.sort(SortByLowestComparator);
|
||||
sortedContours.sort(SortByLowestComparator);
|
||||
break;
|
||||
case Leftmost:
|
||||
input.sort(SortByLeftmostComparator);
|
||||
sortedContours.sort(SortByLeftmostComparator);
|
||||
break;
|
||||
case Rightmost:
|
||||
input.sort(SortByRightmostComparator);
|
||||
sortedContours.sort(SortByRightmostComparator);
|
||||
break;
|
||||
case Centermost:
|
||||
input.sort(SortByCentermostComparator);
|
||||
sortedContours.sort(SortByCentermostComparator);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,8 @@ public class SpeckleRejectPipe implements Pipe<List<MatOfPoint>, List<MatOfPoint
|
||||
public Pair<List<MatOfPoint>, Long> run(List<MatOfPoint> input) {
|
||||
long processStartNanos = System.nanoTime();
|
||||
|
||||
despeckledContours.clear();
|
||||
|
||||
double averageArea = 0.0;
|
||||
|
||||
for (MatOfPoint c : input) {
|
||||
|
||||
Reference in New Issue
Block a user