X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fimage-dup-test.c;h=feece3d1fc7b3f91de3c29fb8e8fb9e098ba6d36;hb=e5d79225e3eef5c39be7f8e5006e331ed0f76f2f;hp=2695cd788f3e2401c31da067b431582307edfb4e;hpb=aafbea40b7613274180c8bab60012a0322f8d7dd;p=libucw.git diff --git a/images/image-dup-test.c b/images/image-dup-test.c index 2695cd78..feece3d1 100644 --- a/images/image-dup-test.c +++ b/images/image-dup-test.c @@ -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 +#include +#include +#include +#include +#include +#include #include #include @@ -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;