MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / build_camera_path

Function build_camera_path

demo_render/rgbd_render/camera.py:532–672  ·  view source on GitHub ↗

Build a CameraPath from CameraConfig segments. Args: cam_config: CameraConfig with fov, transition, segments scene: Scene with c2w_poses, scene_scale, sorted_xyz, etc. If segments is empty, creates a default full-range follow path.

(cam_config, scene)

Source from the content-addressed store, hash-verified

530# ---------------------------------------------------------------------------
531
532def build_camera_path(cam_config, scene) -> CameraPath:
533 """Build a CameraPath from CameraConfig segments.
534
535 Args:
536 cam_config: CameraConfig with fov, transition, segments
537 scene: Scene with c2w_poses, scene_scale, sorted_xyz, etc.
538
539 If segments is empty, creates a default full-range follow path.
540 """
541 from .config import CameraSegment
542
543 segments = cam_config.segments
544 total_frames = scene.num_frames
545 fov = cam_config.fov
546 transition = cam_config.transition
547
548 # Default: single follow segment
549 if not segments:
550 segments = [CameraSegment(mode='follow', frames=[0, -1])]
551
552 # Resolve -1 → last frame
553 resolved = []
554 for seg in segments:
555 s = seg.frames[0] if len(seg.frames) > 0 else 0
556 e = seg.frames[1] if len(seg.frames) > 1 else -1
557 if s < 0:
558 s = max(0, total_frames + s)
559 if e < 0:
560 e = total_frames
561 resolved.append((s, e, seg))
562
563 # Build per-segment camera paths
564 seg_paths = []
565 for s, e, seg in resolved:
566 if e <= s:
567 continue
568
569 if seg.mode == 'follow':
570 follow_scale = compute_local_scale(
571 scene.c2w_poses, seg.scale_frames) \
572 if 0 < seg.scale_frames < total_frames else None
573 path = make_follow_path(
574 scene.c2w_poses, scene.scene_scale,
575 smooth_window=seg.smooth_window,
576 back_offset=seg.back_offset,
577 up_offset=seg.up_offset,
578 look_offset=seg.look_offset,
579 follow_scale=follow_scale,
580 fov_deg=fov)
581 seg_paths.append((s, e, path))
582
583 elif seg.mode == 'birdeye':
584 path = make_birdeye_path(
585 scene.c2w_poses, scene.sorted_xyz,
586 scene.sorted_frames, scene.scene_scale,
587 total_frames,
588 scene.intrinsics[0][0, 2].item() * 2 if scene.intrinsics is not None else 1920,
589 scene.intrinsics[0][1, 2].item() * 2 if scene.intrinsics is not None else 1080,

Callers 2

render_with_pipelineFunction · 0.90
mainFunction · 0.90

Calls 11

CameraSegmentClass · 0.85
compute_local_scaleFunction · 0.85
make_follow_pathFunction · 0.85
make_birdeye_pathFunction · 0.85
make_static_pathFunction · 0.85
make_pivot_pathFunction · 0.85
CameraPathClass · 0.85
_smoothstepFunction · 0.85
_lerp_cameraFunction · 0.85
get_cameraMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected