Skip to content

Commit 0b3db70

Browse files
authored
[api] switch to schema 1.0.0 (#221)
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
1 parent e830eea commit 0b3db70

File tree

9 files changed

+209
-188
lines changed

9 files changed

+209
-188
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ include(FetchContent)
127127
FetchContent_Declare(
128128
rawtoaces_data
129129
GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/rawtoaces-data
130-
GIT_TAG 4db0acc872965ecdbbf578664be20abf17c18e8c # v0.1.0
130+
GIT_TAG 265e0038826572439d23934120f4bc69c19933e3 # v1.0.0
131131
)
132132

133133
FetchContent_MakeAvailable(rawtoaces_data)

include/rawtoaces/spectral_data.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ struct SpectralData
100100
/// Header data
101101
std::string manufacturer;
102102
std::string model;
103-
std::string illuminant;
104-
std::string catalog_number;
103+
std::string type;
105104
std::string description;
106105
std::string document_creator;
107106
std::string unique_identifier;

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void generate_illuminant(
147147
SpectralData::SpectralChannel( "power", Spectrum( 0 ) ) );
148148
auto &power_spectrum = power_data.second;
149149

150-
illuminant.illuminant = type;
150+
illuminant.type = type;
151151
if ( is_daylight )
152152
{
153153
calculate_daylight_SPD( cct, power_spectrum );
@@ -335,7 +335,7 @@ bool SpectralSolver::find_illuminant( const std::string &type )
335335
{
336336
if ( !illuminant.load( illuminant_file ) )
337337
continue;
338-
if ( is_not_equal_insensitive( illuminant.illuminant, type ) )
338+
if ( is_not_equal_insensitive( illuminant.type, type ) )
339339
continue;
340340
return true;
341341
}
@@ -403,7 +403,7 @@ bool SpectralSolver::find_illuminant( const vector<double> &wb )
403403

404404
if ( verbosity > 1 )
405405
std::cerr << "The illuminant calculated to be the best match to the "
406-
<< "camera metadata is '" << illuminant.illuminant << "'."
406+
<< "camera metadata is '" << illuminant.type << "'."
407407
<< std::endl;
408408

409409
return true;

src/rawtoaces_core/spectral_data.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ bool SpectralData::load( const std::string &path, bool reshape )
183183
// Reset all in case the object has been initialised before.
184184
manufacturer.erase();
185185
model.erase();
186-
illuminant.erase();
187-
catalog_number.erase();
186+
type.erase();
188187
description.erase();
189188
document_creator.erase();
190189
unique_identifier.erase();
@@ -216,8 +215,7 @@ bool SpectralData::load( const std::string &path, bool reshape )
216215
nlohmann::json &h = file_data["header"];
217216
parse_string( h, manufacturer, "manufacturer" );
218217
parse_string( h, model, "model" );
219-
parse_string( h, illuminant, "illuminant" );
220-
parse_string( h, catalog_number, "catalog_number" );
218+
parse_string( h, type, "type" );
221219
parse_string( h, description, "description" );
222220
parse_string( h, document_creator, "document_creator" );
223221
parse_string( h, unique_identifier, "unique_identifier" );
@@ -227,6 +225,19 @@ bool SpectralData::load( const std::string &path, bool reshape )
227225
parse_string( h, comments, "comments" );
228226
parse_string( h, license, "license" );
229227

228+
// The schema version 1.0.0 replaces 'header/illuminant' with
229+
// 'header/type' in the illuminant files. If both are present, the type
230+
// takes precedence.
231+
if ( type.empty() )
232+
{
233+
std::string schema_version;
234+
parse_string( h, schema_version, "schema_version" );
235+
if ( schema_version == "0.1.0" )
236+
{
237+
parse_string( h, type, "illuminant" );
238+
}
239+
}
240+
230241
nlohmann::json &d = file_data["spectral_data"];
231242
parse_string( d, units, "units" );
232243
parse_string( d, reflection_geometry, "reflection_geometry" );

src/rawtoaces_util/image_converter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ bool prepare_transform_spectral(
344344

345345
if ( settings.verbosity > 0 )
346346
{
347-
std::cerr << "Found illuminant: '" << solver.illuminant.illuminant
348-
<< "'." << std::endl;
347+
std::cerr << "Found illuminant: '" << solver.illuminant.type << "'."
348+
<< std::endl;
349349
}
350350
}
351351
else
@@ -1180,7 +1180,7 @@ std::vector<std::string> ImageConverter::get_supported_illuminants() const
11801180
core::SpectralData data;
11811181
if ( data.load( file, false ) )
11821182
{
1183-
result.push_back( data.illuminant );
1183+
result.push_back( data.type );
11841184
}
11851185
}
11861186

tests/testIDT.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
void testIDT_LoadCameraSpst()
1919
{
2020
std::filesystem::path absolutePath =
21-
std::filesystem::absolute( DATA_PATH "camera/arri_d21_380_780_5.json" );
21+
std::filesystem::absolute( DATA_PATH "camera/ARRI_D21_380_780_5.json" );
2222

2323
rta::core::SpectralData camera;
2424
bool result;
2525

2626
result = camera.load( absolutePath.string() );
2727
OIIO_CHECK_ASSERT( result );
28-
OIIO_CHECK_EQUAL( camera.manufacturer, "arri" );
29-
OIIO_CHECK_EQUAL( camera.model, "d21" );
28+
OIIO_CHECK_EQUAL( camera.manufacturer, "ARRI" );
29+
OIIO_CHECK_EQUAL( camera.model, "D21" );
3030
OIIO_CHECK_EQUAL( camera.data.size(), 1 );
3131
OIIO_CHECK_EQUAL( camera.data.count( "main" ), 1 );
3232
OIIO_CHECK_EQUAL( camera.data.at( "main" ).size(), 3 );
@@ -163,7 +163,7 @@ void testIDT_LoadIlluminant()
163163
1.0000000000000
164164
};
165165

166-
OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
166+
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
167167
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );
168168

