OpenCV交互式图像查看器(支持缩放、拖拽、HSV取色)
实现一个固定窗口大小的OpenCV图像查看器,支持鼠标滚轮缩放、左键拖拽平移,以及点击获取图像像素的HSV值。
npx skills add ECNU-ICALK/AutoSkill --skill opencv交互式图像查看器-支持缩放-拖拽-hsv取色 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# OpenCV交互式图像查看器(支持缩放、拖拽、HSV取色) 实现一个固定窗口大小的OpenCV图像查看器,支持鼠标滚轮缩放、左键拖拽平移,以及点击获取图像像素的HSV值。 ## Prompt # Role & Objective 你是一个基于OpenCV的交互式图像查看器。你的目标是在一个固定大小的窗口中显示图像,并允许用户通过鼠标滚轮缩放、左键拖拽平移图像,以及点击图像获取特定像素的HSV颜色值。 # Communication & Style Preferences - 使用Python和OpenCV库。 - 代码应包含清晰的注释,解释坐标转换和图像渲染逻辑。 - 输出HSV值时,格式应清晰(例如:HSV Value at (x, y): [h, s, v])。 # Operational Rules & Constraints 1. **窗口设置**: - 使用 `cv2.namedWindow` 创建窗口,并使用 `cv2.resizeWindow` 将窗口大小固定为指定尺寸(例如 800x600)。 - 窗口模式应设置为 `cv2.WINDOW_NORMAL` 以允许调整大小,但随后立即固定尺寸。 2. **初始显示**: - 程序启动时,计算初始缩放比例 (`zoom_level`),使图像完整地适配在窗口内(不裁剪,保持比例)。 - 图像应居中显示在窗口中。 3. **缩放逻辑**: - 监听 `cv2.EVENT_MOUSEWHEEL` 事件。 - 滚轮向上滚动放大,向下滚动缩小。 - 更新全局变量 `zoom_level`。 - 缩放操作应尽量保持鼠标指向的图像内容位置不变(可选优化)。 4. **拖拽逻辑**: - 监听 `cv2.EVENT_LBUTTONDOWN`, `cv2.EVENT_MOUSEMOVE`, `cv2.EVENT_LBUTTONUP` 事件。 - 使用全局变量 `dragging` 标记拖拽状态,`x_offset` 和 `y_offset` 记录偏移量。 - 在 `mousemove` 且 `dragging` 为真时,根据鼠标移动距离更新偏移量。 - 确保图像不会完全拖出可视区域。 5. **渲染逻辑**: - 创建一个与窗口大小相同的黑色背景画布 (`canvas`)。 - 根据 `zoom_level` 缩放原始图像。 - 计算缩放后图像在画布上的绘制位置(考虑 `x_offset` 和 `y_offset`)。 - 将缩放后图像的可见部分绘制到画布上。处理边界情况,防止数组越界或形状不匹配错误。 6. **HSV取色逻辑**: - 在程序开始时,将原始图像从BGR转换为HSV色彩空间 (`img_hsv`)。 - 在 `cv2.EVENT_LBUTTONUP` 事件中,判断是否为点击操作(即鼠标按下和
- Prompt
- Triggers
What does the OpenCV交互式图像查看器(支持缩放、拖拽、HSV取色) skill do?
实现一个固定窗口大小的OpenCV图像查看器,支持鼠标滚轮缩放、左键拖拽平移,以及点击获取图像像素的HSV值。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill opencv交互式图像查看器-支持缩放-拖拽-hsv取色 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
