Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
cxcscmu avatar

Template Object Counting

  • 1 installs
  • 77 repo stars
  • Updated July 9, 2026
  • cxcscmu/skilllearnbench

Count specific objects in images using template matching against reference images to detect game sprites, coins, enemies, and recurring patterns.

About

Guides counting objects in images with template matching, searching a larger image for matches to a reference template and tallying them. A developer uses it to detect and count game elements or recurring visual patterns in screenshots or frames.

  • Workflow for preparing minimal, format-consistent template images
  • Detects and counts sprites like coins, enemies, and turtles

Template Object Counting by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #1,803 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
  • Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cxcscmu/skilllearnbench --skill template-object-counting

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars77
Last updatedJuly 9, 2026
Repositorycxcscmu/skilllearnbench

What it does

Count specific objects in images using template matching against reference images to detect game sprites, coins, enemies, and recurring patterns.

Files

SKILL.mdMarkdownGitHub ↗

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

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.