@@ -0,0 +1,2143 @@
+#this script will get all files in a dir to rotate and crop images to create%0A#a dataset%0A%0Aimport numpy as np%0Aimport cv2 as cv%0Aimport glob%0Aimport math%0Aimport os.path%0A%0AcurrentImg = None%0Ap1 = None%0Ap2 = None%0Ap3 = None%0Ap4 = None%0Aclick = 0%0Acount = 0%0Aimgs =  glob.glob('*.jpg')%0Acv.namedWindow('Imagem')%0Adirectory = './imgs/'%0A%0Adef cropRotateCenter(event, x, y, flags, param):%0A    global p1, p2, p3, click, currentImg%0A    color = (255, 0, 0)%0A    if event == cv.EVENT_MOUSEMOVE:%0A        img = currentImg.copy()%0A        if click == 1:%0A            cv.line(img, p1, (x, y), color)%0A        if click %3E 1:%0A            cv.line(img, (x,0), (x, currentImg.shape%5B0%5D), color)%0A            cv.line(img, (0, y), (currentImg.shape%5B1%5D, y), color)%0A        cv.imshow(%22Imagem%22, img)%0A    if event == cv.EVENT_LBUTTONDOWN:%0A        click += 1%0A        if click == 1:%0A            p1 = (x, y)%0A        if click == 2:%0A            p2 = (x, y)%0A            height, width, channels = currentImg.shape%0A            angulo = math.atan2(p2%5B1%5D - p1%5B1%5D, p2%5B0%5D - p1%5B0%5D)%0A            deg = math.degrees(angulo)%0A            M = cv.getRotationMatrix2D((width/2, height/2), deg, 1)%0A            currentImg = cv.warpAffine(currentImg, M, (width, height))%0A        if click == 3:%0A            p3 = (x, y)%0A            cv.line(currentImg, (p3%5B0%5D,0), (p3%5B0%5D, currentImg.shape%5B0%5D), color)%0A            cv.line(currentImg, (0, p3%5B1%5D), (currentImg.shape%5B1%5D, p3%5B1%5D), color)%0A        if click == 4:%0A            p4 = (x, y)%0A            cv.line(currentImg, (p4%5B0%5D,0), (p4%5B0%5D, currentImg.shape%5B0%5D), color)%0A            cv.line(currentImg, (0, p4%5B1%5D), (currentImg.shape%5B1%5D, p4%5B1%5D), color)%0A            h = p4%5B1%5D - p3%5B1%5D%0A            w = p4%5B0%5D - p3%5B0%5D%0A            currentImg = currentImg%5Bp3%5B1%5D:p4%5B1%5D,p3%5B0%5D:p4%5B0%5D%5D%0A        cv.imshow('Imagem', currentImg)%0A%0Acv.setMouseCallback('Imagem', cropRotateCenter)%0A%0Afor imgName in imgs:%0A    img = cv.imread(imgName)%0A    currentImg = img.copy()%0A    cv.imshow('Imagem', img)%0A    if cv.waitKey(0) == 32:%0A        if not os.path.exists(directory):%0A            os.makedirs(directory)%0A        cv.imwrite(directory + 'img' + str(count) + '.jpg', currentImg)%0A        count += 1%0A    click = 0%0A

Add script