|
|
@@ -7,6 +7,7 @@
|
|
7
|
7
|
#include <math.h>
|
|
8
|
8
|
|
|
9
|
9
|
#include "haader.h"
|
|
|
10
|
+#include "csv_reader.h"
|
|
10
|
11
|
|
|
11
|
12
|
#define max_number(a, b) (a) > (b) ? (a) : (b)
|
|
12
|
13
|
#define min_number(a, b) (a) < (b) ? (a) : (b)
|
|
|
@@ -343,11 +344,11 @@ bool HdrImageStack::read_from_files(char * const* file_paths, int number_of_path
|
|
343
|
344
|
return true;
|
|
344
|
345
|
}
|
|
345
|
346
|
|
|
346
|
|
-bool HdrImageStack::add_from_file_path(const char* file_path) {
|
|
|
347
|
+bool HdrImageStack::add_from_file_path(const char* file_path, double exposure_time) {
|
|
347
|
348
|
unsigned int i = m_images.size();
|
|
348
|
349
|
m_images.push_back(Image());
|
|
349
|
350
|
|
|
350
|
|
- if (m_images[i].read_from_file(file_path)) {
|
|
|
351
|
+ if (m_images[i].read_from_file(file_path, exposure_time)) {
|
|
351
|
352
|
cout << "Read \"" << file_path << "\"" << endl;
|
|
352
|
353
|
if (!m_images[0].has_equal_dimensions(m_images[i])) {
|
|
353
|
354
|
cerr << "HdrImageStack::add_from_file_path: Dimensions do not match (\""
|
|
|
@@ -372,6 +373,53 @@ bool HdrImageStack::add_from_file_path(const char* file_path) {
|
|
372
|
373
|
return true;
|
|
373
|
374
|
}
|
|
374
|
375
|
|
|
|
376
|
+struct CSVUserData {
|
|
|
377
|
+ bool ok;
|
|
|
378
|
+ HdrImageStack *stack;
|
|
|
379
|
+};
|
|
|
380
|
+
|
|
|
381
|
+static bool csv_row_callback(const CSVRow &row, void *userData) {
|
|
|
382
|
+ CSVUserData *cud = (CSVUserData*)userData;
|
|
|
383
|
+
|
|
|
384
|
+ string path;
|
|
|
385
|
+ double exposure_time = 0.0;
|
|
|
386
|
+
|
|
|
387
|
+ bool ok = row.getFieldAsString(0, &path);
|
|
|
388
|
+ ok = ok && row.getFieldAsDouble(1, &exposure_time);
|
|
|
389
|
+
|
|
|
390
|
+ if (ok) {
|
|
|
391
|
+ ok = ok && cud->stack->add_from_file_path(path.c_str(), exposure_time);
|
|
|
392
|
+ } else {
|
|
|
393
|
+ cout << "Failed to parse line " << row.getLineNumber() << endl;
|
|
|
394
|
+ }
|
|
|
395
|
+
|
|
|
396
|
+ if (!ok) {
|
|
|
397
|
+ cud->ok = false;
|
|
|
398
|
+ return false;
|
|
|
399
|
+ } else {
|
|
|
400
|
+ return true;
|
|
|
401
|
+ }
|
|
|
402
|
+}
|
|
|
403
|
+
|
|
|
404
|
+bool HdrImageStack::read_from_csv_file(const char* csv_path) {
|
|
|
405
|
+ string path(csv_path);
|
|
|
406
|
+
|
|
|
407
|
+ CSVUserData cud;
|
|
|
408
|
+ cud.ok = true;
|
|
|
409
|
+ cud.stack = this;
|
|
|
410
|
+
|
|
|
411
|
+ bool csv_ok = CSVReader::readFromFile(path, &csv_row_callback, &cud);
|
|
|
412
|
+
|
|
|
413
|
+ if (csv_ok && cud.ok) {
|
|
|
414
|
+ cout << "Successful read from " << csv_path << endl;
|
|
|
415
|
+ return true;
|
|
|
416
|
+ } else {
|
|
|
417
|
+ cout << "Failed to read from CSV " << csv_path << endl;
|
|
|
418
|
+ m_images.clear();
|
|
|
419
|
+ return false;
|
|
|
420
|
+ }
|
|
|
421
|
+}
|
|
|
422
|
+
|
|
375
|
423
|
bool HdrImageStack::get_average_image_slow(Image &output) {
|
|
376
|
424
|
if (m_images.size() == 0) {
|
|
377
|
425
|
return false;
|