45
45
from collections import defaultdict
46
46
from types import FunctionType
47
47
from typing import Optional
48
+ import asyncio
49
+ import subprocess
50
+ from subprocess import Popen
51
+ from subprocess import PIPE
48
52
49
53
import cv2
50
54
import yaml
60
64
SCRIPT_DIR = os .path .dirname (SCRIPT_PATH )
61
65
EUROC_DATA_PATH = '/data/euroc/V1_01'
62
66
67
+ ###############################################################################
68
+ # PIP
69
+ ###############################################################################
70
+
71
+
72
+ def pip_install (package ):
73
+ """ Install package via pip """
74
+ subprocess .check_call ([sys .executable , "-m" , "pip" , "install" , package ])
75
+
76
+
63
77
###############################################################################
64
78
# YAML
65
79
###############################################################################
@@ -2547,6 +2561,12 @@ def plot_xyz(title, data, key_time, key_x, key_y, key_z, ylabel, **kwargs):
2547
2561
2548
2562
def pyqtgraph_mesh (widget ):
2549
2563
""" Plot mesh """
2564
+ try :
2565
+ import pyqtgraph
2566
+ except :
2567
+ pip_install ("pyqtgraph" )
2568
+ pip_install ("pyopengl" )
2569
+
2550
2570
import pyqtgraph .opengl as gl # Lazy importing
2551
2571
g = gl .GLGridItem ()
2552
2572
g .scale (1 , 1 , 1 )
@@ -2556,9 +2576,14 @@ def pyqtgraph_mesh(widget):
2556
2576
2557
2577
def pyqtgraph_axes (widget , T , ** kwargs ):
2558
2578
""" Plot axes """
2559
- import pyqtgraph .opengl as gl # Lazy importing
2579
+ try :
2580
+ import pyqtgraph
2581
+ except :
2582
+ pip_install ("pyqtgraph" )
2583
+ pip_install ("pyopengl" )
2560
2584
2561
2585
# Settings
2586
+ import pyqtgraph .opengl as gl # Lazy importing
2562
2587
w = kwargs .get ("width" , 2.0 )
2563
2588
s = kwargs .get ("scale" , 1.0 )
2564
2589
a = kwargs .get ("antialias" , False )
@@ -2592,9 +2617,14 @@ def pyqtgraph_axes(widget, T, **kwargs):
2592
2617
2593
2618
def pyqtgraph_example (sys ):
2594
2619
""" Run Qt plot """
2620
+ try :
2621
+ import pyqtgraph
2622
+ except :
2623
+ pip_install ("pyqtgraph" )
2624
+ pip_install ("pyopengl" )
2625
+
2595
2626
from pyqtgraph .Qt import QtWidgets # Lazy importing
2596
2627
import pyqtgraph .opengl as gl # Lazy importing
2597
-
2598
2628
app = QtWidgets .QApplication (sys .argv )
2599
2629
widget = gl .GLViewWidget ()
2600
2630
@@ -12704,10 +12734,10 @@ def on_key(event, fig):
12704
12734
# Visualizer
12705
12735
###############################################################################
12706
12736
12707
- import websockets
12708
- import asyncio
12709
-
12710
- from subprocess import Popen , PIPE
12737
+ try :
12738
+ import websockets
12739
+ except :
12740
+ pip_install ( "websockets" )
12711
12741
12712
12742
12713
12743
class DevServer :
0 commit comments