提交 6d91c3aa 编写于 作者: Eric.Lee2021's avatar Eric.Lee2021 🚴🏻

update

上级 0cd88a57
......@@ -72,7 +72,11 @@ def img_agu_crop(img_):
x2 = min(img_.shape[1]-1,img_.shape[1] - random.randint(0,scale_))
y2 = min(img_.shape[0]-1,img_.shape[1] - random.randint(0,scale_))
# print(img_.shape,'-crop- : ',x1,y1,x2,y2)
img_crop_ = img_[y1:y2,x1:x2,:]
try:
img_crop_ = img_[y1:y2,x1:x2,:]
except:
img_crop_ = img_
print("img_agu_crop error ")
return img_crop_
# 图像旋转
def M_rotate_image(image , angle , cx , cy):
......@@ -126,8 +130,6 @@ class LoadImagesAndLabels(Dataset): # for training/testing
img_path = self.files[index]
label_ = self.labels[index]
# print(img_path)
img = cv2.imread(img_path) # BGR
#--------------------------------------------
if self.have_label_file:
......@@ -148,8 +150,6 @@ class LoadImagesAndLabels(Dataset): # for training/testing
img = img[y1:y2,x1:x2,:]
break
#--------------------------------------------
if self.flag_agu == True and random.random()>0.5:
......@@ -167,7 +167,11 @@ class LoadImagesAndLabels(Dataset): # for training/testing
offset_x = random.randint(-range_limit_x,range_limit_x)
offset_y = random.randint(-range_limit_y,range_limit_y)
if not(angle==0 and offset_x==0 and offset_y==0):
img,_ = M_rotate_image(img , angle , cx+offset_x , cy+offset_y)
try:
img,_ = M_rotate_image(img , angle , cx+offset_x , cy+offset_y)
except:
print("M_rotate_image error ")
img = cv2.imread(img_path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册