我正在尝试在OpenCV中创建一个圆并模糊其内容。然而,我能够创建圆,但无法模糊该部分。我的代码如下所示。请帮帮我。
import io
import picamera
import cv2
import numpy as np
import glob
from time import sleep
from PIL import ImageFilter
image = cv2.imread('/home/pi/Desktop/cricle-test/output_0020.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faceCascade = cv2.CascadeClassifier('/home/pi/Desktop/Image-Detection-test/haarcascade_frontalface_alt.xml')
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.2,
minNeighbors=5,
minSize=(30, 30),
flags = cv2.cv.CV_HAAR_SCALE_IMAGE
)
print "Found {0} faces!".format(len(faces))
# Draw a circle around the faces and blur
for (x, y, w, h) in faces:
sub = cv2.circle(image, ( int((x + x + w )/2), int((y + y + h)/2 )), int (h / 2), (0, 255, 0), 5)
cv2.blur(image(x,y,w,h),(23,23), 40000)
cv2.imwrite("/home/pi/Desktop/cricle-test/output_0020.jpg" ,image)