pythonopencvfacial-identification

I'm getting a syntax Error but cannot identify


Newbie here. I'm working with OpenCV to create a facial recognition program, but I'm getting a syntax error and cannot identify why it is happening

import cv2

face_cascade = cv2.CascadeClassifier("D:\\Python\\Pycharm Projects\\haarcascade_frontalface_default.xml")
img = cv2.imread("E:\\pic\\Cam\\py.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

faces = face_cascade.detectMultiScale(gray_img, scaleFactor_=_1, minNeighbors=5)
print(type(faces))
print(faces)

for x, y, w, h in faces:
    img = cv2.rectangle(img, (int(img, (x,y), (x+w, y+h), (0, 255, 0), 3)

resized = cv2.resize(img, (int(img.shape[1]/2), int(img.shape[0]/2)))
cv2.imshow("Gray", resized)
cv2.waitkey(0)
cv2.destroyAllWindows()

The error I get is

File "C:/Users/Areeb Irfan/.PyCharmCE2018.3/config/scratches/facialdetect.py", line 14
resized = cv2.resize(img, (int(img.shape[1]/2), int(img.shape[0]/2)))
      ^
SyntaxError: invalid syntax

Solution

  • img = cv2.rectangle(img, (int(img, (x,y), (x+w, y+h), (0, 255, 0), 3)
    

    doesn't have a closing ')' for rectangle(