Skip to content

Commit 04bd901

Browse files
author
Fabien Servant
committed
ExportImages support different storage data types for exr
1 parent b3d7eb4 commit 04bd901

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

meshroom/aliceVision/ExportImages.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__version__ = "1.1"
22

33
from meshroom.core import desc
4-
from meshroom.core.utils import VERBOSE_LEVEL
4+
from meshroom.core.utils import COLORSPACES, EXR_STORAGE_DATA_TYPE, VERBOSE_LEVEL
55

66

77
class ExportImages(desc.AVCommandLineNode):
@@ -29,6 +29,17 @@ class ExportImages(desc.AVCommandLineNode):
2929
description="This SfMData file contains the required intrinsics for the output images.",
3030
value="",
3131
),
32+
desc.ListAttribute(
33+
elementDesc=desc.File(
34+
name="masksFolder",
35+
label="Masks Folder",
36+
description="",
37+
value="",
38+
),
39+
name="masksFolders",
40+
label="Masks Folders",
41+
description="Use masks from specific folder(s). Filename should be the same or the image UID.",
42+
),
3243
desc.ChoiceParam(
3344
name="outputFileType",
3445
label="Output File Type",
@@ -61,24 +72,25 @@ class ExportImages(desc.AVCommandLineNode):
6172
value="viewid",
6273
values=["viewid", "frameid", "keep"],
6374
),
64-
desc.ListAttribute(
65-
elementDesc=desc.File(
66-
name="masksFolder",
67-
label="Masks Folder",
68-
description="",
69-
value="",
70-
),
71-
name="masksFolders",
72-
label="Masks Folders",
73-
description="Use masks from specific folder(s). Filename should be the same or the image UID.",
74-
),
7575
desc.ChoiceParam(
7676
name="maskExtension",
7777
label="Mask Extension",
7878
description="File extension for the masks to use.",
7979
value="png",
8080
values=["exr", "jpg", "png"],
8181
),
82+
desc.ChoiceParam(
83+
name="storageDataType",
84+
label="Storage Data Type",
85+
description="Storage image data type:\n"
86+
" - float: Use full floating point (32 bits per channel).\n"
87+
" - half: Use half float (16 bits per channel).\n"
88+
" - halfFinite: Use half float, but clamp values to avoid non-finite values.\n"
89+
" - auto: Use half float if all values can fit, else use full float.",
90+
values=EXR_STORAGE_DATA_TYPE,
91+
value="halfFinite",
92+
enabled=lambda node: node.outputFileType.value == "exr"
93+
),
8294
desc.ChoiceParam(
8395
name="verboseLevel",
8496
label="Verbose Level",

src/software/utils/main_exportImages.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void ImageRemoveDistortion(const image::Image<T>& imageIn,
202202
* @param medianCameraExposure median camera exposure for the sfmData
203203
* @param masksFolders the mask folders list
204204
* @param maskExtension the mask extension
205+
* @param storageDatatype output image storage data type
205206
* @return false on error
206207
*/
207208
bool processImage(const std::string& dstFileName,
@@ -214,7 +215,8 @@ bool processImage(const std::string& dstFileName,
214215
double cameraExposure,
215216
double medianCameraExposure,
216217
const std::vector<std::string> & masksFolders,
217-
const std::string & maskExtension)
218+
const std::string & maskExtension,
219+
const image::EStorageDataType & storageDataType)
218220
{
219221
image::Image<image::RGBAfColor> image;
220222
image::Image<image::RGBAfColor> image_ud;
@@ -304,7 +306,9 @@ bool processImage(const std::string& dstFileName,
304306
//Write the result
305307
try
306308
{
307-
writeImage(dstFileName, image_ud, image::ImageWriteOptions(), metadata, roi);
309+
image::ImageWriteOptions writeOptions;
310+
writeOptions.storageDataType(storageDataType);
311+
writeImage(dstFileName, image_ud, writeOptions, metadata, roi);
308312
}
309313
catch (...)
310314
{
@@ -324,6 +328,7 @@ bool processImage(const std::string& dstFileName,
324328
* @param exportFullRod do we export the full rod or not
325329
* @param masksFolders the mask folders list
326330
* @param maskExtension the mask extension
331+
* @param storageDatatype output image storage data type
327332
* @param rangeStart the initial view index to process (range selection)
328333
* @param rangeEnd the last view index to process (range selection)
329334
*/
@@ -334,6 +339,7 @@ bool process(const sfmData::SfMData & input,
334339
bool exportFullRod,
335340
const std::vector<std::string> & masksFolders,
336341
const std::string & maskExtension,
342+
const image::EStorageDataType & storageDataType,
337343
size_t rangeStart,
338344
size_t rangeEnd)
339345
{
@@ -391,7 +397,8 @@ bool process(const sfmData::SfMData & input,
391397
view.getImage().getCameraExposureSetting().getExposure(),
392398
medianCameraExposure,
393399
masksFolders,
394-
maskExtension);
400+
maskExtension,
401+
storageDataType);
395402
}
396403

397404
return true;
@@ -413,6 +420,7 @@ int aliceVision_main(int argc, char* argv[])
413420
int rangeSize = 1;
414421
bool evCorrection = false;
415422
bool exportFullROD = false;
423+
image::EStorageDataType storageDataType = image::EStorageDataType::HalfFinite;
416424

417425
// clang-format off
418426
po::options_description requiredParams("Required parameters");
@@ -443,7 +451,9 @@ int aliceVision_main(int argc, char* argv[])
443451
"Use masks from specific folder(s).\n"
444452
"Filename should be the same or the image UID.")
445453
("maskExtension", po::value<std::string>(&maskExtension)->default_value(maskExtension),
446-
"File extension of the masks to use.");
454+
"File extension of the masks to use.")
455+
("storageDataType", po::value<image::EStorageDataType>(&storageDataType)->default_value(storageDataType),
456+
("Storage data type: " + image::EStorageDataType_informations()).c_str());
447457
// clang-format on
448458

449459
CmdLine cmdline("AliceVision prepareDenseScene");
@@ -561,6 +571,7 @@ int aliceVision_main(int argc, char* argv[])
561571
exportFullROD,
562572
masksFolders,
563573
maskExtension,
574+
storageDataType,
564575
rangeStart,
565576
rangeEnd))
566577
{

0 commit comments

Comments
 (0)