diff --git a/mmdet3d/core/visualizer/open3d_vis.py b/mmdet3d/core/visualizer/open3d_vis.py index 08d1d31534..d0fc8a1a66 100644 --- a/mmdet3d/core/visualizer/open3d_vis.py +++ b/mmdet3d/core/visualizer/open3d_vis.py @@ -1,9 +1,14 @@ import cv2 import numpy as np -import open3d as o3d import torch from matplotlib import pyplot as plt -from open3d import geometry + +try: + import open3d as o3d + from open3d import geometry +except ImportError: + raise ImportError( + 'Please run "pip install open3d" to install open3d first.') def _draw_points(points, diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index 2b5f059198..522604ad79 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -3,8 +3,6 @@ import trimesh from os import path as osp -from .open3d_vis import Visualizer - def _write_ply(points, out_filename): """Write points into ``ply`` format for meshlab visualization. @@ -81,6 +79,8 @@ def show_result(points, gt_bboxes, pred_bboxes, out_dir, filename, show=True): filename (str): Filename of the current frame. show (bool): Visualize the results online. """ + from .open3d_vis import Visualizer + if show: vis = Visualizer(points) if pred_bboxes is not None: diff --git a/requirements/optional.txt b/requirements/optional.txt index a9b8ad8e25..d3434d5046 100644 --- a/requirements/optional.txt +++ b/requirements/optional.txt @@ -1 +1,2 @@ +open3d waymo-open-dataset-tf-2-1-0==1.2.0 diff --git a/requirements/tests.txt b/requirements/tests.txt index 1297a5a2da..303cc37d6f 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -5,7 +5,6 @@ interrogate isort # Note: used for kwarray.group_items, this may be ported to mmcv in the future. kwarray -open3d pytest pytest-cov pytest-runner diff --git a/setup.cfg b/setup.cfg index 5fd1a7aae9..b4c6c44fee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,6 @@ line_length = 79 multi_line_output = 0 known_standard_library = setuptools known_first_party = mmdet,mmdet3d -known_third_party = cv2,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,open3d,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset +known_third_party = cv2,load_scannet_data,lyft_dataset_sdk,m2r,matplotlib,mmcv,nuimages,numba,numpy,nuscenes,pandas,plyfile,pycocotools,pyquaternion,pytest,recommonmark,scannet_utils,scipy,seaborn,shapely,skimage,tensorflow,terminaltables,torch,trimesh,waymo_open_dataset no_lines_before = STDLIB,LOCALFOLDER default_section = THIRDPARTY