Skip to content

Commit

Permalink
Go back to delayed import for performance reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
nachovizzo committed Jan 18, 2024
1 parent ba5aaa9 commit 6f4f5fe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ A flexible, easy-to-use, LiDAR (or any point cloud) visualizer for Linux, Window

If you also need to obtain poses from your dataset, consider checking out [KISS-ICP](https://github.com/PRBonn/kiss-icp).

## Install
## Install (\*)

```sh
pip install lidar-visualizer
```

Next, follow the instructions on how to run the system by typing:
(\*) This package relies on the power of [Open3D](https://www.open3d.org) but does not list it as a dependency. If you haven't installed `open3d` then `pip install open3d` or check [the official instructions](https://www.open3d.org/docs/release/getting_started.html)

## Optional dependencies

Depending on the [dataloaders](./src/lidar_visualizer/datasets/) you plan to use you might need to install optional dependencies. The tool will prompt which tools is the one you are requesting and is not accessible, but if you want to go for brute force and install all of it just run:

```sh
pip install lidar-visualizer[all]
```

## Usage

```sh
lidar_visualizer --help
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ dependencies = [
"natsort",
"numpy",
"tqdm",
"open3d>=0.16.0",
"typer[all]>=0.6.0",
]

[project.optional-dependencies]
all = [
"pyntcloud",
"trimesh",
"ouster-sdk>=0.7.1",
"ouster-sdk",
]

[project.urls]
Expand Down
19 changes: 15 additions & 4 deletions src/lidar_visualizer/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,37 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import importlib
import os
from functools import partial
from typing import Callable, List

import open3d as o3d
from tqdm import tqdm


class Visualizer:
def __init__(self, dataset, n_scans: int = -1, jump: int = 0):
# Open3D is a big monster. This package dependes 100% on it, but each user will need to
# figure out how to install it properly
try:
self.o3d = importlib.import_module("open3d")
except ModuleNotFoundError:
print(
"Open3D is not installed on your system, to fix this either "
'run "pip install open3d" '
"or check https://www.open3d.org/docs/release/getting_started.html"
)
exit(1)
# Initialize GUI controls
self.block_vis = True
self.play_crun = False
self.reset_bounding_box = True

# Create data
self.source = o3d.geometry.PointCloud()
self.source = self.o3d.geometry.PointCloud()

# Initialize visualizer
self.vis = o3d.visualization.VisualizerWithKeyCallback()
self.vis = self.o3d.visualization.VisualizerWithKeyCallback()
self._register_key_callbacks()
self._initialize_visualizer()

Expand Down Expand Up @@ -103,7 +114,7 @@ def _get_frame(self, idx):
return frame

def _update_geometries(self, source):
self.source.points = o3d.utility.Vector3dVector(source)
self.source.points = self.o3d.utility.Vector3dVector(source)
self.vis.update_geometry(self.source)
if self.reset_bounding_box:
self.vis.reset_view_point(True)
Expand Down

0 comments on commit 6f4f5fe

Please sign in to comment.