|
@@ -5,6 +5,7 @@
|
|
|
#include <tiffio.h>
|
|
|
#include <jpeglib.h>
|
|
|
#include <libexif/exif-data.h>
|
|
|
+#include <time.h>
|
|
|
#include "postprocess.h"
|
|
|
#include "stacker.h"
|
|
|
|
|
@@ -384,7 +385,7 @@ postprocess_internal(char *burst_dir, char *target_dir)
|
|
|
printf("No DNG files found\n");
|
|
|
exit(1);
|
|
|
}
|
|
|
- stacker_t *stacker = stacker_create();
|
|
|
+ stacker_t *stacker = stacker_create(1);
|
|
|
while (burst_size--) {
|
|
|
fprintf(stderr, "DEBAYER %s\n", namelist[burst_size]->d_name);
|
|
|
snprintf(path, sizeof(path), "%s/%s", burst_dir, namelist[burst_size]->d_name);
|
|
@@ -422,3 +423,50 @@ postprocess_internal(char *burst_dir, char *target_dir)
|
|
|
snprintf(stackpath, sizeof(stackpath), "%s.stacked.jpg", target_dir);
|
|
|
save_jpeg(stackpath, stacked_data, 90, exif);
|
|
|
}
|
|
|
+
|
|
|
+void
|
|
|
+postprocess_single(char *in_path, char *out_path, int quality, int verbose)
|
|
|
+{
|
|
|
+ libraw_processed_image_t *decoded;
|
|
|
+ libraw_processed_image_t *processed_data;
|
|
|
+ struct Imagedata imagedata;
|
|
|
+ ExifData *exif;
|
|
|
+ int width, height, result_size;
|
|
|
+ char *result;
|
|
|
+ clock_t timer;
|
|
|
+ stacker_t *stacker = stacker_create(verbose);
|
|
|
+
|
|
|
+ // Parse exif data from original file
|
|
|
+ timer = clock();
|
|
|
+ imagedata = read_exif(in_path);
|
|
|
+ exif = create_exif(imagedata);
|
|
|
+ if (verbose) {
|
|
|
+ printf("[%.1fms] %s\n", (float) (clock() - timer) / CLOCKS_PER_SEC * 1000, "exif read");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Convert the sensor data to rgb
|
|
|
+ timer = clock();
|
|
|
+ decoded = debayer_file(in_path);
|
|
|
+ if (verbose) {
|
|
|
+ printf("[%.1fms] %s\n", (float) (clock() - timer) / CLOCKS_PER_SEC * 1000, "debayer");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Run the opencv postprocessing on the single frame
|
|
|
+ result = stacker_postprocess(stacker, decoded->data, decoded->width, decoded->height);
|
|
|
+ width = stacker_get_width(stacker);
|
|
|
+ height = stacker_get_height(stacker);
|
|
|
+
|
|
|
+ // Export the final jpeg with the original exif data
|
|
|
+ timer = clock();
|
|
|
+ result_size = width * height * 3;
|
|
|
+ processed_data = (libraw_processed_image_t *) malloc(sizeof(libraw_processed_image_t) + result_size);
|
|
|
+ memset(processed_data, 0, sizeof(libraw_processed_image_t));
|
|
|
+ processed_data->colors = 3;
|
|
|
+ processed_data->width = decoded->width;
|
|
|
+ processed_data->height = decoded->height;
|
|
|
+ memmove(processed_data->data, result, result_size);
|
|
|
+ save_jpeg(out_path, processed_data, quality, exif);
|
|
|
+ if (verbose) {
|
|
|
+ printf("[%.1fms] %s\n", (float) (clock() - timer) / CLOCKS_PER_SEC * 1000, "export");
|
|
|
+ }
|
|
|
+}
|