@preserve_shape<EOL>def optical_distortion(img, k=<NUM_LIT:0>, dx=<NUM_LIT:0>, dy=<NUM_LIT:0>, interpolation=cv2.INTER_LINEAR, border_mode=cv2.BORDER_REFLECT_101,<EOL>value=None):
height, width = img.shape[:<NUM_LIT:2>]<EOL>fx = width<EOL>fy = width<EOL>cx = width * <NUM_LIT:0.5> + dx<EOL>cy = height * <NUM_LIT:0.5> + dy<EOL>camera_matrix = np.array([[fx, <NUM_LIT:0>, cx],<EOL>[<NUM_LIT:0>, fy, cy],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>]], dtype=np.float32)<EOL>distortion = np.array([k, k, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>], dtype=np.float32)<EOL>map1, map2 = cv2.initUndistortRectifyMap(camera_matrix, distortion, None, None, (width, height), cv2.CV_32FC1)<EOL>img = cv2.remap(img, map1, map2, interpolation=interpolation, borderMode=border_mode, borderValue=value)<EOL>return img<EOL>
Barrel / pincushion distortion. Unconventional augment.

    Reference:
        |  https://stackoverflow.com/questions/6199636/formulas-for-barrel-pincushion-distortion
        |  https://stackoverflow.com/questions/10364201/image-transformation-in-opencv
        |  https://stackoverflow.com/questions/2477774/correcting-fisheye-distortion-programmatically
        |  http://www.coldvision.io/2017/03/02/advanced-lane-finding-using-opencv/