modify demo

pull/3335/head
赵楚洋 3 years ago
parent fb9a5d7ff4
commit b44ba61be4
  1. 33
      modules/imgaug/samples/opencv_aug_demo.py

@ -1,36 +1,38 @@
import cv2
import copy
def random_crop(image):
transform = cv2.RandomCrop((300, 300))
transform = cv2.imgaug.RandomCrop((300, 300))
return transform.call(image)
def random_flip(image):
transform = cv2.RandomFlip(flipCode=1, p=0.8)
transform = cv2.imgaug.RandomFlip(flipCode=1, p=0.8)
return transform.call(image)
def center_crop(image):
transform = cv2.CenterCrop(size=(100, 100))
transform = cv2.imgaug.CenterCrop(size=(100, 100))
return transform.call(image)
def pad(image):
transform = cv2.Pad(padding=(10, 10, 10, 10))
transform = cv2.imgaug.Pad(padding=(10, 10, 10, 10))
return transform.call(image)
def random_resized_crop(image):
transform = cv2.RandomResizedCrop(size=(100, 100))
transform = cv2.imgaug.RandomResizedCrop(size=(100, 100))
return transform.call(image)
def compose(image):
transform = cv2.Compose([
cv2.RandomCrop((300, 300)),
cv2.RandomFlip(),
cv2.CenterCrop((100, 200)),
transform = cv2.imgaug.Compose([
cv2.imgaug.Resize((1024, 1024)),
cv2.imgaug.RandomCrop((800, 800)),
cv2.imgaug.RandomFlip(),
cv2.imgaug.CenterCrop((512, 512)),
])
return transform.call(image)
@ -38,10 +40,15 @@ def compose(image):
def main():
# read image
input_path = "../../../samples/data/corridor.jpg"
image = cv2.imread(input_path)
image = compose(image)
cv2.imshow(image)
src = cv2.imread(input_path)
while True:
image = copy.copy(src)
image = compose(image)
cv2.imshow("dst", image)
ch = cv2.waitKey(1000)
if ch == 27:
break
if __name__ == '__main__':

Loading…
Cancel
Save