Skip to content

Commit

Permalink
Merge pull request #23 from Pattonville-Robotics/opencv-optimizations
Browse files Browse the repository at this point in the history
Opencv optimizations
  • Loading branch information
greg-bahr authored Feb 22, 2018
2 parents cbe60c1 + f72af86 commit 30c8e30
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,32 @@ public AnalysisResult getAnalysis() {
return new AnalysisResult(leftJewelColor, rightJewelColor);
}

/**
* Has the option to compare jewel locations to tape. If jewels are compared against each other
* instead of the tape then leftJewelColor and rightJewelColor will never evaluate to null.
*
* @param compareToTape whether or not to compare jewels to tape location
* @return
* @see #getAnalysis()
*/
public AnalysisResult getAnalysis(boolean compareToTape) {
ColorSensorColor leftJewelColor = null;
ColorSensorColor rightJewelColor = null;

if (compareToTape) return getAnalysis();
if (redJewel == null || blueJewel == null) return new AnalysisResult();

if (redJewel.getX() < blueJewel.getX()) {
leftJewelColor = ColorSensorColor.RED;
rightJewelColor = ColorSensorColor.BLUE;
} else if (blueJewel.getX() < redJewel.getX()) {
rightJewelColor = ColorSensorColor.RED;
leftJewelColor = ColorSensorColor.BLUE;
}

return new AnalysisResult(leftJewelColor, rightJewelColor);
}

public void setAnalysisMode(JewelAnalysisMode analysisMode) {
this.analysisMode = analysisMode;
}
Expand Down

0 comments on commit 30c8e30

Please sign in to comment.