kitcar_ml.utils.data_generation package
Subpackages
Submodules
kitcar_ml.utils.data_generation.augmentation_utils module
Functions:
|
Add gaussian noise to image. |
|
Add intensity/contrast to image. |
|
Adapt contrast/mean of img to background. |
|
Supersample (resize) given image. |
|
Revert previous supersampling (resize) of given image. |
|
Blend artificial image into background image. |
- gaussian_noise(img: ndarray, sigma: float, mean: float) ndarray[source]
Add gaussian noise to image.
- add_random_intensity_and_contrast(img: ndarray, sigma_all: float, mean_all: float, gauss_blur_all: float)[source]
Add intensity/contrast to image.
- adapt_contrast_and_mean(img: ndarray, dev_bckg_img: float)[source]
Adapt contrast/mean of img to background.
- revert_supersampling(img: ndarray, s: float) ndarray[source]
Revert previous supersampling (resize) of given image.
- add_object_to_background(background_img: ndarray, aug_img: ndarray, img_coords: ndarray, noise_sigma: float, noise_mean: float, gauss_blur_sign: int, bckg_img_stddev: float, hor_motion_blur_size: int) ndarray[source]
Blend artificial image into background image.
- Parameters
background_img – Image without the current generation.
aug_img – Pattern that should be inserted into background image.
img_coords – Coordinates where to insert the aug_img.
noise_mean – Mean of the noise.
noise_sigma – Stddev of the noise.
gauss_blur_sign – Gaussian blur kernel size applied to aug_img.
bckg_img_stddev – Stddev of noise applied to the background img.
hor_motion_blur_size – Kernel size of motion blur applied in hor direction.
- Returns
Background image with aug_img added to it.
kitcar_ml.utils.data_generation.data_generation_tool module
Functions:
|
|
|
kitcar_ml.utils.data_generation.generation_config module
Classes:
|
- class GenerationConfiguration(supersampling: int, max_number_of_objects: int, min_distance: float, max_distance: float, angle_x_max: float, angle_z_max: float, noise_sigma: float, noise_mean: float, gauss_blur_all: float, gauss_blur_sign: float, overlay_treshold: float, sigma_all: float, mean_all: float, crop_box: List[int], bbox_min_visibility: float, bbox_min_area: int, hor_motion_blur_size: float)[source]
Bases:
InitOptionsAttributes:
- supersampling: int
- max_number_of_objects: int
- min_distance: float
- max_distance: float
- angle_x_max: float
- angle_z_max: float
- noise_sigma: float
- noise_mean: float
- gauss_blur_all: float
- gauss_blur_sign: float
- overlay_treshold: float
- sigma_all: float
- mean_all: float
- crop_box: List[int]
- bbox_min_visibility: float
- bbox_min_area: int
- hor_motion_blur_size: float
kitcar_ml.utils.data_generation.object_generation_utils module
Functions:
|
|
|
Sort/Clip coordinates and filter invalid/overlayed bboxes. |
|
Try to create randomized objects that have valid bboxes. |
|
Add multiple objects to image. |
|
Add artificial objects to the given image. |
|
Load provided images and generate synthetic images out of them. |
Classes:
|
- clean_bbox(x_coords: Sequence[int], y_coords: Sequence[int], crop_box: Tuple[int, int, int, int], min_visibility, min_area, max_overlay, other_bboxes) Optional[Tuple[int, int, int, int]][source]
Sort/Clip coordinates and filter invalid/overlayed bboxes.
- class GeneratedObject(img_coords: Sequence[int], aug_idx: int, label: str)[source]
Bases:
objectAttributes:
- img_coords: Sequence[int]
- aug_idx: int
- label: str
- sample_objects(number_of_objects: int, name_list: List[str], sample_generator: SampleGenerator, angle_x_max: float, angle_z_max: float, overlay_trshld: float, crop_box: float, bbox_min_visibility: float, bbox_min_area: int) List[GeneratedObject][source]
Try to create randomized objects that have valid bboxes.
- add_objects_to_image(max_number_of_objects: int, name_list: List[str], aug_images: List[ndarray], input_image: ndarray, sample_generator: SampleGenerator, supersampling: float, angle_x_max: float, angle_z_max: float, noise_sigma: float, noise_mean: float, gauss_blur_sign: float, overlay_trshld: float, crop_box: float, bbox_min_visibility: float, bbox_min_area: int, hor_motion_blur_size: int) Tuple[ndarray, List[str]][source]
Add multiple objects to image.
- Parameters
max_number_of_objects – # of inserted objects.
name_list – Names of available objects.
aug_images – Available generation images.
input_image – Image that should be altered.
sample_generator – Generator of sample points for generations.
supersampling – Supersampling factor.
angle_x_max – Maximum rotation of generation around x axis.
angle_z_max – Maximum rotation of generation in z axis (after x rotation).
noise_sigma – Stddev of noise applied to generation image.
noise_mean – Mean of noise applied to generation image.
gauss_blur_sign – Filter kernel size of gaussian blur.
overlay_trshld – Threshold of max. overlay between two generations.
crop_box – ROI.
min_pxl_size – Minimal size of generation in pixels.
bbox_min_visibility – Minimal portion of generated bbox that is visible.
bbox_min_area – Minimal area of generated bbox.
hor_motion_blur_size – Kernel size of motion blur applied in hor direction.
- Returns
Augmented image and list of labels.
- create_artificial_objects_in_image(image: List[ndarray], config: GenerationConfiguration, name_list, aug_images, sample_generator) Tuple[ndarray, List[str]][source]
Add artificial objects to the given image.
The objects are sampled from aug_images and added as labels to the dataset.
- Parameters
image – Image.
config_data – Configurations; e.g. max number of objects in one image.
name_list – Class names of objects.
aug_images – Images of the objects (e.g. image of a stop sign)
sample_generator – Generator of positions in vehicle coordinates.
dataset – Dataset
naming_convention – Callable that returns a unique name for each index.
- Returns
Altered image and labels.
- load_and_create_artificial_images(img_names: List[str], dataset, config, name_list, aug_images, sample_generator)[source]
Load provided images and generate synthetic images out of them.
- Parameters
img_names – Names(paths) to all images that should be used.
dataset – The dataset.
config – Configuration of the image generation.
name_list – Names of available generations.
aug_images – Available generation images.
sample_generator – Generator of sample points for generations.
kitcar_ml.utils.data_generation.sample_generator module
Classes:
|
- class SampleGenerator(camera_specs_path, ts_sizes_path, min_distance, max_distance)[source]
Bases:
objectAttributes:
Camera specification including calibration.
Sizes of all traffic signs.
Minimal distance to generated sign.
Maximal distance to generated sign.
Methods:
Sample vector to point in the fov.
_H(height)Calculate transform from vehicle coords to img at a given height.
vehicle_point_to_img(vec)Transform vector in vehicle coords to pixel.
sign_coords(sign_name, angle_x, angle_z)Calculate rotated sign coordinates.
- camera_specs: CameraSpecs
Camera specification including calibration.
- ts_sizes: Dict[str, Tuple[float, float, float]]
Sizes of all traffic signs.
- min_distance: float
Minimal distance to generated sign.
- max_distance: float
Maximal distance to generated sign.
kitcar_ml.utils.data_generation.utils module
Functions:
Read augmentation images and file names. |
|
|
Create dataset. |
|
- read_augmentation_data(path_to_augmentation_images: str) Tuple[List[ndarray], List[str]][source]
Read augmentation images and file names.
- create_dataset(path_dataset_generated: str, class_names: List[str]) LabeledDataset[source]
Create dataset.
- Parameters
path_dataset_generated – Path to dataset directory.
class_names – Classes added to dataset.
- write_annotations_to_dataset(dataset: LabeledDataset, name, sample_data)[source]