agentsclimarketplace

Template object counting

Skill cxcscmu/SkillLearnBench/skills/b4-skill-creator-claude-haiku-4-5/video-object-counting/template-object-counting

Count specific objects in images using template matching with reference object images. Use this skill when you need to detect and count game elements, sprites, or recurring visual patterns in screenshots or game frames using a template image as reference.From its SKILL.md

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

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

SKILL.md

3.4 KB, 754 tokens by cl100k_base, as published. Nobody here has run it

Template-Based Object Counting

This skill provides guidance on counting objects in images using template matching techniques, commonly used for detecting game sprites, coins, enemies, and other visual elements.

Overview

Template matching is a computer vision technique where:

  1. You provide a template image (reference) of the object you want to find
  2. The algorithm searches the larger image for matches
  3. Matches are counted and their locations are identified

Workflow

Step 1: Prepare Template Images

Each object type needs a clear reference template image:

  • Coins: /root/coin.png - Image showing a single coin sprite
  • Enemies: /root/enemy.png - Image showing a single enemy sprite
  • Turtles: /root/turtle.png - Image showing a single turtle sprite

Templates should be:

  • Minimal size (just the object itself, with minimal surrounding pixels)
  • Consistent with objects in the larger image
  • In the same color format as the image being analyzed (grayscale for this task)

Step 2: Use Object Counter

Use the object_counter skill to count objects in each frame:

Input:
- Frame image: /root/keyframes_001.png (grayscale)
- Template image: /root/coin.png (grayscale)

Output:
- Count of coins in the frame: integer value

Step 3: Repeat for All Object Types

For each keyframe, repeat the counting process:

  1. Count coins using coin.png template
  2. Count enemies using enemy.png template
  3. Count turtles using turtle.png template

Step 4: Process All Frames

Iterate through all extracted keyframes:

  • keyframes_001.png → count coins, enemies, turtles
  • keyframes_002.png → count coins, enemies, turtles
  • keyframes_003.png → count coins, enemies, turtles
  • ... and so on

Data Structure

Organize results as you process them:

Frame IDCoinsEnemiesTurtles
/root/keyframes_001.png521
/root/keyframes_002.png310
/root/keyframes_003.png732

Output Format

After processing all frames, create a CSV file with:

  • Column 1: frame_id (format: /root/keyframes_%03d.png)
  • Column 2: coins (count)
  • Column 3: enemies (count)
  • Column 4: turtles (count)

Example CSV structure:

frame_id,coins,enemies,turtles
/root/keyframes_001.png,5,2,1
/root/keyframes_002.png,3,1,0
/root/keyframes_003.png,7,3,2

Important Considerations

  • Template matching accuracy depends on template quality and image similarity
  • Grayscale conversion is necessary for consistent matching across frames
  • Template size matters: Use templates that match the object size in the larger image
  • Overlapping objects may affect accuracy; the object counter will do its best
  • Frame format: Ensure all images are in PNG format for consistency

Troubleshooting

  • No objects detected: Template may not match objects in the frame; verify templates are in grayscale
  • False positives: Template may be matching similar-looking elements; refine template if needed
  • Inconsistent counts: Ensure all frames are in the same format (grayscale) and resolution is consistent

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.