About the face blurring process

Hi Yuta!

Your code seems OK.

First, the large aperture of the gaussian kernel can make the processing slow. Try cv2.blur() or cv2.boxFilter() and see if it’s faster.

You can try to blur all the image and copy it over the original using a mask; something like (untested code):

img_blurred = cv2.blur(image,(101,101))
mask = np.zeros(...same shape as image...) # create a black mask
for coord in coords:
    mask[coord[1]:coord[3], coord[0]:coord[2]]=1 # set the ROIs to 1
img_blurred.copyTo(image,mask) # copy the blurred image on top the original using the mask

(not sure if this will speed up the processing, but still worth trying).

If it’s still slow, try to speed up the blurring using GPU. It should have a big impact on the speed. Here’s the code for CUDA (on Nvidia cards); for AMD cards you can try with OpenCL:

gpu_image = cv2.cuda_GpuMat()
gpu_image.upload(image)
gpu_blurred = cv2.cuda.blur(...)
img_blurred = gpu_blurred.download()
...same code as above...