{"slug": "blurring-faces-to-preserve-privacy-with-computer-vision", "title": "Blurring Faces to Preserve Privacy with Computer Vision", "summary": "A Roboflow tutorial demonstrates building an anonymization step that detects faces and license plates with a trained computer vision model and blurs or pixelates each region of interest before images enter a storage pipeline, following the approach Google uses to censor faces in Google Maps Street View imagery. The walkthrough trains detection models on face and license plate datasets from Roboflow Universe, then calls the model through the Roboflow inference SDK and applies blur via supervision, Roboflow's open source computer vision library, using a kernel_size of 35 to hide facial features without smearing surrounding areas. The technique is presented as a drop-in privacy layer for image, video, or livestream pipelines that leaves downstream processing unchanged.", "body_md": "Automatically blurring faces and license plates before data enters a storage pipeline is a practical way to handle personally identifiable information in computer vision deployments, following the same approach used by Google Maps Street View. This tutorial covers collecting face and license plate datasets from Roboflow Universe, training a detection model, and using the Roboflow API to run inference and then apply OpenCV blur or pixelation to each detected region of interest. The result is an anonymization step that can be inserted into any image or video pipeline without changing downstream processing.\n\nQuote of the day: “Keep calm and carry on.” -Winston Churchill\n\nComputer vision applications can be used in a variety of settings and sometimes information captured in your dataset might not be information you want to be responsible for having such as personally identifiable information, banking information, or any other sensitive data.\n\nIn these instances, you can ensure the data is anonymized by blurring, pixelating, or fogging any specific data before it enters your database. This post will show you how to do this using computer vision.\n\nWhat to expect from this blog post?\n\nHow to train models to detect faces and license plates from a given image.\n\nFogging, also known as blurring, is used for censorship or privacy in which a visual area of any image, video, or livestream is blurred to obscure the data captured.\n\nPixelizationis also a form of fogging. This technique is used widely across industries from street mapping to news reporting to social media.\n\nExample: Face Blurring Used in Google Maps\n\nWhen Street View imagery is published to Google Maps, Google employs censoring faces to protect individuals’ privacy.\n\nSteps Involved for Blurring Faces with Computer Vision\n\nAlong with model performance data, we also have access to visualizations for the training and validation curves.\n\nUsing the Computer Vision Model to Censor the Region of Interest (ROI)\n\nAfter successfully training the model, go to the Deploy page (opens in a new tab) and use the API script provided to censor the images.\n\nAfter training, call your model from Python with the Roboflow inference SDK, then use supervision (opens in a new tab), Roboflow's open source computer vision library, to blur or pixelate every detected face. Install both packages:\n\nShell\n\n```\npip install inference-sdk supervision\n```\n\nRun the model on an image and convert the response into a supervision Detections object. Replace MODEL_ID with your project ID and version from your model's Deploy page (opens in a new tab), and add your Roboflow API key.\n\nPython\n\n``` python\nimport cv2\nimport supervision as sv\nfrom inference_sdk import InferenceHTTPClient\n\nclient = InferenceHTTPClient(\n    api_url=\"https://serverless.roboflow.com\",\n    api_key=\"YOUR_ROBOFLOW_API_KEY\",\n)\nMODEL_ID = \"your-project/1\"  # your face (or license plate) model ID and version\n\nimage = cv2.imread(\"people.jpg\")\nresult = client.infer(image, model_id=MODEL_ID)\ndetections = sv.Detections.from_inference(result)\ndetections = detections[detections.confidence > 0.4]\n```\n\nThe model returns one prediction per face with the box center, width, height, class, and confidence:\n\nAfter the prediction, extract the region of interest (ROI):\n\nPython\n\n```\nroi = sv.crop_image(image=image, xyxy=detections.xyxy[0])\n```\n\nTo blur every face, use BlurAnnotator. Faces are oval, so the helper below keeps the blur inside an ellipse fitted to each box instead of the whole rectangle. A larger kernel_size gives a stronger blur; 35 hides facial features without smearing the area around the face.\n\nPython\n\n``` python\nimport numpy as np\n\ndef anonymize(image, detections, annotator):\n    # Run the annotator on each box, then keep its result only inside an\n    # ellipse fitted to the box, since faces are oval.\n    annotated = annotator.annotate(scene=image.copy(), detections=detections)\n    mask = np.zeros(image.shape[:2], dtype=np.uint8)\n    for x1, y1, x2, y2 in detections.xyxy.astype(int):\n        center = ((x1 + x2) // 2, (y1 + y2) // 2)\n        axes = ((x2 - x1) // 2, (y2 - y1) // 2)\n        cv2.ellipse(mask, center, axes, 0, 0, 360, 255, -1)\n    return np.where(mask[..., None] == 255, annotated, image)\n\nblur_annotator = sv.BlurAnnotator(kernel_size=35)\nblurred = anonymize(image, detections, blur_annotator)\ncv2.imwrite(\"blurred.jpg\", blurred)\n```\n\nTo pixelate instead, pass a PixelateAnnotator to the same helper. A larger pixel_size gives bigger blocks.\n\nPython\n\n```\npixelate_annotator = sv.PixelateAnnotator(pixel_size=12)\npixelated = anonymize(image, detections, pixelate_annotator)\ncv2.imwrite(\"pixelated.jpg\", pixelated)\n```\n\nBoth annotators cover every face the model finds, so group photos and crowded scenes are handled in one call.\n\nBlur Faces in Video\n\nThe same helper works frame by frame. sv.process_video reads a video, runs your callback on each frame, and writes the anonymized result:\n\nPython\n\n``` python\ndef callback(frame, index):\n    result = client.infer(frame, model_id=MODEL_ID)\n    detections = sv.Detections.from_inference(result)\n    detections = detections[detections.confidence > 0.4]\n    return anonymize(frame, detections, blur_annotator)\n\nsv.process_video(source_path=\"input.mp4\", target_path=\"blurred.mp4\", callback=callback)\n```\n\nStart Your First Blurring Project with Computer Vision", "url": "https://wpnews.pro/news/blurring-faces-to-preserve-privacy-with-computer-vision", "canonical_source": "https://roboflow.com/blog/face-blur-privacy-computer-vision", "published_at": "2026-11-18 14:00:00+00:00", "updated_at": "2026-11-18 19:43:01.517505+00:00", "lang": "en", "topics": ["computer-vision", "ai-tools", "developer-tools", "ai-ethics"], "entities": ["Roboflow", "Roboflow Universe", "Google Maps", "supervision", "OpenCV", "Winston Churchill"], "also_reported_by": [], "takeaway": "Insert a detection-then-blur step before storage: run a face or license plate model via the Roboflow inference SDK, filter detections below 0.4 confidence, and apply supervision's BlurAnnotator with kernel_size 35, masking the blur to an ellipse fitted to each box because faces are oval.", "recommendation": {"advice": "Blur detected faces and plates before data hits storage: filter detections under 0.4 confidence and use kernel_size 35 with an elliptical mask so features are hidden without smearing the surroundings.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/blurring-faces-to-preserve-privacy-with-computer-vision", "markdown": "https://wpnews.pro/news/blurring-faces-to-preserve-privacy-with-computer-vision.md", "text": "https://wpnews.pro/news/blurring-faces-to-preserve-privacy-with-computer-vision.txt", "jsonld": "https://wpnews.pro/news/blurring-faces-to-preserve-privacy-with-computer-vision.jsonld"}}