小编ray*_*yon的帖子

使用 Open3D 将点云与地板(平面)对齐

社区,

\n

我正在尝试使用 Open3D 将点云与检测到的地板对齐。到目前为止,我实施了以下步骤(此答案的一部分):

\n
    \n
  1. 使用 Open3D 的平面分割检测地板
  2. \n
  3. 将平面平移到坐标中心
  4. \n
  5. 计算平面法线与 z 轴之间的旋转角度
  6. \n
  7. 计算旋转轴
  8. \n
  9. 使用 Open3Ds 函数旋转点云get_rotation_matrix_from_axis_angle(参见3
  10. \n
\n

结果还不错,但我必须在最后使用优化因子以获得更好的结果。是否有错误或更简单/更精确的对齐方式?

\n
# See functions below\n\n# Get the plane equation of the floor \xe2\x86\x92 ax+by+cz+d = 0\nfloor = get_floor_plane(pcd)\na, b, c, d = floor\n\n# Translate plane to coordinate center\npcd.translate((0,-d/c,0))\n\n# Calculate rotation angle between plane normal & z-axis\nplane_normal = tuple(floor[:3])\nz_axis = (0,0,1)\nrotation_angle = vector_angle(plane_normal, z_axis)\n\n# Calculate rotation axis\nplane_normal_length = …
Run Code Online (Sandbox Code Playgroud)

python 3d numpy rotational-matrices open3d

7
推荐指数
0
解决办法
5771
查看次数

创建 pydantic 对象时触发函数

每当我创建/实例化 pydantic 对象时,是否有一种干净的方法来触发函数调用?

目前我正在root_validator为此“滥用”:

from pydantic import BaseModel

class PydanticClass(BaseModel):
  name: str

  @root_validator()
  def on_create(cls, values):
    print("Put your logic here!")
    return values
Run Code Online (Sandbox Code Playgroud)

因此PydanticClass(name="Test")执行我的逻辑并简单地返回相同的对象值。

这可行,但我有两个问题,这就是为什么我对更干净的解决方案感兴趣:

  1. 我基本上不进行验证(返回相同的值)。
  2. 我认为一旦对象发生更改,这个函数也会被执行,这是我不想要的。

所以我很高兴了解任何更好的方法/解决方案。

python python-3.x pydantic

6
推荐指数
1
解决办法
5081
查看次数

如何使用 overpy 使 {{geocodeArea: xxx }} 查询在 python 中工作?

我想使用Overpass API查找特定区域中的所有酒吧,并使用geocodeArea选择区域。

overpass-turbo.eu上测试以下查询给了我想要的结果:

{{geocodeArea:berlin}}->.searchArea;
(
  node["amenity"="pub"](area.searchArea);
  way["amenity"="pub"](area.searchArea);
  relation["amenity"="pub"](area.searchArea);
);
out body;
>;
out skel qt;
Run Code Online (Sandbox Code Playgroud)

但是当我使用overpy在 python 中实现该查询时......

import overpy

api = overpy.Overpass()

result = api.query("""
        {{geocodeArea:berlin}}->.searchArea;
        (
          node["amenity"="pub"](area.searchArea);
          way["amenity"="pub"](area.searchArea);
          relation["amenity"="pub"](area.searchArea);
        );
        out body;
        >;
        out skel qt;
    """)

print("Amenities in nodes: %d" % len(result.nodes))
print("Amenities in ways: %d" % len(result.ways))
Run Code Online (Sandbox Code Playgroud)

...我收到以下错误:

Traceback (most recent call last):
  File "testOP.py", line 15, in <module>
    """)
  File "/usr/local/lib/python2.7/dist-packages/overpy/__init__.py", line 119, in query
    msgs=msgs
overpy.exception.OverpassBadRequest: …
Run Code Online (Sandbox Code Playgroud)

python openstreetmap overpass-api

4
推荐指数
2
解决办法
1725
查看次数