The whole end of your code can be replaced:
img[startX:endX, startY:endY] = cv2.blur(img[startX:endX, startY:endY], (23, 23))
instead:
# Get the origin co-ordinates and the length and width till where the face extends x, y, w, h = [ v for v in f ]
Moreover, you do not require a round mask, it (for me) is much easier to read.
PS: sorry for not commenting, not enough reputation to do this. Even if the post is 5 years old, I think it might be worth it as it found for this particular issue ..
ZettaCircl
source share