import cv2
import numpy as py
def get_img_info(src):
height = src.shape[0]
width = src.shape[1]
channels = src.shape[2]
print('长度:%d 宽度:%d 通道:%d' % (height, width, channels))
def nothing(x):
pass
img = cv2.imread('football.png')
cv2.rectangle(img, (100, 300), (188, 368), (0, 0, 255), 1)
width1 = 601
height1 = 375
dim = (width1, height1)
img2 = cv2.imread('tree.jpg')
img2 = cv2.resize(img2, dim, interpolation=cv2.INTER_AREA)
cv2.namedWindow('input img', cv2.WINDOW_AUTOSIZE)
cv2.createTrackbar('bar', 'input img', 0, 10, nothing)
cv2.imshow('input img', img)
get_img_info(img)
get_img_info(img2)
while(1):
tmp = cv2.getTrackbarPos('bar', 'input img')
dst = cv2.addWeighted(img2, float(tmp/10), img, float(1-(tmp/10)), 0)
cv2.imshow('input img', dst)
c = cv2.waitKey(1)
if c == 27:
break