]> mj.ucw.cz Git - libucw.git/blobdiff - images/image-dup-test.c
Updated TODO
[libucw.git] / images / image-dup-test.c
index cbd37e5a89e5b00eaff3c62a546f8614fa54a73c..feece3d1fc7b3f91de3c29fb8e8fb9e098ba6d36 100644 (file)
@@ -7,13 +7,13 @@
  *     of the GNU General Public License.
  */
 
-#include "lib/lib.h"
-#include "lib/getopt.h"
-#include "lib/fastbuf.h"
-#include "lib/mempool.h"
-#include "images/images.h"
-#include "images/color.h"
-#include "images/duplicates.h"
+#include <ucw/lib.h>
+#include <ucw/getopt.h>
+#include <ucw/fastbuf.h>
+#include <ucw/mempool.h>
+#include <images/images.h>
+#include <images/color.h>
+#include <images/duplicates.h>
 
 #include <stdlib.h>
 #include <fcntl.h>
@@ -46,7 +46,7 @@ static struct option longopts[] =
   { "transormations",  0, 0, 't' },
   { NULL,              0, 0, 0 }
 };
-                                                         
+
 static uns verbose = 1;
 static byte *file_name_1;
 static byte *file_name_2;
@@ -55,7 +55,7 @@ static enum image_format format_2;
 static struct color background_color;
 static uns transformations = IMAGE_DUP_TRANS_ALL;
 
-#define MSG(x...) do{ if (verbose) log(L_INFO, ##x); }while(0)
+#define MSG(x...) do{ if (verbose) msg(L_INFO, ##x); }while(0)
 
 int
 main(int argc, char **argv)
@@ -106,12 +106,14 @@ main(int argc, char **argv)
     usage();
   file_name_1 = argv[optind++];
   file_name_2 = argv[optind];
-  
+
 #define TRY(x) do{ if (!(x)) exit(1); }while(0)
   MSG("Initializing image library");
   struct image_context ctx;
+  struct image_dup_context idc;
   struct image_io io;
   image_context_init(&ctx);
+  image_dup_context_init(&ctx, &idc);
 
   struct image *img1, *img2;
 
@@ -129,7 +131,7 @@ main(int argc, char **argv)
   bclose(io.fastbuf);
   img1 = io.image;
   MSG("Image size=%ux%u", img1->cols, img1->rows);
-  
+
   image_io_reset(&io);
   MSG("Reading %s", file_name_2);
   io.fastbuf = bopen(file_name_2, O_RDONLY, 1 << 18);
@@ -146,18 +148,26 @@ main(int argc, char **argv)
   image_io_cleanup(&io);
   MSG("Image size=%ux%u", img2->cols, img2->rows);
 
-  struct image_dup dup1, dup2;
+  struct image_dup *dup1, *dup2;
   struct mempool *pool = mp_new(1 << 18);
   MSG("Creating internal structures");
-  TRY(image_dup_init(&ctx, &dup1, img1, pool));
-  TRY(image_dup_init(&ctx, &dup2, img2, pool));
+  dup1 = mp_start(pool, image_dup_estimate_size(img1->cols, img1->rows, 1, idc.qtree_limit));
+  uns size = image_dup_new(&idc, img1, dup1, 1);
+  TRY(size);
+  mp_end(pool, (void *)dup1 + size);
+  dup2 = mp_start(pool, image_dup_estimate_size(img2->cols, img2->rows, 1, idc.qtree_limit));
+  size = image_dup_new(&idc, img2, dup2, 1);
+  TRY(size);
+  mp_end(pool, (void *)dup2 + size);
 
-  MSG("Similarity bitmap %02x", image_dup_compare(&dup1, &dup2, transformations | IMAGE_DUP_SCALE | IMAGE_DUP_WANT_ALL));
+  idc.flags = transformations | IMAGE_DUP_SCALE | IMAGE_DUP_WANT_ALL;
+  MSG("Similarity bitmap %02x", image_dup_compare(&idc, dup1, dup2));
 
   mp_delete(pool);
-  
+
   image_destroy(img1);
   image_destroy(img2);
+  image_dup_context_cleanup(&idc);
   image_context_cleanup(&ctx);
   MSG("Done.");
   return 0;