Use libdng to parse the calibration file
This commit is contained in:
32
src/dcp.c
32
src/dcp.c
@@ -1,7 +1,9 @@
|
|||||||
#include "dcp.h"
|
#include "dcp.h"
|
||||||
|
|
||||||
|
#include <libdng.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -15,18 +17,18 @@ find_calibration_by_model(char *conffile, char *model, const char *sensor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check user overridden /etc/megapixels/config/%model,%sensor.dcp
|
// Check user overridden /etc/megapixels/config/%model,%sensor.dcp
|
||||||
sprintf(conffile,
|
sprintf(conffile, "%s/megapixels/config/%s,%s.dcp", "/etc", model, sensor);
|
||||||
"%s/megapixels/config/%s,%s.dcp",
|
|
||||||
"/etc",
|
|
||||||
model,
|
|
||||||
sensor);
|
|
||||||
if (access(conffile, F_OK) != -1) {
|
if (access(conffile, F_OK) != -1) {
|
||||||
printf("Found calibration file at %s\n", conffile);
|
printf("Found calibration file at %s\n", conffile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check packaged /usr/share/megapixels/config/%model,%sensor.ini
|
// Check packaged /usr/share/megapixels/config/%model,%sensor.ini
|
||||||
sprintf(conffile, "%s/megapixels/config/%s,%s.dcp", "/usr/share", model, sensor);
|
sprintf(conffile,
|
||||||
|
"%s/megapixels/config/%s,%s.dcp",
|
||||||
|
"/usr/share",
|
||||||
|
model,
|
||||||
|
sensor);
|
||||||
if (access(conffile, F_OK) != -1) {
|
if (access(conffile, F_OK) != -1) {
|
||||||
printf("Found calibration file at %s\n", conffile);
|
printf("Found calibration file at %s\n", conffile);
|
||||||
return true;
|
return true;
|
||||||
@@ -63,3 +65,21 @@ find_calibration(char *conffile, const char *sensor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct MPCameraCalibration
|
||||||
|
parse_calibration_file(const char *path)
|
||||||
|
{
|
||||||
|
struct MPCameraCalibration result;
|
||||||
|
libdng_info temp = { 0 };
|
||||||
|
libdng_new(&temp);
|
||||||
|
libdng_load_calibration_file(&temp, path);
|
||||||
|
|
||||||
|
memcpy(result.color_matrix_1, temp.color_matrix_1, 9 * sizeof(float));
|
||||||
|
memcpy(result.color_matrix_2, temp.color_matrix_2, 9 * sizeof(float));
|
||||||
|
memcpy(result.forward_matrix_1, temp.forward_matrix_1, 9 * sizeof(float));
|
||||||
|
memcpy(result.forward_matrix_2, temp.forward_matrix_2, 9 * sizeof(float));
|
||||||
|
result.tone_curve_length = temp.tone_curve_length;
|
||||||
|
memcpy(result.tone_curve,
|
||||||
|
temp.tone_curve,
|
||||||
|
temp.tone_curve_length * sizeof(float));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user