From a6763c4878275c1d2884bd83a07ec9de4a1c975d Mon Sep 17 00:00:00 2001 From: fatboab Date: Thu, 5 Nov 2015 22:54:20 +0000 Subject: [PATCH 01/15] Correct spellink... --- Sources/Templates/Template.c | 4 ++-- Sources/Templates/Template.h | 4 ++-- Sources/Tests/EndToEnd/Test_EndToEnd.c | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index cf0ac0a..01409d4 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -3,7 +3,7 @@ #include #include -void Template_AddMinuitia(Template *template, TemplateMinutia *minutia) +void Template_AddMinutia(Template *template, TemplateMinutia *minutia) { List_AddData(&(template->minutiae), minutia); } @@ -13,7 +13,7 @@ List *Template_GetMinutiae(Template *template) return &template->minutiae; } -Template Template_Constuct() +Template Template_Construct() { Template template; template.originalDpi = 0; diff --git a/Sources/Templates/Template.h b/Sources/Templates/Template.h index 8477ede..ac6129f 100644 --- a/Sources/Templates/Template.h +++ b/Sources/Templates/Template.h @@ -13,8 +13,8 @@ typedef struct Template List minutiae; } Template; -Template Template_Constuct(void); -void Template_AddMinuitia(Template *, TemplateMinutia *); +Template Template_Construct(void); +void Template_AddMinutia(Template *, TemplateMinutia *); void Template_Free(Template *); #endif diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c index ec703c1..e49ff3f 100644 --- a/Sources/Tests/EndToEnd/Test_EndToEnd.c +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -59,7 +59,7 @@ static void ReadTemplate(const char *expectedFileName, Template *expectedTemplat ret = fread(&(minutia->type), sizeof(int32_t), 1, f); TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed on minutia->type"); - Template_AddMinuitia(expectedTemplate, minutia); + Template_AddMinutia(expectedTemplate, minutia); } /* Check end of file */ @@ -72,7 +72,6 @@ static void ReadTemplate(const char *expectedFileName, Template *expectedTemplat assert(ret != EOF); } - static void UnityFreeTemplate(Template *template) { while (List_GetCount(&template->minutiae) > 0) @@ -92,8 +91,8 @@ static void ImageToTemplate(const char *inputFileName, const char *expectedFileN perfdata perfdata; - Template template = Template_Constuct(); - Template expectedTemplate = Template_Constuct(); + Template template = Template_Construct(); + Template expectedTemplate = Template_Construct(); printf("%s %s\r\n", inputFileName, expectedFileName); @@ -134,7 +133,6 @@ static void ImageToTemplate(const char *inputFileName, const char *expectedFileN printf("Missing from expected = %d%%\n", missingFromExpected.count * 100 / expectedTemplate.minutiae.count); } - UnityFreeTemplate(&template); UnityFreeTemplate(&expectedTemplate); } From a99bca6d18d8fb7ca316cea28b553b920f8a2ea8 Mon Sep 17 00:00:00 2001 From: fatboab Date: Thu, 5 Nov 2015 22:57:57 +0000 Subject: [PATCH 02/15] Start on ISO/IEC 19794-2:2005 template support. --- Sources/Makefile | 1 + Sources/Templates/TemplateIO.c | 109 ++++++++++++++++++ Sources/Templates/TemplateIO.h | 8 ++ .../Tests/Templates/TestRunner_Templates.c | 7 ++ Sources/Tests/Templates/Test_Templates.c.c | 24 ++++ Sources/Tests/all_tests.c | 7 +- 6 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 Sources/Templates/TemplateIO.c create mode 100644 Sources/Templates/TemplateIO.h create mode 100644 Sources/Tests/Templates/TestRunner_Templates.c create mode 100644 Sources/Tests/Templates/Test_Templates.c.c diff --git a/Sources/Makefile b/Sources/Makefile index bc529c5..604a0a3 100644 --- a/Sources/Makefile +++ b/Sources/Makefile @@ -58,6 +58,7 @@ UTEST_SRCS = General/*.c General/runners/*.c \ Extraction/Filters/*.c Extraction/Filters/runners/*.c \ DataStructures/*.c \ EndToEnd/*.c \ + Templates/*.c \ Matcher/*.c Matcher/runners/*.c UTEST_SRCS_EXCLUDE = diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c new file mode 100644 index 0000000..815b5dd --- /dev/null +++ b/Sources/Templates/TemplateIO.c @@ -0,0 +1,109 @@ +// +// Created by bob.arnott on 11/5/2015. +// + +#include "General/Calc.h" +#include "Templates/TemplateIO.h" + +#include +#include + +// Format (all numbers are big-endian): +// 4B magic "FMR\0" +// 4B version (ignored, set to " 20\0" +// 4B total length (including header) +// 2B rubbish (zeroed) +// 2B image size in pixels X +// 2B image size in pixels Y +// 2B rubbish (pixels per cm X, set to 196 = 500dpi) +// 2B rubbish (pixels per cm Y, set to 196 = 500dpi) +// 1B rubbish (number of fingerprints, set to 1) +// 1B rubbish (zeroed) +// 1B rubbish (finger position, zeroed) +// 1B rubbish (zeroed) +// 1B rubbish (fingerprint quality, set to 100) +// 1B minutia count +// N*6B minutiae +// 2B minutia position X in pixels +// 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other) +// 2B minutia position Y in pixels (upper 2b ignored, zeroed) +// 1B direction, compatible with SourceAFIS angles +// 1B quality (ignored, zeroed) +// 2B rubbish (extra data length, zeroed) +// N*1B rubbish (extra data) +void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFileName) +{ + // Open a binary file to output the template to... + FILE *output = fopen(outputFileName, "wb"); + + // 4B magic "FMR\0" + char magic[] = {'F', 'M', 'R', '\0'}; + int count = fwrite(magic, sizeof(magic), 1, output); + assert(count == 1); + + // 4B version (ignored, set to " 20\0" + char version[] = {' ', '2', '0', '\0'}; + count = fwrite(version, sizeof(version), 1, output); + assert(count == 1); + + // 4B total length (including header, will be updated later) + int32_t totalLength = 0; + count = fwrite(&totalLength, sizeof(totalLength), 1, output); + assert(count == 1); + + // 2B rubbish (zeroed) + int16_t twoByteRubbish = 0; + count = fwrite(&twoByteRubbish, sizeof(twoByteRubbish), 1, output); + assert(count == 1); + + // 2B image size in pixels X + int16_t imageSizeX = Calc_DivRoundUp(template->originalWidth * 500, template->originalDpi); + count = fwrite(&imageSizeX, sizeof(imageSizeX), 1, output); + assert(count == 1); + + // 2B image size in pixels Y + int16_t imageSizeY = Calc_DivRoundUp(template->originalHeight * 500, template->originalDpi); + count = fwrite(&imageSizeY, sizeof(imageSizeY), 1, output); + assert(count == 1); + + // 2B rubbish (pixels per cm X, set to 196 = 500dpi) + int16_t pixelsPerCm = 196; + count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); + assert(count == 1); + + // 2B rubbish (pixels per cm Y, set to 196 = 500dpi) + count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); + assert(count == 1); + + // 1B rubbish (number of fingerprints, set to 1) + int8_t oneByteRubbish = 1; + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (zeroed) + oneByteRubbish = 0; + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (finger position, zeroed) + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (zeroed) + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (fingerprint quality, set to 100) + int8_t fingerprintQuality = 100; + count = fwrite(&fingerprintQuality, sizeof(fingerprintQuality), 1, output); + assert(count == 1); + + // 1B minutia count + int32_t minutiaCount = List_GetCount(&template->minutiae); + count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); + assert(count == 1); + + // Flush and close the binary file... + fflush(output); + fclose(output); +} diff --git a/Sources/Templates/TemplateIO.h b/Sources/Templates/TemplateIO.h new file mode 100644 index 0000000..54c20d5 --- /dev/null +++ b/Sources/Templates/TemplateIO.h @@ -0,0 +1,8 @@ +#ifndef LIBAFIS_TEMPLATEIO_H +#define LIBAFIS_TEMPLATEIO_H + +#include "Templates/Template.h" + +void TemplateIO_ISO19794_2_2005_Export(Template *, const char *); + +#endif //LIBAFIS_TEMPLATEIO_H diff --git a/Sources/Tests/Templates/TestRunner_Templates.c b/Sources/Tests/Templates/TestRunner_Templates.c new file mode 100644 index 0000000..465e430 --- /dev/null +++ b/Sources/Tests/Templates/TestRunner_Templates.c @@ -0,0 +1,7 @@ +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(Templates) +{ + RUN_TEST_CASE(Templates, TemplateIO_ISO19794_2_2005); +} diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c.c new file mode 100644 index 0000000..73155da --- /dev/null +++ b/Sources/Tests/Templates/Test_Templates.c.c @@ -0,0 +1,24 @@ +#include "Templates/Template.h" +#include "Templates/TemplateIO.h" +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(Templates); + +TEST_SETUP(Templates) +{ +} + +TEST_TEAR_DOWN(Templates) +{ +} + +TEST(Templates, TemplateIO_ISO19794_2_2005) +{ + Template template = Template_Construct(); + template.originalDpi = 500; + template.originalWidth = 640; + template.originalHeight = 480; + + TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); +} diff --git a/Sources/Tests/all_tests.c b/Sources/Tests/all_tests.c index 49df26d..996860a 100644 --- a/Sources/Tests/all_tests.c +++ b/Sources/Tests/all_tests.c @@ -1,7 +1,7 @@ #ifdef _MSC_VER - #include + #include #else - #include + #include #endif #include "unity_fixture.h" @@ -45,6 +45,9 @@ static void RunAllTests(void) printf("\nBestMatchSkipper tests\n"); RUN_TEST_GROUP(BestMatchSkipper); + + printf("\nTemplate tests\n"); + RUN_TEST_GROUP(Templates); } int main(int argc, const char * argv[]) From c16500cf02412fc9914a1747eff1bd19d94745ba Mon Sep 17 00:00:00 2001 From: "U-RED-GATE\\bob.arnott" Date: Fri, 6 Nov 2015 00:34:21 +0000 Subject: [PATCH 03/15] Initial stab at an ISO/IEC 19794-2:2005 template writer --- Sources/Templates/TemplateIO.c | 218 +++++++++--------- Sources/Templates/TemplateIO.h | 16 +- .../Tests/Templates/TestRunner_Templates.c | 14 +- Sources/Tests/Templates/Test_Templates.c.c | 48 ++-- 4 files changed, 148 insertions(+), 148 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index 815b5dd..457d6f2 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -1,109 +1,109 @@ -// -// Created by bob.arnott on 11/5/2015. -// - -#include "General/Calc.h" -#include "Templates/TemplateIO.h" - -#include -#include - -// Format (all numbers are big-endian): -// 4B magic "FMR\0" -// 4B version (ignored, set to " 20\0" -// 4B total length (including header) -// 2B rubbish (zeroed) -// 2B image size in pixels X -// 2B image size in pixels Y -// 2B rubbish (pixels per cm X, set to 196 = 500dpi) -// 2B rubbish (pixels per cm Y, set to 196 = 500dpi) -// 1B rubbish (number of fingerprints, set to 1) -// 1B rubbish (zeroed) -// 1B rubbish (finger position, zeroed) -// 1B rubbish (zeroed) -// 1B rubbish (fingerprint quality, set to 100) -// 1B minutia count -// N*6B minutiae -// 2B minutia position X in pixels -// 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other) -// 2B minutia position Y in pixels (upper 2b ignored, zeroed) -// 1B direction, compatible with SourceAFIS angles -// 1B quality (ignored, zeroed) -// 2B rubbish (extra data length, zeroed) -// N*1B rubbish (extra data) -void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFileName) -{ - // Open a binary file to output the template to... - FILE *output = fopen(outputFileName, "wb"); - - // 4B magic "FMR\0" - char magic[] = {'F', 'M', 'R', '\0'}; - int count = fwrite(magic, sizeof(magic), 1, output); - assert(count == 1); - - // 4B version (ignored, set to " 20\0" - char version[] = {' ', '2', '0', '\0'}; - count = fwrite(version, sizeof(version), 1, output); - assert(count == 1); - - // 4B total length (including header, will be updated later) - int32_t totalLength = 0; - count = fwrite(&totalLength, sizeof(totalLength), 1, output); - assert(count == 1); - - // 2B rubbish (zeroed) - int16_t twoByteRubbish = 0; - count = fwrite(&twoByteRubbish, sizeof(twoByteRubbish), 1, output); - assert(count == 1); - - // 2B image size in pixels X - int16_t imageSizeX = Calc_DivRoundUp(template->originalWidth * 500, template->originalDpi); - count = fwrite(&imageSizeX, sizeof(imageSizeX), 1, output); - assert(count == 1); - - // 2B image size in pixels Y - int16_t imageSizeY = Calc_DivRoundUp(template->originalHeight * 500, template->originalDpi); - count = fwrite(&imageSizeY, sizeof(imageSizeY), 1, output); - assert(count == 1); - - // 2B rubbish (pixels per cm X, set to 196 = 500dpi) - int16_t pixelsPerCm = 196; - count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); - assert(count == 1); - - // 2B rubbish (pixels per cm Y, set to 196 = 500dpi) - count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); - assert(count == 1); - - // 1B rubbish (number of fingerprints, set to 1) - int8_t oneByteRubbish = 1; - count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); - assert(count == 1); - - // 1B rubbish (zeroed) - oneByteRubbish = 0; - count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); - assert(count == 1); - - // 1B rubbish (finger position, zeroed) - count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); - assert(count == 1); - - // 1B rubbish (zeroed) - count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); - assert(count == 1); - - // 1B rubbish (fingerprint quality, set to 100) - int8_t fingerprintQuality = 100; - count = fwrite(&fingerprintQuality, sizeof(fingerprintQuality), 1, output); - assert(count == 1); - - // 1B minutia count - int32_t minutiaCount = List_GetCount(&template->minutiae); - count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); - assert(count == 1); - - // Flush and close the binary file... - fflush(output); - fclose(output); -} +// +// Created by bob.arnott on 11/5/2015. +// + +#include "General/Calc.h" +#include "Templates/TemplateIO.h" + +#include +#include + +// Format (all numbers are big-endian): +// 4B magic "FMR\0" +// 4B version (ignored, set to " 20\0" +// 4B total length (including header) +// 2B rubbish (zeroed) +// 2B image size in pixels X +// 2B image size in pixels Y +// 2B rubbish (pixels per cm X, set to 196 = 500dpi) +// 2B rubbish (pixels per cm Y, set to 196 = 500dpi) +// 1B rubbish (number of fingerprints, set to 1) +// 1B rubbish (zeroed) +// 1B rubbish (finger position, zeroed) +// 1B rubbish (zeroed) +// 1B rubbish (fingerprint quality, set to 100) +// 1B minutia count +// N*6B minutiae +// 2B minutia position X in pixels +// 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other) +// 2B minutia position Y in pixels (upper 2b ignored, zeroed) +// 1B direction, compatible with SourceAFIS angles +// 1B quality (ignored, zeroed) +// 2B rubbish (extra data length, zeroed) +// N*1B rubbish (extra data) +void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFileName) +{ + // Open a binary file to output the template to... + FILE *output = fopen(outputFileName, "wb"); + + // 4B magic "FMR\0" + char magic[] = {'F', 'M', 'R', '\0'}; + int count = fwrite(magic, sizeof(magic), 1, output); + assert(count == 1); + + // 4B version (ignored, set to " 20\0" + char version[] = {' ', '2', '0', '\0'}; + count = fwrite(version, sizeof(version), 1, output); + assert(count == 1); + + // 4B total length (including header, will be updated later) + int32_t totalLength = 0; + count = fwrite(&totalLength, sizeof(totalLength), 1, output); + assert(count == 1); + + // 2B rubbish (zeroed) + int16_t twoByteRubbish = 0; + count = fwrite(&twoByteRubbish, sizeof(twoByteRubbish), 1, output); + assert(count == 1); + + // 2B image size in pixels X + int16_t imageSizeX = Calc_DivRoundUp(template->originalWidth * 500, template->originalDpi); + count = fwrite(&imageSizeX, sizeof(imageSizeX), 1, output); + assert(count == 1); + + // 2B image size in pixels Y + int16_t imageSizeY = Calc_DivRoundUp(template->originalHeight * 500, template->originalDpi); + count = fwrite(&imageSizeY, sizeof(imageSizeY), 1, output); + assert(count == 1); + + // 2B rubbish (pixels per cm X, set to 196 = 500dpi) + int16_t pixelsPerCm = 196; + count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); + assert(count == 1); + + // 2B rubbish (pixels per cm Y, set to 196 = 500dpi) + count = fwrite(&pixelsPerCm, sizeof(pixelsPerCm), 1, output); + assert(count == 1); + + // 1B rubbish (number of fingerprints, set to 1) + int8_t oneByteRubbish = 1; + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (zeroed) + oneByteRubbish = 0; + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (finger position, zeroed) + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (zeroed) + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + + // 1B rubbish (fingerprint quality, set to 100) + int8_t fingerprintQuality = 100; + count = fwrite(&fingerprintQuality, sizeof(fingerprintQuality), 1, output); + assert(count == 1); + + // 1B minutia count + int32_t minutiaCount = List_GetCount(&template->minutiae); + count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); + assert(count == 1); + + // Flush and close the binary file... + fflush(output); + fclose(output); +} diff --git a/Sources/Templates/TemplateIO.h b/Sources/Templates/TemplateIO.h index 54c20d5..4ab1b2a 100644 --- a/Sources/Templates/TemplateIO.h +++ b/Sources/Templates/TemplateIO.h @@ -1,8 +1,8 @@ -#ifndef LIBAFIS_TEMPLATEIO_H -#define LIBAFIS_TEMPLATEIO_H - -#include "Templates/Template.h" - -void TemplateIO_ISO19794_2_2005_Export(Template *, const char *); - -#endif //LIBAFIS_TEMPLATEIO_H +#ifndef LIBAFIS_TEMPLATEIO_H +#define LIBAFIS_TEMPLATEIO_H + +#include "Templates/Template.h" + +void TemplateIO_ISO19794_2_2005_Export(Template *, const char *); + +#endif //LIBAFIS_TEMPLATEIO_H diff --git a/Sources/Tests/Templates/TestRunner_Templates.c b/Sources/Tests/Templates/TestRunner_Templates.c index 465e430..c832f1d 100644 --- a/Sources/Tests/Templates/TestRunner_Templates.c +++ b/Sources/Tests/Templates/TestRunner_Templates.c @@ -1,7 +1,7 @@ -#include "unity.h" -#include "unity_fixture.h" - -TEST_GROUP_RUNNER(Templates) -{ - RUN_TEST_CASE(Templates, TemplateIO_ISO19794_2_2005); -} +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(Templates) +{ + RUN_TEST_CASE(Templates, TemplateIO_ISO19794_2_2005); +} diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c.c index 73155da..b430bf4 100644 --- a/Sources/Tests/Templates/Test_Templates.c.c +++ b/Sources/Tests/Templates/Test_Templates.c.c @@ -1,24 +1,24 @@ -#include "Templates/Template.h" -#include "Templates/TemplateIO.h" -#include "unity.h" -#include "unity_fixture.h" - -TEST_GROUP(Templates); - -TEST_SETUP(Templates) -{ -} - -TEST_TEAR_DOWN(Templates) -{ -} - -TEST(Templates, TemplateIO_ISO19794_2_2005) -{ - Template template = Template_Construct(); - template.originalDpi = 500; - template.originalWidth = 640; - template.originalHeight = 480; - - TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); -} +#include "Templates/Template.h" +#include "Templates/TemplateIO.h" +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(Templates); + +TEST_SETUP(Templates) +{ +} + +TEST_TEAR_DOWN(Templates) +{ +} + +TEST(Templates, TemplateIO_ISO19794_2_2005) +{ + Template template = Template_Construct(); + template.originalDpi = 500; + template.originalWidth = 640; + template.originalHeight = 480; + + TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); +} From dffbe3153ccb78c85b00944b3288d618a02f497f Mon Sep 17 00:00:00 2001 From: fatboab Date: Fri, 6 Nov 2015 09:46:10 +0000 Subject: [PATCH 04/15] Add minutia to the ISO/IEC 19794-2:2005 template output. Currently commented out as it core dumps. --- Sources/Templates/TemplateIO.c | 54 ++++++++++++++++++++++ Sources/Tests/Templates/Test_Templates.c.c | 24 ++++++++-- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index 457d6f2..53581f0 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -36,6 +36,8 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil // Open a binary file to output the template to... FILE *output = fopen(outputFileName, "wb"); + printf("\nWriting header..."); + // 4B magic "FMR\0" char magic[] = {'F', 'M', 'R', '\0'}; int count = fwrite(magic, sizeof(magic), 1, output); @@ -103,6 +105,58 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); assert(count == 1); + printf("\nWriting %d minutiae...", minutiaCount); + + for (ListElement *element = template->minutiae.head; element != NULL; element = element->next) + { + // Get the minutia from the list element... + TemplateMinutia *minutia = element->data; + + // 2B minutia position X in pixels + // 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other (considered ending))ore + int x = minutia->position.x; + printf("minutia->position.x - %d", minutia->position.x); + assert(x <= 0x3fff); // ::TODO:: Query this...? + + int type; + switch (minutia->type) + { + case ENDING: + type = 0x4000; + break; + case BIFURCATION: + type = 0x8000; + break; + case OTHER: + type = 0; + break; + default: + assert(false); + } + uint16_t combined = (x | type); + count = fwrite(&combined, sizeof(uint16_t), 1, output); + assert(count == 1); + + // 2B minutia position Y in pixels (upper 2b ignored, zeroed) + int y = imageSizeY - minutia->position.y - 1; + assert(y <= 0x3fff); + count = fwrite(&y, sizeof(int16_t), 1, output); + assert(count == 1); + + // 1B direction, compatible with SourceAFIS angles + count = fwrite(&minutia->direction, sizeof(uint8_t), 1, output); + assert(count == 1); + + // 1B quality (ignored, zeroed) + count = fwrite(&oneByteRubbish, sizeof(oneByteRubbish), 1, output); + assert(count == 1); + } + + // 2B rubbish (extra data length, zeroed) + // N*1B rubbish (extra data) + count = fwrite(&twoByteRubbish, sizeof(twoByteRubbish), 1, output); + assert(count == 1); + // Flush and close the binary file... fflush(output); fclose(output); diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c.c index b430bf4..ed83d21 100644 --- a/Sources/Tests/Templates/Test_Templates.c.c +++ b/Sources/Tests/Templates/Test_Templates.c.c @@ -5,20 +5,34 @@ TEST_GROUP(Templates); +Template template; + TEST_SETUP(Templates) { + template = Template_Construct(); + template.originalDpi = 500; + template.originalWidth = 640; + template.originalHeight = 480; + + // ::TODO:: Figure out wht this causes a core dump when position.x is accessed... +// for(int ii = 0; ii < 5; ii++) +// { +// TemplateMinutia minutia = (TemplateMinutia) +// { +// .position = (Point) { .x = ii, .y = ii }, +// .direction = (uint8_t) ii, +// .type = (MinutiaType) (ii % 3) +// }; +// Template_AddMinutia(&template, &minutia); +// } } TEST_TEAR_DOWN(Templates) { + Template_Free(&template); } TEST(Templates, TemplateIO_ISO19794_2_2005) { - Template template = Template_Construct(); - template.originalDpi = 500; - template.originalWidth = 640; - template.originalHeight = 480; - TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); } From 671019a18048eb650b20aee5ea4458f0b2c2b662 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Fri, 6 Nov 2015 10:28:48 +0000 Subject: [PATCH 05/15] Stop the coredump when trying to free non dynamically allocated moemory... --- Sources/Templates/TemplateIO.c | 7 +--- Sources/Tests/Templates/Test_Templates.c.c | 37 ++++++++++++++-------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index 53581f0..c05f695 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -36,8 +36,6 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil // Open a binary file to output the template to... FILE *output = fopen(outputFileName, "wb"); - printf("\nWriting header..."); - // 4B magic "FMR\0" char magic[] = {'F', 'M', 'R', '\0'}; int count = fwrite(magic, sizeof(magic), 1, output); @@ -105,8 +103,6 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); assert(count == 1); - printf("\nWriting %d minutiae...", minutiaCount); - for (ListElement *element = template->minutiae.head; element != NULL; element = element->next) { // Get the minutia from the list element... @@ -115,8 +111,7 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil // 2B minutia position X in pixels // 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other (considered ending))ore int x = minutia->position.x; - printf("minutia->position.x - %d", minutia->position.x); - assert(x <= 0x3fff); // ::TODO:: Query this...? + assert(x <= 0x3fff); int type; switch (minutia->type) diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c.c index ed83d21..b17e0be 100644 --- a/Sources/Tests/Templates/Test_Templates.c.c +++ b/Sources/Tests/Templates/Test_Templates.c.c @@ -6,30 +6,39 @@ TEST_GROUP(Templates); Template template; +TemplateMinutia minutias[5]; TEST_SETUP(Templates) { template = Template_Construct(); template.originalDpi = 500; - template.originalWidth = 640; - template.originalHeight = 480; - + template.originalWidth = 100; + template.originalHeight = 100; + // ::TODO:: Figure out wht this causes a core dump when position.x is accessed... -// for(int ii = 0; ii < 5; ii++) -// { -// TemplateMinutia minutia = (TemplateMinutia) -// { -// .position = (Point) { .x = ii, .y = ii }, -// .direction = (uint8_t) ii, -// .type = (MinutiaType) (ii % 3) -// }; -// Template_AddMinutia(&template, &minutia); -// } + for(int ii = 0; ii < 5; ii++) + { + minutias[ii] = (TemplateMinutia) + { + .position = (Point) { .x = ii, .y = ii }, + .direction = (uint8_t) ii, + .type = (MinutiaType) (ii % 3) + }; + Template_AddMinutia(&template, &minutias[ii]); + } +} + +static void UnityFreeTemplate(Template *template) +{ + while (List_GetCount(&template->minutiae) > 0) + { + List_Remove(&template->minutiae, template->minutiae.tail, NULL); + } } TEST_TEAR_DOWN(Templates) { - Template_Free(&template); + UnityFreeTemplate(&template); } TEST(Templates, TemplateIO_ISO19794_2_2005) From 98e04831af71c2ec82974384247fc2e1e3b4bdc5 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Fri, 6 Nov 2015 10:29:14 +0000 Subject: [PATCH 06/15] Switch back to removing from head, rather than tail. --- Sources/Templates/Template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index 01409d4..d4ff7b8 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -28,7 +28,7 @@ void Template_Free(Template *template) while (List_GetCount(&(template->minutiae)) > 0) { void *dataFound; - List_Remove(&(template->minutiae), (template->minutiae.tail), &dataFound); + List_Remove(&(template->minutiae), (template->minutiae.head), &dataFound); free(dataFound); } } From 2415b4291d3673a396b94fe9923aa3f696fa73d3 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Fri, 6 Nov 2015 13:13:21 +0000 Subject: [PATCH 07/15] Add an ISO/IEC 19794-2:2005 template input routine... --- Sources/Templates/TemplateIO.c | 150 ++++++++++++++++++++- Sources/Templates/TemplateIO.h | 1 + Sources/Tests/Templates/Test_Templates.c.c | 36 ++++- 3 files changed, 180 insertions(+), 7 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index c05f695..829392e 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -6,7 +6,10 @@ #include "Templates/TemplateIO.h" #include +#include #include +#include +#include // Format (all numbers are big-endian): // 4B magic "FMR\0" @@ -99,10 +102,11 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil assert(count == 1); // 1B minutia count - int32_t minutiaCount = List_GetCount(&template->minutiae); + int8_t minutiaCount = List_GetCount(&template->minutiae); count = fwrite(&minutiaCount, sizeof(int8_t), 1, output); assert(count == 1); + // N*6B minutiae for (ListElement *element = template->minutiae.head; element != NULL; element = element->next) { // Get the minutia from the list element... @@ -110,10 +114,10 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil // 2B minutia position X in pixels // 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other (considered ending))ore - int x = minutia->position.x; + int16_t x = minutia->position.x; assert(x <= 0x3fff); - int type; + uint16_t type; switch (minutia->type) { case ENDING: @@ -133,7 +137,7 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil assert(count == 1); // 2B minutia position Y in pixels (upper 2b ignored, zeroed) - int y = imageSizeY - minutia->position.y - 1; + int16_t y = imageSizeY - minutia->position.y - 1; assert(y <= 0x3fff); count = fwrite(&y, sizeof(int16_t), 1, output); assert(count == 1); @@ -156,3 +160,141 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil fflush(output); fclose(output); } + +void TemplateIO_ISO19794_2_2005_Import(const char *inputFileName, Template *template) +{ + // Open a binary file to output the template to... + FILE *input = fopen(inputFileName, "rb"); + + // ::TODO:: Decide if this is acceptable or not, it's what SourceAFIS does... + template->originalDpi = 500; + + // 4B magic "FMR\0" + char header[4]; + int count = fread(header, sizeof(uint8_t) * 4, 1, input); + assert(count == 1); + assert(strcmp("FMR", header) == 0); + + char version[4]; + count = fread(version, sizeof(version), 1, input); + assert(count == 1); + assert(strcmp(" 20", version) == 0); + + // 4B total length (including header, will be updated later) + int32_t totalLength = 0; + count = fread(&totalLength, sizeof(int32_t), 1, input); + assert(count == 1); + + // 2B rubbish (zeroed) + int16_t twoByteRubbish = 0; + count = fread(&twoByteRubbish, sizeof(twoByteRubbish), 1, input); + assert(count == 1); + + // 2B image size in pixels X + int16_t imageSizeX; + count = fread(&imageSizeX, sizeof(imageSizeX), 1, input); + assert(count == 1); + template->originalWidth = (imageSizeX * template-> originalDpi) / 500; + + // 2B image size in pixels Y + int16_t imageSizeY; + count = fread(&imageSizeY, sizeof(imageSizeY), 1, input); + assert(count == 1); + template->originalHeight = (imageSizeY * template->originalDpi) / 500; + + // 2B rubbish (pixels per cm X, set to 196 = 500dpi) + int16_t pixelsPerCm; + count = fread(&pixelsPerCm, sizeof(pixelsPerCm), 1, input); + assert(count == 1); + + // 2B rubbish (pixels per cm Y, set to 196 = 500dpi) + count = fread(&pixelsPerCm, sizeof(pixelsPerCm), 1, input); + assert(count == 1); + + // 1B rubbish (number of fingerprints, set to 1) + int8_t oneByteRubbish = 1; + count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); + assert(count == 1); + + // 1B rubbish (zeroed) + oneByteRubbish = 0; + count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); + assert(count == 1); + + // 1B rubbish (finger position, zeroed) + count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); + assert(count == 1); + + // 1B rubbish (zeroed) + count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); + assert(count == 1); + + // 1B rubbish (fingerprint quality, set to 100) + int8_t fingerprintQuality; + count = fread(&fingerprintQuality, sizeof(fingerprintQuality), 1, input); + assert(count == 1); + + // 1B minutia count + int8_t minutiaCount; + count = fread(&minutiaCount, sizeof(int8_t), 1, input); + assert(count == 1); + + // N*6B minutiae + for (int ii=0; iioriginalHeight - 1 - (y & 0x3fff); + assert(y <= 0x3fff); + + // 1B direction, compatible with SourceAFIS angles + uint8_t direction; + count = fread(&direction, sizeof(uint8_t), 1, input); + assert(count == 1); + + // 1B quality (ignored, zeroed) + count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); + assert(count == 1); + + // Add the minutia to the template list... + templateMinutia->position = (Point) {.x = x, .y = y}; + templateMinutia->direction = direction; + templateMinutia->type = type; + Template_AddMinutia(template, templateMinutia); + } + + // 2B rubbish (extra data length, zeroed) + // N*1B rubbish (extra data) + count = fread(&twoByteRubbish, sizeof(twoByteRubbish), 1, input); + assert(count == 1); + + // Close the binary file... + fclose(input); +} diff --git a/Sources/Templates/TemplateIO.h b/Sources/Templates/TemplateIO.h index 4ab1b2a..cd198a4 100644 --- a/Sources/Templates/TemplateIO.h +++ b/Sources/Templates/TemplateIO.h @@ -4,5 +4,6 @@ #include "Templates/Template.h" void TemplateIO_ISO19794_2_2005_Export(Template *, const char *); +void TemplateIO_ISO19794_2_2005_Import(const char *, Template *); #endif //LIBAFIS_TEMPLATEIO_H diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c.c index b17e0be..00180d0 100644 --- a/Sources/Tests/Templates/Test_Templates.c.c +++ b/Sources/Tests/Templates/Test_Templates.c.c @@ -1,13 +1,38 @@ +#include "General/List.h" #include "Templates/Template.h" #include "Templates/TemplateIO.h" #include "unity.h" #include "unity_fixture.h" +#include + TEST_GROUP(Templates); Template template; TemplateMinutia minutias[5]; +static void TemplatesAreEqual(Template *expected, Template *actual) +{ + TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalDpi, actual->originalDpi, "originalDpi's are different"); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalWidth, actual->originalWidth, "originalWidth's are different"); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalHeight, actual->originalHeight, "originalHeight's are different"); + + int32_t expectedMinutiaeCount = List_GetCount(&expected->minutiae); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutiaeCount, List_GetCount(&actual->minutiae), "minutia list lengths are different"); + + do { + TemplateMinutia *expectedMinutia, *actualMinutia; + List_Remove(&expected->minutiae, expected->minutiae.head, (void**)&expectedMinutia); + List_Remove(&actual->minutiae, actual->minutiae.head, (void**)&actualMinutia); + + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.x, actualMinutia->position.x, "minutia position.x's are different"); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.y, actualMinutia->position.y, "minutia position.x's are different"); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->direction, actualMinutia->direction, "minutia direction's are different"); + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->type, actualMinutia->type, "minutia type's are different"); + } + while(expected->minutiae.head != NULL); +} + TEST_SETUP(Templates) { template = Template_Construct(); @@ -16,13 +41,13 @@ TEST_SETUP(Templates) template.originalHeight = 100; // ::TODO:: Figure out wht this causes a core dump when position.x is accessed... - for(int ii = 0; ii < 5; ii++) + for(int ii = 2; ii < 7; ii++) { minutias[ii] = (TemplateMinutia) { .position = (Point) { .x = ii, .y = ii }, - .direction = (uint8_t) ii, - .type = (MinutiaType) (ii % 3) + .direction = (uint8_t) ii*ii, + .type = BIFURCATION }; Template_AddMinutia(&template, &minutias[ii]); } @@ -43,5 +68,10 @@ TEST_TEAR_DOWN(Templates) TEST(Templates, TemplateIO_ISO19794_2_2005) { + Template fromDisk = Template_Construct(); + TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); + TemplateIO_ISO19794_2_2005_Import("output.bin", &fromDisk); + + TemplatesAreEqual(&template, &fromDisk); } From a7617c9f606e890c7015ff614083d9d0ff1f9315 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Fri, 6 Nov 2015 14:47:31 +0000 Subject: [PATCH 08/15] Calculate and add in the template length when exporting --- Sources/Templates/TemplateIO.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index 829392e..6d2ff52 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -49,8 +49,8 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil count = fwrite(version, sizeof(version), 1, output); assert(count == 1); - // 4B total length (including header, will be updated later) - int32_t totalLength = 0; + // 4B total length (28 bytes for the header, 6 bytes for each minutia and 2 bytes footer padding) + int32_t totalLength = 30 + (List_GetCount(&template->minutiae) * 6); count = fwrite(&totalLength, sizeof(totalLength), 1, output); assert(count == 1); @@ -180,13 +180,13 @@ void TemplateIO_ISO19794_2_2005_Import(const char *inputFileName, Template *temp assert(count == 1); assert(strcmp(" 20", version) == 0); - // 4B total length (including header, will be updated later) - int32_t totalLength = 0; + // 4B total length + int32_t totalLength; count = fread(&totalLength, sizeof(int32_t), 1, input); assert(count == 1); // 2B rubbish (zeroed) - int16_t twoByteRubbish = 0; + int16_t twoByteRubbish; count = fread(&twoByteRubbish, sizeof(twoByteRubbish), 1, input); assert(count == 1); @@ -212,12 +212,11 @@ void TemplateIO_ISO19794_2_2005_Import(const char *inputFileName, Template *temp assert(count == 1); // 1B rubbish (number of fingerprints, set to 1) - int8_t oneByteRubbish = 1; + int8_t oneByteRubbish; count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); assert(count == 1); // 1B rubbish (zeroed) - oneByteRubbish = 0; count = fread(&oneByteRubbish, sizeof(oneByteRubbish), 1, input); assert(count == 1); @@ -240,7 +239,7 @@ void TemplateIO_ISO19794_2_2005_Import(const char *inputFileName, Template *temp assert(count == 1); // N*6B minutiae - for (int ii=0; ii Date: Fri, 6 Nov 2015 16:16:02 +0000 Subject: [PATCH 09/15] Get rid of an auto-generated comment and some hanging chars on another... --- Sources/Templates/TemplateIO.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/Templates/TemplateIO.c b/Sources/Templates/TemplateIO.c index 6d2ff52..bfecf3b 100644 --- a/Sources/Templates/TemplateIO.c +++ b/Sources/Templates/TemplateIO.c @@ -1,7 +1,3 @@ -// -// Created by bob.arnott on 11/5/2015. -// - #include "General/Calc.h" #include "Templates/TemplateIO.h" @@ -113,7 +109,7 @@ void TemplateIO_ISO19794_2_2005_Export(Template *template, const char *outputFil TemplateMinutia *minutia = element->data; // 2B minutia position X in pixels - // 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other (considered ending))ore + // 2b (upper) minutia type (01 ending, 10 bifurcation, 00 other (considered ending)) int16_t x = minutia->position.x; assert(x <= 0x3fff); From fda3fe2773cb7a56894d9914e38415fb144b88b2 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Fri, 6 Nov 2015 16:19:19 +0000 Subject: [PATCH 10/15] Include not --- Sources/Templates/Template.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index d4ff7b8..245c5f6 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -1,6 +1,7 @@ #include "Templates/Template.h" #include "General/List.h" -#include + +#include #include void Template_AddMinutia(Template *template, TemplateMinutia *minutia) From dbf92d63a25ac4ea3291b47f9e53a8f1d1204881 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Sun, 8 Nov 2015 00:57:54 +0000 Subject: [PATCH 11/15] remove the duplicate .c from the end fo the file name --- Sources/Tests/Templates/{Test_Templates.c.c => Test_Templates.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Sources/Tests/Templates/{Test_Templates.c.c => Test_Templates.c} (100%) diff --git a/Sources/Tests/Templates/Test_Templates.c.c b/Sources/Tests/Templates/Test_Templates.c similarity index 100% rename from Sources/Tests/Templates/Test_Templates.c.c rename to Sources/Tests/Templates/Test_Templates.c From 05110103aa72f983a61e03cc5a576255d7645b89 Mon Sep 17 00:00:00 2001 From: fatboab Date: Wed, 11 Nov 2015 12:42:18 +0000 Subject: [PATCH 12/15] Update the VS Solution --- Sources/LibAFIS.vcxproj | 41 +++++++++++ Sources/LibAFIS.vcxproj.filters | 117 ++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) diff --git a/Sources/LibAFIS.vcxproj b/Sources/LibAFIS.vcxproj index 0550bca..50d91fb 100644 --- a/Sources/LibAFIS.vcxproj +++ b/Sources/LibAFIS.vcxproj @@ -163,8 +163,12 @@ + + + + @@ -178,16 +182,30 @@ + + + + + + + + + + + + + + @@ -198,8 +216,14 @@ + + + + + + @@ -227,8 +251,12 @@ + + + + @@ -243,6 +271,16 @@ + + + + + + + + + + @@ -255,6 +293,9 @@ + + + diff --git a/Sources/LibAFIS.vcxproj.filters b/Sources/LibAFIS.vcxproj.filters index 9b174bb..99e9c41 100644 --- a/Sources/LibAFIS.vcxproj.filters +++ b/Sources/LibAFIS.vcxproj.filters @@ -273,6 +273,78 @@ Source Files\Tests\Extraction\Filters\runners + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -404,5 +476,50 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + \ No newline at end of file From 5d0c22bd804907ba9919e16f7bb80a3f6a741e4b Mon Sep 17 00:00:00 2001 From: fatboab Date: Wed, 11 Nov 2015 12:49:39 +0000 Subject: [PATCH 13/15] Revert "Update the VS Solution" This reverts commit 05110103aa72f983a61e03cc5a576255d7645b89. --- Sources/LibAFIS.vcxproj | 41 ----------- Sources/LibAFIS.vcxproj.filters | 117 -------------------------------- 2 files changed, 158 deletions(-) diff --git a/Sources/LibAFIS.vcxproj b/Sources/LibAFIS.vcxproj index 50d91fb..0550bca 100644 --- a/Sources/LibAFIS.vcxproj +++ b/Sources/LibAFIS.vcxproj @@ -163,12 +163,8 @@ - - - - @@ -182,30 +178,16 @@ - - - - - - - - - - - - - - @@ -216,14 +198,8 @@ - - - - - - @@ -251,12 +227,8 @@ - - - - @@ -271,16 +243,6 @@ - - - - - - - - - - @@ -293,9 +255,6 @@ - - - diff --git a/Sources/LibAFIS.vcxproj.filters b/Sources/LibAFIS.vcxproj.filters index 99e9c41..9b174bb 100644 --- a/Sources/LibAFIS.vcxproj.filters +++ b/Sources/LibAFIS.vcxproj.filters @@ -273,78 +273,6 @@ Source Files\Tests\Extraction\Filters\runners - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - @@ -476,50 +404,5 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - \ No newline at end of file From 220272bad2e85eba5ca93925f82c23e0791c668a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 13:03:30 +0000 Subject: [PATCH 14/15] Turns out the TEST_SETUP and TEST_TEAR_DOWN weren't being called when running cvia cygwin --- Sources/Tests/Templates/Test_Templates.c | 71 ++++++++++++------------ 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/Sources/Tests/Templates/Test_Templates.c b/Sources/Tests/Templates/Test_Templates.c index 00180d0..def3d80 100644 --- a/Sources/Tests/Templates/Test_Templates.c +++ b/Sources/Tests/Templates/Test_Templates.c @@ -5,26 +5,34 @@ #include "unity_fixture.h" #include +#include TEST_GROUP(Templates); -Template template; -TemplateMinutia minutias[5]; +TEST_SETUP(Templates) +{ +} + +TEST_TEAR_DOWN(Templates) +{ +} + +static const char *testFile = "test-output.bin"; static void TemplatesAreEqual(Template *expected, Template *actual) { TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalDpi, actual->originalDpi, "originalDpi's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalWidth, actual->originalWidth, "originalWidth's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expected->originalHeight, actual->originalHeight, "originalHeight's are different"); - + int32_t expectedMinutiaeCount = List_GetCount(&expected->minutiae); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutiaeCount, List_GetCount(&actual->minutiae), "minutia list lengths are different"); - + do { TemplateMinutia *expectedMinutia, *actualMinutia; List_Remove(&expected->minutiae, expected->minutiae.head, (void**)&expectedMinutia); List_Remove(&actual->minutiae, actual->minutiae.head, (void**)&actualMinutia); - + TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.x, actualMinutia->position.x, "minutia position.x's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.y, actualMinutia->position.y, "minutia position.x's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->direction, actualMinutia->direction, "minutia direction's are different"); @@ -33,45 +41,38 @@ static void TemplatesAreEqual(Template *expected, Template *actual) while(expected->minutiae.head != NULL); } -TEST_SETUP(Templates) +static void PopulateTemplateToTestWith(Template *template) { - template = Template_Construct(); - template.originalDpi = 500; - template.originalWidth = 100; - template.originalHeight = 100; - - // ::TODO:: Figure out wht this causes a core dump when position.x is accessed... - for(int ii = 2; ii < 7; ii++) - { - minutias[ii] = (TemplateMinutia) - { - .position = (Point) { .x = ii, .y = ii }, - .direction = (uint8_t) ii*ii, - .type = BIFURCATION - }; - Template_AddMinutia(&template, &minutias[ii]); - } -} + template->originalDpi = 500; + template->originalWidth = 100; + template->originalHeight = 100; -static void UnityFreeTemplate(Template *template) -{ - while (List_GetCount(&template->minutiae) > 0) + for(int ii = 2; ii < 7; ii++) { - List_Remove(&template->minutiae, template->minutiae.tail, NULL); + TemplateMinutia *minutia = malloc(sizeof(TemplateMinutia)); + minutia->position = (Point) { .x = ii, .y = ii }; + minutia->direction = (uint8_t) ii*ii; + minutia->type = BIFURCATION; + Template_AddMinutia(template, minutia); } } -TEST_TEAR_DOWN(Templates) -{ - UnityFreeTemplate(&template); -} - TEST(Templates, TemplateIO_ISO19794_2_2005) { + // Create a template and export it to disk... + Template template = Template_Construct(); + PopulateTemplateToTestWith(&template); + TemplateIO_ISO19794_2_2005_Export(&template, testFile); + + // Create a template and read the previously exported template from disk... Template fromDisk = Template_Construct(); + TemplateIO_ISO19794_2_2005_Import(testFile, &fromDisk); - TemplateIO_ISO19794_2_2005_Export(&template, "output.bin"); - TemplateIO_ISO19794_2_2005_Import("output.bin", &fromDisk); - + // They ahould be equal... TemplatesAreEqual(&template, &fromDisk); + + // Clean up... + List_Destroy(&(template.minutiae), &free); + List_Destroy(&(fromDisk.minutiae), &free); + remove(testFile); } From edfddac66ccb2ae793a8e939fade64b8bedb8184 Mon Sep 17 00:00:00 2001 From: fatboab Date: Wed, 11 Nov 2015 17:44:37 +0000 Subject: [PATCH 15/15] W00t! Fix the memory leakage by freeing the right stuff with the right free method... --- Sources/Templates/Template.c | 7 +------ Sources/Tests/Templates/Test_Templates.c | 26 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index 245c5f6..0b99dcc 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -26,10 +26,5 @@ Template Template_Construct() void Template_Free(Template *template) { - while (List_GetCount(&(template->minutiae)) > 0) - { - void *dataFound; - List_Remove(&(template->minutiae), (template->minutiae.head), &dataFound); - free(dataFound); - } + List_Destroy(&(template->minutiae), &(free)); } diff --git a/Sources/Tests/Templates/Test_Templates.c b/Sources/Tests/Templates/Test_Templates.c index def3d80..8357c57 100644 --- a/Sources/Tests/Templates/Test_Templates.c +++ b/Sources/Tests/Templates/Test_Templates.c @@ -28,17 +28,21 @@ static void TemplatesAreEqual(Template *expected, Template *actual) int32_t expectedMinutiaeCount = List_GetCount(&expected->minutiae); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutiaeCount, List_GetCount(&actual->minutiae), "minutia list lengths are different"); - do { - TemplateMinutia *expectedMinutia, *actualMinutia; - List_Remove(&expected->minutiae, expected->minutiae.head, (void**)&expectedMinutia); - List_Remove(&actual->minutiae, actual->minutiae.head, (void**)&actualMinutia); + ListElement *expectedListElement = expected->minutiae.head; + ListElement *actualListElement = actual->minutiae.head; + while (expectedListElement != NULL && actualListElement != NULL) + { + TemplateMinutia *expectedMinutia = (TemplateMinutia *) expectedListElement->data; + TemplateMinutia *actualMinutia = (TemplateMinutia *) actualListElement->data; TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.x, actualMinutia->position.x, "minutia position.x's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->position.y, actualMinutia->position.y, "minutia position.x's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->direction, actualMinutia->direction, "minutia direction's are different"); TEST_ASSERT_EQUAL_INT32_MESSAGE(expectedMinutia->type, actualMinutia->type, "minutia type's are different"); + + expectedListElement = expectedListElement->next; + actualListElement = actualListElement->next; } - while(expected->minutiae.head != NULL); } static void PopulateTemplateToTestWith(Template *template) @@ -47,15 +51,19 @@ static void PopulateTemplateToTestWith(Template *template) template->originalWidth = 100; template->originalHeight = 100; - for(int ii = 2; ii < 7; ii++) + for (int ii = 2; ii < 7; ii++) { TemplateMinutia *minutia = malloc(sizeof(TemplateMinutia)); minutia->position = (Point) { .x = ii, .y = ii }; - minutia->direction = (uint8_t) ii*ii; + minutia->direction = (uint8_t)ii*ii; minutia->type = BIFURCATION; Template_AddMinutia(template, minutia); } } +static void Template_UnityFree(Template *template) +{ + List_Destroy(&(template->minutiae), &(free)); +} TEST(Templates, TemplateIO_ISO19794_2_2005) { @@ -72,7 +80,7 @@ TEST(Templates, TemplateIO_ISO19794_2_2005) TemplatesAreEqual(&template, &fromDisk); // Clean up... - List_Destroy(&(template.minutiae), &free); - List_Destroy(&(fromDisk.minutiae), &free); + Template_UnityFree(&template); //With unity as the malloc happenned here + Template_Free(&fromDisk); remove(testFile); }