169169
vector<double> &illumTestData = illuminant["power"].values;
@@ -746,7 +746,7 @@ void testIDT_scaleLSC()
746746
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
747747

748748
rta::core::SpectralData camera;
749-
load_file( "camera/nikon_d200_380_780_5.json", camera );
749+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
750750

751751
scale_illuminant( camera, illuminant );
752752

@@ -777,7 +777,7 @@ void testIDT_scaleLSC()
777777
const vector<double> illumDataScaled = illuminant["power"].values;
778778

779779
OIIO_CHECK_EQUAL( illumDataScaled.size(), 81 );
780-
OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
780+
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
781781
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );
782782
for ( int i = 0; i < 81; i++ )
783783
OIIO_CHECK_EQUAL_THRESH( illumDataScaled[i], scaledIllum[i], 1e-5 );
@@ -789,7 +789,7 @@ void testIDT_CalCM()
789789
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
790790

791791
rta::core::SpectralData camera;
792-
load_file( "camera/arri_d21_380_780_5.json", camera );
792+
load_file( "camera/ARRI_D21_380_780_5.json", camera );
793793

794794
vector<double> CM_test = calculate_CM( camera, illuminant );
795795

@@ -805,7 +805,7 @@ void testIDT_CalWB()
805805
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
806806

807807
rta::core::SpectralData camera;
808-
load_file( "camera/nikon_d200_380_780_5.json", camera );
808+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
809809

810810
vector<double> WB_test = _calculate_WB( camera, illuminant );
811811

@@ -826,7 +826,7 @@ void testIDT_ChooseIllumSrc()
826826
solver.find_illuminant( wbv );
827827

828828
const auto &best_illuminant = solver.illuminant;
829-
string illumType_Test = best_illuminant.illuminant;
829+
string illumType_Test = best_illuminant.type;
830830
vector<double> illumData_Test = best_illuminant["power"].values;
831831

832832
double illumData[81] = {
@@ -864,7 +864,7 @@ void testIDT_ChooseIllumType()
864864
solver.calculate_WB();
865865

866866
const auto &best_illuminant = solver.illuminant;
867-
string illumType_Test = best_illuminant.illuminant;
867+
string illumType_Test = best_illuminant.type;
868868
vector<double> illumData_Test = best_illuminant["power"].values;
869869

870870
double illumData[81] = {
@@ -887,15 +887,15 @@ void testIDT_ChooseIllumType()
887887
0.1365548815
888888
};
889889

890-
OIIO_CHECK_EQUAL( illumType_Test, "iso7589" );
890+
OIIO_CHECK_EQUAL( illumType_Test, "ISO7589" );
891891
for ( size_t i = 0; i < illumData_Test.size(); i++ )
892892
OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 );
893893
}
894894

