diff --git a/PythonClient/computer_vision/seg_pallete.py b/PythonClient/computer_vision/seg_palette.py similarity index 58% rename from PythonClient/computer_vision/seg_pallete.py rename to PythonClient/computer_vision/seg_palette.py index 269c96eb94..664769cc9e 100644 --- a/PythonClient/computer_vision/seg_pallete.py +++ b/PythonClient/computer_vision/seg_palette.py @@ -1,5 +1,6 @@ import numpy import random + # requires Python 3.5.3 :: Anaconda 4.4.0 # pip install opencv-python import cv2 @@ -13,15 +14,27 @@ def generate_color_palette(numPixelsWide, outputFile): possibilities = [list(range(256)), list(range(256)), list(range(256))] colors = [[0] * 3 for i in range(256)] - + + choice = 0 + j = 0 + for i in range(3): + palette[0, j * numPixelsWide : (j + 1) * numPixelsWide, i] = choice + colors[j][i] = choice + for i in range(3): - for j in range(256): + for j in range(1, 255): choice = random.sample(possibilities[i], 1)[0] possibilities[i].remove(choice) - palette[0, j * numPixelsWide:(j + 1) * numPixelsWide, i] = choice + palette[0, j * numPixelsWide : (j + 1) * numPixelsWide, i] = choice colors[j][i] = choice - cv2.imwrite(outputFile, palette, [cv2.IMWRITE_PNG_COMPRESSION,0]) + choice = 255 + j = 255 + for i in range(3): + palette[0, j * numPixelsWide : (j + 1) * numPixelsWide, i] = choice + colors[j][i] = choice + + cv2.imwrite(outputFile, palette, [cv2.IMWRITE_PNG_COMPRESSION, 0]) rgb_file = open("rgbs.txt", "w") for j in range(256): @@ -29,8 +42,7 @@ def generate_color_palette(numPixelsWide, outputFile): rgb_file.close() -if __name__ == '__main__': - +if __name__ == "__main__": numPixelsWide = 4 - outputFile = 'seg_color_pallet.png' - generate_color_palette(numPixelsWide, outputFile) \ No newline at end of file + outputFile = "seg_color_palette.png" + generate_color_palette(numPixelsWide, outputFile) diff --git a/Unreal/Plugins/AirSim/Content/HUDAssets/SegmentationMaterial.uasset b/Unreal/Plugins/AirSim/Content/HUDAssets/SegmentationMaterial.uasset index 0e35dd1dc8..a1f727e5bf 100644 Binary files a/Unreal/Plugins/AirSim/Content/HUDAssets/SegmentationMaterial.uasset and b/Unreal/Plugins/AirSim/Content/HUDAssets/SegmentationMaterial.uasset differ diff --git a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.png b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.png new file mode 100644 index 0000000000..ecc4513b80 Binary files /dev/null and b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.png differ diff --git a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.uasset b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.uasset new file mode 100644 index 0000000000..a85d7fc4f6 Binary files /dev/null and b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_palette.uasset differ diff --git a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.png b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.png deleted file mode 100644 index c16454f64a..0000000000 Binary files a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.png and /dev/null differ diff --git a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.uasset b/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.uasset deleted file mode 100644 index a5e8ceda99..0000000000 Binary files a/Unreal/Plugins/AirSim/Content/HUDAssets/seg_color_pallet.uasset and /dev/null differ diff --git a/docs/seg_rgbs.txt b/docs/seg_rgbs.txt index a579be929b..465f6d6051 100644 --- a/docs/seg_rgbs.txt +++ b/docs/seg_rgbs.txt @@ -1,4 +1,4 @@ -0 [55, 181, 57] +0 [0, 0, 0] 1 [153, 108, 6] 2 [112, 105, 191] 3 [89, 121, 72] @@ -253,4 +253,4 @@ 252 [130, 56, 55] 253 [147, 210, 11] 254 [162, 203, 118] -255 [43, 47, 206] +255 [255, 255, 255] \ No newline at end of file