Imported from cxcscmu/SkillLearnBench (
skills/b3-teacher-feedback-gemini-3.1-flash-lite-preview/video-object-counting/run3_csv_generation/SKILL.md). Install upstream withnpx skills add cxcscmu/SkillLearnBench --skill run3_csv_generation. Copyright stays with the author.
Iterate through the sorted list of frame files, perform object detection for each, and write the data to /root/counting_results.csv with the header: frame_id,coins,enemies,turtles.
import csv
import glob
import subprocess
files = sorted(glob.glob('/root/keyframes_*.png'))
with open('/root/counting_results.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['frame_id', 'coins', 'enemies', 'turtles'])
for file_path in files:
counts = []
for template in ['/root/coin.png', '/root/enemy.png', '/root/turtle.png']:
result = subprocess.run(['python3', 'scripts/count_objects.py', '--image', file_path, '--template', template], capture_output=True, text=True)
counts.append(result.stdout.strip())
writer.writerow([file_path] + counts)