Skip to content

Commit 4ab9bf7

Browse files
authored
Add support for passing parameters to imwrite() (#225) (#225)
1 parent 5e218cf commit 4ab9bf7

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

stitching/cli/stitch.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,21 @@ def create_parser():
275275
help="The default is 'result.jpg'",
276276
type=str,
277277
)
278+
parser.add_argument(
279+
"--output_params",
280+
action="store",
281+
default=[],
282+
help="Flags that will be passed to OpenCV's imwrite() for saving the "
283+
"final output image. This allows overriding default quality and "
284+
"compression of the final image. It should be a series of integer "
285+
"pairs representing imwrite() flags and values. For example, to "
286+
" output an uncompressed TIFF image, use: '--output_params 259 1' "
287+
"where 259 corresponds to the 'IMWRITE_TIFF_COMPRESSION' flag, and 1 "
288+
"corresponds to a flag value of 'IMWRITE_TIFF_COMPRESSION_NONE'. See "
289+
"OpenCV documentation for all available options.",
290+
nargs="+",
291+
type=int,
292+
)
278293
return parser
279294

280295

@@ -294,6 +309,7 @@ def main():
294309
verbose_dir = args_dict.pop("verbose_dir")
295310
preview = args_dict.pop("preview")
296311
output = args_dict.pop("output")
312+
output_params = args_dict.pop("output_params")
297313

298314
# Create Stitcher
299315
affine_mode = args_dict.pop("affine")
@@ -310,7 +326,7 @@ def main():
310326
else:
311327
print("stitching " + " ".join(images) + " into " + output)
312328
panorama = stitcher.stitch(images, feature_masks)
313-
cv.imwrite(output, panorama)
329+
cv.imwrite(output, panorama, output_params)
314330

315331
if preview:
316332
zoom_x = 600.0 / panorama.shape[1]

0 commit comments

Comments
 (0)