Skip to content

Commit

Permalink
Added main parameter to toggle initial instance segmentation. Set to …
Browse files Browse the repository at this point in the history
…true by default. Ref #23

(cherry picked from commit fe0a647)
  • Loading branch information
WouterJansen committed Oct 4, 2024
1 parent 8769c93 commit 78fba44
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ namespace airlib
float clock_speed = 1.0f;
bool engine_sound = false;
bool move_world_origin = false;
bool initial_instance_segmentation = true;
bool log_messages_visible = true;
bool show_los_debug_lines_ = false;
HomeGeoPoint origin_geopoint{ GeoPoint(47.641468, -122.140165, 122) }; //The geo-coordinate assigned to Unreal coordinate 0,0,0
Expand Down Expand Up @@ -1454,6 +1455,7 @@ namespace airlib
speed_unit_factor = settings_json.getFloat("SpeedUnitFactor", 1.0f);
speed_unit_label = settings_json.getString("SpeedUnitLabel", "m\\s");
move_world_origin = settings_json.getBool("MoveWorldOrigin", false);
initial_instance_segmentation = settings_json.getBool("InitialInstanceSegmentation", true);
log_messages_visible = settings_json.getBool("LogMessagesVisible", true);
show_los_debug_lines_ = settings_json.getBool("ShowLosDebugLines", false);

Expand Down
4 changes: 3 additions & 1 deletion Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ bool ASimModeBase::IsAnnotationRGBValid(FString annotation_name, FColor color) {

void ASimModeBase::InitializeInstanceSegmentation()
{
instance_segmentation_annotator_.Initialize(this->GetLevel());
if (getSettings().initial_instance_segmentation) {
instance_segmentation_annotator_.Initialize(this->GetLevel());
}
ForceUpdateInstanceSegmentation();
updateInstanceSegmentationAnnotation();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/image_apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ When you specify `ImageType = DepthVis` in `ImageRequest`, you get an image that
You normally want to retrieve disparity image as float (i.e. set `pixels_as_float = true` and specify `ImageType = DisparityNormalized` in `ImageRequest`) in which case each pixel is `(Xl - Xr)/Xmax`, which is thereby normalized to values between 0 to 1.

### Segmentation
When you specify `ImageType = Segmentation` in `ImageRequest`, you get an image that gives you ground truth instance segmentation of the scene. At the startup, AirSim assigns a random color index to each mesh available in environment. The RGB values for each color index ID can be retrieved from the API.
When you specify `ImageType = Segmentation` in `ImageRequest`, you get an image that gives you ground truth instance segmentation of the scene. At the startup, AirSim assigns a random color index to each mesh available in environment. You can disable this by setting the main parameter `InitialInstanceSegmentation` to false in the settings.json file. The RGB values for each color index ID can be retrieved from the API.

You can assign a specific value to a specific mesh using APIs. For example, below Python code sets the object ID for the mesh called "Ground" to 20 in Blocks environment and hence changes its color in Segmentation view to the 20th color of the instance segmentation colormap:
Note that this will not do a check if this color is already assigned to a different object!
Expand Down
2 changes: 1 addition & 1 deletion docs/instance_segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ An Instance segmentation system is implemented into Cosys-AirSim. It uses Proxy
* These and other unsupported object types that are less common that either will not be rendered (decals, text, foliage, ...) or will by default be given the RGB color value of [149,149,149] or [0,0,0]. (brush objects, landscape,...).

## Usage
By default, at the start of the simulation, it will give a random color to each object.
By default, at the start of the simulation, it will give a random color to each object. You can disable this by setting the main parameter `InitialInstanceSegmentation` to false in the settings.json file.
Please see the [Image API documentation](image_apis.md#segmentation) on how to manually set or get the color information.

For an example of the Instance Segmentation API, please see the script _segmentation_test.py_ (Cosys-Airsim/PythonClient/segmentation/segmentation_test.py).
Expand Down
1 change: 1 addition & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Note this does not include most sensor types.
"ApiServerPort": 41451,
"RecordUIVisible": true,
"MoveWorldOrigin": false,
"InitialInstanceSegmentation": true,
"LogMessagesVisible": true,
"ShowLosDebugLines": false,
"ViewMode": "",
Expand Down
1 change: 1 addition & 0 deletions docs/settings_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ApiServerPort": 41451,
"RecordUIVisible": true,
"MoveWorldOrigin": false,
"InitialInstanceSegmentation": true,
"LogMessagesVisible": true,
"ShowLosDebugLines": false,
"ViewMode": "",
Expand Down

0 comments on commit 78fba44

Please sign in to comment.