跳转至内容

使用 Ultralytics YOLO11 的对象模糊处理 🚀

什么是目标模糊处理?

使用 Ultralytics YOLO11 的对象模糊处理涉及对图像或视频中特定的检测到的对象应用模糊效果。这可以通过使用 YOLO11 模型的功能来识别和操作给定场景中的对象来实现。



观看: 使用 Ultralytics YOLO11 的对象模糊处理

对象模糊的优势

  • 隐私保护: 通过在图像或视频中隐藏敏感或个人身份信息,对象模糊是保护隐私的有效工具。
  • 选择性聚焦: YOLO11 允许选择性模糊,使用户能够定位特定对象,从而确保隐私与保留相关视觉信息之间的平衡。
  • 实时处理:YOLO11 的效率支持实时对象模糊处理,使其适用于需要在动态环境中进行即时隐私增强的应用。
  • 法规遵从: 通过匿名化视觉内容中的可识别信息,帮助组织遵守 GDPR 等数据保护法规。
  • 内容审核: 可用于模糊媒体平台中不适当或敏感的内容,同时保留整体上下文。

使用 Ultralytics YOLO 进行对象模糊处理

# Blur the objects
yolo solutions blur show=True

# Pass a source video
yolo solutions blur source="path/to/video.mp4"

# Blur the specific classes
yolo solutions blur classes="[0, 5]"
import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.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 参数

这是一个包含以下内容的表格 ObjectBlurrer 参数:

参数 类型 默认值 描述
model str None Ultralytics YOLO 模型文件的路径。
blur_ratio float 0.5 调整模糊强度的百分比,取值范围为 0.1 - 1.0.

字段 ObjectBlurrer 解决方案还支持一系列 track 参数:

参数 类型 默认值 描述
tracker str 'botsort.yaml' 指定要使用的跟踪算法,例如: bytetrack.yamlbotsort.yaml.
conf float 0.3 设置检测的置信度阈值;较低的值允许跟踪更多对象,但可能包含误报。
iou float 0.5 设置用于过滤重叠检测的 Intersection over Union (IoU) 阈值。
classes list None 按类别索引过滤结果。例如, classes=[0, 2, 3] 仅跟踪指定的类别。
verbose bool True 控制跟踪结果的显示,提供被跟踪对象的可视化输出。
device str None 指定用于推理的设备(例如, cpu, cuda:00)。允许用户在 CPU、特定 GPU 或其他计算设备之间进行选择,以执行模型。

此外,可以使用以下可视化参数:

参数 类型 默认值 描述
show bool False 可视化参数: True,则在窗口中显示带注释的图像或视频。这对于开发或测试期间的即时视觉反馈非常有用。
line_width None or int None 指定边界框的线条宽度。 如果 None,则线条宽度会根据图像大小自动调整。 提供视觉自定义以提高清晰度。
show_conf bool True 在标签旁边显示每个检测的置信度分数。 可以深入了解模型对每次检测的确定性。
show_labels bool True 在可视化输出中显示每个检测的标签。 能够立即理解检测到的对象。

真实世界的应用

监控中的隐私保护

安全摄像头 和监控系统可以使用 YOLO11 自动模糊面部、车牌或其他识别信息,同时仍然捕获重要的活动。这有助于在公共场所维护安全,同时尊重隐私权。

医疗保健数据匿名化

医学影像中,患者信息经常出现在扫描或照片中。YOLO11 可以检测并模糊这些信息,以便在共享医学数据用于研究或教育目的时,符合 HIPAA 等法规。

文档编辑

当共享包含敏感信息的文件时,YOLO11 可以自动检测并模糊特定元素,如签名、帐号或个人详细信息,从而简化编辑过程,同时保持文档的完整性。

媒体和内容创作

内容创作者可以使用 YOLO11 模糊视频和图像中的品牌徽标、受版权保护的材料或不当内容,从而帮助避免法律问题,同时保持整体内容质量。

常见问题

什么是使用 Ultralytics YOLO11 进行目标模糊处理?

使用 Ultralytics YOLO11 的对象模糊处理涉及自动检测并对图像或视频中的特定对象应用模糊效果。此技术通过隐藏敏感信息同时保留相关的视觉数据来增强隐私。YOLO11 的实时处理能力使其适用于需要即时隐私保护和选择性焦点调整的应用。

如何使用 YOLO11 实现实时目标模糊处理?

要使用 YOLO11 实现实时对象模糊处理,请按照提供的 python 示例操作。这涉及到使用 YOLO11 进行对象检测,并使用 OpenCV 应用模糊效果。以下是一个简化版本:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.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 进行对象模糊处理有哪些好处?

Ultralytics YOLO11 在对象模糊处理方面具有以下几个优势:

  • 隐私保护: 有效地模糊敏感或可识别的信息。
  • 选择性聚焦: 针对特定对象进行模糊处理,保持必要的视觉内容。
  • 实时处理:在动态环境中高效执行对象模糊处理,适用于即时隐私增强。
  • 可定制的强度: 调整模糊比例,以平衡隐私需求和视觉上下文。
  • 特定类别的模糊处理: 仅选择性地模糊某些类型的对象,同时保持其他对象可见。

有关更详细的应用,请查看对象模糊处理部分的优势

我可以使用Ultralytics YOLO11来模糊视频中的人脸以保护隐私吗?

是的,可以配置 Ultralytics YOLO11 来检测和模糊视频中的人脸,以保护隐私。通过训练或使用预训练模型来专门识别人脸,可以使用 OpenCV 处理检测结果以应用模糊效果。请参阅我们的 YOLO11 对象检测指南,并修改代码以针对人脸检测。

YOLO11 与 Faster R-CNN 等其他目标检测模型在对象模糊处理方面的比较如何?

Ultralytics YOLO11 通常在速度上优于 Faster R-CNN 等模型,使其更适合实时应用。虽然这两种模型都提供准确的检测,但 YOLO11 的架构经过优化,可实现快速推理,这对于实时对象模糊等任务至关重要。请在我们的YOLO11 文档中了解有关技术差异和性能指标的更多信息。



📅 创建于 1 年前 ✏️ 更新于 4 个月前

评论