Skip to content

Commit

Permalink
Updated FtcLib.
Browse files Browse the repository at this point in the history
Removed setXXXXAnnotateEnabled methods. It should be a parameter in the construction of color blob vision just like other vision processors.
  • Loading branch information
trc492 committed Sep 13, 2023
1 parent c0c030f commit 953b6cd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 46 deletions.
2 changes: 1 addition & 1 deletion TeamCode/src/main/java/TrcFtcLib
2 changes: 0 additions & 2 deletions TeamCode/src/main/java/teamcode/FtcAuto.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,12 @@ public void robotInit()
{
robot.globalTracer.traceInfo(funcName, "Enabling RedBlobVision.");
robot.vision.setRedBlobVisionEnabled(true);
robot.vision.setRedBlobAnnotateEnabled(true);
}

if (robot.vision.blueBlobVision != null)
{
robot.globalTracer.traceInfo(funcName, "Enabling BlueBlobVision.");
robot.vision.setBlueBlobVisionEnabled(true);
robot.vision.setBlueBlobAnnotateEnabled(true);
}

if (robot.vision.tensorFlowVision != null)
Expand Down
2 changes: 0 additions & 2 deletions TeamCode/src/main/java/teamcode/FtcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,12 @@ public void startMode(TrcRobot.RunMode prevMode, TrcRobot.RunMode nextMode)
{
robot.globalTracer.traceInfo(funcName, "Enabling RedBlobVision.");
robot.vision.setRedBlobVisionEnabled(true);
robot.vision.setRedBlobAnnotateEnabled(true);
}

if (robot.vision.blueBlobVision != null)
{
robot.globalTracer.traceInfo(funcName, "Enabling BlueBlobVision.");
robot.vision.setBlueBlobVisionEnabled(true);
robot.vision.setBlueBlobAnnotateEnabled(true);
}

if (robot.vision.tensorFlowVision != null)
Expand Down
46 changes: 5 additions & 41 deletions TeamCode/src/main/java/teamcode/vision/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public Vision(Robot robot, TrcDbgTrace tracer)
robot.globalTracer.traceInfo(moduleName, "Starting ColorBlobVision...");
redBlobVision = new FtcVisionEocvColorBlob(
"RedBlob", colorConversion, redBlobColorThresholds, redBlobFilterContourParams,
RobotParams.cameraRect, RobotParams.worldRect, tracer);
RobotParams.cameraRect, RobotParams.worldRect, true, tracer);
redBlobProcessor = redBlobVision.getVisionProcessor();
blueBlobVision = new FtcVisionEocvColorBlob(
"BlueBlob", colorConversion, blueBlobColorThresholds, blueBlobFilterContourParams,
RobotParams.cameraRect, RobotParams.worldRect, tracer);
RobotParams.cameraRect, RobotParams.worldRect, true, tracer);
blueBlobProcessor = blueBlobVision.getVisionProcessor();
}

Expand All @@ -136,8 +136,8 @@ public Vision(Robot robot, TrcDbgTrace tracer)
robot.globalTracer.traceInfo(moduleName, "Starting TensorFlowVision...");
tensorFlowVision = new FtcVisionTensorFlow(
null, TFOD_MODEL_ASSET, TARGET_LABELS, RobotParams.cameraRect, RobotParams.worldRect, tracer);
tensorFlowVision.getVisionProcessor().setMinResultConfidence(TFOD_MIN_CONFIDENCE);
tensorFlowProcessor = tensorFlowVision.getVisionProcessor();
tensorFlowProcessor.setMinResultConfidence(TFOD_MIN_CONFIDENCE);
}

VisionPortal.Builder builder = new VisionPortal.Builder();
Expand Down Expand Up @@ -210,14 +210,6 @@ public void setRedBlobVisionEnabled(boolean enabled)
}
} //setRedBlobVisionEnabled

public void setRedBlobAnnotateEnabled(boolean enabled)
{
if (redBlobProcessor != null)
{
redBlobProcessor.setAnnotateEnabled(enabled);
}
} //setRedBlobAnnotateEnabled

public void setBlueBlobVisionEnabled(boolean enabled)
{
if (blueBlobProcessor != null)
Expand All @@ -226,14 +218,6 @@ public void setBlueBlobVisionEnabled(boolean enabled)
}
} //setBlueBlobVisionEnabled

public void setBlueBlobAnnotateEnabled(boolean enabled)
{
if (blueBlobProcessor != null)
{
blueBlobProcessor.setAnnotateEnabled(enabled);
}
} //setBlueBlobAnnotateEnabled

public void setTensorFlowVisionEnabled(boolean enabled)
{
if (tensorFlowProcessor != null)
Expand Down Expand Up @@ -271,9 +255,6 @@ private void updateVisionLEDs(String label)
{
if (label != null && robot.blinkin != null)
{
// robot.blinkin.setPatternState(BlinkinLEDs.LABEL_BOLT, false);
// robot.blinkin.setPatternState(BlinkinLEDs.LABEL_BULB, false);
// robot.blinkin.setPatternState(BlinkinLEDs.LABEL_PANEL, false);
robot.blinkin.setPatternState(label, true, 1.0);
}
} //updateVisionLEDs
Expand All @@ -287,27 +268,10 @@ private void updateVisionLEDs(String label)
* if a has lower confidence than b.
*/
private int compareConfidence(
TrcVisionTargetInfo<FtcVisionTensorFlow.DetectedObject> a, TrcVisionTargetInfo<FtcVisionTensorFlow.DetectedObject> b)
TrcVisionTargetInfo<FtcVisionTensorFlow.DetectedObject> a,
TrcVisionTargetInfo<FtcVisionTensorFlow.DetectedObject> b)
{
return (int)((b.detectedObj.confidence - a.detectedObj.confidence)*100);
} //compareConfidence

/**
* This method is called by the Arrays.sort to sort the target object by decreasing bottom Y.
*
* @param a specifies the first target
* @param b specifies the second target.
* @return negative value if a has smaller bottom Y than b, 0 if a and b have equal bottom Y,
* positive value if a has larger bottom Y than b.
*/
private int compareBottomY(
TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>> a,
TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>> b)
{
Rect aRect = a.detectedObj.getRect();
Rect bRect = b.detectedObj.getRect();

return (bRect.y + bRect.height) - (aRect.y + aRect.height);
} //compareBottomY

} //class Vision

0 comments on commit 953b6cd

Please sign in to comment.