From bbebbf17003a9fa229085509b9bada40058ba5ca Mon Sep 17 00:00:00 2001 From: demoulinv Date: Thu, 21 Apr 2022 18:17:18 +0200 Subject: [PATCH 1/9] * Temporary bugfix regarding boost through vcpkg (src/CMakeLists.txt) * Update FindOpenImageIO.cmake adding OpenImageIO_Util library * Update AliceVisionConfig.cmake.in adding Alembic dependancy * Add config.ocio file and update cmake file for installation * OCIO usage for output in ACES or ACEScg color space --- src/CMakeLists.txt | 4 + src/aliceVision/image/CMakeLists.txt | 4 + src/aliceVision/image/config.ocio | 534 ++++++++++++++++++++ src/aliceVision/image/io.cpp | 90 +++- src/aliceVision/image/io.hpp | 9 + src/cmake/AliceVisionConfig.cmake.in | 4 + src/software/utils/main_imageProcessing.cpp | 32 +- 7 files changed, 665 insertions(+), 12 deletions(-) create mode 100644 src/aliceVision/image/config.ocio diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16394db109..4ce3cdd5aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -264,6 +264,10 @@ endif() # Disable BOOST autolink add_definitions(-DBOOST_ALL_NO_LIB) +#To be removed later, a bug to make things work with current vcpkg +#https://github.com/microsoft/vcpkg/issues/22495 +add_definitions(-DBOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN7) + if(BUILD_SHARED_LIBS) # Force BOOST to use dynamic libraries (avoid link error with boost program_options) # https://lists.boost.org/boost-users/2009/11/54015.php diff --git a/src/aliceVision/image/CMakeLists.txt b/src/aliceVision/image/CMakeLists.txt index ac21efc702..22983d644b 100644 --- a/src/aliceVision/image/CMakeLists.txt +++ b/src/aliceVision/image/CMakeLists.txt @@ -1,4 +1,5 @@ add_definitions(-DTHIS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") +add_definitions(-DCONFIG_OCIO_PATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/aliceVision/config.ocio") # Headers set(image_files_headers @@ -41,6 +42,9 @@ alicevision_add_library(aliceVision_image ${OPENEXR_INCLUDE_DIR} ) +# Install config.ocio +install(FILES config.ocio DESTINATION ${CMAKE_INSTALL_DATADIR}/aliceVision) + # Unit tests alicevision_add_test(image_test.cpp NAME "image" LINKS aliceVision_image) alicevision_add_test(io_test.cpp NAME "image_io" LINKS aliceVision_image) diff --git a/src/aliceVision/image/config.ocio b/src/aliceVision/image/config.ocio new file mode 100644 index 0000000000..99397082b1 --- /dev/null +++ b/src/aliceVision/image/config.ocio @@ -0,0 +1,534 @@ +ocio_profile_version: 2 + +# +# Note: this is not intended to be a complete production-ready config, its purpose is to +# introduce many of the new features in OCIO v2. +# + +description: A config to demo the new features in OCIO v2. +name: OCIOv2-demo_2021-02-03 + +# +# This config does not require any external files. +# +search_path: + +# +# Defining the environment (even if empty) in the config can be a performance boost. +# +environment: {} + +# +# The family separator is the character used to seprate colorspace family attributes into +# tokens or levels for hierarchical menus. (The "/" character is also the default.) +# +family_separator: / + +# +# Roles +# +roles: + # + # Please define the two interchange roles. This will allow OCIO to convert pixels that are in + # a color space from another config (that also implements these roles) into a color space in + # this config. + # + aces_interchange: ACES2065-1 + cie_xyz_d65_interchange: CIE-XYZ D65 + # + # (As this is just a demo, not all the usual roles have been defined.) + # + color_timing: ACEScct + compositing_log: ACEScct + data: Raw + default: sRGB + scene_linear: ACEScg + +# +# The File Rules allow you to configure default behavior for applications importing image files. +# +file_rules: + # + # The first rule says to assign the colorspace Raw to files with a .tx extension. + # The colorspace Raw, defined below, essentially means no color processing is applied. + # + - ! {name: tx, colorspace: Raw, pattern: "*", extension: tx} + # + # The next rule assigns the colorspace "ARRI LogC" to any files that contain "LogC" in the path. + # + - ! {name: LogC, colorspace: ARRI LogC, pattern: "*LogC*", extension: "*"} + # + # The next rule assigns the colorspace "sRGB" to any file that ends with .TIF or .TIFF. + # + - ! {name: TIFF, colorspace: sRGB, regex: ".*\\.TIF?F$"} + # + # The next rule uses the OCIO v1 method of searching the path for all colorspaces in the config. + # + - ! {name: ColorSpaceNamePathSearch} + # + # The rules are ordered, highest priority first. OCIO takes the path to a file and applies + # the rules one-by-one until there is a match. The last rule, "Default", always matches. + # In this case the colorspace is assigned to the colorspace used by the "default" role. + # + - ! {name: Default, colorspace: default} + +# +# The Viewing Rules allow applications to determine an appropriate default view for a given color +# space. This becomes important for applications that need to display images in a variety of color +# spaces. For example, an ACES Output Transform might be the ideal view for scene-linear or log +# encoded color spaces but not be appropriate for video color spaces. In OCIO v2, there is a new +# getView function that takes a display and a color space as arguments. OCIO uses the viewing rules +# (if present) to filter the list of views to those that are appropriate for the given color space. +# The rules shown here mostly use the new "encoding" property of color spaces but it is also possible +# for a rule to list color spaces directly. Any views that do not use a rule are always returned. +# The active_views list may be used to also sort the filtered views (or do further filtering). +# +viewing_rules: + # + # The first rule means the view will only be used with colorspaces that have an encoding set + # to "scene-linear". + # + - ! {name: scene-linear, encodings: scene-linear} + # + # The next rule is similar but is targeted at colorspaces that have an encoding of "data". + # + - ! {name: data, encodings: data} + # + # The next rule targets colorspaces that have an encoding of either "log" or "scene-linear". + # + - ! {name: log-or-linear, encodings: [ log, scene-linear ]} + # + # The next rule targets colorspaces that have an encoding of either "sdr-video" or "hdr-video". + # + - ! {name: video, encodings: [ sdr-video, hdr-video ]} + # + # The next rule is not used below but is an example of how a rule could target specific colorspaces. + # + - ! {name: film-log, colorspaces: Log film scan (ADX10)} + + +# +# The Shared Views allow you to define a view that will be reused for multiple displays. +# This can make the config easier to read and maintain. +# +shared_views: + # + # The first two shared views, "Log" and "Raw" have no actual dependence on the display, so they + # simply specify the colorspace that will be used to apply the view. + # + # Note that if the application implements support for viewing rules, the Log view will only be + # used with scene-linear colorspaces (it is typically of no value for colorspaces that are already + # logarithmic or that are video or data), and the Raw view will only be used with data colorspaces. + # (Simply removing the rule from the Raw view would make it be offered with all colorspaces, which + # might be preferred in some scenarios.) + # + - ! {name: Log, colorspace: ACEScct, rule: scene-linear} + - ! {name: Raw, colorspace: Raw, rule: data} + # + # The next shared views use a view_transform and display_colorspace rather than a simple colorspace + # because the view does depend on the display. By setting display_colorspace to "", + # the display_colorspace will be replaced by the display colorspace below that has the same name as + # the display. For example, when used with display "sRGB", the display_colorspace is set to "sRGB". + # + - ! + name: ACES 1.0 SDR-video + view_transform: ACES 1.0 SDR-video + display_colorspace: + rule: log-or-linear + # + # Note that YAML syntax allows views to be split onto multiple lines to make them easier to read. + # + # The ordering within the shared_views section is not significant. It is the order they appear + # below that determines the menu order (although active_views may be used to re-order them). + # + - ! + name: Un-tone-mapped + view_transform: Un-tone-mapped + display_colorspace: + rule: log-or-linear + # + # The "Un-tone-mapped" and "Video" views are functionally equivalent but the viewing rules allow + # different names to be used based on the colorspace being viewed. For example, when viewing + # video images, it's nicer to have a view called "Video" rather than "Un-tone-mapped" (the latter + # really only makes sense in the context of scene-referred images). + # + - ! + name: Video + view_transform: Un-tone-mapped + display_colorspace: + rule: video + + +# +# Displays +# +displays: + # + # The first displays simply reference the shared views defined above. The ordering of the views + # determines the menu order (unless active_views is used to re-order them). + # + sRGB: + - ! [ ACES 1.0 SDR-video, Un-tone-mapped, Log, Video, Raw ] + Rec.1886 / Rec.709 video: + - ! [ ACES 1.0 SDR-video, Un-tone-mapped, Log, Video, Raw ] + # + # The next display uses a (non-shared) view as well as shared views. + # + Rec.2100-PQ: + - ! + name: ACES 1.1 HDR-video (1000 nits) + view_transform: ACES 1.1 HDR-video (1000 nits & Rec.2020 lim) + display_colorspace: Rec.2100-PQ + rule: log-or-linear + - ! [ Un-tone-mapped, Log, Video, Raw ] + + +# +# A Virtual Display allows an application to ask OCIO to instantiate a new display from an ICC +# monitor profile. The ICC monitor profile essentially becomes a new display colorspace and a +# new display is added for users, named after the ICC profile. The new display will inherit the +# views from the virtual display. +# +virtual_display: + - ! [ ACES 1.0 SDR-video, Un-tone-mapped, Log, Raw ] + + +# +# The default view transform is the one that will be used if ColorSpaceTransform needs to convert +# between a colorspace and a display colorspace. (In other words, one that uses the scene-referred +# reference space and one that uses the display-referred reference space.) +# +default_view_transform: Un-tone-mapped + +# +# This section of the config defines the View Transforms. A View Transform is a transform that +# converts between the scene-referred reference space and the display-referred reference space +# (which is new in OCIO v2). The View Transform is sometimes referred to by other names in +# various color science documents. For example, in ACES it is called a "rendering" and in the +# ITU standards for HDR television it is called an Opto-Optical Transfer Function (OOTF). It +# is also commonly referred to as a "tone-map". This is typically where the S-shape curve that +# avoids clipped highlights is applied, along with other adjustments necessary to adopt the +# latest color science best-practices. +# +view_transforms: + # + # This first view transform is simply a matrix to convert from the scene-referred reference space, + # which is ACES2065-1 in this config, to the display-referred reference space, which is CIE XYZ + # with a D65 adaptive whitepoint in this config. Rather than put the matrix coefficients in the + # config, it is easier to reference one of the existing BuiltinTransforms. A BuiltinTransform is + # another new OCIO v2 feature, it is essentially a well-known transform that OCIO knows how to + # construct at runtime. + # + - ! + name: Un-tone-mapped + description: | + Convert the scene colorimetry directly to display-referred with no tone-mapping. + This is often described as a "linear workflow." It is intended only for diagnostic purposes. + from_scene_reference: ! {style: "UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD"} + # + # The next view transform implements the bulk of the ACES Output Transform for SDR video. In ACES, + # the transform from scene-referred colorimetry to display-referred colorimetry is identical for + # a set of Output Transforms (e.g., sRGB and Rec.709). Only the final conversion from display + # colorimetry to display code values differs. That last part is implemented in OCIO as a display + # colorspace. The BuiltinTransform here applies the RRT and first half of the ODT. There are + # Builtins available in OCIO for all of the ACES Output Transforms (though for brevity only two + # of them are included in this demo config). + # + - ! + name: ACES 1.0 SDR-video + description: | + ACES Output Transform for SDR displays in a video viewing environment. ACES neutrals are at D65. + from_scene_reference: ! {style: "ACES-OUTPUT - ACES2065-1_to_CIE-XYZ-D65 - SDR-VIDEO_1.0"} + # + # The next view transform is very similar, implementing the bulk of the ACES Output Transform for + # 1000 nit HDR video. The output transform is completed via the addition of an HDR display colorspace + # defined below. + # + - ! + name: ACES 1.1 HDR-video (1000 nits & Rec.2020 lim) + description: | + ACES Output Transform for 1000 nit HDR displays. ACES neutrals are at D65. Gamut limit uses Rec.2020 primaries. + from_scene_reference: ! {style: "ACES-OUTPUT - ACES2065-1_to_CIE-XYZ-D65 - HDR-VIDEO-1000nit-15nit-REC2020lim_1.1"} + +# +# Looks +# +looks: + + - ! + name: ACES-LMT - Blue light artifact fix + description: | + LMT for desaturating blue hues to reduce clipping artifacts + process_space: ACES2065-1 + transform: ! {style: "ACES-LMT - BLUE_LIGHT_ARTIFACT_FIX"} + + +# +# The inactive colorspace list is another new OCIO v2 feature. It allows you to include colorspaces +# in the config but hide them from user menus. In this case, we want this colorspace in the config +# for use in the cie_xyz_d65_interchange role above, but we don't want users to be able to select it. +# Note that you may override the inactive list via an environment variable. +# +inactive_colorspaces: [ CIE-XYZ D65 ] + +# +# The Display Colorspaces are another new OCIO v2 feature. These are like traditional colorspaces +# but are defined in relation to a display-referred reference space rather than a scene-referred space. +# One of the benefits of this is that a ColorSpaceTransform may now convert between a pair of display +# colorspaces (e.g., from Rec.709 to sRGB) without needing to invert a tone-map all the way back to +# the scene-referred reference space. +# +display_colorspaces: + # + # The display-referred reference space for this config is CIE XYZ tristimulus values (colorimetry) + # with an adaptive white point of D65. As with the scene-referred reference space, no transforms + # are defined for it. + # + # This colorspace does not need to be exposed to users so it is in the inactive_colorspaces list + # above. Also, it does not have any categories, which also means it would not be exposed to users + # in applications that support categories. + # + - ! + name: CIE-XYZ D65 + family: + description: | + Display connection space, CIE XYZ with D65 adaptive white point + encoding: display-linear + isdata: false + categories: + # + # The next display colorspace is for sRGB. It simply applies a matrix and a gamma to convert from + # the desired display colorimetry (in CIE XYZ space) to display code values that may be sent to a + # monitor. Note that display colorspaces use the YAML keys "from_display_reference" and + # "to_display_reference" to specify their transforms. + # + - ! + name: sRGB + family: Displays/SDR + description: | + sRGB monitor (piecewise EOTF) + isdata: false + categories: [ file-io, basic-3d, advanced-3d, basic-2d, advanced-2d ] + encoding: sdr-video + from_display_reference: ! + children: + - ! {matrix: [ 3.240969941905, -1.537383177570, -0.498610760293, 0, -0.969243636281, 1.875967501508, 0.041555057407, 0, 0.055630079697, -0.203976958889, 1.056971514243, 0, 0, 0, 0, 1 ]} + - ! {gamma: 2.4, offset: 0.055, direction: inverse} + - ! {min_in_value: 0., min_out_value: 0., max_in_value: 1., max_out_value: 1.} + # + # For the purposes of the demo, the preceding and following colorspaces are implemented + # explicitly, but they could also have been implemented using BuiltinTransforms as: + # - ! {style: "DISPLAY - CIE-XYZ-D65_to_sRGB"} + # - ! {style: "DISPLAY - CIE-XYZ-D65_to_REC.1886-REC.709"} + # + - ! + name: Rec.1886 / Rec.709 video + aliases: [ rec709 ] + family: Displays/SDR + description: | + Rec.709 HD broadcast monitor with Rec.1886 EOTF (gamma 2.4) + isdata: false + categories: [ file-io, basic-3d, advanced-3d, basic-2d, advanced-2d ] + encoding: sdr-video + from_display_reference: ! + children: + - ! {matrix: [ 3.240969941905, -1.537383177570, -0.498610760293, 0, -0.969243636281, 1.875967501508, 0.041555057407, 0, 0.055630079697, -0.203976958889, 1.056971514243, 0, 0, 0, 0, 1 ]} + - ! {value: 2.4, direction: inverse} + - ! {min_in_value: 0., min_out_value: 0., max_in_value: 1., max_out_value: 1.} + # + # This next colorspace requires the PQ curve, which would require an external LUT file so the + # BuiltinTransform is used in this case. Note that the Builtin display transforms do not clamp, + # so it is followed by a RangeTransform which clamps to [0,1]. + # + - ! + name: Rec.2100-PQ + family: Displays/HDR + description: | + Rec.2100-PQ monitor with Rec.2020 primaries and ST-2084 EOTF + isdata: false + categories: [ file-io, advanced-3d, basic-2d, advanced-2d ] + encoding: hdr-video + from_display_reference: ! + children: + - ! {style: "DISPLAY - CIE-XYZ-D65_to_REC.2100-PQ"} + - ! {min_in_value: 0., min_out_value: 0., max_in_value: 1., max_out_value: 1.} + + +# +# The next config section is the traditional section for colorspaces that are defined relative to a +# scene-referred connection space. This section may be placed either before or after the display +# colorspaces, based on which you prefer appear first in colorspace menus. +# +colorspaces: + # + # Note that colorspaces may have some new attributes in OCIO v2 including categories and encoding. + # The categories are intended to indicate which colorspace menus in an application should include + # a given colorspace. The categories may come both from the application and from the end-user. + # Application-defined categories such as "file-io" or "working-space" indicate which menus in the + # application the colorspaces will appear in. The application categories are intended to be + # combined with the encodings. So for example, an application might filter by "working-space" as + # a category and "scene-linear" as an encoding to get all the scene-linear working space options + # to display in a certain menu. User-defined categories such as "basic-3d" or "advanced-2d" + # indicate what type or artist should see those colorspaces. OCIO uses the intersection of the + # application categories (combined with the encoding) along with the user categories to filter + # the list of colorspaces. Note that the user categories are intended to be set via an environment + # variable based on the type of artist using the application. OCIO does not yet provide an official + # list of categories, so it will be up to application developers and config authors to determine + # what strings to use. OCIO does however provide a specific list of allowed encoding strings. + # + - ! + name: ACEScg + family: ACES + description: | + ACEScg working space + isdata: false + categories: [ file-io, working-space, basic-3d, advanced-3d, basic-2d, advanced-2d ] + encoding: scene-linear + to_scene_reference: ! {matrix: [ 0.695452241357, 0.140678696470, 0.163869062172, 0, 0.044794563372, 0.859671118456, 0.095534318172, 0, -0.005525882558, 0.004025210306, 1.001500672252, 0, 0, 0, 0, 1 ]} + # + # OCIO v2 introduces an "aliases" property that may be used to define synonyms for the canonical + # colorspace name. This may be used to define short names that are easier to embed in file paths + # or to handle backwards compatibility when the name of a colorspace evolves over time. + # + - ! + name: ACES2065-1 + aliases: [ aces ] + family: ACES + description: | + The Academy Color Encoding System reference color space + isdata: false + categories: [ file-io, basic-3d, advanced-3d, basic-2d, advanced-2d ] + encoding: scene-linear + # + # Note that this section of the config uses "to_scene_reference" and "from_scene_reference" to + # specify the transforms, but "to_reference" and "from_reference" are also allowed for backwards + # compatibility with OCIO v1. + # + - ! + name: scene-linear Rec.709-sRGB + family: Linear + description: | + Scene-linear Rec.709 or sRGB primaries + isdata: false + categories: [ file-io, basic-3d, advanced-3d, advanced-2d ] + encoding: scene-linear + to_scene_reference: ! {matrix: [ 0.439632981919, 0.382988698152, 0.177378319929, 0, 0.089776442959, 0.813439428749, 0.096784128292, 0, 0.017541170383, 0.111546553302, 0.870912276314, 0, 0, 0, 0, 1 ]} + # + # Note that in OCIO v2 it is not necessary to include most keys if they have their default values. + # This also applies to properties such as the interpolation method for FileTransforms. + # + - ! + name: Raw + family: Data + description: | + Raw (no color processing) + isdata: true + categories: [ file-io, basic-3d, advanced-3d, basic-2d, advanced-2d ] + encoding: data + # + # The ACEScct transform could be implemented as a Builtin using style: "ACEScct_to_ACES2065-1", + # but the implementation here is an opportunity to demo the new LogCameraTransform, which may + # be used to implement most of the camera-log type transforms (and is used internally by the + # ACEScct BuiltinTransform implementation). + # + - ! + name: ACEScct + family: ACES + description: | + ACES camera log working space + isdata: false + categories: [ file-io, working-space, advanced-3d, basic-2d, advanced-2d ] + encoding: log + to_scene_reference: ! + children: + - ! + log_side_slope: 0.05707762557077626 + log_side_offset: 0.55479452054794520 + lin_side_slope: 1. + lin_side_offset: 0. + lin_side_break: 0.0078125 + base: 2 + direction: inverse + - ! {matrix: [ 0.695452241357, 0.140678696470, 0.163869062172, 0, 0.044794563372, 0.859671118456, 0.095534318172, 0, -0.005525882558, 0.004025210306, 1.001500672252, 0, 0, 0, 0, 1 ]} + # + # The remaining colorspaces use the BuiltinTransforms for simplicity and readability. + # + - ! + name: ACEScc + family: ACES + description: | + ACES log working space + isdata: false + categories: [ file-io, advanced-2d ] + encoding: log + to_scene_reference: ! {style: "ACEScc_to_ACES2065-1"} + + - ! + name: ARRI LogC + family: Cameras/ARRI + description: | + Alexa-v3-LogC-EI800 (SUP v3 color science) + isdata: false + categories: [ file-io, advanced-3d, basic-2d, advanced-2d ] + encoding: log + to_scene_reference: ! {style: "ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1"} + + - ! + name: RED Log3G10 / REDWideGamutRGB + family: Cameras/RED + description: | + RED Log3G10 / REDWideGamutRGB + isdata: false + categories: [ file-io, basic-2d, advanced-2d ] + encoding: log + to_scene_reference: ! {style: "RED_LOG3G10-RWG_to_ACES2065-1"} + + - ! + name: Sony SLog3 / SGamut3 + family: Cameras/Sony + description: | + Sony SLog3 / SGamut3 + isdata: false + categories: [ file-io, basic-2d, advanced-2d ] + encoding: log + to_scene_reference: ! {style: "SONY_SLOG3-SGAMUT3_to_ACES2065-1"} + + - ! + name: Log film scan (ADX10) + aliases: [ ADX10 ] + family: ACES + description: | + ADX10 Academy Density Exchange (10-bit printing density) + isdata: false + categories: [ file-io, advanced-2d ] + encoding: log + to_scene_reference: ! {style: "ADX10_to_ACES2065-1"} + + +# +# Sometimes it is helpful to include one or more transforms in a config that are essentially +# stand-alone transforms that do not have a fixed relationship to a reference space or a +# process space. An example would be a "utility curve" transform where the intent is to +# simply apply a LUT1D without any conversion to a reference space. In these cases, a +# named_transforms section may be added to the config with one or more named transforms. +# +# Note that named transforms do not show up in color space menus by default, so the +# application developer must implement support to make them available to users. +# +# This feature may be used to emulate older methods of color management that ignored the +# RGB primaries and simply applied one-dimensional transformations. However, config authors +# are encouraged to implement transforms as normal OCIO color spaces wherever possible. +# +named_transforms: + + - ! + name: Utility Curve -- Cineon Log to Lin + description: | + Traditional Cineon-style log-to-lin with RefWhite=695, RefBlack=95, Gamma=0.6 + transform: ! + log_side_slope: 0.293255131965 + log_side_offset: 0.669599217986 + lin_side_slope: 0.989202248377 + lin_side_offset: 0.010797751623 + base: 10 + direction: inverse \ No newline at end of file diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index 6c3aef143d..33d65cc2ac 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -23,12 +24,76 @@ #include #include - namespace fs = boost::filesystem; namespace aliceVision { namespace image { +std::string EImageColorSpace_informations() +{ + return EImageColorSpace_enumToString(EImageColorSpace::AUTO) + ", " + + EImageColorSpace_enumToString(EImageColorSpace::LINEAR) + ", " + + EImageColorSpace_enumToString(EImageColorSpace::SRGB) + ", " + + EImageColorSpace_enumToString(EImageColorSpace::ACES) + ", " + + EImageColorSpace_enumToString(EImageColorSpace::ACEScg) + ", " + + EImageColorSpace_enumToString(EImageColorSpace::NO_CONVERSION); +} + +EImageColorSpace EImageColorSpace_stringToEnum(const std::string& dataType) +{ + std::string type = dataType; + std::transform(type.begin(), type.end(), type.begin(), ::tolower); // tolower + + if(type == "auto") + return EImageColorSpace::AUTO; + if(type == "linear") + return EImageColorSpace::LINEAR; + if(type == "srgb") + return EImageColorSpace::SRGB; + if(type == "aces") + return EImageColorSpace::ACES; + if(type == "acescg") + return EImageColorSpace::ACEScg; + if(type == "no_conversion") + return EImageColorSpace::NO_CONVERSION; + + throw std::out_of_range("Invalid EImageColorSpace: " + dataType); +} + +std::string EImageColorSpace_enumToString(const EImageColorSpace dataType) +{ + switch(dataType) + { + case EImageColorSpace::AUTO: + return "auto"; + case EImageColorSpace::LINEAR: + return "linear"; + case EImageColorSpace::SRGB: + return "srgb"; + case EImageColorSpace::ACES: + return "aces"; + case EImageColorSpace::ACEScg: + return "acescg"; + case EImageColorSpace::NO_CONVERSION: + return "no_conversion"; + } + throw std::out_of_range("Invalid EImageColorSpace enum"); +} + +std::ostream& operator<<(std::ostream& os, EImageColorSpace dataType) +{ + return os << EImageColorSpace_enumToString(dataType); +} + +std::istream& operator>>(std::istream& in, EImageColorSpace& dataType) +{ + std::string token; + in >> token; + dataType = EImageColorSpace_stringToEnum(token); + return in; +} + + std::string EImageFileType_informations() { return "Image file type :\n" @@ -454,11 +519,30 @@ void writeImage(const std::string& path, const oiio::ImageBuf imgBuf = oiio::ImageBuf(imageSpec, const_cast(image.data())); // original image buffer const oiio::ImageBuf* outBuf = &imgBuf; // buffer to write + std::string configOCIOFilePath = ""; +#ifdef CONFIG_OCIO_PATH + configOCIOFilePath = CONFIG_OCIO_PATH; +#endif + oiio::ImageBuf colorspaceBuf; // buffer for image colorspace modification if(imageColorSpace == EImageColorSpace::SRGB) { - oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", "sRGB"); - outBuf = &colorspaceBuf; + oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", "sRGB"); + outBuf = &colorspaceBuf; + } + else if(imageColorSpace != EImageColorSpace::LINEAR) // ACES or ACEScg + { + if (configOCIOFilePath.empty()) + { + throw std::runtime_error("OCIO config file not defined."); + } + + //oiio::ColorConfig colorConfig("C:/LocalDev/imgConvertOIIO/install/config.ocio"); + oiio::ColorConfig colorConfig(configOCIOFilePath); + oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", + (imageColorSpace != EImageColorSpace::ACES) ? "ACES" : "ACEScg", true, "", "", + &colorConfig); + outBuf = &colorspaceBuf; } oiio::ImageBuf formatBuf; // buffer for image format modification diff --git a/src/aliceVision/image/io.hpp b/src/aliceVision/image/io.hpp index d567157b12..d9399f6dc6 100644 --- a/src/aliceVision/image/io.hpp +++ b/src/aliceVision/image/io.hpp @@ -29,9 +29,18 @@ enum class EImageColorSpace AUTO, LINEAR, SRGB, + ACES, + ACEScg, NO_CONVERSION }; +std::string EImageColorSpace_informations(); +EImageColorSpace EImageColorSpace_stringToEnum(const std::string& dataType); +std::string EImageColorSpace_enumToString(const EImageColorSpace dataType); +std::ostream& operator<<(std::ostream& os, EImageColorSpace dataType); +std::istream& operator>>(std::istream& in, EImageColorSpace& dataType); + + /** * @brief Available image file type for pipeline output */ diff --git a/src/cmake/AliceVisionConfig.cmake.in b/src/cmake/AliceVisionConfig.cmake.in index 56f4927262..d1fad036d3 100644 --- a/src/cmake/AliceVisionConfig.cmake.in +++ b/src/cmake/AliceVisionConfig.cmake.in @@ -107,6 +107,10 @@ endif() set(ALICEVISION_HAVE_OPENGV @ALICEVISION_HAVE_OPENGV@) set(ALICEVISION_HAVE_ALEMBIC @ALICEVISION_HAVE_ALEMBIC@) +if(ALICEVISION_HAVE_ALEMBIC) + find_dependency(Alembic) +endif() + message(STATUS "Found AliceVision version: ${@exportedProjectName@_VERSION}") include("${CMAKE_CURRENT_LIST_DIR}/@targetsExportName@.cmake") diff --git a/src/software/utils/main_imageProcessing.cpp b/src/software/utils/main_imageProcessing.cpp index 7dc0939de0..3a1cabde5e 100644 --- a/src/software/utils/main_imageProcessing.cpp +++ b/src/software/utils/main_imageProcessing.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include // These constants define the current software version. // They must be updated when the command line is changed. @@ -177,6 +177,7 @@ inline std::ostream& operator<<(std::ostream& os, const NoiseFilterParams& nfPar } enum class EImageFormat { RGBA, RGB, Grayscale }; +//enum class EColorSpace { sRGB, Linear, ACES, ACEScg }; inline std::string EImageFormat_enumToString(EImageFormat imageFormat) { @@ -218,6 +219,7 @@ struct ProcessingParams bool keepImageFilename = false; bool exposureCompensation = false; EImageFormat outputFormat = EImageFormat::RGBA; + //image::EImageColorSpace outputColorSpace = image::EImageColorSpace::LINEAR; float scaleFactor = 1.0f; float contrast = 1.0f; int medianFilter = 0; @@ -406,8 +408,8 @@ void processImage(image::Image& image, const ProcessingParams } void saveImage(image::Image& image, const std::string& inputPath, const std::string& outputPath, - const std::vector& metadataFolders, - const EImageFormat outputFormat, const image::EStorageDataType storageDataType) + const std::vector& metadataFolders, const EImageFormat outputFormat, + const image::EImageColorSpace outputColorSpace, const image::EStorageDataType storageDataType) { // Read metadata path std::string metadataFilePath; @@ -465,18 +467,21 @@ void saveImage(image::Image& image, const std::string& inputP { image::Image outputImage; image::ConvertPixelType(image, &outputImage); - image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); + //image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); + image::writeImage(outputPath, outputImage, outputColorSpace, metadata); } else if(outputFormat == EImageFormat::RGB) { image::Image outputImage; image::ConvertPixelType(image, &outputImage); - image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); + //image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); + image::writeImage(outputPath, outputImage, outputColorSpace, metadata); } else { // Already in RGBAf - image::writeImage(outputPath, image, image::EImageColorSpace::AUTO, metadata); + //image::writeImage(outputPath, image, image::EImageColorSpace::AUTO, metadata); + image::writeImage(outputPath, image, outputColorSpace, metadata); } } @@ -488,8 +493,10 @@ int aliceVision_main(int argc, char * argv[]) std::vector metadataFolders; std::string outputPath; EImageFormat outputFormat = EImageFormat::RGBA; + image::EImageColorSpace outputColorSpace = image::EImageColorSpace::LINEAR; image::EStorageDataType storageDataType = image::EStorageDataType::Float; std::string extension; + std::string configOCIOPath; ProcessingParams pParams; @@ -506,12 +513,15 @@ int aliceVision_main(int argc, char * argv[]) "Use images from specific folder(s) instead of those specify in the SfMData file.") ("output,o", po::value(&outputPath)->required(), "Output folder.") + ("ocio", po::value(&configOCIOPath)->required(), + "OpenColorIO configuration file.") ; po::options_description optionalParams("Optional parameters"); optionalParams.add_options() ("metadataFolders", po::value>(&metadataFolders)->multitoken(), "Use images metadata from specific folder(s) instead of those specified in the input images.") + ("reconstructedViewsOnly", po::value(&pParams.reconstructedViewsOnly)->default_value(pParams.reconstructedViewsOnly), "Process only recontructed views or all views.") @@ -564,7 +574,10 @@ int aliceVision_main(int argc, char * argv[]) ("outputFormat", po::value(&outputFormat)->default_value(outputFormat), "Output image format (rgba, rgb, grayscale)") - + + ("outputColorSpace", po::value(&outputColorSpace)->default_value(outputColorSpace), + ("Output color space: " + image::EImageColorSpace_informations()).c_str()) + ("storageDataType", po::value(&storageDataType)->default_value(storageDataType), ("Storage data type: " + image::EStorageDataType_informations()).c_str()) @@ -572,6 +585,7 @@ int aliceVision_main(int argc, char * argv[]) "Output image extension (like exr, or empty to keep the source file format.") ; + po::options_description logParams("Log parameters"); logParams.add_options() ("verboseLevel,v", po::value(&verboseLevel)->default_value(verboseLevel), @@ -729,7 +743,7 @@ int aliceVision_main(int argc, char * argv[]) processImage(image, pParams); // Save the image - saveImage(image, viewPath, outputfilePath, metadataFolders, outputFormat, storageDataType); + saveImage(image, viewPath, outputfilePath, metadataFolders, outputFormat, outputColorSpace, storageDataType); // Update view for this modification view.setImagePath(outputfilePath); @@ -824,7 +838,7 @@ int aliceVision_main(int argc, char * argv[]) processImage(image, pParams); // Save the image - saveImage(image, inputFilePath, outputFilePath, metadataFolders, outputFormat, storageDataType); + saveImage(image, inputFilePath, outputFilePath, metadataFolders, outputFormat, outputColorSpace, storageDataType); } } From f2613cb32484feb996e76ca1b5e269a90709ec05 Mon Sep 17 00:00:00 2001 From: demoulinv Date: Mon, 25 Apr 2022 14:56:37 +0200 Subject: [PATCH 2/9] Set sRGB-Linear as the reference linear space in config.ocio --- src/aliceVision/image/config.ocio | 6 +++--- src/aliceVision/image/io.cpp | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/aliceVision/image/config.ocio b/src/aliceVision/image/config.ocio index 99397082b1..3c90c26ee8 100644 --- a/src/aliceVision/image/config.ocio +++ b/src/aliceVision/image/config.ocio @@ -5,8 +5,8 @@ ocio_profile_version: 2 # introduce many of the new features in OCIO v2. # -description: A config to demo the new features in OCIO v2. -name: OCIOv2-demo_2021-02-03 +description: A config to convert color space in AliceVision. +name: OCIOv2-AliceVision # # This config does not require any external files. @@ -42,7 +42,7 @@ roles: compositing_log: ACEScct data: Raw default: sRGB - scene_linear: ACEScg + scene_linear: scene-linear Rec.709-sRGB # # The File Rules allow you to configure default behavior for applications importing image files. diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index 33d65cc2ac..482f68089a 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -537,10 +537,9 @@ void writeImage(const std::string& path, throw std::runtime_error("OCIO config file not defined."); } - //oiio::ColorConfig colorConfig("C:/LocalDev/imgConvertOIIO/install/config.ocio"); oiio::ColorConfig colorConfig(configOCIOFilePath); oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", - (imageColorSpace != EImageColorSpace::ACES) ? "ACES" : "ACEScg", true, "", "", + (imageColorSpace != EImageColorSpace::ACES) ? "aces" : "ACEScg", true, "", "", &colorConfig); outBuf = &colorspaceBuf; } From aa6960fa1feb11f43878607110e56723d218afd5 Mon Sep 17 00:00:00 2001 From: demoulinv Date: Mon, 25 Apr 2022 21:24:20 +0200 Subject: [PATCH 3/9] Add reference to an environment variable ALICEVISION_ROOT to access config.ocio and cameraSensors.db files. In main_cameraInit.cpp, filepath to access cameraSensors.db becomes an optional parameter. If not specified, try to access the default file with filepath $ALICEVISION_ROOT/share/aliceVision/cameraSensors.db src/CMakeLists.txt : Limit some Boost def to Windows. Remove definition of config.ocio filepath in cmake file. --- src/CMakeLists.txt | 13 ++++++++----- src/aliceVision/image/CMakeLists.txt | 1 - src/aliceVision/image/io.cpp | 12 +++++------- src/software/pipeline/main_cameraInit.cpp | 20 ++++++++++++++------ src/software/utils/main_imageProcessing.cpp | 3 --- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ce3cdd5aa..31d28ddc51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -261,12 +261,15 @@ else() message(SEND_ERROR "${Boost_ERROR_REASON}") endif() -# Disable BOOST autolink -add_definitions(-DBOOST_ALL_NO_LIB) -#To be removed later, a bug to make things work with current vcpkg -#https://github.com/microsoft/vcpkg/issues/22495 -add_definitions(-DBOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN7) +if(WIN32) + # Disable BOOST autolink + add_definitions(-DBOOST_ALL_NO_LIB) + + #To be removed later, a bug to make things work with current vcpkg + #https://github.com/microsoft/vcpkg/issues/22495 + add_definitions(-DBOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN7) +endif() if(BUILD_SHARED_LIBS) # Force BOOST to use dynamic libraries (avoid link error with boost program_options) diff --git a/src/aliceVision/image/CMakeLists.txt b/src/aliceVision/image/CMakeLists.txt index 22983d644b..3149fe038c 100644 --- a/src/aliceVision/image/CMakeLists.txt +++ b/src/aliceVision/image/CMakeLists.txt @@ -1,5 +1,4 @@ add_definitions(-DTHIS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") -add_definitions(-DCONFIG_OCIO_PATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/aliceVision/config.ocio") # Headers set(image_files_headers diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index 482f68089a..8052cd2a0d 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -519,11 +519,6 @@ void writeImage(const std::string& path, const oiio::ImageBuf imgBuf = oiio::ImageBuf(imageSpec, const_cast(image.data())); // original image buffer const oiio::ImageBuf* outBuf = &imgBuf; // buffer to write - std::string configOCIOFilePath = ""; -#ifdef CONFIG_OCIO_PATH - configOCIOFilePath = CONFIG_OCIO_PATH; -#endif - oiio::ImageBuf colorspaceBuf; // buffer for image colorspace modification if(imageColorSpace == EImageColorSpace::SRGB) { @@ -532,10 +527,13 @@ void writeImage(const std::string& path, } else if(imageColorSpace != EImageColorSpace::LINEAR) // ACES or ACEScg { - if (configOCIOFilePath.empty()) + char const* val = getenv("ALICEVISION_ROOT"); + if (val == NULL) { - throw std::runtime_error("OCIO config file not defined."); + throw std::runtime_error("ALICEVISION_ROOT is not defined, OCIO config file cannot be accessed."); } + std::string configOCIOFilePath = std::string(val); + configOCIOFilePath.append("/share/aliceVision/config.ocio"); oiio::ColorConfig colorConfig(configOCIOFilePath); oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index 771812e6fe..b97919e68f 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -170,13 +170,13 @@ int aliceVision_main(int argc, char **argv) "A SfMData file (*.sfm) [if specified, --imageFolder cannot be used].") ("imageFolder", po::value(&imageFolder)->default_value(imageFolder), "Input images folder [if specified, --input cannot be used].") - ("sensorDatabase,s", po::value(&sensorDatabasePath)->required(), - "Camera sensor width database path.") ("output,o", po::value(&outputFilePath)->default_value("cameraInit.sfm"), "Output file path for the new SfMData file"); po::options_description optionalParams("Optional parameters"); optionalParams.add_options() + ("sensorDatabase,s", po::value(&sensorDatabasePath)->default_value(""), + "Camera sensor width database path.") ("defaultFocalLength", po::value(&defaultFocalLength)->default_value(defaultFocalLength), "Focal length in mm. (or '-1' to unset)") ("defaultFieldOfView", po::value(&defaultFieldOfView)->default_value(defaultFieldOfView), @@ -315,13 +315,21 @@ int aliceVision_main(int argc, char **argv) // check sensor database std::vector sensorDatabase; - if(!sensorDatabasePath.empty()) + if (sensorDatabasePath.empty()) + { + char const* val = getenv("ALICEVISION_ROOT"); + if (val == NULL) + { + throw std::runtime_error("ALICEVISION_ROOT is not defined, default sensor database cannot be accessed."); + } + sensorDatabasePath = std::string(val); + sensorDatabasePath.append("/share/aliceVision/cameraSensors.db"); + } + + if(!sensorDB::parseDatabase(sensorDatabasePath, sensorDatabase)) { - if(!sensorDB::parseDatabase(sensorDatabasePath, sensorDatabase)) - { ALICEVISION_LOG_ERROR("Invalid input database '" << sensorDatabasePath << "', please specify a valid file."); return EXIT_FAILURE; - } } camera::EINTRINSIC allowedCameraModels = camera::EINTRINSIC_parseStringToBitmask(allowedCameraModelsStr); diff --git a/src/software/utils/main_imageProcessing.cpp b/src/software/utils/main_imageProcessing.cpp index 3a1cabde5e..44656e7803 100644 --- a/src/software/utils/main_imageProcessing.cpp +++ b/src/software/utils/main_imageProcessing.cpp @@ -496,7 +496,6 @@ int aliceVision_main(int argc, char * argv[]) image::EImageColorSpace outputColorSpace = image::EImageColorSpace::LINEAR; image::EStorageDataType storageDataType = image::EStorageDataType::Float; std::string extension; - std::string configOCIOPath; ProcessingParams pParams; @@ -513,8 +512,6 @@ int aliceVision_main(int argc, char * argv[]) "Use images from specific folder(s) instead of those specify in the SfMData file.") ("output,o", po::value(&outputPath)->required(), "Output folder.") - ("ocio", po::value(&configOCIOPath)->required(), - "OpenColorIO configuration file.") ; po::options_description optionalParams("Optional parameters"); From 87a9627b2ff383cbd450e2a7610a7186d81ee99b Mon Sep 17 00:00:00 2001 From: demoulinv Date: Mon, 25 Apr 2022 22:01:55 +0200 Subject: [PATCH 4/9] Update installation doc. --- INSTALL.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 69a394dab0..79bbfb304c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -427,3 +427,9 @@ To retrieve the generated files: # Create an instance of the image, copy the files and remove the temporary docker instance. CID=$(docker create alicevision:centos7-cuda9.2) && docker cp ${CID}:/opt/AliceVision_install . && docker cp ${CID}:/opt/AliceVision_bundle . && docker rm ${CID} ``` + +Environment variable +-------------------- + +Whatever the way AliceVision has been installed, before using it, an environment variable named ALICEVISION_ROOT must be created and set with the local installation directory. + From b2663003422317a830dba14e80b3ca8a4798d292 Mon Sep 17 00:00:00 2001 From: demoulinv <99878110+demoulinv@users.noreply.github.com> Date: Tue, 26 Apr 2022 10:59:23 +0200 Subject: [PATCH 5/9] Update src/software/pipeline/main_cameraInit.cpp Co-authored-by: Simone Gasparini --- src/software/pipeline/main_cameraInit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index b97919e68f..0693273c55 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -320,7 +320,7 @@ int aliceVision_main(int argc, char **argv) char const* val = getenv("ALICEVISION_ROOT"); if (val == NULL) { - throw std::runtime_error("ALICEVISION_ROOT is not defined, default sensor database cannot be accessed."); + ALICEVISION_LOG_WARNING("ALICEVISION_ROOT is not defined, default sensor database cannot be accessed."); } sensorDatabasePath = std::string(val); sensorDatabasePath.append("/share/aliceVision/cameraSensors.db"); From 27deb509ae334b1c498286a4a490d3a980557486 Mon Sep 17 00:00:00 2001 From: demoulinv <99878110+demoulinv@users.noreply.github.com> Date: Tue, 26 Apr 2022 11:01:05 +0200 Subject: [PATCH 6/9] Update src/software/pipeline/main_cameraInit.cpp Co-authored-by: Simone Gasparini --- src/software/pipeline/main_cameraInit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index 0693273c55..94c0e9740a 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -326,7 +326,7 @@ int aliceVision_main(int argc, char **argv) sensorDatabasePath.append("/share/aliceVision/cameraSensors.db"); } - if(!sensorDB::parseDatabase(sensorDatabasePath, sensorDatabase)) + if(!sensorDatabasePath.empty() && !sensorDB::parseDatabase(sensorDatabasePath, sensorDatabase)) { ALICEVISION_LOG_ERROR("Invalid input database '" << sensorDatabasePath << "', please specify a valid file."); return EXIT_FAILURE; From f0fd559f53c9cd498640179cf30c7a4f0da19d9d Mon Sep 17 00:00:00 2001 From: demoulinv Date: Tue, 26 Apr 2022 11:56:40 +0200 Subject: [PATCH 7/9] Complete throwing replacement with warning if cameraSensors filepath not existing. Update Docker files with new environment variable ALICEVISION_ROOT. Code cleaning. --- docker/Dockerfile_centos | 2 +- docker/Dockerfile_ubuntu | 1 + src/aliceVision/image/io.cpp | 6 ++---- src/software/pipeline/main_cameraInit.cpp | 7 +++++-- src/software/utils/main_imageProcessing.cpp | 5 ----- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/docker/Dockerfile_centos b/docker/Dockerfile_centos index 6d547f9550..fdb366c3ab 100644 --- a/docker/Dockerfile_centos +++ b/docker/Dockerfile_centos @@ -42,4 +42,4 @@ RUN make -j"$(nproc)" && \ rm -rf "${AV_DEV}" "${AV_BUILD}" && \ echo "export ALICEVISION_SENSOR_DB=${AV_BUNDLE}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh - +ENV ALICEVISION_ROOT=${AV_INSTALL} diff --git a/docker/Dockerfile_ubuntu b/docker/Dockerfile_ubuntu index 000d36eab8..de47b9be68 100644 --- a/docker/Dockerfile_ubuntu +++ b/docker/Dockerfile_ubuntu @@ -56,3 +56,4 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \ rm -rf "${AV_BUILD}" "${AV_DEV}" && \ echo "export ALICEVISION_SENSOR_DB=${AV_INSTALL}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh +ENV ALICEVISION_ROOT=${AV_INSTALL} diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index 8052cd2a0d..d094423985 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -41,8 +41,7 @@ std::string EImageColorSpace_informations() EImageColorSpace EImageColorSpace_stringToEnum(const std::string& dataType) { - std::string type = dataType; - std::transform(type.begin(), type.end(), type.begin(), ::tolower); // tolower + const std::string type = boost::to_lower_copy(dataType); if(type == "auto") return EImageColorSpace::AUTO; @@ -105,8 +104,7 @@ std::string EImageFileType_informations() EImageFileType EImageFileType_stringToEnum(const std::string& imageFileType) { - std::string type = imageFileType; - std::transform(type.begin(), type.end(), type.begin(), ::tolower); //tolower + const std::string type = boost::to_lower_copy(imageFileType); if(type == "jpg" || type == "jpeg") return EImageFileType::JPEG; if(type == "png") return EImageFileType::PNG; diff --git a/src/software/pipeline/main_cameraInit.cpp b/src/software/pipeline/main_cameraInit.cpp index 94c0e9740a..59e3dc1c8f 100644 --- a/src/software/pipeline/main_cameraInit.cpp +++ b/src/software/pipeline/main_cameraInit.cpp @@ -322,8 +322,11 @@ int aliceVision_main(int argc, char **argv) { ALICEVISION_LOG_WARNING("ALICEVISION_ROOT is not defined, default sensor database cannot be accessed."); } - sensorDatabasePath = std::string(val); - sensorDatabasePath.append("/share/aliceVision/cameraSensors.db"); + else + { + sensorDatabasePath = std::string(val); + sensorDatabasePath.append("/share/aliceVision/cameraSensors.db"); + } } if(!sensorDatabasePath.empty() && !sensorDB::parseDatabase(sensorDatabasePath, sensorDatabase)) diff --git a/src/software/utils/main_imageProcessing.cpp b/src/software/utils/main_imageProcessing.cpp index 44656e7803..e125e2471a 100644 --- a/src/software/utils/main_imageProcessing.cpp +++ b/src/software/utils/main_imageProcessing.cpp @@ -177,7 +177,6 @@ inline std::ostream& operator<<(std::ostream& os, const NoiseFilterParams& nfPar } enum class EImageFormat { RGBA, RGB, Grayscale }; -//enum class EColorSpace { sRGB, Linear, ACES, ACEScg }; inline std::string EImageFormat_enumToString(EImageFormat imageFormat) { @@ -219,7 +218,6 @@ struct ProcessingParams bool keepImageFilename = false; bool exposureCompensation = false; EImageFormat outputFormat = EImageFormat::RGBA; - //image::EImageColorSpace outputColorSpace = image::EImageColorSpace::LINEAR; float scaleFactor = 1.0f; float contrast = 1.0f; int medianFilter = 0; @@ -467,20 +465,17 @@ void saveImage(image::Image& image, const std::string& inputP { image::Image outputImage; image::ConvertPixelType(image, &outputImage); - //image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); image::writeImage(outputPath, outputImage, outputColorSpace, metadata); } else if(outputFormat == EImageFormat::RGB) { image::Image outputImage; image::ConvertPixelType(image, &outputImage); - //image::writeImage(outputPath, outputImage, image::EImageColorSpace::AUTO, metadata); image::writeImage(outputPath, outputImage, outputColorSpace, metadata); } else { // Already in RGBAf - //image::writeImage(outputPath, image, image::EImageColorSpace::AUTO, metadata); image::writeImage(outputPath, image, outputColorSpace, metadata); } } From 907889afce988e430d328aa9f3a55ea0a55cd271 Mon Sep 17 00:00:00 2001 From: demoulinv Date: Tue, 26 Apr 2022 15:16:05 +0200 Subject: [PATCH 8/9] [Docker] Updates Update environment variable definition ALICEVISION_ROOT Bugfix in Docker ubuntu version --- docker/Dockerfile_centos | 5 ++--- docker/Dockerfile_ubuntu | 11 ++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile_centos b/docker/Dockerfile_centos index fdb366c3ab..6f54af3319 100644 --- a/docker/Dockerfile_centos +++ b/docker/Dockerfile_centos @@ -40,6 +40,5 @@ RUN make -j"$(nproc)" && \ make install && \ make bundle && \ rm -rf "${AV_DEV}" "${AV_BUILD}" && \ - echo "export ALICEVISION_SENSOR_DB=${AV_BUNDLE}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh - -ENV ALICEVISION_ROOT=${AV_INSTALL} + echo "export ALICEVISION_SENSOR_DB=${AV_BUNDLE}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh && \ + echo "export ALICEVISION_ROOT=${AV_BUNDLE}" >> /etc/profile.d/alicevision.sh diff --git a/docker/Dockerfile_ubuntu b/docker/Dockerfile_ubuntu index de47b9be68..3270abaad8 100644 --- a/docker/Dockerfile_ubuntu +++ b/docker/Dockerfile_ubuntu @@ -27,6 +27,7 @@ LABEL maintainer="AliceVision Team alicevision-team@googlegroups.com" ENV AV_DEV=/opt/AliceVision_git \ AV_BUILD=/tmp/AliceVision_build \ AV_INSTALL=/opt/AliceVision_install \ + AV_BUNDLE=/opt/AliceVision_bundle \ PATH="${PATH}:${AV_BUNDLE}" \ VERBOSE=1 @@ -52,8 +53,8 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \ -DALICEVISION_BUILD_DOC:BOOL=OFF \ -DALICEVISION_BUILD_EXAMPLES:BOOL=OFF \ "${AV_DEV}" && \ - make install -j"$(nproc)" && \ - rm -rf "${AV_BUILD}" "${AV_DEV}" && \ - echo "export ALICEVISION_SENSOR_DB=${AV_INSTALL}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh - -ENV ALICEVISION_ROOT=${AV_INSTALL} + make install -j"$(nproc)" && \ + make bundle && \ + rm -rf "${AV_BUILD}" "${AV_DEV}" && \ + echo "export ALICEVISION_SENSOR_DB=${AV_BUNDLE}/share/aliceVision/cameraSensors.db" >> /etc/profile.d/alicevision.sh && \ + echo "export ALICEVISION_ROOT=${AV_BUNDLE}" >> /etc/profile.d/alicevision.sh From 77bcf7b3cbaeea9af3de1fbb8646fa33dd791d96 Mon Sep 17 00:00:00 2001 From: demoulinv Date: Wed, 27 Apr 2022 10:56:49 +0200 Subject: [PATCH 9/9] [Write image] Avoid ACES or ACEScg conversion if NO_CONVERSION is specified for output color space. --- src/aliceVision/image/io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aliceVision/image/io.cpp b/src/aliceVision/image/io.cpp index d094423985..0b3b48b9df 100644 --- a/src/aliceVision/image/io.cpp +++ b/src/aliceVision/image/io.cpp @@ -523,7 +523,7 @@ void writeImage(const std::string& path, oiio::ImageBufAlgo::colorconvert(colorspaceBuf, *outBuf, "Linear", "sRGB"); outBuf = &colorspaceBuf; } - else if(imageColorSpace != EImageColorSpace::LINEAR) // ACES or ACEScg + else if((imageColorSpace != EImageColorSpace::LINEAR) && (imageColorSpace != EImageColorSpace::NO_CONVERSION)) // ACES or ACEScg { char const* val = getenv("ALICEVISION_ROOT"); if (val == NULL)