Skip to content

Commit 5e5541d

Browse files
committed
Fix Open3D import
1 parent cb6b1d1 commit 5e5541d

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Diff for: agml/data/point_cloud.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@
2121
from agml.utils.general import is_float, is_int
2222
from agml.utils.logging import log
2323

24-
try:
25-
import open3d as o3d
26-
except:
27-
log("Open3D is not installed. If you want to have high-res point cloud "
28-
"visualizations, please install Open3D using `pip install open3d`. "
29-
"For now, defaulting to using 3D matplotlib visualizations.")
30-
o3d = None
31-
3224

3325
class PointCloud(object):
3426
"""Represents a 3D point cloud object, with utilities for format + visualization."""
@@ -183,6 +175,14 @@ def _read_point_cloud(self, contents):
183175
def _build_3d_object(self):
184176
"""Function to construct the point cloud as a open3d point cloud object
185177
"""
178+
try:
179+
import open3d as o3d
180+
except:
181+
log("Open3D is not installed. If you want to have high-res point cloud "
182+
"visualizations, please install Open3D using `pip install open3d`. "
183+
"For now, defaulting to using 3D matplotlib visualizations.")
184+
o3d = None
185+
186186
# Construct the point cloud with the points and colors.
187187
if o3d is not None:
188188
self._structure_3d = o3d.geometry.PointCloud()

Diff for: agml/viz/point_clouds.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
import matplotlib.pyplot as plt
1818

19-
from agml.data.point_cloud import PointCloud, o3d
19+
from agml.data.point_cloud import PointCloud
20+
from agml.utils.logging import log
2021

2122

2223
def show_point_cloud(point_cloud, format = 'default'):
@@ -33,6 +34,14 @@ def show_point_cloud(point_cloud, format = 'default'):
3334
done using Open3D. If 'matplotlib', then the visualization will be
3435
done using matplotlib. Defaults to 'default'.
3536
"""
37+
try:
38+
import open3d as o3d
39+
except:
40+
log("Open3D is not installed. If you want to have high-res point cloud "
41+
"visualizations, please install Open3D using `pip install open3d`. "
42+
"For now, defaulting to using 3D matplotlib visualizations.")
43+
o3d = None
44+
3645
# We need to hard-code this check because this method isn't designed to
3746
# run with regular point cloud arrays, only `point_cloud` objects.
3847
if not isinstance(point_cloud, PointCloud):

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ numpy
22
matplotlib
33
tqdm
44
scikit-learn
5+
requests>=2.0.0
56
opencv-python; sys.platform != 'linux'
67
opencv-python-headless; sys.platform == 'linux'
78
pyyaml>=5.4.1

0 commit comments

Comments
 (0)