python将两张图片拼在一起并加上描述

from hashlib import new
from importlib.resources import path
from os import listdir, mkdir
import cv2,os,glob
import numpy as np
from tqdm import tqdm
from colorama import Fore


save_path = ""

path1 = ''
path2 = ''


if not os.path.exists((save_path)):
    os.mkdir(save_path)
else:
    print('文件夹已经存在')
    exit()

for i in tqdm(glob.glob(rf'{path1}\\*.jpg'),bar_format ='{l_bar}%s{bar}%s{r_bar}' % (Fore.BLUE,Fore.RESET)):

    name = i.split('\\')[-1]
    img1 = cv2.imread(i)
    img2 = cv2.imread(f'{path2}\\{name}')

    cv2.putText(img1,txt,(10,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
    cv2.putText(img2,txt,(10,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
   
    #横向连接
    image = np.hstack([img1,img2])

    # image = cv2.resize(image,(2784,1000))
    #cv2.imshow("",image)
    #cv2.waitKey()
    cv2.imwrite(save_path+'\\'f'{name}',image)






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值