11111

http://gxzz.gxeduyun.edu.cn/pros/identity/indexgx.action

`import cv2

def overlay_img(imgm,img_over,img_over_x,img_over_y):
img_w
img_p=img.shape
img_over_h,img_over_w,img_over_c=img_over.shape
if image_over_c==3:
img_over = cv2.cvtColor(img_over,cv2.COLOR_BGR2BGRA)
for w in range(0,img_over_w):
for h in range(0,img_over_h):
if img_over[h,w,3]!=0:
for c in range(0,3):
x=img_over_x +w
y=img_over_y+h
if x>=img_w or y>=img_h:
break
img[y,x,c]=img_over[h,w,c]
return img
face_img = cv2.imread("people.jpg")
glass_img = cv2.imread("‪glass.png",cv2.IMREAD_UNCHANGED)
height,width,channel = glass_img.shape
face_cascade = cv2.CascadeClassifier("导入xml文件invalid")
grayframe=cv2.cvtColor(face_img,cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(grayframe,1.15,5)
for(x,y,w,h)in faces:
gw=w
gh = int(heightw/width)
glass_img = cv2.resize(glass_img,(gw,gh))
overlay_img(face_img,glass_img,x,y+int(h
1/3))
cv2.imshow("screen",face-img)
cv2.waitkey()
cv2.destroyAllWindows()`

posted @ 2022-09-24 15:17  鹅城小铁匠  阅读(726)  评论(0)    收藏  举报
Fork me on GitHub