Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PhotonVision/photonvision
Browse files Browse the repository at this point in the history
…into multiag-pnp
  • Loading branch information
mcm001 committed Sep 23, 2023
2 parents 465b97a + 9d0f1a3 commit e56ae83
Show file tree
Hide file tree
Showing 15 changed files with 1,152 additions and 366 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void initCmds(HardwareConfig config) {
cpuUptimeCommand = "uptime -p | cut -c 4-";

// RAM
ramUsageCommand = "awk '/MemFree:/ {print int($2 / 1000);}' /proc/meminfo";
ramUsageCommand = "awk '/MemAvailable:/ {print int($2 / 1000);}' /proc/meminfo";

// Disk
diskUsageCommand = "df ./ --output=pcent | tail -n +2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.ArrayList;
import java.util.List;

import org.opencv.core.RotatedRect;
import org.photonvision.common.util.numbers.DoubleCouple;
import org.photonvision.vision.frame.FrameStaticProperties;
Expand Down Expand Up @@ -47,31 +46,13 @@ protected List<Contour> process(List<Contour> in) {
private void rejectOutliers(List<Contour> list, double xTol, double yTol) {
if (list.size() < 2) return; // Must have at least 2 points to reject outliers

/*
// Sort by X and find median
list.sort(Comparator.comparingDouble(c -> c.getCenterPoint().x));
double medianX = list.get(list.size() / 2).getCenterPoint().x;
if (list.size() % 2 == 0)
medianX = (medianX + list.get(list.size() / 2 - 1).getCenterPoint().x) / 2;
*/

double meanX = list.stream().mapToDouble(it -> it.getCenterPoint().x).sum() / list.size();

double stdDevX =
list.stream().mapToDouble(it -> Math.pow(it.getCenterPoint().x - meanX, 2.0)).sum();
stdDevX /= (list.size() - 1);
stdDevX = Math.sqrt(stdDevX);

/*
// Sort by Y and find median
list.sort(Comparator.comparingDouble(c -> c.getCenterPoint().y));
double medianY = list.get(list.size() / 2).getCenterPoint().y;
if (list.size() % 2 == 0)
medianY = (medianY + list.get(list.size() / 2 - 1).getCenterPoint().y) / 2;
*/

double meanY = list.stream().mapToDouble(it -> it.getCenterPoint().y).sum() / list.size();

double stdDevY =
Expand Down Expand Up @@ -112,7 +93,8 @@ private void filterContour(Contour contour) {
if (contourArea <= minFullness || contourArea >= maxFullness) return;

// Aspect Ratio Filtering.
double aspectRatio = TargetCalculations.getAspectRatio(contour.getMinAreaRect(), params.isLandscape);
double aspectRatio =
TargetCalculations.getAspectRatio(contour.getMinAreaRect(), params.isLandscape);
if (aspectRatio < params.getRatio().getFirst() || aspectRatio > params.getRatio().getSecond())
return;

Expand All @@ -134,7 +116,8 @@ public FilterContoursParams(
DoubleCouple extent,
FrameStaticProperties camProperties,
double xTol,
double yTol, boolean isLandscape) {
double yTol,
boolean isLandscape) {
this.m_area = area;
this.m_ratio = ratio;
this.m_fullness = extent;
Expand Down
Loading

0 comments on commit e56ae83

Please sign in to comment.