Skip to content

Commit

Permalink
Updated CommonLib.
Browse files Browse the repository at this point in the history
Updated FtcLib.
Minor cleanup.
Changed vision color space to HSV instead of RGB.
  • Loading branch information
trc492 committed Sep 25, 2023
1 parent 58b040c commit 907bd58
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion TeamCode/src/main/java/TrcFtcLib
53 changes: 27 additions & 26 deletions TeamCode/src/main/java/teamcode/FtcAuto.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,31 @@ public void robotInit()

if (robot.vision != null)
{
// Enabling vision early so we can detect signal position before match starts.
if (robot.vision.aprilTagVision != null)
{
robot.globalTracer.traceInfo(funcName, "Enabling AprilTagVision.");
robot.vision.setAprilTagVisionEnabled(true);
}

if (robot.vision.redBlobVision != null)
{
robot.globalTracer.traceInfo(funcName, "Enabling RedBlobVision.");
robot.vision.setRedBlobVisionEnabled(true);
}

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

if (robot.vision.tensorFlowVision != null)
{
robot.globalTracer.traceInfo(funcName, "Enabling TensorFlowVision.");
robot.vision.setTensorFlowVisionEnabled(true);
}
// Enabling vision early so we can detect target before match starts if necessary.
// Only enable the necessary vision for that purpose.
// if (robot.vision.aprilTagVision != null)
// {
// robot.globalTracer.traceInfo(funcName, "Enabling AprilTagVision.");
// robot.vision.setAprilTagVisionEnabled(true);
// }
//
// if (robot.vision.redBlobVision != null)
// {
// robot.globalTracer.traceInfo(funcName, "Enabling RedBlobVision.");
// robot.vision.setRedBlobVisionEnabled(true);
// }
//
// if (robot.vision.blueBlobVision != null)
// {
// robot.globalTracer.traceInfo(funcName, "Enabling BlueBlobVision.");
// robot.vision.setBlueBlobVisionEnabled(true);
// }
//
// if (robot.vision.tensorFlowVision != null)
// {
// robot.globalTracer.traceInfo(funcName, "Enabling TensorFlowVision.");
// robot.vision.setTensorFlowVisionEnabled(true);
// }
}

robot.zeroCalibrate();
Expand All @@ -196,8 +197,8 @@ public void robotInit()
//

/**
* This method is called periodically after robotInit() is called but before competition starts. For this season,
* we are detecting the duck's barcode position before the match starts.
* This method is called periodically after robotInit() is called but before competition starts. For example,
* we can put vision code here to detect target before autonomous starts.
*/
@Override
public void initPeriodic()
Expand Down
11 changes: 6 additions & 5 deletions TeamCode/src/main/java/teamcode/vision/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public class Vision
{
private static final String moduleName = "Vision";
private static final double[] DEF_COLORBLOB_THRESHOLDS = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0};
// RGB Color Space.
private static final int colorConversion = Imgproc.COLOR_BGRA2BGR;
private static final double[] redBlobColorThresholds = {100.0, 255.0, 0.0, 100.0, 0.0, 60.0};
private static final double[] blueBlobColorThresholds = {0.0, 60.0, 0.0, 100.0, 100, 255.0};
// HSV Color Space.
private static final int colorConversion = Imgproc.COLOR_BGR2HSV;
private static final double[] redBlobColorThresholds = {160.0, 200.0, 120.0, 255.0, 150.0, 255.0};
private static final double[] blueBlobColorThresholds = {0.0, 80.0, 120.0, 255.0, 100.0, 255.0};
private static final TrcOpenCvColorBlobPipeline.FilterContourParams colorBlobFilterContourParams =
new TrcOpenCvColorBlobPipeline.FilterContourParams()
.setMinArea(1000.0)
Expand All @@ -70,7 +70,8 @@ public class Vision
.setHeightRange(10.0, 1000.0)
.setSolidityRange(0.0, 100.0)
.setVerticesRange(0.0, 1000.0)
.setAspectRatioRange(0.0, 10.0);
.setAspectRatioRange(0.5, 2.0);

private static final String TFOD_MODEL_ASSET = "MyObject.tflite";
private static final float TFOD_MIN_CONFIDENCE = 0.75f;
public static final String[] TFOD_TARGET_LABELS = {"MyObject"};
Expand Down

0 comments on commit 907bd58

Please sign in to comment.