-
Notifications
You must be signed in to change notification settings - Fork 57
Add data-dir argument and auto matrix method #189
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
Add data-dir argument and auto matrix method #189
Conversation
mikaelsundell
commented
Sep 8, 2025
- Added --data-dir argument (Fixes add a command line parameter for the database search path #180)
- Added auto matrix method (Fixes Add "auto" matrix method and make it default. #181)
- Add size checks for lambda array assignments
| for ( int i = 0; i < 4; i++ ) | ||
| settings.WB_box[i] = 0; | ||
| } ); | ||
| if ( WB_box.size() == 4 ) |
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 check is not needed as it is performed inside of check_param, I assume you were fixing the crash we introduced recently, we do have a PR with a fix #186
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.
Yes, I was too fast — now removed.
| std::string data_dir = arg_parser["data-dir"].get(); | ||
| if ( data_dir.size() ) | ||
| { | ||
| OIIO::Strutil::split( data_dir, settings.database_directories, ":" ); |
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.
Will this work on windows? See the logic in database_paths(). Perhaps it would be better to pass this string as a parameter to database_paths() so all pass resolving logic is in one place.
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.
Fixed in latest commit.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (27.89%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #189 +/- ##
==========================================
- Coverage 74.40% 71.33% -3.07%
==========================================
Files 10 10
Lines 2227 2348 +121
Branches 292 311 +19
==========================================
+ Hits 1657 1675 +18
- Misses 570 673 +103
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
The new changes, along with a draft for verbose output, are ready for review. Once they are approved, I’ll add tests to improve coverage and address the Codecov report. |
include/rawtoaces/image_converter.h
Outdated
| /// Output flag that becomes true if no files were processed. | ||
| /// @result | ||
| /// true if all files were processed successfully, false otherwise. | ||
| bool process_batch( |
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 like all other changes, but I find this one questionable.
- Is this important enough to warrant an API change? It is just a loop, why can't it live on the client side?
- the name is misleading, it should be called
process_batches - the output
emptyflag looks kludgy for a public API
I prefer this logic being on the client side, because the user can decide how to treat failures - is it important that all files succeed? shall we continue if a file failed? does a failed file means the whole sequence is broken, or a single batch? All these decisions should be on the client side.
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.
Thanks, this is a very quick draft/ idea for discussion, in short, I moved it into the image converter to make it a part of the library (using settings.verbosity) etc. The empty flag is redundant as-is. Guess we would need to provide some sort of status per file after a run to make it work, let's drop the idea for now and let the client do all batch processing?
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.
Yes, let's drop it for now, we can return to this at a later stage. I'm anticipating the image processing pipeline being much longer in the future, with many more steps added. We may need to reconsider the error reporting and failure detection logic then. Please finish up the rest of the PR and we'll get it merged in.
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, you could argue for having a bit more output even when not calling -v, like at least giving info about the current file being processed. Right now it's silent except for OIIO output for debug builds.
See my other PR curretly open. I was adding those tests before I saw your PR. Just be mindfull of it. |
58263ff to
5e8f8ff
Compare
|
To get better test coverage are we using util_usage.cpp for matrix mode Auto and new data-dir arguments? The rest of the PR should be about verbose output. |
No, the util_usage.cpp is an example of using the new API, as it is very different from the old one. I linked it in the release notes. We just added it to the test suite to be sure it works. Any additional testing should be in proper unit-tests. |
|
we may want to rename it to |
|
@mikaelsundell could you please rebase from main and resolve conflicts |
5e8f8ff to
0471ab5
Compare
|
|
||
| for ( auto const &batch: batches ) | ||
| total_files += static_cast<int>( batch.size() ); | ||
|
|
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.
why not use size_t and avoid casting? this use case is exactly what size_t is for
| if ( settings.verbosity > 0 ) | ||
| { | ||
| std::cerr << "Input transform matrix:" << std::endl; | ||
| std::cerr << "Input Device Transform (IDT) matrix:" << 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.
The ACES group has stopped using the term IDT some time ago. I've been trying to minimise its usage here.
|
Looks good. Please don't forget to address your changes in README. |
|
|
| else | ||
| { | ||
| settings.database_directories = database_paths(); | ||
| } |
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.
there are unit tests now for list-cameras and list-illuminants. They are the only but maybe the easest way you can test functionality above. Tests currently setup test-dit location via env. You could have one more test for cameras with same exact logic, but setup path with --data-dir and it would test new branch above.
| << ( settings.create_dirs ? "yes" : "no" ) << std::endl; | ||
| std::cerr << " Verbosity: " << settings.verbosity << 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.
I feel line all this above can live in own private function. Takes settings in and prints it out. print_out_settings() or something.
| { | ||
| std::cerr << " Crop box: [" << settings.crop_box[0] << ", " | ||
| << settings.crop_box[1] << ", " << settings.crop_box[2] | ||
| << ", " << settings.crop_box[3] << "]" << 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.
check out OIIO::Strutil::join()
| if ( settings.matrix_method == Settings::MatrixMethod::Custom ) | ||
| { | ||
| std::cerr << " Custom matrix:" << std::endl; | ||
| for ( int i = 0; i < 3; i++ ) |
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.
/nit there is FORI(3) template available if you want
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.
Please don't. Let them die already.
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.
oh! I didn't know that's the direction we have. Sry, I don't have good feel for what's better, I thought it's short and neat. Let me kill the rest of them them, so it's not confusinb
| settings.WB_method == Settings::WBMethod::Illuminant; | ||
| bool spectral_matrix = | ||
| settings.matrix_method == Settings::MatrixMethod::Spectral; | ||
| bool spectral_matrix = matrix_method == Settings::MatrixMethod::Spectral; |
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.
/nit is_spectral_matrix? otherwise one might think it's spectral matrix itself
Though, I can see spectral_white_balance above already spoils my ask ha ha
include/rawtoaces/image_converter.h
Outdated
| /// use `Spectral`. | ||
| /// - Otherwise, fall back to `Metadata`. | ||
| /// The "auto" mode solves this by first attempting "spectral", and if no | ||
| /// spectral data is available for the camera, it falls back to "metadata". |
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.
/nit last two lines are repeating 2 lines before that.
|
I would leave them in the code, where it makes sense.
Yes, that is purely for unit-testing. No objection to moving to test. We should avoid duplicating things.
Yes, we should be reporting the errors regardless of the verbosity level. I have no strong opinion on reporting progress. If we could suppress the OIIO debug messages, that would be great. |
c432cb7 to
b8795cf
Compare
|
/nit
Was this required in this PR? I just worry it get's very big and I am not sure if there were any changes in those methods that got moved. Seems could have been own separate PR. |
|
"Yes, that is purely for unit-testing. No objection to moving to test. We should avoid duplicating things." The reordering was required to remove the private header (which belongs in tests). It’s not actually needed in core, it was just there to satisfy the tests. Removing it exposed an ordering issue: functions must be declared before they are used. ... and Yes, it could of course be its own PR, it just depends on where we want to spend our time :-) The project is still manageable, but I’d like to move on as quickly as possible to focus on the GUI and the actual RAW processing. Every PR/ change/ rebase is extra work to make sure it stays up to date with the changes in main. @antond-weta Please double-check the updated comments for calculate_daylight_SPD and calculate_blackbody_SPD. I first wrote my own version and then refined it with copilot. |
I agree with this. We should strive to have smaller PRs, which are easier to write, to review, and, probably the most important, to maintain the code afterwards. When you have a PR implementing 10 different things, the git history is essentially useless after squashing the commits.
Doesn't reordering also mean that we loose git history, or making using
This is exactly why you want several smaller PRs. The smaller the PR, the less the chance it will require any rebasing. Sure, it is a bit more work to create them, but then the amount of time saved for everyone involved is huge. This PR is actually a very good example - the amount of back and forth this has seen is ridiculous comparing to the amount of change it introduces. 3 separate PRs for each of the features would have been merged in long time ago, and had clean git history, and be easier to maintain for those who come after us. |
These already had comments on the public header, what am I missing? |
|
Ok, you win - 2 against 1! :-) |
ab3ba4f to
cbf17d2
Compare
|
@mikaelsundell it seems I can't merge this in. Could you please squash your commits on top of up-to-date main and force push again please. |
- Added --data-dir argument (Fixes AcademySoftwareFoundation#180) - Added auto matrix method (Fixes AcademySoftwareFoundation#181) Signed-off-by: Mikael Sundell <[email protected]>
cbf17d2 to
88a5f9b
Compare