{"record":{"id":"1ed0900402a9c500","repo":"nexu-io/open-design","slug":"could-not-find-frame-count-sprite-components-in","errorCode":null,"errorMessage":"could not find {frame_count} sprite components in {strip_path}","messagePattern":"could not find (.+?) sprite components in (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/extract_strip_frames.py","lineNumber":252,"sourceCode":"    state: str,\n    output_root: Path,\n    chroma_key: tuple[int, int, int],\n    threshold: float,\n    method: str,\n) -> dict[str, object]:\n    frame_count = ROW_FRAME_COUNTS[state]\n    with Image.open(strip_path) as opened:\n        strip = remove_chroma_background(opened, chroma_key, threshold)\n\n    state_dir = output_root / state\n    state_dir.mkdir(parents=True, exist_ok=True)\n\n    frames = None\n    used_method = method\n    if method in {\"auto\", \"components\"}:\n        frames = extract_component_frames(strip, frame_count)\n        if frames is None and method == \"components\":\n            raise SystemExit(f\"could not find {frame_count} sprite components in {strip_path}\")\n        if frames is not None:\n            used_method = \"components\"\n\n    if frames is None:\n        frames = extract_slot_frames(strip, frame_count)\n        used_method = \"slots\"\n\n    outputs = []\n    for index, frame in enumerate(frames):\n        output = state_dir / f\"{index:02d}.png\"\n        frame.save(output)\n        outputs.append(str(output))\n    return {\"state\": state, \"frames\": outputs, \"method\": used_method}\n\n\ndef main() -> None:\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"--decoded-dir\", required=True)","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/extract_strip_frames.py#L234-L270","documentation":"With --method components (explicit), extract_component_frames could not find frame_count distinct connected sprite blobs (seeds) in the chroma-keyed strip and returned None, so the script aborts instead of silently falling back to slots. In --method auto it would fall back to equal slots instead of erroring.","triggerScenarios":"Passing --method components on a strip whose sprites are touching/overlapping (one connected blob), have low alpha contrast against the background, or whose chroma threshold erased too much of the sprite.","commonSituations":"Generated sprites bleeding together; a wrong chroma key that eats sprite edges; a sparse strip with fewer distinct figures than the expected frame count for that state.","solutions":["Use --method auto (the default) so extraction can fall back to equal slots when components fail.","Tune --key-threshold so the chroma background is removed without erasing sprite edges.","Verify or override --chroma-key to match the strip's actual background color.","If sprites genuinely overlap, regenerate the strip so frames are visually separated."],"exampleFix":"# before\n--method components\n# after\n--method auto","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nfrom PIL import Image\n\nstrip_path = Path(\"<decoded_dir>/<state>.png\")\nwith Image.open(strip_path) as img:\n    print(\"size:\", img.size, \"mode:\", img.mode)\n# Inspect visually first; components method needs visually separated sprites.","typeGuard":null,"tryCatchPattern":"import subprocess, sys\n\nresult = subprocess.run([sys.executable, \"extract_strip_frames.py\", \"--method\", \"components\", ...])\nif result.returncode != 0:\n    # fall back to auto/slots instead of failing the whole pipeline\n    subprocess.run([sys.executable, \"extract_strip_frames.py\", \"--method\", \"auto\", ...], check=True)","preventionTips":["Default to --method auto so slot extraction catches what components cannot.","Tune --key-threshold so the chroma background is removed without erasing sprite edges.","Regenerate strips whose sprites visually overlap before forcing components."],"tags":["hatch-pet","frame-extraction","components","chroma-key"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}