X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=images%2Fimage-dup-test.c;h=93fde378819e8573df42257a6fe7cb68fd65b775;hb=c4bf633211b0424492b5a3937d6a6d2e0d79a4cf;hp=2695cd788f3e2401c31da067b431582307edfb4e;hpb=d60ede19ab84382101d313e3185b1a0ef6714088;p=libucw.git diff --git a/images/image-dup-test.c b/images/image-dup-test.c index 2695cd78..93fde378 100644 --- a/images/image-dup-test.c +++ b/images/image-dup-test.c @@ -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;