def add_rain(img, slant, drop_length, drop_width, drop_color, blur_value, brightness_coefficient, rain_drops):
    """

    From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

    Args:
        img (np.uint8):
        slant (int):
        drop_length:
        drop_width:
        drop_color:
        blur_value (int): rainy view are blurry
        brightness_coefficient (float): rainy days are usually shady
        rain_drops:

    Returns:

    """
    non_rgb_warning(img)

    input_dtype = img.dtype
    needs_float = False

    if input_dtype == np.float32:
        img = from_float(img, dtype=np.dtype('uint8'))
        needs_float = True
    elif input_dtype not in (np.uint8, np.float32):
        raise ValueError('Unexpected dtype {} for RandomSnow augmentation'.format(input_dtype))

    image = img.copy()

    for (rain_drop_x0, rain_drop_y0) in rain_drops:
        rain_drop_x1 = rain_drop_x0 + slant
        rain_drop_y1 = rain_drop_y0 + drop_length

        cv2.line(image, (rain_drop_x0, rain_drop_y0), (rain_drop_x1, rain_drop_y1), drop_color, drop_width)

    image = cv2.blur(image, (blur_value, blur_value))  # rainy view are blurry
    image_hls = cv2.cvtColor(image, cv2.COLOR_RGB2HLS).astype(np.float32)
    image_hls[:, :, 1] *= brightness_coefficient

    image_rgb = cv2.cvtColor(image_hls.astype(np.uint8), cv2.COLOR_HLS2RGB)

    if needs_float:
        image_rgb = to_float(image_rgb, max_value=255)

    return image_rgb
def add_rain ( img , slant , drop_length , drop_width , drop_color , blur_value , brightness_coefficient , rain_drops ) : non_rgb_warning ( img ) input_dtype = img . dtype needs_float = False if input_dtype == np . float32 : img = from_float ( img , dtype = np . dtype ( 'uint8' ) ) needs_float = True elif input_dtype not in ( np . uint8 , np . float32 ) : raise ValueError ( 'Unexpected dtype {} for RandomSnow augmentation' . format ( input_dtype ) ) image = img . copy ( ) for ( rain_drop_x0 , rain_drop_y0 ) in rain_drops : rain_drop_x1 = rain_drop_x0 + slant rain_drop_y1 = rain_drop_y0 + drop_length cv2 . line ( image , ( rain_drop_x0 , rain_drop_y0 ) , ( rain_drop_x1 , rain_drop_y1 ) , drop_color , drop_width ) image = cv2 . blur ( image , ( blur_value , blur_value ) ) image_hls = cv2 . cvtColor ( image , cv2 . COLOR_RGB2HLS ) . astype ( np . float32 ) image_hls [ : , : , 1 ] *= brightness_coefficient image_rgb = cv2 . cvtColor ( image_hls . astype ( np . uint8 ) , cv2 . COLOR_HLS2RGB ) if needs_float : image_rgb = to_float ( image_rgb , max_value = 255 ) return image_rgb
From https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library

    Args:
        img (np.uint8):
        slant (int):
        drop_length:
        drop_width:
        drop_color:
        blur_value (int): rainy view are blurry
        brightness_coefficient (float): rainy days are usually shady
        rain_drops:

    Returns: