Updated Java Sample TensorFlow Object Detection Op Mode (markdown)
@ -154,7 +154,7 @@ If a zoom factor has been set, then the Camera Stream preview on the Driver Stat
|
|||||||
<p align="center">[[/images/Blocks-Sample-TensorFlow-Object-Detection-Op-Mode/magnifiedArea.png]]<br/>Camera stream preview indicating magnified area (at a distance of about 4 feet or 1.2 meters).<p>
|
<p align="center">[[/images/Blocks-Sample-TensorFlow-Object-Detection-Op-Mode/magnifiedArea.png]]<br/>Camera stream preview indicating magnified area (at a distance of about 4 feet or 1.2 meters).<p>
|
||||||
|
|
||||||
### Iterating and Processing List of Recognized Objects
|
### Iterating and Processing List of Recognized Objects
|
||||||
The op mode will then iterate until a Stop command is received. At the beginning of each iteration, the op mode will check with the object detector to see how many objects it recognizes in its field of view. In the screenshot below, the variable "recognitions" is set to a list of objects that were recognized using the TensorFlow technology.
|
The op mode will then iterate until a Stop command is received. At the beginning of each iteration, the op mode will check with the object detector to see how many objects it recognizes in its field of view. In the screenshot below, the variable "updatedRecognitions" is set to a list of objects that were recognized using the TensorFlow technology.
|
||||||
|
|
||||||
```
|
```
|
||||||
if (opModeIsActive()) {
|
if (opModeIsActive()) {
|
||||||
@ -182,12 +182,10 @@ The op mode will then iterate until a Stop command is received. At the beginnin
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If the list is empty (i.e., if no objects were detected) the op mode sends a telemetry message to the Driver Station indicating that no items were detected.
|
If the list is not empty, then the op mode iterates through the list and sends information via telemetry about each detected object.
|
||||||
|
|
||||||
If the list is not empty, then the op mode iterates through the list and calls a function "displayInfo" to display information via telemetry about each detected object.
|
|
||||||
|
|
||||||
### Modifying the Sample Op Mode to display Target Zone
|
### Modifying the Sample Op Mode to display Target Zone
|
||||||
Let's modify the sample Blocks Op Mode so it will indicate which target zone the robot should drive to. Using the Blocks editor, add a conditional clause for an empty list (i.e., no targets detected) so that a telemetry message indicating that zone A should be targeted by the robot.
|
Let's modify the sample op mode so it will indicate which target zone the robot should drive to. Using the OnBot Java editor, modify the example code so it looks like the following sample. Specifically, you want the op mode to check the size of the updatedRecognitions list. If the size is zero, then no objects were detected and the op mode should send a telemetry message indicating that no objects were detected and the target zone is zone A.
|
||||||
|
|
||||||
```
|
```
|
||||||
if (opModeIsActive()) {
|
if (opModeIsActive()) {
|
||||||
@ -231,7 +229,7 @@ Let's modify the sample Blocks Op Mode so it will indicate which target zone the
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Also, when an object is detected, check its label to see which target zone is associated with that object. If the label reads "Single" then send a telemetry message to indicate target zone B. If the label reads "Quad" then send a telemetry message to indicate target zone C. If the label is neither "Single" or "Quad" send a telemetry message indicating that the target zone is unknown.
|
Also, when an object is detected, the op mode should check the object's label to see which target zone is associated with that object. If the label reads "Single" then send a telemetry message to indicate target zone B. If the label reads "Quad" then send a telemetry message to indicate target zone C. If the label is neither "Single" or "Quad" send a telemetry message indicating that the target zone is unknown.
|
||||||
|
|
||||||
Note that in this example, since the op mode iterates through the list of recognized objects, the target zone will be displayed for each recognized object in the list.
|
Note that in this example, since the op mode iterates through the list of recognized objects, the target zone will be displayed for each recognized object in the list.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user