0
import cv2
import  cvzone
cap = cv2.VideoCapture(0)
cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
overlay = cv2.imread('santa_hat.png', cv2.IMREAD_UNCHANGED)
while True:
    _, frame = cap.read()
    gray_scale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = cascade.detectMultiScale(gray_scale)
    for (x, y, w, h) in faces:
        # cv2.rectangle(frame,(x, y), (x+w, y+h), (0, 255, 0), 2)
        overlay_resize = cv2.resize(overlay, (int(w*1.5), int(h*1.5)))
        frame = cvzone.overlayPNG(frame, overlay_resize, [x-75, y-45])
    cv2.imshow('img', frame)
    if cv2.waitKey(15) == ord('q'):
        break

I am trying to create filter and getting the following error:

cv2.error: OpenCV(4.6.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:214: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and type), nor 'array op scalar', nor 'scalar op array' in function 'binary_op' This issue is being caused by Line13: frame = cvzone.overlayPNG(frame, overlay_resize, [x-75, y-45])

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • 1
    Apparently either your image size, dtype or number of channels do not match what is expected. Print the shape and dtype of the two images to see what you actually have. – fmw42 Jun 13 '22 at 20:42
  • complete traceback please. which line of python code causes this? since you're new here, please review [ask] and [mre] – Christoph Rackwitz Jun 13 '22 at 21:06

0 Answers0