Skip to content
Back to skills

Yolov5 Object Detection With Roi Masking And Gpu Support

ASecurity

Implement real-time object detection using YOLOv5 constrained to a specific Region of Interest (ROI) polygon, utilizing GPU acceleration and the supervision library for annotation.

  • 581 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 30, 2026
educationpythongo

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill yolov5-object-detection-with-roi-masking-and-gpu-support --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Yolov5 Object Detection With Roi Masking And Gpu Support?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Yolov5 Object Detection With Roi Masking And Gpu Support
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-yolov5-object-detection-with-roi-masking-and-gpu-s/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-yolov5-object-detection-with-roi-masking-and-gpu-s)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "ee4e0037-ac33-4813-aad9-0a950ddcc6c2"
name: "YOLOv5 Object Detection with ROI Masking and GPU Support"
description: "Implement real-time object detection using YOLOv5 constrained to a specific Region of Interest (ROI) polygon, utilizing GPU acceleration and the supervision library for annotation."
version: "0.1.0"
tags:
  - "yolo"
  - "computer-vision"
  - "roi"
  - "gpu"
  - "python"
  - "opencv"
triggers:
  - "yolov5 roi masking"
  - "detect objects in polygon area"
  - "yolov5 gpu inference"
  - "supervision library yolo"
---

# YOLOv5 Object Detection with ROI Masking and GPU Support

Implement real-time object detection using YOLOv5 constrained to a specific Region of Interest (ROI) polygon, utilizing GPU acceleration and the supervision library for annotation.

## Prompt

# Role & Objective
Act as a Computer Vision Engineer. Write Python code to perform real-time object detection using YOLOv5, constrained to a specific Region of Interest (ROI) defined by a polygon. The code must run on GPU if available.

# Operational Rules & Constraints
1. **Model Loading**: Load YOLOv5 via `torch.hub.load('ultralytics/yolov5', 'yolov5s6', device=device)`.
2. **Device Selection**: Automatically select CUDA if available: `device = 'cuda' if torch.cuda.is_available() else 'cpu'`.
3. **ROI Definition**: Define the ROI as a numpy array of integer coordinates (e.g., `np.array([[x1,y1], [x2,y2], ...], dtype=np.int32)`).
4. **Masking Logic**:
   - Create a black mask matching frame dimensions.
   - Fill the ROI polygon with white (255, 255, 255).
   - Apply `cv2.bitwise_and` to mask the frame.
5. **Inference**: Run model inference on the *masked* frame.
6. **Filtering**: Filter detections to keep only class ID 0 (person) with confidence > 0.5.
7. **Annotation**: Use `supervision.BoxAnnotator` to draw boxes on the *original* (unmasked) frame.
8. **Visualization**: Draw the ROI polygon outline on the annotated frame and display the count of detections.

# Communication & Style Preferences
Provide the complete, runnable Python script including imports and the main execution loop.

## Triggers

- yolov5 roi masking
- detect objects in polygon area
- yolov5 gpu inference
- supervision library yolo

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.