MCPcopy Create free account
hub / github.com/Ar-Ray-code/lingbot-depth-trt / create_camera

Function create_camera

python/scripts/camera/__init__.py:63–109  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

61
62
63def create_camera(args: argparse.Namespace) -> RgbdCamera:
64 from . import orbbec, realsense
65
66 devices, errors = list_devices()
67 if args.list_devices:
68 print_devices(devices, errors)
69 raise SystemExit(0)
70
71 if args.camera == "realsense":
72 return realsense.create_camera(
73 selector=_selector(args, "realsense"), width=args.width, height=args.height, fps=args.fps
74 )
75 if args.camera == "orbbec":
76 return orbbec.create_camera(selector=_selector(args, "orbbec"), width=args.width, height=args.height, fps=args.fps)
77
78 if args.realsense not in (None, "", "auto"):
79 return realsense.create_camera(
80 selector=_selector(args, "realsense"), width=args.width, height=args.height, fps=args.fps
81 )
82 if args.orbbec not in (None, "", "auto"):
83 return orbbec.create_camera(selector=_selector(args, "orbbec"), width=args.width, height=args.height, fps=args.fps)
84
85 if args.serial or args.usb_id:
86 target = args.serial or args.usb_id
87 matched = [info for info in devices if target and target.lower() in " ".join(info.values()).lower()]
88 if len(matched) == 1:
89 backend = matched[0]["backend"]
90 if backend == "realsense":
91 return realsense.create_camera(selector=target, width=args.width, height=args.height, fps=args.fps)
92 if backend == "orbbec":
93 return orbbec.create_camera(selector=target, width=args.width, height=args.height, fps=args.fps)
94 print_devices(devices, errors)
95 if not matched:
96 raise RuntimeError(f"No camera matched target: {target}")
97 raise RuntimeError(f"Multiple cameras matched target: {target}")
98
99 if len(devices) == 1:
100 backend = devices[0]["backend"]
101 if backend == "realsense":
102 return realsense.create_camera(selector="auto", width=args.width, height=args.height, fps=args.fps)
103 if backend == "orbbec":
104 return orbbec.create_camera(selector="auto", width=args.width, height=args.height, fps=args.fps)
105
106 print_devices(devices, errors)
107 if not devices:
108 raise RuntimeError("No RGB-D cameras found")
109 raise RuntimeError("Multiple RGB-D cameras found; specify --camera realsense or --camera orbbec")
110
111
112__all__ = ["CameraIntrinsics", "DeviceInfo", "RgbdCamera", "RgbdFrame", "create_camera", "list_devices", "print_devices"]

Callers

nothing calls this directly

Calls 3

print_devicesFunction · 0.85
_selectorFunction · 0.85
list_devicesFunction · 0.70

Tested by

no test coverage detected