-
Notifications
You must be signed in to change notification settings - Fork 56
More refactoring and descriptions #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More refactoring and descriptions #185
Conversation
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 ) ); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
include/rawtoaces/image_converter.h
Outdated
bool collect_image_files( | ||
const std::string &path, std::vector<std::vector<std::string>> &batches ); | ||
|
||
struct CameraIdentifier |
There was a problem hiding this comment.
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?
include/rawtoaces/image_converter.h
Outdated
std::string model; | ||
|
||
CameraIdentifier() = default; | ||
CameraIdentifier( const std::string &_make, const std::string &_model ) |
There was a problem hiding this comment.
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 ) ); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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; | ||
} | ||
|
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
camera_make + "', model = '" + | ||
camera_model + "'"; | ||
camera_identifier.make + "', model = '" + | ||
camera_identifier.model + "'"; |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, put that back
There was a problem hiding this comment.
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: " |
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
Signed-off-by: Aleksandr Motsjonov <[email protected]>
…inants Signed-off-by: Aleksandr Motsjonov <[email protected]>
std::cerr << std::endl; | ||
std::cout << std::endl | ||
<< "The following illuminants are supported:" << std::endl | ||
<< OIIO::Strutil::join( illuminants, "\n" ) << std::endl; |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 ); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
* 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]>
No description provided.