aboutsummaryrefslogtreecommitdiff
path: root/deduper/libpuzzle/src/regress_3.c
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-06 00:50:58 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-06 00:50:58 +0800
commited47c1557915bb2472f6959e723cd76155312a98 (patch)
tree85bc451630ebaa4f5ffce3043b4cbf948a912a66 /deduper/libpuzzle/src/regress_3.c
parent0a094f28c2e2ebfaac91398ae62e40f00f09221b (diff)
downloadoddities-ed47c1557915bb2472f6959e723cd76155312a98.tar.xz
Add deduper (unfinished tool for finding image duplicates).
Diffstat (limited to 'deduper/libpuzzle/src/regress_3.c')
-rw-r--r--deduper/libpuzzle/src/regress_3.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/deduper/libpuzzle/src/regress_3.c b/deduper/libpuzzle/src/regress_3.c
new file mode 100644
index 0000000..33698ba
--- /dev/null
+++ b/deduper/libpuzzle/src/regress_3.c
@@ -0,0 +1,35 @@
+#include "puzzle_common.h"
+#include "puzzle.h"
+
+#define PUZZLE_VECTOR_SLICE 0.6
+
+int main(void)
+{
+ PuzzleContext context;
+ PuzzleCvec cvec1, cvec2;
+ double d1, d2;
+
+ puzzle_init_context(&context);
+ puzzle_init_cvec(&context, &cvec1);
+ puzzle_init_cvec(&context, &cvec2);
+ if (puzzle_fill_cvec_from_file(&context, &cvec1,
+ "pics/pic-a-0.jpg") != 0) {
+ fprintf(stderr, "File 1 not found\n");
+ exit(0);
+ }
+ if (puzzle_fill_cvec_from_file(&context, &cvec2,
+ "pics/pic-a-1.jpg") != 0) {
+ fprintf(stderr, "File 2 not found\n");
+ exit(0);
+ }
+ d1 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 1);
+ d2 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 0);
+ printf("%g %g\n", d1, d2);
+ puzzle_free_cvec(&context, &cvec1);
+ puzzle_free_cvec(&context, &cvec2);
+ puzzle_free_context(&context);
+ if (d1 > PUZZLE_VECTOR_SLICE || d2 > PUZZLE_VECTOR_SLICE) {
+ return 2;
+ }
+ return 0;
+}