Skip to content

Conversation

soswow
Copy link
Contributor

@soswow soswow commented Sep 5, 2025

No description provided.

Signed-off-by: Aleksandr Motsjonov <[email protected]>
"raw:pre_mul",
OIIO::TypeDesc( OIIO::TypeDesc::FLOAT, 4 ) );
OIIO::TypeDesc(
OIIO::TypeDesc::FLOAT, OIIO::TypeDesc::AGGREGATE::VEC4 ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice use of enums for some of them (OIIO::TypeDesc::AGGREGATE::VEC4)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

killed it. 4 is cleaner

}
else
{
on_success(); // TODO Verify with Anton.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO Verify that lack of on_success in this return true case was a bug or intentional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I can't remember the logic there. Should have put a comment. Could you try reproducing visiting that branch? Also, probably checking the size in the branch above where return true; is not necessary anymore, as ArgParse should enforce that.

}
return keys;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something. Not sure if there is an easier way of extracting keys from a Map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough. there is a simpler way in c++20, but we're not there yet

alternatively, you could use 2 separate vectors for your keys and values.

keep in mind that the map stores the data sorted. not a big problem, but you may get the "custom" listed first, not last.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

killing it anyway.

<< "'. The following methods are supported: '"
<< OIIO::Strutil::join( get_map_keys( wb_methods ), "', '" )
<< "'." << std::endl;
return false;
Copy link
Contributor Author

@soswow soswow Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two improvements in one. No need for repeating code in if/else + listing available options in error.
Integrating it with actuall help message might be even better.

<< "provided. D55 will be used as default." << std::endl;

std::string default_illuminant = "D55";
settings.illuminant = default_illuminant;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just replacing a comment with a named variable.

const OIIO::TypeDesc int_vec4_type_desc(
OIIO::TypeDesc::INT, OIIO::TypeDesc::AGGREGATE::VEC4 );
const OIIO::TypeDesc float_vec2_type_desc(
OIIO::TypeDesc::FLOAT, OIIO::TypeDesc::AGGREGATE::VEC2 );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO Eithe rmove it up top outside all methods and use them in other methods or use inline in all the places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just don't. I'd rather see the type on the line I'm working on, rather than have to search for it. this saves 5 lines of code by making it harder to read.

bool collect_image_files(
const std::string &path, std::vector<std::vector<std::string>> &batches );

struct CameraIdentifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Can this live in the .cpp?

std::string model;

CameraIdentifier() = default;
CameraIdentifier( const std::string &_make, const std::string &_model )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this constructor is not strictly needed, you can initialise the struct members directly
camera_identifier = { "ARRI", "too_expensive_for_me" };

auto matrix2_attr = image_spec.find_attribute(
key2,
OIIO::TypeDesc(
OIIO::TypeDesc::FLOAT, OIIO::TypeDesc::AGGREGATE::MATRIX44 ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you confirmed that this works? that float[4][4] has the correct order of items when read from float[16]? A zero or identity matrix is not a sufficient test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Am killing this anyway, but I thought this is just a fency variable that holds value 16

enum AGGREGATE {
        SCALAR   =  1,  ///< A single scalar value (such as a raw `int` or
                        ///<   `float` in C).  This is the default.
        VEC2     =  2,  ///< 2 values representing a 2D vector.
        VEC3     =  3,  ///< 3 values representing a 3D vector.
        VEC4     =  4,  ///< 4 values representing a 4D vector.
        MATRIX33 =  9,  ///< 9 values representing a 3x3 matrix.
        MATRIX44 = 16   ///< 16 values representing a 4x4 matrix.
    };

}
else
{
on_success(); // TODO Verify with Anton.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I can't remember the logic there. Should have put a comment. Could you try reproducing visiting that branch? Also, probably checking the size in the branch above where return true; is not necessary anymore, as ArgParse should enforce that.

}
return keys;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough. there is a simpler way in c++20, but we're not there yet

alternatively, you could use 2 separate vectors for your keys and values.

keep in mind that the map stores the data sorted. not a big problem, but you may get the "custom" listed first, not last.

settings.WB_method = Settings::WBMethod::Custom;
}
else
static std::map<std::string, Settings::WBMethod> wb_methods = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want it to const as well

