用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill image-object-detection命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | image-object-detection |
| description | Techniques for image preprocessing and template matching to count objects in images. |
This skill covers grayscale conversion and template matching using Python's opencv-python and numpy.
Converting an image to grayscale simplifies the data and is often a prerequisite for template matching.
import cv2
def convert_to_grayscale(image_path):
img = cv2.imread(image_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite(image_path, gray) # Overwrite original
Template matching finds instances of a small "template" image within a larger "source" image.
import cv2
import numpy as np
def count_objects(source_path, template_path, threshold=0.8):
source = cv2.imread(source_path, 0) # Read as grayscale
template = cv2.imread(template_path, 0) # Read as grayscale
w, h = template.shape[::-1]
res = cv2.matchTemplate(source, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= threshold)
# Group nearby matches to avoid double counting
points = list(zip(*loc[::-1]))
if not points:
return 0
rects = []
for pt in points:
rects.append([pt[0], pt[1], pt[0] + w, pt[1] + h])
# Use cv2.groupRectangles to merge overlapping detections
rects, weights = cv2.groupRectangles(rects, 1, 0.2)
return len(rects)