Variable Tuner
Last updated
Last updated
From EOCV-Sim v2.0.0 and going forward, there's a variable tuner implemented into the simulator, inspired by FTC Dashboard, it allows to edit public, non-final variables from your pipeline in real time seamlessly through Java reflection.
The "blur" variable simply consists of a public, non-final field declared in the DefaultPipeline, which is automatically detected and displayed by the simulator:
The tuner supports a handful of Java types, such as most primitives (int, float, double, boolean...) and some other types from OpenCV. The full list of types currently supported by the tuner on the latest version is:
Java:
int (or Integer)
float (or Float)
double (or Double)
long (or Long)
boolean (or Boolean)
String
Enums
OpenCV:
Scalar
Rect
Point
We can write a simple pipeline for achieving this, taking advantage of the variable tuner. Here's an example code with detailed comments:
And so, when initially selecting this pipeline in the simulator, its initial state should look something like this:
All pixels from the input Mat are entirely visible; this is because we specified a range of 0 lower and 255 upper (0-255) for all three channels (see the sliders values). Since those values are the minimum (0%) and maximum (100%) for YCrCb respectively, all pixels are able to go through our "threshold". The last slider can be ignored since we don't have a 4th color channel
After a bit of playing around with the sliders, it's possible to come up with some decent values which successfully filter out the orange ring stack out of everything else:
Let's say we need to tune a threshold for finding the ring stack in the 2020-2021 "Ultimate Goal" game. For this, we will use the YCrCb color space since it's one of the most used ones in FTC, and it behaves better under different lightning conditions. (see for more extended explanation and comparing of different color spaces).
A problem with the YCrCb color space, especially this year, is that the difference between red and orange is very subtle. So we need to play with the values for a good while until we find some that filters out the red from the goals (in the image you can see there's still red leftovers at the top right) but displays the ring stack. Or do some other technique alongside thresholding such as with the "horizon" mechanism.
To keep this explanation simple, you can find the final pipeline with some additional features, in the TeamCode module, since serves as a good sample alongside other sample classes from EOCV itself.