-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add point visualization to calibrate pipeline
- Loading branch information
Showing
11 changed files
with
6,566 additions
and
8,963 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
photon-core/src/main/java/org/photonvision/vision/pipe/impl/DrawCalibrationPipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (C) Photon Vision. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.photonvision.vision.pipe.impl; | ||
|
||
import java.awt.Color; | ||
import java.util.List; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.opencv.core.Mat; | ||
import org.opencv.core.Point; | ||
import org.opencv.imgproc.Imgproc; | ||
import org.photonvision.common.util.ColorHelper; | ||
import org.photonvision.vision.frame.FrameDivisor; | ||
import org.photonvision.vision.pipe.MutatingPipe; | ||
import org.photonvision.vision.target.TrackedTarget; | ||
|
||
public class DrawCalibrationPipe | ||
extends MutatingPipe< | ||
Pair<Mat, List<TrackedTarget>>, DrawCalibrationPipe.DrawCalibrationPipeParams> { | ||
@Override | ||
protected Void process(Pair<Mat, List<TrackedTarget>> in) { | ||
|
||
var image = in.getLeft(); | ||
|
||
for (var target : in.getRight()) { | ||
|
||
for (var c : target.getTargetCorners()) { | ||
c = new Point(c.x / params.divisor.value.doubleValue(), c.y / params.divisor.value.doubleValue()); | ||
var r = 4; | ||
var r2 = r / Math.sqrt(2); | ||
var color = ColorHelper.colorToScalar(Color.RED, 0.4); | ||
Imgproc.circle(image, c, r, color, 1); | ||
Imgproc.line(image, | ||
new Point(c.x-r2, c.y-r2), | ||
new Point(c.x+r2, c.y+r2), | ||
color); | ||
Imgproc.line(image, | ||
new Point(c.x+r2, c.y-r2), | ||
new Point(c.x-r2, c.y+r2), | ||
color); | ||
} | ||
|
||
} | ||
|
||
return null; | ||
} | ||
|
||
public static class DrawCalibrationPipeParams { | ||
private final FrameDivisor divisor; | ||
|
||
public DrawCalibrationPipeParams( | ||
FrameDivisor divisor) { | ||
this.divisor = divisor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...core/src/main/java/org/photonvision/vision/pipeline/result/CalibrationPipelineResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) Photon Vision. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.photonvision.vision.pipeline.result; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.opencv.core.Point; | ||
import org.photonvision.vision.frame.Frame; | ||
import org.photonvision.vision.target.TrackedTarget; | ||
|
||
|
||
public class CalibrationPipelineResult extends CVPipelineResult { | ||
|
||
private static List<TrackedTarget> cornersToTarget(List<List<Point>> corners) { | ||
return corners.stream().map(TrackedTarget::new).collect(Collectors.toList()); | ||
} | ||
|
||
public CalibrationPipelineResult(double latencyNanos, double fps, Frame outputFrame, List<List<Point>> corners) { | ||
super(latencyNanos, fps, cornersToTarget(corners), outputFrame); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.78 MB
photon-server/src/main/resources/nativelibraries/winx86-64/libmrgingham_winx86-64.dll
Binary file not shown.