Skip to content

Commit 2f39668

Browse files
authored
Add support for recording encoded color stereo (#10)
1 parent 340f5ac commit 2f39668

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

python/cli/record/oak.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ def define_args(p):
5050
# for options that might be available. On Raspberry Pi or Jetson, try "h264_v4l2m2m",
5151
# and on Linux machines with Nvidia GPUs, try "h264_nvenc".
5252
p.add_argument('--ffmpeg_codec', help="FFMpeg codec for host", default=None)
53+
p.add_argument('--ffmpeg_preview', help="Save PNG previews while recording with ffmpeg every Nth frame", type=int)
54+
p.add_argument('--ffmpeg_preview_scale', help="Scale of the ffmpeg PNG previews 0.5 half, 1.0 full resolution etc.", type=float)
55+
p.add_argument("--use_encoded_video", help="Encodes video on OAK-D, works only in recording only mode", action="store_true")
56+
p.add_argument("--color_stereo", help="Use this flag with devices that have color stereo cameras", action="store_true")
5357
p.add_argument('--map', help='Record SLAM map', action="store_true")
5458
p.add_argument('--no_feature_tracker', help='Disable on-device feature tracking', action="store_true")
5559
p.add_argument('--vio_auto_exposure', help='Enable SpectacularAI auto exposure which optimizes exposure parameters for VIO performance (BETA)', action="store_true")
5660
p.add_argument('--ir_dot_brightness', help='OAK-D Pro (W) IR laser projector brightness (mA), 0 - 1200', type=float, default=0)
5761
p.add_argument("--resolution", help="Gray input resolution (gray)",
5862
default='400p',
59-
choices=['400p', '800p'])
63+
choices=['400p', '800p', '1200p'])
6064

6165
return p
6266

@@ -89,6 +93,8 @@ def record(args):
8993
autoFolderName = datetime.datetime.now().strftime("%Y%m%dT%H%M%S")
9094
outputFolder = os.path.join(outputFolder, autoFolderName)
9195

96+
internalParameters = {}
97+
9298
if not args.no_inputs:
9399
config.recordingFolder = outputFolder
94100
if args.map:
@@ -111,10 +117,20 @@ def record(args):
111117
if args.disable_cameras:
112118
config.disableCameras = True
113119
if args.ffmpeg_codec is not None:
114-
config.internalParameters = { 'ffmpegVideoCodec': args.ffmpeg_codec + ' -b:v 8M' }
115-
print(config.internalParameters)
120+
internalParameters["ffmpegVideoCodec"] = args.ffmpeg_codec + ' -b:v 8M'
116121
if args.no_usb_speed_check:
117122
config.ensureSufficientUsbSpeed = False
123+
if args.color_stereo:
124+
config.useColorStereoCameras = True
125+
if args.use_encoded_video:
126+
config.forceUnrectified = True
127+
config.useEncodedVideo = True
128+
if args.ffmpeg_preview:
129+
internalParameters["ffmpegPngPreviewNthFrame"] = str(args.ffmpeg_preview)
130+
if args.ffmpeg_preview_scale:
131+
internalParameters["ffmpegPngPreviewScale"] = str(args.ffmpeg_preview_scale).replace(",", ".")
132+
133+
config.internalParameters = internalParameters
118134

119135
# Enable recoding by setting recordingFolder option
120136
vio_pipeline = spectacularAI.depthai.Pipeline(pipeline, config)

0 commit comments

Comments
 (0)