Skip to content

camera

相机与截图相关 CLI 命令。

cmd_camera_screenshot(fmt)

截图并返回生成的图片路径(需 Dimine 运行)。

Source code in dimine_python_sdk\cli\commands\camera.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def cmd_camera_screenshot(fmt: str) -> None:
    """截图并返回生成的图片路径(需 Dimine 运行)。"""
    err = require_remote_sdk()
    if err:
        output_error(err, fmt)

    async def _run():
        client = await get_client()
        image_path = await client.take_screenshot()
        return {
            "success": True,
            "image": image_path
        }

    try:
        result = asyncio.run(_run())
        output_result(result, fmt)
    except Exception as e:
        handle_sdk_error(e, fmt, "截图失败")

cmd_camera_set(fmt, center_point, normal_vector)

设置相机视角(需 Dimine 运行)。

Source code in dimine_python_sdk\cli\commands\camera.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def cmd_camera_set(fmt: str, center_point: str, normal_vector: str) -> None:
    """设置相机视角(需 Dimine 运行)。"""
    err = require_remote_sdk()
    if err:
        output_error(err, fmt)

    try:
        cp = parse_json_arg(center_point, "center_point")
        nv = parse_json_arg(normal_vector, "normal_vector")
    except ValueError as e:
        output_error(str(e), fmt)

    async def _run():
        client = await get_client()
        await client.set_camera(center_point=cp, normal_vector=nv)
        return {
            "success": True,
            "center_point": cp,
            "normal_vector": nv,
            "message": "相机视角已设置",
        }

    try:
        result = asyncio.run(_run())
        output_result(result, fmt)
    except Exception as e:
        handle_sdk_error(e, fmt, "设置相机视角失败")

register_commands(subparsers, format_parent)

向 subparsers 注册相机相关子命令。

Source code in dimine_python_sdk\cli\commands\camera.py
65
66
67
68
69
70
71
def register_commands(subparsers, format_parent) -> None:
    """向 subparsers 注册相机相关子命令。"""
    p = subparsers.add_parser("camera-set", parents=[format_parent], help="设置相机视角")
    p.add_argument("--center-point", required=True, help="相机中心点坐标 JSON 数组,如 '[1.0, 2.0, 3.0]'")
    p.add_argument("--normal-vector", required=True, help="相机法向量 JSON 数组,如 '[0.0, 0.0, 1.0]'")

    subparsers.add_parser("camera-screenshot", parents=[format_parent], help="截图")