const OIIO::TypeDesc int_vec4_type_desc(
OIIO::TypeDesc::INT, OIIO::TypeDesc::AGGREGATE::VEC4 );
const OIIO::TypeDesc float_vec2_type_desc(
OIIO::TypeDesc::FLOAT, OIIO::TypeDesc::AGGREGATE::VEC2 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just don't. I'd rather see the type on the line I'm working on, rather than have to search for it. this saves 5 lines of code by making it harder to read.

Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
camera_make + "', model = '" +
camera_model + "'";
camera_identifier.make + "', model = '" +
camera_identifier.model + "'";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we'll end up having to print out make='Sony', model='who_cares' in more than just this place, especially in higher verbosity modes. You may want to move this to CameraIdentifier.description(), or CameraIdentifier.to_string()

auto demosaic_algorithm = arg_parser["demosaic"].get();
static std::set<std::string> demosaic_algorithms = {
auto demosaic = arg_parser["demosaic"].get();
static std::set<std::string> demosaic_algos = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, put that back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. that was accedental.

<< ". The following methods are supported: "
<< "ERROR: unsupported demosaicing algorithm '" << demosaic
<< "'. "
<< "The following algorithms are supported: "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is a good spot to use join()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

return std::find( vec.begin(), vec.end(), value ) != vec.end();
}

static std::vector<std::string> supported_wb_methods = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have put these static methods inside the Settings, close to there the enums are defined.

Or try something like this https://stackoverflow.com/a/31836401

std::cerr << std::endl;
std::cout << std::endl
<< "The following illuminants are supported:" << std::endl
<< OIIO::Strutil::join( illuminants, "\n" ) << std::endl;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found this other place wher join can be used

std::cout << std::endl
<< "The following illuminants are supported:" << std::endl
<< OIIO::Strutil::join( illuminants, "\n" ) << std::endl;
exit( 0 );
Copy link
Contributor Author

@soswow soswow Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes the problem of showing help message for these two commands. Returning false would cause for programm to exit with 1 in main, which semantically incorrect.

camera_make + "', model = '" +
camera_model + "'";
const std::string data_type =
"spectral data for camera " + camera_identifier;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested, I've implemented toString operator in CameraIdentifier

operator+( const std::string &lhs, const CameraIdentifier &rhs )
{
return lhs + static_cast<std::string>( rhs );
}
Copy link
Contributor Author

@soswow soswow Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't claim I know how it's done in c++. That's what I came up with so I can do "mystring" + this_object. I believe it would need smth like

// Stream insertion operator
    friend std::ostream& operator<<(std::ostream& os, const CameraIdentifier& camera) {
        return os << camera.make << " " << camera.model;
    }

if we want to use it in "some string" << this_object scenario. But I am not adding it now

Copy link
Contributor

@antond-weta antond-weta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@antond-weta antond-weta merged commit 5bf5db5 into AcademySoftwareFoundation:main Sep 6, 2025
13 checks passed
mangopep pushed a commit to mangopep/rawtoaces that referenced this pull request Sep 10, 2025
* More refactoring and descriptions

Signed-off-by: Aleksandr Motsjonov <[email protected]>

* PR review comments address

Signed-off-by: Aleksandr Motsjonov <[email protected]>

* changes to be deleted in next commit

Signed-off-by: Aleksandr Motsjonov <[email protected]>

* revert to good old copy paste and simpler code

Signed-off-by: Aleksandr Motsjonov <[email protected]>

* More PR comment address

Signed-off-by: Aleksandr Motsjonov <[email protected]>

* Fix bug where help is printed out for --list-cameras and --list-illuminants

Signed-off-by: Aleksandr Motsjonov <[email protected]>

---------

Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Savitha M <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants