Skip to content

Instantly share code, notes, and snippets.

@pranjalAI
Created September 11, 2020 04:25
Show Gist options
  • Save pranjalAI/a9367ec30b84896a156d57c5b50aa7a9 to your computer and use it in GitHub Desktop.
Save pranjalAI/a9367ec30b84896a156d57c5b50aa7a9 to your computer and use it in GitHub Desktop.
if __name__ == "__main__":
angels=[45,90,135,180,225,270,315]
for filename in tqdm(os.listdir()):
file =filename.split(".")
if(file[-1]=="jpg"):
image_name=file[0]
image_ext="."+file[1]
else:
continue
for angle in angels:
im = yoloRotatebbox(image_name, image_ext, angle)
bbox = im.rotateYolobbox()
image = im.rotate_image()
# to write rotateed image to disk
cv2.imwrite(image_name+'_' + str(angle) + '.jpg', image)
file_name = image_name+'_' + str(angle) + '.txt'
#print("For angle "+str(angle))
if os.path.exists(file_name):
os.remove(file_name)
# to write the new rotated bboxes to file
for i in bbox:
with open(file_name, 'a') as fout:
fout.writelines(
' '.join(map(str, cvFormattoYolo(i, im.rotate_image().shape[0], im.rotate_image().shape[1]))) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment