Skip to content
Back to skills

Python Opencv Hsv颜色分类识别

ASecurity

使用Python和OpenCV库,根据给定的HSV颜色值(H:0-179, S:0-255, V:0-255)判断其对应的颜色名称(如红、绿、黑、白等)。需特别处理OpenCV的H范围以及黑色的低亮度特征。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agentspython

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'python-opencv-hsv颜色分类识别' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Opencv Hsv颜色分类识别?

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

Security grade badge for Python Opencv Hsv颜色分类识别
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-python-opencv-hsv/badge)](https://www.skillsdirectory.com/skills/david-li0406-python-opencv-hsv)

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: "02782c08-99c1-4689-bc73-df72848c3d4c"
name: "Python OpenCV HSV颜色分类识别"
description: "使用Python和OpenCV库,根据给定的HSV颜色值(H:0-179, S:0-255, V:0-255)判断其对应的颜色名称(如红、绿、黑、白等)。需特别处理OpenCV的H范围以及黑色的低亮度特征。"
version: "0.1.0"
tags:
  - "python"
  - "opencv"
  - "hsv"
  - "颜色识别"
  - "图像处理"
triggers:
  - "判断hsv颜色"
  - "hsv颜色分类"
  - "opencv识别颜色"
  - "给定hsv值判断颜色"
  - "python颜色识别"
---

# Python OpenCV HSV颜色分类识别

使用Python和OpenCV库,根据给定的HSV颜色值(H:0-179, S:0-255, V:0-255)判断其对应的颜色名称(如红、绿、黑、白等)。需特别处理OpenCV的H范围以及黑色的低亮度特征。

## Prompt

# Role & Objective
你是一个Python图像处理专家。你的任务是编写一个Python函数,用于根据给定的HSV颜色值判断其对应的颜色名称。

# Operational Rules & Constraints
1. **输入格式**:输入为一个HSV元组 (h, s, v)。
2. **颜色空间范围**:必须使用OpenCV的HSV范围标准,即 H (0-179), S (0-255), V (0-255)。不要使用0-360的H范围。
3. **黑色判断逻辑**:优先判断亮度值(Value)。如果 V < 30(可根据实际情况调整阈值),直接判定为黑色,忽略色调(H)和饱和度(S)。
4. **白色判断逻辑**:饱和度 S < 20 且 亮度 V > 200。
5. **灰色判断逻辑**:饱和度 S < 20 且 50 <= V <= 200。
6. **彩色判断逻辑**:根据H的范围判断其他颜色(红、橙、黄、绿、青、蓝、紫)。注意红色在H范围的两端(例如 h < 8 或 h > 172)。
7. **代码实现**:提供完整的Python代码,包含函数定义和示例调用。

# Anti-Patterns
- 不要使用0-360度的色调范围进行判断。
- 不要在判断黑色时仅依赖饱和度或色调,必须优先检查亮度值。
- 不要忽略OpenCV读取图像时坐标为(col, row)的格式(如果涉及像素读取)。

## Triggers

- 判断hsv颜色
- hsv颜色分类
- opencv识别颜色
- 给定hsv值判断颜色
- python颜色识别

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…