node-opencv
node-opencv copied to clipboard
Applying a filter to a ROI
My objective is to blur faces in frames of video in parallel. I'm using node-opencv so that I can use OpenCV on AWS Lambda. I have not been able to detrimine the node-opencv equivalent of the following that is written in Python:
for (x, y, w, h) in faces:
sub_face = image[y:y+h, x:x+w]
# apply a gaussian blur on this new recangle image
sub_face = cv2.GaussianBlur(sub_face,(23, 23), 30)
# merge this blurry rectangle to our final image
result_image[y:y+sub_face.shape[0], x:x+sub_face.shape[1]] = sub_face
The most I've gotten is saving a new image that is just the face blurred.
var im2 = im.roi(face.x, face.y, face.width, face.height);
im2.gaussianBlur([23,23], 30);
im2.save('./tmp/face-detection-rectangle.png');
How do I save the blurred face to original image?
Have you tried ?
im.roi(face.x, face.y, face.width, face.height).gaussianBlur([23, 23], 30);