@@ -38,6 +38,7 @@ def define_args(p):
38
38
p .add_argument ("--no_rgb" , help = "Disable recording RGB video feed" , action = "store_true" )
39
39
p .add_argument ("--no_inputs" , help = "Disable recording JSONL and depth" , action = "store_true" )
40
40
p .add_argument ("--gray" , help = "Record (rectified) gray video data" , action = "store_true" )
41
+ p .add_argument ("--gray_preview" , help = "Show live preview of (rectified) gray video" , action = "store_true" )
41
42
p .add_argument ("--no_convert" , help = "Skip converting h265 video file" , action = "store_true" )
42
43
p .add_argument ('--no_preview' , help = 'Do not show a live preview' , action = "store_true" )
43
44
p .add_argument ('--preview3d' , help = 'Use more advanced visualizer instead of matplotlib' , action = "store_true" )
@@ -220,6 +221,15 @@ def create_gray_encoder(node, name):
220
221
create_gray_encoder (vio_pipeline .stereo .rectifiedLeft , 'left' )
221
222
create_gray_encoder (vio_pipeline .stereo .rectifiedRight , 'right' )
222
223
224
+ if args .gray_preview :
225
+ def create_gray_preview (node , name ):
226
+ xout_preview = pipeline .create (depthai .node .XLinkOut )
227
+ xout_preview .setStreamName ("gray-preview-" + name )
228
+ node .link (xout_preview .input )
229
+
230
+ create_gray_preview (vio_pipeline .stereo .rectifiedLeft , 'left' )
231
+ create_gray_preview (vio_pipeline .stereo .rectifiedRight , 'right' )
232
+
223
233
cameraControlQueueNames = []
224
234
if args .white_balance or args .exposure or args .sensitivity :
225
235
def create_rgb_camera_control (colorCameraNode ):
@@ -249,18 +259,29 @@ def createDevice():
249
259
if args .ir_dot_brightness > 0 :
250
260
device .setIrLaserDotProjectorBrightness (args .ir_dot_brightness )
251
261
252
- def open_gray_video (name ):
253
- grayVideoFile = open (outputFolder + '/rectified_' + name + '.h264' , 'wb' )
254
- queue = device .getOutputQueue (name = 'h264-' + name , maxSize = 10 , blocking = False )
255
- return (queue , grayVideoFile )
256
-
257
262
grayVideos = []
258
263
if args .gray :
264
+ def open_gray_video (name ):
265
+ grayVideoFile = open (outputFolder + '/rectified_' + name + '.h264' , 'wb' )
266
+ queue = device .getOutputQueue (name = 'h264-' + name , maxSize = 10 , blocking = False )
267
+ return (queue , grayVideoFile )
268
+
259
269
grayVideos = [
260
270
open_gray_video ('left' ),
261
271
open_gray_video ('right' )
262
272
]
263
273
274
+ grayPreviews = []
275
+ if args .gray_preview :
276
+ def open_gray_preview (name ):
277
+ queue = device .getOutputQueue (name = 'gray-preview-' + name , maxSize = 10 , blocking = False )
278
+ return (queue , name )
279
+
280
+ grayPreviews = [
281
+ open_gray_preview ('left' ),
282
+ open_gray_preview ('right' )
283
+ ]
284
+
264
285
if rgb_as_video :
265
286
videoFile = open (outputFolder + "/rgb_video.h265" , "wb" )
266
287
rgbQueue = device .getOutputQueue (name = "h265-rgb" , maxSize = 30 , blocking = False )
@@ -297,6 +318,14 @@ def open_gray_video(name):
297
318
grayQueue .get ().getData ().tofile (grayVideoFile )
298
319
progress = True
299
320
321
+ for (grayPreviewQueue , name ) in grayPreviews :
322
+ if grayPreviewQueue .has ():
323
+ import cv2
324
+ frame = grayPreviewQueue .get ().getCvFrame ()
325
+ cv2 .imshow (name , frame )
326
+ cv2 .waitKey (1 )
327
+ progress = True
328
+
300
329
if vio_session .hasOutput ():
301
330
out = vio_session .getOutput ()
302
331
progress = True
@@ -320,6 +349,10 @@ def open_gray_video(name):
320
349
videoFileNames .append (grayVideoFile .name )
321
350
grayVideoFile .close ()
322
351
352
+ if len (grayPreviews ) > 0 :
353
+ import cv2
354
+ cv2 .destroyAllWindows ()
355
+
323
356
for fn in videoFileNames :
324
357
if not args .no_convert :
325
358
withoutExt = fn .rpartition ('.' )[0 ]
0 commit comments