欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: www国产成人免费观看视频,深夜成人网 | 欧美久久天天综合香蕉伊 | 国产日韩精品久久 | 天干天夜啪天天碰 | 91精品国产综合久久久久 | 欧美不卡 | 国产日产精品一区二区三区四区 | 国产一级毛片高清 | 久久黄色大片 | 久久中文字幕在线 | 国产一极毛片 | 日韩乱视频 | 亚洲 中文 欧美 日韩 在线观看 | 国产成人精品免费视频大 | 午夜福利视频 | 日韩视频一 | 久色| 久久久久国产视频 | 91免费在线看 | 欧美综合图区亚欧综合图区 | 日本喷潮 | 日韩电影网站 | 毛片a片 | 日韩美女一区二区三区在线观看 | 亚洲成人av| 国产日韩视频 | 99久久精品免费看国产一区二区 | 色婷婷AV99XX| 久久国产一区 | 毛片毛片毛片毛片毛片 | 欧美白人黑人xxxx猛交 | 国产一级免费视频 | 美国黄色网址 | 国产精品久久婷婷六月丁香 | 欧洲男女下面进出的视频 | 国产精品久久久久久久久电影网 | 精品欧美一区二区三区久久久小说 | 日韩欧美在线视频 | 日日碰狠狠躁久久躁婷婷 | 欧美日韩一区二区在线视频 | 黑人巨大videosjapan高清 婷婷在线免费观看 |