]> mj.ucw.cz Git - libucw.git/blobdiff - images/image-dup-test.c
Added the local copy of the regex library back.
[libucw.git] / images / image-dup-test.c
index ef1e044d2427c368d5e0a05f28d87d3dd07bad4d..93fde378819e8573df42257a6fe7cb68fd65b775 100644 (file)
@@ -110,8 +110,10 @@ main(int argc, char **argv)
 #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;
 
@@ -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));
-
-  MSG("Similarity bitmap %02x", image_dup_compare(&dup1, &dup2, transformations | IMAGE_DUP_SCALE | IMAGE_DUP_WANT_ALL));
+  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);
+
+  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;