Feature Extraction API
- class sdc_scissor.feature_extraction_api.feature_extraction.RoadFeatures
- __init__()
Class representing the road features as attributes
- to_dict()
Serialize the road features to a python dictionary
- Returns:
A dictionary with the road features
- class sdc_scissor.feature_extraction_api.feature_extraction.RoadSegment
- __init__()
A class representing a road segment
- class sdc_scissor.feature_extraction_api.feature_extraction.SegmentType
- l_turn = 'left_turn'
- r_turn = 'right_turn'
- straight = 'straight'
- class sdc_scissor.feature_extraction_api.feature_extraction.FeatureExtractor(segmentation_strategy)
- __init__(segmentation_strategy)
A class that is responsible for extracting road features of test scenarios.
- Parameters:
segmentation_strategy – A road segmentation strategy
- static save_to_csv(road_features: list, out_dir: Path)
Save the road features to a csv file.
- Parameters:
road_features – List of road features
out_dir – Path to store the csv file
- extract_features(test: Test) RoadFeatures
Input is a list of (x, y) tuples which defines the road. This function extract the angles and radius of segments. Furthermore, the statistics of angles and radius are calculated.
- Parameters:
test – A test object
- Returns:
A road feature object
- class sdc_scissor.feature_extraction_api.road_geometry_calculator.RoadGeometryCalculator
- extract_turn_angles(road_points)
Extract angles of raod points and ad them to the instance variable.
- Parameters:
road_points – Points that define the road in the test scenario.
- Returns:
Angles in degrees of road’s turns defined by the road points.
- static get_angle(first_vec, second_vec)
Returns the angle in degrees between the first and second vector. A left turn as positive angles whereas right turns have negatives.
- Parameters:
first_vec – First 2D vector
second_vec – Second 3D vector
- Returns:
Angle between the vectors in degrees
- static get_distance_between(first_point, second_point) float
Calculate Euclidean distance between two points.
- Parameters:
first_point – (x,y) coordinates of first point
second_point – (x,y) coordinates of second point
- Returns:
Euclidean distance between the points
- static get_direction(first_point, second_point)
Get the direction vector from the first point to the second point.
- Parameters:
first_point – (x,y) coordinates of first point
second_point – (x,y) coordinates of second point
- Returns:
Return the difference 2D vector (second_point-first_point)
- static get_road_length(road_points)
Compute the length of the road.
- Parameters:
road_points – List of road points defining the road
- Returns:
Length of the road
- class sdc_scissor.feature_extraction_api.segmentation_strategy.SegmentationStrategy
Interface for implementing different segmentation strategies.
- abstract extract_segments(road_points)
Abstract method to retrieve segments from a road, based on a specific strategy.
- Parameters:
road_points – Sequence of coordinates specifying the road.
- class sdc_scissor.feature_extraction_api.angle_based_strategy.AngleBasedStrategy(angle_threshold=5, decision_distance=10)
Define segments based on identified turns. The center of a turn where the angles possibly reaches the maximum will also be the center of the segment. Straight segments are identified where no significant turn angles are present.
- __init__(angle_threshold=5, decision_distance=10)
Instantiate a strategy object defining the segmentation strategy of the road. Class is coherent to the strategy pattern.
- Parameters:
angle_threshold – Angle threshold defining a new segment.
decision_distance – Road distance for calculating the turn angle.
- extract_segments(road_points)
Extract segments from road points according to the angle-based segmentation strategy.
- Parameters:
road_points – List of 2D points, defining the road to be segmented
- Returns:
List of indexes defining the start and end of segments
- class sdc_scissor.feature_extraction_api.equi_distance_strategy.EquiDistanceStrategy(number_of_segments)
Define segments with equal lengts. The last segment might be different to the others since there might be a remainder while dividing the road into predefined number of segments.
- __init__(number_of_segments)
Initialize the strategy by providing the number of segments that should be generated
- Parameters:
number_of_segments – The number of segments with equal distances that should be generated
- extract_segments(road_points)
Extract the segments of the road specified by the road points
- Parameters:
road_points – Road points defining the road
- Returns:
List of indexes representing the start and end point of segments
- class sdc_scissor.feature_extraction_api.parameterized_uniform_strategy.ParameterizedUniformStrategy(risk_factor: str, max_seg_length_to_full_road)
This class segments the road based on parameters like risk factor and fullroad length.
- __init__(risk_factor: str, max_seg_length_to_full_road)
- Parameters:
risk_factor – Risk factor of the driving AI.
max_seg_length_to_full_road – Relative size of the longest allowed segment compared to the full road length.
- extract_segments(road_points)
Returns a list of tuples that contain start end end indexes of road segments.
- Parameters:
road_points – List of coordinates specifying the road.
- Returns:
List of start and end indexes defining the start and end road points of segments.