用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill opencv-template-matching命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | opencv-template-matching |
| description | Count occurrences of a template in a target image. |
Use cv2.matchTemplate to find objects matching a template image in the main image. Multiple detections of the same object can be filtered via Non-Maximum Suppression (NMS).
import cv2
import numpy as np
def count_objects(main_img_path, template_path, threshold=0.8):
img_gray = cv2.imread(main_img_path, 0)
template = cv2.imread(template_path, 0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= threshold)
rects = []
for pt in zip(*loc[::-1]):
rects.append([int(pt[0]), int(pt[1]), int(w), int(h)])
# Apply non-maximum suppression (requires imutils.object_detection or cv2.dnn.NMSBoxes)
rects, weights = cv2.groupRectangles(rects, 1, 0.2)
return len(rects)