Communitygithub.com

블렌더 모션 캡처 및 트래킹

블렌더에서 BVH 또는 FBX 모션 캡처 데이터를 가져오고, 아마추어에 리타겟팅하며, 비디오에서 카메라 또는 객체 모션을 트래킹하고, 카메라 모션을 해결하며, 모션 캡처 데이터를 정리하고, 트래킹 파이프라인을 스크립팅합니다.

블렌더 모션 캡처 및 트래킹란 무엇인가요?

이 스킬은 블렌더에서 Python을 사용하여 모션 캡처(mocap) 및 트래킹 워크플로우를 자동화합니다. BVH 및 FBX 파일 형식을 사용하여 모션 캡처 데이터를 가져오고, 아마추어 간에 모션을 리타겟팅하며, 비디오에서 카메라 및 객체 모션을 트래킹하고, 3D 카메라 경로를 해결하며, 애니메이션 데이터를 정리할 수 있습니다. 또한 벤치와 같은 명령줄에서 직접 실행 가능한 Python 스크립트를 제공합니다. 이 스킬은 블렌더의 애니메이션 도구를 활용하는 게임 개발자, 애니메이터, VFX 아티스트에게 특히 유용합니다. 주요 이점으로는 모션 데이터 가져오기, 리타겟팅, 정리, 비디오 기반 트래킹 및 솔빙, 그리고 내보내기를 포함한 완벽한 파이프라인을 스크립트로 구성할 수 있다는 점입니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/blender-motion-capture

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

블렌더 모션 캡처

개요

블렌더에서 Python을 사용하여 모션 캡처 데이터를 가져오고, 처리하고, 리타겟팅합니다. BVH/FBX 모션 캡처 파일로 작업하고, 비디오 푸티지에서 카메라 및 객체 모션을 트래킹하며, 3D 카메라 경로를 해결하고, 애니메이션 데이터를 정리할 수 있습니다. 모든 작업을 터미널에서 스크립트로 제어할 수 있습니다.

지침

1. BVH 모션 캡처 파일 가져오기

import bpy

bpy.ops.import_anim.bvh(
    filepath="/path/to/mocap.bvh",
    target='ARMATURE',
    global_scale=1.0,
    frame_start=1,
    use_fps_scale=False,
    rotate_mode='NATIVE',
    axis_forward='-Z', axis_up='Y'
)

armature = bpy.context.active_object
action = armature.animation_data.action
print(f"가져옴: {armature.name}, 본 수: {len(armature.data.bones)}, 프레임: {action.frame_range}")

2. FBX 애니메이션 가져오기

bpy.ops.import_scene.fbx(
    filepath="/path/to/mocap.fbx",
    use_anim=True,
    ignore_leaf_bones=True,
    automatic_bone_orientation=True,
    primary_bone_axis='Y', secondary_bone_axis='X'
)

3. 아마추어 간 모션 리타겟팅

from mathutils import Matrix

def retarget_motion(source_armature, target_armature, bone_mapping):
    """본 이름 매핑을 사용하여 애니메이션 리타겟팅: {target_bone: source_bone}"""
    source_action = source_armature.animation_data.action
    frame_start, frame_end = int(source_action.frame_range[0]), int(source_action.frame_range[1])

    if not target_armature.animation_data:
        target_armature.animation_data_create()
    new_action = bpy.data.actions.new(f"{source_action.name}_retarget")
    target_armature.animation_data.action = new_action

    for frame in range(frame_start, frame_end + 1):
        bpy.context.scene.frame_set(frame)
        for tgt_name, src_name in bone_mapping.items():
            src = source_armature.pose.bones.get(src_name)
            tgt = target_armature.pose.bones.get(tgt_name)
            if not src or not tgt:
                continue
            tgt.rotation_quaternion = src.rotation_quaternion
            tgt.keyframe_insert(data_path="rotation_quaternion", frame=frame)
            # 루트 본에만 위치 복사
            if src_name == list(bone_mapping.values())[0]:
                tgt.location = src.location
                tgt.keyframe_insert(data_path="location", frame=frame)

# 예시 Mixamo → Rigify 매핑
mapping = {
    "spine": "mixamorig:Hips", "spine.001": "mixamorig:Spine",
    "spine.004": "mixamorig:Neck", "spine.006": "mixamorig:Head",
    "upper_arm.L": "mixamorig:LeftArm", "forearm.L": "mixamorig:LeftForeArm",
    "upper_arm.R": "mixamorig:RightArm", "forearm.R": "mixamorig:RightForeArm",
    "thigh.L": "mixamorig:LeftUpLeg", "shin.L": "mixamorig:LeftLeg",
    "thigh.R": "mixamorig:RightUpLeg", "shin.R": "mixamorig:RightLeg",
}

4. 모션 캡처 데이터 정리

def decimate_fcurve(fcurve, factor=0.5):
    """형태를 유지하면서 데이터를 줄이기 위해 키프레임 제거."""
    points = fcurve.keyframe_points
    total = len(points)
    keep_every = max(1, int(1.0 / factor))
    remove_indices = [i for i in range(total) if i % keep_every != 0 and i != 0 and i != total - 1]
    for i in reversed(remove_indices):
        points.remove(points[i])

armature = bpy.context.active_object
action = armature.animation_data.action
for fcurve in action.fcurves:
    decimate_fcurve(fcurve, factor=0.5)
    fcurve.update()

