../src/yuv.c \
../src/mark.c \
../src/process.c \
+ ../src/settings.c \
image.c \
palette.c \
timeline.c \
colorize.c \
diag_bc.c \
- level.c \
+ diag_level.c \
fill.c \
buttons/b_size_1.c buttons/b_size_3.c buttons/b_size_5.c buttons/b_size_9.c \
buttons/b_size_11.c buttons/b_size_19.c buttons/b_move.c buttons/b_pick.c \
#include <unistd.h>
#include <math.h>
#include "main.h"
-#include "level.h"
+#include "diag_level.h"
#include "../src/mark.h"
#include "../src/yuv.h"
#include "palette.h"
#include "timeline.h"
#include "colorize.h"
#include "diag_bc.h"
-#include "level.h"
+#include "diag_level.h"
#include "fill.h"
#ifdef WITH_OPENCV
#include "diag_flow.h"
#include "timeline.h"
#include "colorize.h"
#include "diag_bc.h"
-#include "level.h"
+#include "diag_level.h"
#include "fill.h"
#ifdef WITH_OPENCV
#include "diag_flow.h"
static void save_event(gpointer priv)
{
+ anything_modified = 1;
timeline_select_and_save(timeline_selected, timeline_selected);
}
#include "image.h"
#include "main.h"
#include "palette.h"
+#include "../src/settings.h"
#include "../src/dir_seperator.h"
#ifdef WITH_OPENCV
#include "../src/opticalflow.h"
if (frame_list) {
int i;
+ load_settings(frame_list[0].filename);
load_palette(frame_list[0].filename);
for (i = 0; i < 255; i++)
update_color(i);
-#ifdef WITH_OPENCV
- load_flow(frame_list[0].filename);
-#endif
}
}
if (frame_list) {
save_palette(frame_list[0].filename);
-#ifdef WITH_OPENCV
if (timeline_frames > 1)
- save_flow(frame_list[0].filename);
+ save_settings(frame_list[0].filename);
save_sequence();
-#endif
}
}
#include "timeline.h"
#include "colorize.h"
#include "diag_bc.h"
-#include "level.h"
+#include "diag_level.h"
#include "fill.h"
#ifdef WITH_OPENCV
#include "diag_flow.h"
colorize_SOURCES = \
colorize.c \
+ settings.c \
process.c \
img.c \
yuv.c \
#include "yuv.h"
#include "mark.h"
#include "process.h"
+#include "settings.h"
#include "dir_seperator.h"
#ifdef WITH_OPENCV
#include "opticalflow.h"
}
#ifdef WITH_OPENCV
// load flow settings
- if (sequence && optical_flow) {
+ if (sequence && optical_flow)
flow_default();
- load_flow(first_filename);
+#endif
+ load_settings(first_filename);
+#ifdef WITH_OPENCV
+ // load flow settings
+ if (sequence && optical_flow) {
if (flow_enable == 0 && (test == FLOW_NEXT || test == FLOW_PREV)) {
fprintf(stderr, "Cannot test optical flow, because it is not enabled by GUI.\n");
exit (0);
}
for (i = 0; i < 255; i++)
fprintf(fp, "%03d %03d %03d \"%s\" %f %f %f\n", mark_palette[i].r, mark_palette[i].g, mark_palette[i].b, mark_palette[i].name, mark_palette[i].bright, mark_palette[i].contrast, mark_palette[i].alpha);
- fprintf(fp, "blacklevel %f\n", black_level);
- fprintf(fp, "whitelevel %f\n", white_level);
- fprintf(fp, "fadelevel %f\n", fade_level);
- fprintf(fp, "yuv_mod %d\n", yuv_mod);
fclose(fp);
}
if (line[0]) line[strlen(line)-1] = '\0';
if (line[0] && line[strlen(line)-1] == '\r') line[strlen(line)-1] = '\0';
- /* check for special attrs */
- if (!strncmp(line, "blacklevel ", 11)) {
- p = line + 11;
- sscanf(p, "%lf", &black_level);
- continue;
- }
- if (!strncmp(line, "whitelevel ", 11)) {
- p = line + 11;
- sscanf(p, "%lf", &white_level);
- continue;
- }
- if (!strncmp(line, "fadelevel ", 10)) {
- p = line + 10;
- sscanf(p, "%lf", &fade_level);
- continue;
- }
- if (!strncmp(line, "yuv_mod ", 8)) {
- p = line + 8;
- sscanf(p, "%d", &yuv_mod);
- continue;
- }
-
/* read palette */
if (i == 256)
break;
flow_view_uv = 0; /* disabled */
}
-/* save flow setting */
-void save_flow(const char *filename)
-{
- char name[256];
- FILE *fp;
-
- sprintf(name, "%s_opticalflow", filename);
- fp = fopen(name, "w");
- if (!fp) {
- printf("failed to save flow setting '%s'\n", name);
- return;
- }
- fprintf(fp, "flow_enable %d\n", flow_enable);
- fprintf(fp, "flow_window %d\n", flow_window);
- fprintf(fp, "flow_view_vector %d\n", flow_view_vector);
- fprintf(fp, "flow_view_uv %d\n", flow_view_uv);
- fclose(fp);
-}
-
-/* load flow setting */
-int load_flow(const char *filename)
-{
- char name[256];
- char line[256],*p;
- FILE *fp;
- int i;
-
- sprintf(name, "%s_opticalflow", filename);
- fp = fopen(name, "r");
- if (!fp) {
- printf("flow setting '%s' does not (yet) exists\n", name);
- return -1;
- }
- for (i = 0; ; i++) {
- if (!fgets(line, sizeof(line), fp))
- break;
- line[sizeof(line)-1] = '\0';
- if (line[0]) line[strlen(line)-1] = '\0';
- if (line[0] && line[strlen(line)-1] == '\r') line[strlen(line)-1] = '\0';
-
- if (!strncmp(line, "flow_enable ", 12)) {
- p = line + 12;
- sscanf(p, "%d", &flow_enable);
- continue;
- }
- if (!strncmp(line, "flow_window ", 12)) {
- p = line + 12;
- sscanf(p, "%d", &flow_window);
- continue;
- }
- if (!strncmp(line, "flow_view_vector ", 17)) {
- p = line + 17;
- sscanf(p, "%d", &flow_view_vector);
- continue;
- }
- if (!strncmp(line, "flow_view_uv ", 13)) {
- p = line + 13;
- sscanf(p, "%d", &flow_view_uv);
- continue;
- }
- }
- fclose(fp);
- return 0;
-}
-
/* draw flow matrix as lines */
static void draw_lines_from_matrix(CvMat *flow, int width, int height, int steps, int color, IplImage *image)
{
extern int flow_enable, flow_window, flow_levels, flow_iter, flow_view_vector, flow_view_uv;
void flow_default(void);
-void save_flow(const char *filename);
-int load_flow(const char *filename);
void *create_flow_maps(const double *img_prev_buffer, const double *img_next_buffer, const double *img_buffer, int width, int height, int win_size, int steps, double *flow_map_x_prev, double *flow_map_y_prev, double *flow_map_x_next, double *flow_map_y_next, void *_image_preview);
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "mark.h"
+#include "opticalflow.h"
+#include "yuv.h"
+#include "settings.h"
+
+enum setting_type {
+ SETTING_DOUBLE,
+ SETTING_INT,
+};
+
+struct settings {
+ const char *keyword;
+ enum setting_type type;
+ void *variable;
+};
+
+static struct settings settings[] = {
+ { "blacklevel", SETTING_DOUBLE, &black_level },
+ { "whitelevel", SETTING_DOUBLE, &white_level },
+ { "fadelevel", SETTING_DOUBLE, &fade_level },
+ { "yuv_mod", SETTING_INT, &yuv_mod },
+#ifdef WITH_OPENCV
+ { "flow_enable", SETTING_INT, &flow_enable },
+ { "flow_window", SETTING_INT, &flow_window },
+ { "flow_view_vector", SETTING_INT, &flow_view_vector },
+ { "flow_view_uv", SETTING_INT, &flow_view_uv },
+#endif
+ { NULL, 0, NULL }
+};
+
+/* save settings */
+void save_settings(const char *filename)
+{
+ char name[256];
+ FILE *fp;
+ int i;
+
+ sprintf(name, "%s_settings", filename);
+ fp = fopen(name, "w");
+ if (!fp) {
+ printf("failed to save settings '%s'\n", name);
+ return;
+ }
+ for (i = 0; settings[i].keyword; i++) {
+ switch (settings[i].type) {
+ case SETTING_DOUBLE:
+ fprintf(fp, "%s %f\n", settings[i].keyword, *((double *)settings[i].variable));
+ break;
+ case SETTING_INT:
+ fprintf(fp, "%s %d\n", settings[i].keyword, *((int *)settings[i].variable));
+ break;
+ }
+ }
+ fclose(fp);
+}
+
+/* load settings */
+int _load_settings(const char *filename, const char *suffix)
+{
+ char name[256];
+ char line[256], *p;
+ FILE *fp;
+ int i;
+ int rc = 0;
+
+ sprintf(name, "%s_%s", filename, suffix);
+ fp = fopen(name, "r");
+ if (!fp) {
+ return -1;
+ }
+ while (fgets(line, sizeof(line), fp)) {
+ line[sizeof(line)-1] = '\0';
+ if (line[0]) line[strlen(line)-1] = '\0';
+ if (line[0] && line[strlen(line)-1] == '\r') line[strlen(line)-1] = '\0';
+
+ for (i = 0; settings[i].keyword; i++) {
+ if (!!strncmp(line, settings[i].keyword, strlen(settings[i].keyword)))
+ continue;
+ if (line[strlen(settings[i].keyword)] != ' ')
+ continue;
+ p = line + strlen(settings[i].keyword) + 1;
+ switch (settings[i].type) {
+ case SETTING_DOUBLE:
+ sscanf(p, "%lf", (double *)settings[i].variable);
+ rc = 1;
+ break;
+ case SETTING_INT:
+ sscanf(p, "%d", (int *)settings[i].variable);
+ rc = 1;
+ break;
+ }
+ }
+ }
+ fclose(fp);
+
+ return rc;
+}
+
+int load_settings(const char *filename)
+{
+ int rc;
+
+ rc = _load_settings(filename, "palette");
+ if (rc > 0) {
+ printf("Keywords in file '%s_palette' have moved. After saving, they are moved to *_settings.\n", filename);
+ }
+#ifdef WITH_OPENCV
+ rc = _load_settings(filename, "opticalflow");
+ if (rc >= 0) {
+ printf("File '%s_opticalflow' is obsolete. After saving, keywords are moved to *_settings and you can remove it.\n", filename);
+ }
+#endif
+ rc = _load_settings(filename, "settings");
+
+ return rc;
+}
--- /dev/null
+void save_settings(const char *filename);
+int load_settings(const char *filename);
+