Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,<pybind11/functional.h>
Posted 沉迷单车的追风少年
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,<pybind11/functional.h>相关的知识,希望对你有一定的参考价值。
项目场景:
基于深度学习的三维点云可视化
问题描述:
Traceback (most recent call last):
File ".\\draw_npy.py", line 25, in <module>
o3d.visualization.draw_geometries([pcd.points])
TypeError: draw_geometries(): incompatible function arguments. The following argument types are supported:
1. (geometry_list: List[open3d.cpu.pybind.geometry.Geometry], window_name: str = 'Open3D', width: int = 1920, height: int = 1080, left: int = 50, top: int = 50, point_show_normal: bool = False, mesh_show_wireframe: bool = False, mesh_show_back_
face: bool = False) -> None
2. (geometry_list: List[open3d.cpu.pybind.geometry.Geometry], window_name: str = 'Open3D', width: int = 1920, height: int = 1080, left: int = 50, top: int = 50, point_show_normal: bool = False, mesh_show_wireframe: bool = False, mesh_show_back_
face: bool = False, lookat: numpy.ndarray[float64[3, 1]], up: numpy.ndarray[float64[3, 1]], front: numpy.ndarray[float64[3, 1]], zoom: float) -> None
Invoked with: [std::vector<Eigen::Vector3d> with 2967 elements.
Use numpy.asarray() to access data.]
Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.
原因分析:
这个error提示看得我一脸懵逼,在反复折腾之后,终于搞定。
核心是这句话:
o3d.visualization.draw_geometries([pcd.points])
改成
o3d.visualization.draw_geometries([pcd])
解决方案:
原先报错的代码:
import numpy as np
import open3d as o3d
filePath = './GEN_Ours_chair_1631677128/out.npy'
# filePath = './GEN_Ours_airplane_1631630214/out.npy'
np.set_printoptions(suppress=True) # 取消默认科学计数法,open3d无法读取科学计数法表示
loadData = np.load(filePath)
print("----type----")
print(type(loadData))
print("----shape----")
print(loadData.shape)
print("----data----")
print(loadData)
# source_data = np.load(filePath)[:,0:3][:,0:3]
point_cloud = o3d.geometry.PointCloud()
source_data = np.load(filePath)
# source_data = np.squeeze(source_data)
print(source_data.shape)
# print(source_data)
pcd = o3d.geometry.PointCloud()
source_data = source_data[:, 0:3].reshape(-1, 3)
pcd.points = o3d.utility.Vector3dVector(source_data) # numpy.array转换成point cloud
o3d.visualization.draw_geometries([pcd.points])
print("finish!")
改正后:
import numpy as np
import open3d as o3d
filePath = './GEN_Ours_chair_1631677128/out.npy'
# filePath = './GEN_Ours_airplane_1631630214/out.npy'
np.set_printoptions(suppress=True) # 取消默认科学计数法,open3d无法读取科学计数法表示
loadData = np.load(filePath)
print("----type----")
print(type(loadData))
print("----shape----")
print(loadData.shape)
print("----data----")
print(loadData)
# source_data = np.load(filePath)[:,0:3][:,0:3]
point_cloud = o3d.geometry.PointCloud()
source_data = np.load(filePath)
# source_data = np.squeeze(source_data)
print(source_data.shape)
# print(source_data)
pcd = o3d.geometry.PointCloud()
source_data = source_data[:, 0:3].reshape(-1, 3)
pcd.points = o3d.utility.Vector3dVector(source_data) # numpy.array转换成point cloud
o3d.visualization.draw_geometries([pcd])
print("finish!")
以上是关于Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,<pybind11/functional.h>的主要内容,如果未能解决你的问题,请参考以下文章
django Did you forget to register or load this tag?
The following tasks did not complete: first Did you forget to signal async completion?
HiltExpected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
gulp4.0 存在的错误信息 The following tasks did not complete: default,Did you forget to signal async complet
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to ad
openFeign 远程调用失败 No Feign Client for loadBalancing defined.Did you forget to include spring-cloud-st