1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| file_list=[x for x in os.listdir(path) if x.endswith("jpg")]
random.shuffle(file_list)
train_list=file_list[:rate]
for index,file in enumerate(train_list):
os.path.join(path+"train","train_{0:0>3d}.jpg".format(index+1))
shutil.copy(old_file,new_file)
img1=cv2.resize(img,(256,256))
h,w,c=img.shape
M=cv2.getRotationMatrix2D((w/2,h/2),random.randint(1,10),1)
img2=cv2.warpAffine(img,M,(h,w))
rotated_list.append
img1=cv2.flip(img,1)
img=cv2.imread(file_jpg,0)
with open(json_path,"r",encoding="utf-8") as f: content=json.load(f)
text=content["results"][0]["classes"]
cv2.rectangle(img,(x1,y1),(x2,y2),(0,0,255),3)
cv2.putText(img,"文字",(x1-5,y1-5),cv2.FONT_HERSHEY_SIMPLEX,1,(0,0,255),2)
now_time=time.strftime('%Y_%m_%d')
os.mkdir(path+"picture")
zeros=np.zeros((h,w),dtype='uint8')
cvt=img_gray[i,j]*1.3-30
b,g,r=cv2.split(img_ori)
bb=cv2.equalizeHist(b)
img_hist=cv2.merge([bb,gg,rr])
big_pts=np.array(big_points,dtype=np.int32)
bg=np.ones(img.shape,dtype='uint8')*255
cv2.fillPoly(bg,[big_pts],(0,0,0))
|