agentsclimarketplace

Object counting in images

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-gemini-3.1-flash-lite-preview/video-object-counting/object-counting-in-images

Detect and count occurrences of template images within a larger target image.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill object-counting-in-images

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

0.9 KB, 207 tokens by cl100k_base, as published. Nobody here has run it

Object Counting

To count occurrences of a template object within a scene image, use OpenCV in Python:

import cv2
import numpy as np

def count_objects(scene_path, template_path, threshold=0.8):
    img = cv2.imread(scene_path, cv2.IMREAD_GRAYSCALE)
    template = cv2.imread(template_path, cv2.IMREAD_GRAYSCALE)
    w, h = template.shape[::-1]
    
    res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED)
    loc = np.where(res >= threshold)
    
    # Filter matches to ensure they are distinct objects
    count = 0
    matches = []
    for pt in zip(*loc[::-1]):
        if not any([abs(pt[0]-m[0]) < w and abs(pt[1]-m[1]) < h for m in matches]):
            matches.append(pt)
            count += 1
    return count

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.