mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
avoid creating new mats in group contors pipe
This commit is contained in:
@@ -94,10 +94,14 @@ public class GroupContoursPipe implements Pipe<List<MatOfPoint>, List<StandardCV
|
||||
Pair.of(Imgproc.boundingRect(firstContour),
|
||||
Imgproc.boundingRect(secondContour));
|
||||
|
||||
target.leftRightRotatedRect =
|
||||
Pair.of(Imgproc.minAreaRect(new MatOfPoint2f(firstContour.toArray())),
|
||||
Imgproc.minAreaRect(new MatOfPoint2f(secondContour.toArray())));
|
||||
tempRectMat.fromArray(firstContour.toArray());
|
||||
var minAreaRect1 = Imgproc.minAreaRect(tempRectMat);
|
||||
tempRectMat.fromArray(secondContour.toArray());
|
||||
var minAreaRect2 = Imgproc.minAreaRect(tempRectMat);
|
||||
|
||||
target.leftRightRotatedRect =
|
||||
Pair.of(minAreaRect1, minAreaRect2);
|
||||
|
||||
groupedContours.add(target);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
@@ -113,6 +117,8 @@ public class GroupContoursPipe implements Pipe<List<MatOfPoint>, List<StandardCV
|
||||
return Pair.of(groupedContours, processTime);
|
||||
}
|
||||
|
||||
MatOfPoint2f tempRectMat = new MatOfPoint2f();
|
||||
|
||||
private static double calcMomentsX(MatOfPoint c) {
|
||||
Moments m = Imgproc.moments(c);
|
||||
return (m.get_m10() / m.get_m00());
|
||||
|
||||
Reference in New Issue
Block a user