-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (64 loc) · 2.63 KB
/
Copy pathmain.cpp
File metadata and controls
79 lines (64 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <P1Image.hpp>
// basic file operations
#include <fstream>
#include <filesystem>
#include <nlohmann/json.hpp>
using namespace std;
using json = nlohmann::json;
int main(int argc, const char** argv)
{
if(argc != 3 ) {
cout << "2 argument must be provided to run the program.";
return -1;
}
// first argument is the json file
std::ifstream f(argv[1]);
// parse json file
json object = json::parse(f);
// build a json empty array
json outputJson;
outputJson = json::array();
for (auto& el : object["paths"].items())
{
string input = el.value()["input"];
string outputPendingTiff = el.value()["outputPendingTiff"];
try{
// Open an IIQ-file
P1::ImageSdk::RawImage iiq(input);
// Setup a convert config with the description about how to convert image into Rgb domain
P1::ImageSdk::ConvertConfig config;
config.SetOutputScale(1);
P1::ImageSdk::SetSensorProfilesLocation(getenv("P1SensorProfiles"));
P1::ImageSdk::BitmapImage bitmap = iiq.Convert(config);
// The resulting bitmap can now be stored to a tiff file.
P1::ImageSdk::TiffConfig tiff;
P1::ImageSdk::TiffWriter(outputPendingTiff, bitmap, iiq, tiff);
std::cout << "iiq to tiff conversion complete!" << std::endl;
// create an empty structure (null)
json fileDetails;
fileDetails["input"] = input;
fileDetails["outputPendingTiff"] = outputPendingTiff;
fileDetails["finalOutput"] = el.value()["finalOutput"]; // pass this along for next step
fileDetails["orderId"] = el.value()["orderId"]; // pass this along for next step
fileDetails["originalFilename"] = el.value()["originalFilename"]; // pass this along for next step
fileDetails["success"] = true;
outputJson.push_back(fileDetails);
} catch ( ... ) {
std::cout << "Error converting image from iiq to tiff" << std::endl;
// create an empty structure (null)
json fileDetails;
fileDetails["input"] = input;
fileDetails["outputPendingTiff"] = outputPendingTiff;
fileDetails["finalOutput"] = el.value()["finalOutput"]; // pass this along for next step
fileDetails["orderId"] = el.value()["orderId"]; // pass this along for next step
fileDetails["originalFilename"] = el.value()["originalFilename"]; // pass this along for next step
fileDetails["success"] = false;
outputJson.push_back(fileDetails);
};
}
// write json file
std::ofstream file(argv[2]);
file << outputJson;
return 0;
}