Image enhancement

Flip horizontally (denoted inverted):
DEF random_horizontal_flip (Image, bboxes):
, W, = image.shape
# [:: -. 1] Operation in the reverse order
# A = [. 1, 2,. 3,. 4,. 5]
# A [: : -1]
# Out [. 3]: [. 5,. 4,. 3, 2,. 1]
Image Image = [:, :: -. 1,:]
bboxes [:, [0, 2]] = W - bboxes [: , [2, 0]]
return Image, bboxes
BBOX = np.array ([[185,62,279,199,14]])
Image = np.array (cv2.imread ( "000001.jpg"))
image1, bboxes random_horizontal_flip = ( image.copy (), bbox.copy ())
cv2.namedWindow ( '0', 0)
cv2.imshow ( '0', image1)
cv2.waitKey (0)

Guess you like

Origin www.cnblogs.com/lzq116/p/12167080.html