Skip to content

No module named 'bop_toolkit_lib' #1204

@ZsjSpace

Description

@ZsjSpace

Describe the issue

when I try to use bproc.loader.load_bop_intrinsics(), this error occurs, before that I have run "blenderproc pip install bop_toolkit", and downloarded successfully. How to fix it?

Image Image

Minimal code example

import blenderproc as bproc
import bpy
import os
import numpy as np

# 初始化Blenderproc
bproc.init()

# 设置输出路径
output_dir = "output"
os.makedirs(output_dir, exist_ok=True)

# 加载物体(示例:加载一个cube)
obj = bproc.loader.load_obj("/home/zhangsijin/new_func/modules/obj_01.ply")

# 加载相机内参
bproc.loader.load_bop_intrinsics("/home/zhangsijin/new_func/camera.json")

# 创建光源
# 平面光源(天花板位置)
light_plane = bproc.object.create_primitive('PLANE', scale=[3, 3, 1], location=[0, 0, 10])  # 创建一个大平面作为天花板光源
light_plane.set_name('light_plane')  # 命名光源平面
light_plane_material = bproc.material.create('light_material')  # 创建光源材质
# 点光源
light_point = bproc.types.Light()  # 创建点光源
light_point.set_energy(200)  # 设置点光源能量(亮度)

# 设置渲染参数
bproc.renderer.set_max_amount_of_samples(50)
bproc.renderer.set_noise_threshold(0.01)
bproc.renderer.set_cpu_threads(0)

# 启用Alpha通道以去除背景
bproc.renderer.set_output_format(enable_transparency=True)

# 渲染图像
data = bproc.renderer.render()

# 渲染深度图(用于姿态计算)
depth = bproc.renderer.render_depth()

# 保存图像
bproc.writer.write_hdf5(output_dir, data)
bproc.writer.write_depth(output_dir, depth, file_format="exr")

# 获取物体姿态信息
for obj in bproc.filter.all_objects():
    if obj.get_cp("is_from_loaded_obj"):
        # 获取世界矩阵(包含位置和旋转信息)
        world_matrix = obj.get_local2world_mat()
        print(f"Object: {obj.get_name()}")
        print(f"World Matrix:\n{world_matrix}")
        
        # 提取位置和四元数旋转
        position = world_matrix.to_translation()
        rotation = world_matrix.to_quaternion()
        
        # 保存姿态信息到文件
        with open(os.path.join(output_dir, "poses.txt"), "a") as f:
            f.write(f"{obj.get_name()}: {position} {rotation}\n")

print(f"渲染完成,结果保存在: {output_dir}")

Files required to run the code

No response

Expected behavior

Solve this question

BlenderProc version

main Branch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions