Skip to content

Commit

Permalink
[Enhance]: Hide the import of open3d (#323)
Browse files Browse the repository at this point in the history
* Reduce the open3d dependency

* Reduce the open3d dependency

* Reduce dependency of open3d if open3d is not used

* remove the warning in show_result
  • Loading branch information
xiliu8006 authored Mar 1, 2021
1 parent 93597a5 commit ccd3047
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions mmdet3d/core/visualizer/open3d_vis.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions mmdet3d/core/visualizer/show_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
open3d
waymo-open-dataset-tf-2-1-0==1.2.0
1 change: 0 additions & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ccd3047

Please sign in to comment.