-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented adas semantic segmentation
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
utils/open_model_zoo/Transportation/semantic-segmentation-adas/interp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import numpy as np | ||
from skimage.measure import approximate_polygon, find_contours | ||
|
||
import cv2 | ||
|
||
|
||
for frame_results in detections: | ||
frame_height = frame_results['frame_height'] | ||
frame_width = frame_results['frame_width'] | ||
frame_number = frame_results['frame_id'] | ||
detection = frame_results['detections'] | ||
detection = detection[0, 0, :, :] | ||
width, height = detection.shape | ||
|
||
for i in range(21): | ||
zero = np.zeros((width,height),dtype=np.uint8) | ||
|
||
f = float(i) | ||
zero = ((detection == f) * 255).astype(np.float32) | ||
zero = cv2.resize(zero, dsize=(frame_width, frame_height), interpolation=cv2.INTER_CUBIC) | ||
|
||
contours = find_contours(zero, 0.8) | ||
|
||
for contour in contours: | ||
contour = np.flip(contour, axis=1) | ||
contour = approximate_polygon(contour, tolerance=2.5) | ||
segmentation = contour.tolist() | ||
if len(segmentation) < 3: | ||
continue | ||
|
||
results.add_polygon(segmentation, i, frame_number) |
25 changes: 25 additions & 0 deletions
25
utils/open_model_zoo/Transportation/semantic-segmentation-adas/mapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"label_map": { | ||
"0": "road", | ||
"1": "sidewalk", | ||
"2": "building", | ||
"3": "wall", | ||
"4": "fence", | ||
"5": "pole", | ||
"6": "traffic light", | ||
"7": "traffic sign", | ||
"8": "vegetation", | ||
"9": "terrain", | ||
"10": "sky", | ||
"11": "person", | ||
"12": "rider", | ||
"13": "car", | ||
"14": "truck", | ||
"15": "bus", | ||
"16": "train", | ||
"17": "motorcycle", | ||
"18": "bicycle", | ||
"19": "ego-vehicle", | ||
"20": "background" | ||
} | ||
} |