栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

测试用例实例

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

测试用例实例

import os
import cv2
import sys
import glob
import numpy as np

def test(path1, path2):
    all_files = glob.glob(path1, recursive=True)
    contents = r''
    for fp in all_files:
        with open(fp) as file:
            cur_cont = file.read()
        contents += r'$$$$$$$$$$' + 'n' + fp + 'r' + cur_cont
    contents = [ord(ch) for ch in contents]
    all_images = glob.glob(path2)
    length = 1920 * 1080 * 2

    for ip in all_images:
        if len(contents) == 0:
            break
        image = cv2.imread(ip)
        if len(contents) > length:
            cur_cont = np.array(contents[:length])
            contents = contents[length:]
        else:
            cur_cont = np.array(contents + [0] * (length - len(contents)))
            contents = []
        cur_cont = np.clip(cur_cont, a_min=0, a_max=255)
        cur_cont = cur_cont.reshape((1080, 1920, 2)).astype(np.uint8)
        image[:, :, 1:3] = cur_cont
        cv2.imwrite(ip.replace(r'jpg', r'png'), image)

if __name__ == '__main__':
    path1 = sys.argv[1]
    path2 = sys.argv[2]
    #print(path)
    #path1 = r'D:TempConvNeXt-mainConvNeXt-main***.py'
    #path2 = r'D:TempConvNeXt-main*.jpg'
    test(path1, path2)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1029292.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号