895895
void testIDT_CalTI()
896896
{
897897
rta::core::SpectralData camera;
898-
load_file( "camera/nikon_d200_380_780_5.json", camera );
898+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
899899

900900
rta::core::SpectralData illuminant;
901901
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
@@ -4809,7 +4809,7 @@ void testIDT_CalTI()
48094809
void testIDT_CalXYZ()
48104810
{
48114811
rta::core::SpectralData camera;
4812-
load_file( "camera/nikon_d200_380_780_5.json", camera );
4812+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
48134813

48144814
rta::core::SpectralData illuminant;
48154815
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
@@ -5024,7 +5024,7 @@ void testIDT_CalXYZ()
50245024
void testIDT_CalRGB()
50255025
{
50265026
rta::core::SpectralData camera;
5027-
load_file( "camera/nikon_d200_380_780_5.json", camera );
5027+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
50285028

50295029
rta::core::SpectralData illuminant;
50305030
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
@@ -5239,7 +5239,7 @@ void testIDT_CalRGB()
52395239
void testIDT_CurveFit()
52405240
{
52415241
rta::core::SpectralData camera;
5242-
load_file( "camera/nikon_d200_380_780_5.json", camera );
5242+
load_file( "camera/Nikon_D200_380_780_5.json", camera );
52435243

52445244
rta::core::SpectralData illuminant;
52455245
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );

tests/testIllum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void testIllum_readSPD()
5555
1.0000000000000
5656
};
5757

58-
OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
58+
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
5959
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );
6060

6161
vector<double> &illumTestData = illuminant["power"].values;

tests/test_SpectralData.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ void init_SpectralData( rta::core::SpectralData &data )
5555
{
5656
data.manufacturer = "manufacturer";
5757
data.model = "model";
58-
data.illuminant = "illuminant";
59-
data.catalog_number = "catalog_number";
58+
data.type = "type";
6059
data.description = "description";
6160
data.document_creator = "document_creator";
6261
data.unique_identifier = "unique_identifier";
@@ -84,8 +83,7 @@ void check_SpectralData( const rta::core::SpectralData &data )
8483
{
8584
OIIO_CHECK_EQUAL( data.manufacturer, "manufacturer" );
8685
OIIO_CHECK_EQUAL( data.model, "model" );
87-
OIIO_CHECK_EQUAL( data.illuminant, "illuminant" );
88-
OIIO_CHECK_EQUAL( data.catalog_number, "catalog_number" );
86+
OIIO_CHECK_EQUAL( data.type, "type" );
8987
OIIO_CHECK_EQUAL( data.description, "description" );
9088
OIIO_CHECK_EQUAL( data.document_creator, "document_creator" );
9189
OIIO_CHECK_EQUAL( data.unique_identifier, "unique_identifier" );
@@ -126,15 +124,15 @@ void testSpectralData_Properties()
126124
void testSpectralData_LoadSpst()
127125
{
128126
std::filesystem::path absolutePath =
129-
std::filesystem::absolute( DATA_PATH "camera/arri_d21_380_780_5.json" );
127+
std::filesystem::absolute( DATA_PATH "camera/ARRI_D21_380_780_5.json" );
130128

131129
rta::core::SpectralData camera;
132130
bool result;
133131

134132
result = camera.load( absolutePath.string() );
135133
OIIO_CHECK_ASSERT( result );
136-
OIIO_CHECK_EQUAL( camera.manufacturer, "arri" );
137-
OIIO_CHECK_EQUAL( camera.model, "d21" );
134+
OIIO_CHECK_EQUAL( camera.manufacturer, "ARRI" );
135+
OIIO_CHECK_EQUAL( camera.model, "D21" );
138136
OIIO_CHECK_EQUAL( camera.data.size(), 1 );
139137
OIIO_CHECK_EQUAL( camera.data.count( "main" ), 1 );
140138
OIIO_CHECK_EQUAL( camera.data.at( "main" ).size(), 3 );

0 commit comments

Comments
 (0)