Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | Learn how to use Ultralytics YOLO11 for real-time object blurring to enhance privacy and focus in your images and videos. | YOLO11, object blurring, real-time processing, privacy protection, image manipulation, video editing, Ultralytics |
Object blurring with Ultralytics YOLO11 involves applying a blurring effect to specific detected objects in an image or video. This can be achieved using the YOLO11 model capabilities to identify and manipulate objects within a given scene.
Watch: Object Blurring using Ultralytics YOLO11
!!! example "Object Blurring using Ultralytics YOLO"
=== "CLI"
```bash
# Blur the objects
yolo solutions blur show=True
# Pass a source video
yolo solutions blur source="path/to/video/file.mp4"
# Blur the specific classes
yolo solutions blur classes=[0, 5]
```
=== "Python"
```python
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
# Video writer
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
video_writer = cv2.VideoWriter("object_blurring_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Initialize object blurrer object
blurrer = solutions.ObjectBlurrer(
show=True, # display the output
model="yolo11n.pt", # model for object blurring i.e. yolo11m.pt
# line_width=2, # width of bounding box.
# classes=[0, 2], # count specific classes i.e, person and car with COCO pretrained model.
# blur_ratio=0.5, # adjust percentage of blur intensity, the value in range 0.1 - 1.0
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or processing is complete.")
break
results = blurrer(im0)
# print(results") # access the output
video_writer.write(results.plot_im) # write the processed frame.
cap.release()
video_writer.release()
cv2.destroyAllWindows() # destroy all opened windows
```
ObjectBlurrer
ArgumentsHere's a table with the ObjectBlurrer
arguments:
{% from "macros/solutions-args.md" import param_table %} {{ param_table(["model", "line_width", "blur_ratio"]) }}
The ObjectBlurrer
solution also supports a range of track
arguments:
{% from "macros/track-args.md" import param_table %} {{ param_table(["tracker", "conf", "iou", "classes", "verbose", "device"]) }}
Moreover, the following visualization arguments can be used:
{% from "macros/visualization-args.md" import param_table %} {{ param_table(["show", "line_width"]) }}
Object blurring with Ultralytics YOLO11 involves automatically detecting and applying a blurring effect to specific objects in images or videos. This technique enhances privacy by concealing sensitive information while retaining relevant visual data. YOLO11's real-time processing capabilities make it suitable for applications requiring immediate privacy protection and selective focus adjustments.
To implement real-time object blurring with YOLO11, follow the provided Python example. This involves using YOLO11 for object detection and OpenCV for applying the blur effect. Here's a simplified version:
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
# Video writer
video_writer = cv2.VideoWriter("object_blurring_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init ObjectBlurrer
blurrer = solutions.ObjectBlurrer(
show=True, # display the output
model="yolo11n.pt", # model="yolo11n-obb.pt" for object blurring using YOLO11 OBB model.
blur_ratio=0.5, # set blur percentage i.e 0.7 for 70% blurred detected objects
# line_width=2, # width of bounding box.
# classes=[0, 2], # count specific classes i.e, person and car with COCO pretrained model.
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or processing is complete.")
break
results = blurrer(im0)
video_writer.write(results.plot_im)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
Ultralytics YOLO11 offers several advantages for object blurring:
For more detailed applications, check the advantages of object blurring section.
Yes, Ultralytics YOLO11 can be configured to detect and blur faces in videos to protect privacy. By training or using a pre-trained model to specifically recognize faces, the detection results can be processed with OpenCV to apply a blur effect. Refer to our guide on object detection with YOLO11 and modify the code to target face detection.
Ultralytics YOLO11 typically outperforms models like Faster R-CNN in terms of speed, making it more suitable for real-time applications. While both models offer accurate detection, YOLO11's architecture is optimized for rapid inference, which is critical for tasks like real-time object blurring. Learn more about the technical differences and performance metrics in our YOLO11 documentation.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?