欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

python-opencv 圖像旋轉保存

系統 1871 0

轉自:?opencv+python3.6圖像旋轉、并保持圖像像素大小不變、不被裁剪(旋轉90/180/270度)

            
              import cv2
import numpy as np
import os, shutil

def rotate_bound(image, angle):
    # grab the dimensions of the image and then determine the
    # center
    (h, w) = image.shape[:2]
    (cX, cY) = (w // 2, h // 2)
    # grab the rotation matrix (applying the negative of the
    # angle to rotate clockwise), then grab the sine and cosine
    # (i.e., the rotation components of the matrix)
    M = cv2.getRotationMatrix2D((cX, cY), -angle, 1.0)
    cos = np.abs(M[0, 0])
    sin = np.abs(M[0, 1])
    # compute the new bounding dimensions of the image
    nW = int((h * sin) + (w * cos))
    nH = int((h * cos) + (w * sin))
    # adjust the rotation matrix to take into account translation
    M[0, 2] += (nW / 2) - cX
    M[1, 2] += (nH / 2) - cY
    # perform the actual rotation and return the image
    return cv2.warpAffine(image, M, (nW, nH))

# 遍歷某文件夾下所有文件名,包括子文件夾下的文件名
def rotate_imagine(raw_img_path, save_img_path, angle):
    now_file_path = raw_img_path
    for dirpath, dirnames, filenames in os.walk(now_file_path):
        for filename in filenames:
            file_path = now_file_path + filename
            img = cv2.imread(file_path)
            img_rotate = rotate_bound(img, angle)
            save_file_path = save_img_path + filename
            cv2.imwrite(save_file_path, img_rotate)

if __name__=='__main__':
    for date in ['20181217', '20181218', '20181219', '20181220', '20181221']:
        for angle in [90, 180, 270]:
            raw_img_path = '/home/dl/huipu/AOI_data/factory_data_test/factory_testdata/'+ date +'/crop/aoi_crop_500_v2/JPEGImages/'
            save_img_path = '/home/dl/huipu/AOI_data/factory_data_test/factory_testdata/'+ date +'/crop/aoi_crop_500_v2/rotate/' + str(angle) + '/'
            if(os.path.exists(save_img_path)):
                shutil.rmtree(save_img_path)
            os.mkdir(save_img_path)
            rotate_imagine(raw_img_path, save_img_path, angle)









            
          

?


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: a级毛片高清免费视频 | 久久伊人婷婷 | 精品久久久久久免费影院 | www.75zzz.com| 欧美久草在线 | 日本福利在线观看 | 成人在线精品 | 精品欧美一区二区在线观看 | 欧美一级黄视频 | 岛国毛片一级一级特级毛片 | 国产91色在线 | 亚洲 | 免费中文视频 | 久久亚洲一区二区 | 国产精品日本欧美一区二区 | 五月天激情视频在线观看 | 国产综合亚洲精品一区二 | 国产亚洲一区在线 | av免费网站| 成人毛片视频免费看 | 国产在线视频91 | 国产一区久久 | 欧美日韩在线视频不卡一区二区三区 | jizzjizzjizz亚洲18| 久久久99精品免费观看精品 | 色婷婷亚洲五月色综合色 | 99午夜高清在线视频在观看 | 亚洲三区在线观看 | 一区二区三区免费看 | 国产高清毛片 | 99视频这里有精品 | 2022国产成人福利精品视频 | 亚洲日本免费 | 国产综合精品一区二区三区 | 亚洲AV国产精品无码A片 | jizz 亚洲大全| 亚洲欧美中文日韩在线v日本 | 中文乱码一二三四有限公司 | 亚洲精品自拍 | 婷婷天天 | 青青免费视频精品一区二区 | 中文一区二区 |