Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

README.md

a/ — CV-based System and Staff Group Detection

Detects systems (horizontal rows of staves) and staff groups (instrument sections sharing a bracket) from scanned score images using computer vision. No machine learning model is used; detection relies entirely on morphological barline extraction.

Files

a_1_system_group.py

Single-page prototype. Given a score image and a YOLO staff info JSON, it:

  1. Detects vertical lines — binarizes the image, applies a morphological open with a tall vertical kernel, and extracts connected components filtered by height to get candidate barlines. Close barlines at the same x position are merged into single segments.
  2. Detects systems — filters vertical lines near the staff start x-position (left edge of the score) and groups staves that are spanned by the same vertical line into one system.
  3. Detects staff groups — filters vertical lines near the right edges of YOLO-detected brace boxes and groups staves similarly.
  4. Visualizes — draws red horizontal lines for staves, yellow for staff-group barlines, and green for system barlines onto a debug image (optional output).

Input: grayscale PNG score image + *_yolostaff.json Output: printed system/group lists + optional debug PNG


a_2_outputcsv.py

Batch version of a_1_system_group.py. Processes all pages of a dataset and writes results to a CSV file.

Each page's staves become rows in the output CSV with columns: page, staff, system, staffgroup, num_ins, ens, ins1, part1, tone1, ...

Also detects and reports cross-system staff group cases (where a single group spans multiple systems, which is usually an error).

Input: image directory + staff JSON directory Output: a_2_cv_result.csv


a_2_eva.py

Evaluates a_2_cv_result.csv against a ground truth CSV.

Metrics computed:

  • Staff count accuracy — exact match of number of staves per page
  • System accuracy — per-staff match of system assignment
  • Staff group accuracy — per-staff match of staff group assignment

Uses pandas merge on (page, staff) keys.

Input: prediction CSV + ground truth CSV Output: printed accuracy report