@@ -40,6 +40,7 @@ def define_args(p):
40
40
p .add_argument ("--gray" , help = "Record (rectified) gray video data" , action = "store_true" )
41
41
p .add_argument ("--no_convert" , help = "Skip converting h265 video file" , action = "store_true" )
42
42
p .add_argument ('--no_preview' , help = 'Do not show a live preview' , action = "store_true" )
43
+ p .add_argument ('--preview3d' , help = 'Use more advanced visualizer instead of matplotlib' , action = "store_true" )
43
44
p .add_argument ('--no_slam' , help = 'Record with SLAM module disabled' , action = "store_true" )
44
45
p .add_argument ('--recording_only' , help = 'Do not run VIO, may be faster' , action = "store_true" )
45
46
p .add_argument ('--april_tag_path' , help = 'Record with April Tags (path to tags.json)' )
@@ -169,8 +170,27 @@ def record(args):
169
170
170
171
config .internalParameters = internalParameters
171
172
173
+ if args .no_preview :
174
+ plotter = None
175
+ visualizer = None
176
+ elif args .preview3d :
177
+ from spectacularAI .cli .visualization .visualizer import Visualizer , VisualizerArgs
178
+ visArgs = VisualizerArgs ()
179
+ visArgs .targetFps = 30
180
+ visualizer = Visualizer (visArgs )
181
+ plotter = None
182
+ config .parameterSets .append ('point-cloud' )
183
+ else :
184
+ from spectacularAI .cli .visualization .vio_visu import make_plotter
185
+ import matplotlib .pyplot as plt
186
+ plotter , anim = make_plotter ()
187
+ visualizer = None
188
+
189
+ def on_mapping_output (mapperOutput ):
190
+ visualizer .onMappingOutput (mapperOutput )
191
+
172
192
# Enable recoding by setting recordingFolder option
173
- vio_pipeline = spectacularAI .depthai .Pipeline (pipeline , config )
193
+ vio_pipeline = spectacularAI .depthai .Pipeline (pipeline , config , None if visualizer is None else on_mapping_output )
174
194
175
195
# Optionally also record other video streams not used by the Spectacular AI SDK, these
176
196
# can be used for example to render AR content or for debugging.
@@ -214,7 +234,7 @@ def create_rgb_camera_control(colorCameraNode):
214
234
if vio_pipeline .monoRight : create_rgb_camera_control (vio_pipeline .monoRight )
215
235
216
236
should_quit = threading .Event ()
217
- def main_loop (plotter = None ):
237
+ def main_loop (plotter = None , visualizer = None ):
218
238
frame_number = 1
219
239
220
240
deviceInfo = None
@@ -259,7 +279,7 @@ def open_gray_video(name):
259
279
260
280
print ("Recording to '{0}'" .format (config .recordingFolder ))
261
281
print ("" )
262
- if plotter is not None :
282
+ if plotter is not None or visualizer is not None :
263
283
print ("Close the visualization window to stop recording" )
264
284
265
285
while not should_quit .is_set ():
@@ -280,6 +300,10 @@ def open_gray_video(name):
280
300
if vio_session .hasOutput ():
281
301
out = vio_session .getOutput ()
282
302
progress = True
303
+
304
+ if visualizer is not None :
305
+ visualizer .onVioOutput (out .getCameraPose (0 ), status = out .status )
306
+
283
307
if plotter is not None :
284
308
if not plotter (json .loads (out .asJson ())): break
285
309
@@ -309,19 +333,15 @@ def open_gray_video(name):
309
333
print ("Use ffmpeg to convert video into a viewable format:" )
310
334
print (" " + ffmpegCommand )
311
335
312
- if args .no_preview :
313
- plotter = None
314
- else :
315
- from spectacularAI .cli .visualization .vio_visu import make_plotter
316
- import matplotlib .pyplot as plt
317
- plotter , anim = make_plotter ()
318
-
319
- reader_thread = threading .Thread (target = lambda : main_loop (plotter ))
336
+ reader_thread = threading .Thread (target = lambda : main_loop (plotter , visualizer ))
320
337
reader_thread .start ()
321
- if plotter is None :
322
- input ( "---- Press ENTER to stop recording ----" )
323
- else :
338
+ if visualizer is not None :
339
+ visualizer . run ( )
340
+ elif plotter is not None :
324
341
plt .show ()
342
+ else :
343
+ input ("---- Press ENTER to stop recording ----" )
344
+
325
345
should_quit .set ()
326
346
327
347
reader_thread .join ()
0 commit comments