import numpy as np
import cv2
eye=cv2.CascadeClassifier(r"C:\Users\Dibakar Chaudhary\Desktop\Practice\Computer-Vision-Tutorial-master\Haarcascades\eye.xml")
gl=cv2.imread(r"C:\Users\Dibakar Chaudhary\Desktop\Electro\glasses.png")
img=cv2.imread(r"C:\Users\Dibakar Chaudhary\Desktop\Electro\Before.png")
ey=eye.detectMultiScale(img,1.3,4)
x,y,w,h=ey[0]
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
gl1=cv2.resize(gl,(h,w))
for i in range (gl1.shape[0]):
for j in range(gl.shape[1]):
if(gl1[i,j,3]>0):
img[y+i,x+j,:]=gl1[i,j,:-1]
cv2.imshow(“Frame”,img)
cv2.waitKey(0)
cv2.destroyAllWindows()
error :
IndexError Traceback (most recent call last)
in
12 for i in range (gl1.shape[0]):
13 for j in range(gl.shape[1]):
—> 14 if(gl1[i,j,3]>0):
15 img[y+i,x+j,:]=gl1[i,j,:-1]
16
IndexError: index 3 is out of bounds for axis 2 with size 3