欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 91 在线观看 | 高清人人天天夜夜曰狠狠狠狠 | 插下面视频 | 色玖玖| 亚洲最黄网站 | 韩国久久久久无码国产精品 | 欧美高清在线视频一区二区 | 国产综合视频在线观看 | 99动漫| 免费观看一级欧美在线视频 | 成人精品视频 | 草久视频在线 | 精品国产自在久久 | 一区二区三区四区视频 | 欧美交换乱理伦片120秒 | 久久久国产99久久国产一 | 免费看a| 国产亚洲精品久久久久久老妇小说 | 91亚洲国产精品 | www.色综合 | 香蕉香蕉国产片一级一级毛片 | 免费在线公开视频 | 天天综合亚洲 | 久久国产精品99久久小说 | 久久精品国产999大香线焦 | 色吧欧美 | 日韩精品区| 亚洲一本 | 福利视频在线免费观看 | 天天干天天在线 | 97av视频在线播放 | 播五月开心婷婷综合 | 日本黄色福利视频 | 日韩精品亚洲一级在线观看 | 亚洲欧美日韩精品中文乱码 | 九一精品 | 色播欧美 | 成人免费观看在线网址 | 日韩中文字幕在线看 | 成人区视频爽爽爽爽爽 | 亚洲精品在线不卡 |