in
37
38 cv2.imshow(“video Frame”,frame)
—> 39 cv2.imshow(“FACE_SECTION”,face_section)
40 ## CHECK THE VALUE
41 if cv2.waitKey(1) & 0xFF == ord(‘q’):
NameError: name ‘face_section’ is not defined
//// HERE IS MY CODE
import cv2
cap = cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier(“haarcascade_frontalface_alt.xml”)
skip = 0
face_data=[]
dataset_path = ‘./DATA_SET/’
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == False:
continue
gray_frame = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(frame,1.3,5)
faces = sorted(faces,key=lambda f:f[2]*f[3])
print(faces)
for face in faces[-1:]:
x,y,w,h=face
cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)
#EXTRACT THE REGION OF INTREST
offset = 10 #GIVING THE 10 UNITS EACH SIDE TO THE FACE
face_section = frame[y-offset:y+h+offset,x-offset:x+w+offset]
face_section = cv2.resize(face_section,(100,100))
if skip%10==0:
face_data.append(face_section)
print(len(face_data))
cv2.imshow("video Frame",frame)
cv2.imshow("FACE_SECTION",face_section)
## CHECK THE VALUE
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()