Skip to content

Commit 1e7d636

Browse files
authored
Merge pull request #373 from miriamsr/tfod_removal
Update TensorFlow References to Color Processing
2 parents 5870112 + cddab8e commit 1e7d636

File tree

5 files changed

+45
-167
lines changed

5 files changed

+45
-167
lines changed

docs/source/apriltag/vision_portal/vision_processor_init/vision-processor-init.rst

Lines changed: 10 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Vision Processor Initialization
44
Processor Initialization - Overview
55
-----------------------------------
66

7-
Your OpMode must **first prepare** for using AprilTag and/or TensorFlow Object
8-
Detection (TFOD) commands, or methods.
7+
Your OpMode must **first prepare** for using AprilTag and/or
8+
Color Processing commands, or methods.
99

1010
In the INIT portion of your Java or Blocks code, before ``waitForStart()``, use
1111
these steps:
@@ -18,11 +18,11 @@ these steps:
1818

1919
- **Step 2.** *Required:*
2020

21-
- Create the **AprilTag Processor** (or the **TFOD
21+
- Create the **AprilTag Processor** (or the **Color Locator or Color Sensor
2222
Processor**), to analyze frames streaming in from the camera. "Under the
2323
hood", the Apriltag Processor is attached to an EOCV **pipeline**, which
2424
performs various steps, in order, to each stream frame. The stream is the
25-
input to the pipeline. A similar process happens for TFOD.
25+
input to the pipeline. A similar process happens for Color Processing.
2626

2727
- **Step 3.** *Required:*
2828

@@ -141,106 +141,15 @@ Here the object ``myAprilTagProcessorBuilder`` was not created; the build was
141141
performed directly on ``myAprilTagProcessor``. The Builder pattern allows the
142142
"dot" methods to be chained in a single Java statement ending with ``.build()``.
143143

144-
TensorFlow Initialization - Easy
145-
--------------------------------
144+
Color Processing Initialization
145+
-------------------------------
146146

147-
**Step 2** is similar for creating the **TensorFlow TFOD Processor**, software
147+
**Step 2** is similar for creating the **Color Sensor/Locator Processor**, software
148148
that evaluates frames streaming in from the camera.
149149

150-
The SDK provides an "easy" way to create the processor, using only **defaults**
151-
and not mentioning a "Builder":
152-
153-
.. tab-set::
154-
.. tab-item:: Blocks
155-
:sync: blocks
156-
157-
.. figure:: images/040-TFOD-Processor-easy.png
158-
:width: 75%
159-
:align: center
160-
:alt: Easy TFOD Initialization
161-
162-
Easy TensorFlow TFOD Processor Initialization without a Builder
163-
164-
.. tab-item:: Java
165-
:sync: java
166-
167-
Example of TensorFlow TFOD Processor Initialization without a Builder
168-
169-
.. code-block:: java
170-
171-
TfodProcessor myTfodProcessor;
172-
// Create the TensorFlow Object Detection processor and assign it to a variable.
173-
myTfodProcessor = TfodProcessor.easyCreateWithDefaults();
174-
175-
176-
TensorFlow Initialization - Builder
177-
-----------------------------------
178-
179-
The SDK also provides the "Builder" way to create the processor, allowing
180-
**custom settings**.
181-
182-
**Builder** is a Java pattern or structure for adding features or parameters,
183-
finalized with the ``.build()`` command. Such features are **not** modified
184-
later during an OpMode.
185-
186-
*Inside the SDK, even the "easy" process uses the Builder pattern to set the default parameters.*
187-
188-
.. tab-set::
189-
.. tab-item:: Blocks
190-
:sync: blocks
191-
192-
.. figure:: images/050-TFOD-Processor-builder.png
193-
:width: 75%
194-
:align: center
195-
:alt: TFOD Initialization with Builder
196-
197-
TensorFlow TFOD Processor Initialization with a Builder
198-
199-
.. tab-item:: Java
200-
:sync: java
201-
202-
.. code-block:: java
203-
204-
TfodProcessor.Builder myTfodProcessorBuilder;
205-
TfodProcessor myTfodProcessor;
206-
207-
// Create a new TFOD Processor Builder object.
208-
myTfodProcessorBuilder = new TfodProcessor.Builder();
209-
210-
// Optional: set other custom features of the TFOD Processor (4 are shown here).
211-
myTfodProcessorBuilder.setMaxNumRecognitions(10); // Max. number of recognitions the network will return
212-
myTfodProcessorBuilder.setUseObjectTracker(true); // Whether to use the object tracker
213-
myTfodProcessorBuilder.setTrackerMaxOverlap((float) 0.2); // Max. % of box overlapped by another box at recognition time
214-
myTfodProcessorBuilder.setTrackerMinSize(16); // Min. size of object that the object tracker will track
215-
216-
// Create a TFOD Processor by calling build()
217-
myTfodProcessor = myTfodProcessorBuilder.build();
218-
219-
This example shows only 4 TFOD Processor Builder features; others are
220-
available. Most others relate to custom TFOD Models, beyond this scope of this
221-
VisionPortal Guide.
222-
223-
TensorFlow Java Builder Chain
224-
-----------------------------
225-
226-
The Builder pattern can be implemented in a streamlined manner, using Java. The following code is equivalent to the above individual method calls.
227-
228-
Comments are omitted here, to clearly illustrate the chaining.
229-
230-
.. code-block:: java
231-
232-
TfodProcessor myTfodProcessor;
233-
234-
myTfodProcessor = new TfodProcessor.Builder()
235-
.setMaxNumRecognitions(10)
236-
.setUseObjectTracker(true)
237-
.setTrackerMaxOverlap((float) 0.2)
238-
.setTrackerMinSize(16)
239-
.build();
240-
241-
Here the object ``myTfodProcessorBuilder`` was not created; the build was
242-
performed directly on ``myTfodProcessor``. The Builder pattern allows the "dot"
243-
methods to be chained in a single Java statement ending with ``.build()``.
150+
The Builder is going to look a little different depending on if you are using
151+
the **Color Sensor** or the **Color Locator**. For more information, see the
152+
:doc:`Color Processing Documentation </color_processing/index>`.
244153

245154
Enabling and Disabling Processors
246155
---------------------------------

docs/source/apriltag/vision_portal/visionportal_previews/visionportal-previews.rst

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ VisionPortal Previews
44
Introduction
55
------------
66

7-
Managing AprilTag and TFOD performance is greatly enhanced with visual
7+
Managing AprilTag and Color Processing performance is greatly enhanced with visual
88
feedback of the camera’s view.
99

1010
.. figure:: images/040-RC-preview-2-webcams-Moto-e4.png
@@ -26,13 +26,13 @@ LiveView refers only to the **Robot Controller** preview (example shown above).
2626
It’s completely separate from **DS Camera Stream**, which still operates
2727
normally even if LiveView is stopped (manually or automatically).
2828

29-
Instructions for viewing DS Camera Stream are shown at
30-
:ref:`ftc-docs <hardware_and_software_configuration/configuring/configuring_external_webcam/configuring-external-webcam:image preview>`.
29+
Instructions for viewing DS Camera Stream are shown
30+
:ref:`here <hardware_and_software_configuration/configuring/configuring_external_webcam/configuring-external-webcam:image preview>`.
3131

3232
Camera Stream uses its own frame collection process, which naturally still
3333
requires the camera/pipeline status to be ``STREAMING``. Disabling the stream
3434
will prevent the DS preview. Camera status is covered at the **Managing CPU and
35-
Bandwidth** page, and the **VisionPort Camera Controls** page.
35+
Bandwidth** page, and the **VisionPortal Camera Controls** page.
3636

3737
Side Note: For SDK 8.2, “LiveView” became the new universal name for the
3838
RC preview. There remain two instances of old names:
@@ -62,39 +62,14 @@ do affect the displayed image and the actual recognitions.
6262
During Camera Stream, manual adjustments to Camera Controls cannot be
6363
made in real time (with visible feedback) since gamepads are disabled.
6464

65-
Thus teams wanting to optimize AprilTag or TFOD recognitions with Camera
65+
Thus teams wanting to optimize AprilTag or Color Processing recognitions with Camera
6666
Controls should use ``scrcpy`` or an HDMI monitor. Doing this via Camera
6767
Stream (“back and forth”) will be less effective and less efficient.
6868

6969
More information is available at the **VisionPortal Camera Controls** page, and
7070
at the
7171
:ref:`Webcam Control tutorial <programming_resources/vision/webcam_controls/index:webcam controls>`.
7272

73-
Aspect Ratios in Previews
74-
-------------------------
75-
76-
Here’s a Control Hub’s LiveView (via ``scrcpy``) of TFOD recognitions:
77-
78-
.. figure:: images/050-CH-TFOD-preview-grey-bands.png
79-
:width: 75%
80-
:align: center
81-
:alt: Gray Band Aspect Ratio Mismatch
82-
83-
LiveView demonstrating Grey Bands from Aspect Ratio mismatch
84-
85-
The **greyed bands** at top and bottom are from the **mismatch of aspect
86-
ratios**:
87-
88-
- 4:3 for camera (640x480)
89-
90-
- 16:9 for TFOD (per model training)
91-
92-
Both of these ratios are set as defaults, hidden from the user in some
93-
Sample OpModes. Only the non-greyed region is eligible for TFOD
94-
recognitions.
95-
96-
Note that the TFOD annotations (text) extend beyond the image.
97-
9873
BIG Previews
9974
------------
10075

@@ -130,7 +105,7 @@ is rather high.
130105

131106
Note that viewing the video stream from the same orientation as the
132107
statistics text box will show you the orientation of the stream passed
133-
to the AprilTag and/or TFOD processors.
108+
to the AprilTag and/or Color Sensor/Locator processors.
134109

135110
Also note that for RC phone cameras, the LiveView preview is rotated
136111
(independent of rotation enum) such that the preview is the way you
380 KB
Loading
290 KB
Loading

docs/source/programming_resources/vision/vision_overview/vision-overview.rst

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ computer vision technologies:
1414
points for autonomous navigation and for assisted navigation and
1515
identification of points of interest on a game field.
1616

17-
- Each season, FIRST provides 2D image tagets that can be used as
17+
- Each season, *FIRST* provides 2D image tagets that can be used as
1818
navigational reference points.
1919
- If the AprilTag system recognizes an AprilTag image, it provides
2020
very accurate pose information (assuming the camera used has
@@ -23,21 +23,20 @@ computer vision technologies:
2323
- A robot can use this information to navigate autonomously on the
2424
field.
2525

26-
2. TensorFlow Lite - `TensorFlow
27-
Lite <https://ai.google.dev/edge/litert>`__ is a lightweight version
28-
of Google’s `TensorFlow <https://www.tensorflow.org>`__ *machine
29-
learning* technology that is designed to run on mobile devices such
30-
as an Android smartphone.
31-
32-
- Each season FIRST creates a TensorFlow *inference model* that can
33-
be used to “look” for specific game elements.
34-
- If TensorFlow recognizes an object, it returns location info about
35-
the identified object.
36-
- A robot can use this location information to navigate to the
26+
2. Color Processing -
27+
:doc:`Color Processing </color_processing/index>` is a
28+
feature in the *FIRST* Tech Challenge SDK that provides the ability
29+
to process colors using `OpenCV <https://opencv.org/>`__.
30+
31+
- Color Sensor can detect the exact color in an image, which can
32+
help determine what is in front of a robot.
33+
- Color Locator can look for a specific color and return information
34+
about the size, shape and location of the color in the camera frame.
35+
- A robot can use this information to navigate to the
3736
recognized object.
3837

39-
TensorFlow vs AprilTags
40-
-----------------------
38+
AprilTags vs Color Processing
39+
-----------------------------
4140

4241
AprilTag Advantages
4342
~~~~~~~~~~~~~~~~~~~
@@ -73,53 +72,48 @@ AprilTag Disadvantages
7372

7473
AprilTags not in Tag Library detected, but no pose data available
7574

76-
TensorFlow Advantages
77-
~~~~~~~~~~~~~~~~~~~~~
75+
Color Processing Advantages
76+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
7877

79-
- TensorFlow learns how to recognize target objects, not just specific
80-
images.
78+
- Color Processing looks for colors, not specific images.
8179

8280
- Recognizes objects in spite of different backgrounds.
83-
- Recognizes objects in varied lighting conditions.
81+
- Recognizes objects both up close and further away.
8482
- Recognizes objects even when objects are oriented in different
8583
positions.
8684

87-
- TensorFlow can be taught how to distinguish between similar looking
88-
(but still distinct) objects, such as a Stone and a Skystone from the
89-
2019-2020 challenge.
85+
- Pre-defined colors are included in the *FIRST* Tech Challenge SDK
86+
that have already been tested on season-specific game elements.
9087

91-
TensorFlow Disadvantages
92-
~~~~~~~~~~~~~~~~~~~~~~~~
88+
Color Processing Disadvantages
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9390

94-
- Training a TensorFlow model can be daunting at first. It requires a
95-
lot of understanding of the TensorFlow training metrics and behaviors.
96-
- TensorFlow is computationally intensive and has a low detection rate
97-
(an estimated 1 to 2 detections per second).
98-
- If TensorFlow recognizes an object in its field of view, it only
91+
- Color Processing can be sensitive to different lighting conditions.
92+
- If Color Processing recognizes an object in its field of view, it only
9993
returns location information on where the target object is within its
10094
field of view.
10195

102-
.. figure:: images/tfodIndirect.jpg
96+
.. figure:: images/82-targeting.png
10397
:align: center
10498
:width: 75%
10599

106-
TensorFlow can recognize actual objects (and not just 2D image targets).
100+
Color Processing can recognize actual objects (and not just 2D image targets).
107101

108-
.. figure:: images/tfodDual.jpg
102+
.. figure:: images/33-circleFit-LiveView.png
109103
:align: center
110104
:width: 75%
111105

112-
TensorFlow can be taught to distinguish between similar looking objects.
106+
Color Processing can recognize the shape of the object.
113107

114108
Which Should I Use?
115109
~~~~~~~~~~~~~~~~~~~
116110

117-
The choice of whether to use TensorFlow Lite or AprilTags will be
111+
The choice of whether to use AprilTags or Color Processing will be
118112
influenced by factors such as distance-to-target, lighting, accuracy
119113
required, camera placement and etc..
120114

121115
If the object and tag can always be guaranteed to be in a specific orientation
122116
and the tag fully visible, AprilTags are likely the best solution. However,
123117
if the object does not belong to you or a tag is not able to be physically
124-
placed on the object, TensorFlow can be a good solution.
118+
placed on the object, Color Processing can be a good solution.
125119

0 commit comments

Comments
 (0)