5. 비디오 모션 트래킹 및 카메라 솔빙

# 푸티지 로드
clip = bpy.data.movieclips.load("/path/to/footage.mp4")
scene = bpy.context.scene
scene.active_clip = clip

# 트래킹 구성
tracking = clip.tracking
settings = tracking.settings
settings.default_pattern_size = 21
settings.default_search_size = 71
settings.default_motion_model = 'AFFINE'

# 솔빙용 카메라 설정
camera = tracking.camera
camera.sensor_width = 36.0
camera.focal_length = 50.0

# 카메라 모션 솔빙
bpy.ops.clip.solve_camera()
solve_error = tracking.reconstruction.average_error
print(f"솔빙 오류: {solve_error:.4f} px ({'양호' if solve_error < 0.5 else '개선 필요'})")

# 솔빙된 데이터로 씬 설정
bpy.ops.clip.setup_tracking_scene()

6. 트래킹된 모션을 객체에 적용

obj = bpy.data.objects["MyObject"]
constraint = obj.constraints.new(type='FOLLOW_TRACK')
constraint.clip = clip
constraint.track = tracking.tracks["Marker_01"]
constraint.use_3d_position = True
constraint.camera = scene.camera

# 제약 조건을 키프레임으로 베이크
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
bpy.ops.nla.bake(
    frame_start=1, frame_end=clip.frame_duration,
    only_selected=True, visual_keying=True,
    clear_constraints=True, bake_types={'OBJECT'}
)

7. 애니메이션 데이터 내보내기

# BVH로 내보내기
bpy.ops.export_anim.bvh(
    filepath="/tmp/output_mocap.bvh",
    frame_start=int(action.frame_range[0]),
    frame_end=int(action.frame_range[1]),
    rotate_mode='NATIVE'
)

# 베이크된 애니메이션으로 FBX 내보내기
bpy.ops.export_scene.fbx(
    filepath="/tmp/output_anim.fbx",
    use_selection=True, bake_anim=True,
    bake_anim_use_all_bones=True, add_leaf_bones=False
)

예시

예시 1: 모션 캡처 라이브러리 배치 스캔

사용자 요청: "폴더에서 모든 BVH 파일을 가져와 본 개수와 프레임 범위를 나열"

import bpy, glob, os

for filepath in sorted(glob.glob("/path/to/mocap_library/*.bvh")):
    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.delete()
    bpy.ops.import_anim.bvh(filepath=filepath, target='ARMATURE', global_scale=0.01, frame_start=1)
    arm = bpy.context.active_object
    if arm and arm.animation_data:
        action = arm.animation_data.action
        duration = (action.frame_range[1] - action.frame_range[0]) / bpy.context.scene.render.fps
        print(f"{os.path.basename(filepath)}: {len(arm.data.bones)} 본, {duration:.1f}초")

실행: blender --background --python scan_mocap.py

예시 2: 캐릭터에 모션 캡처 적용 및 렌더링

사용자 요청: "BVH 파일을 가져와 리깅된 캐릭터에 적용하고 미리보기 렌더링"

import bpy

bpy.ops.wm.open_mainfile(filepath="/path/to/character.blend")
char_armature = bpy.data.objects["Armature"]

bpy.ops.import_anim.bvh(filepath="/path/to/walk_cycle.bvh", target='ARMATURE', global_scale=0.01)
mocap_armature = bpy.context.active_object
mocap_action = mocap_armature.animation_data.action

# 액션 전송 (본 이름이 일치할 때 작동)
if not char_armature.animation_data:
    char_armature.animation_data_create()
char_armature.animation_data.action = mocap_action

# 임시 아마추어 제거, 프레임 범위 설정, 카메라 추가, 렌더링
bpy.data.objects.remove(mocap_armature)
scene = bpy.context.scene
scene.frame_start, scene.frame_end = int(mocap_action.frame_range[0]), int(mocap_action.frame_range[1])
scene.render.filepath = "/tmp/mocap_preview/frame_"
bpy.ops.render.render(animation=True)

가이드라인

  • BVH는 가장 간단합니다(계층 + 모션이 포함된 일반 텍스트). FBX는 더 풍부한 데이터(블렌드 셰이프, 여러 테이크)를 지원합니다.
  • 스케일이 중요합니다. BVH 파일은 종종 센티미터 단위를 사용합니다. cm 기반 파일의 경우 global_scale=0.01로 설정합니다.
  • 리타겟팅에는 본 이름 매칭이 중요합니다. 각 소스 형식에 대한 매핑 딕셔너리를 만듭니다.
  • 리타겟팅 시 모든 본의 회전은 복사하지만 루트/엉덩이 본의 위치만 복사합니다.
  • 키프레임을 줄여 가져온 모션 캡처를 정리합니다. 원시 모션 캡처는 모든 프레임에 키가 있어 편집이 어렵습니다.
  • 카메라 솔빙 품질은 마커 수와 분포에 따라 달라집니다. 8개 이상의 잘 분포된 마커를 사용하고 오류를 0.5px 미만으로 유지합니다.
  • 내보내기 전에 bpy.ops.nla.bake()를 사용하여 제약 조건을 키프레임으로 변환합니다.
  • FBX로 내보낼 때 NLA 스트립과 제약 조건을 평탄화하려면 항상 bake_anim=True를 사용합니다.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

관련 스킬