From 0429e4e334661f1a0397782a3114011948e31097 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Wed, 4 Nov 2015 19:51:48 +0000 Subject: [PATCH 01/10] Remove a printf that was confusing the test output... --- Sources/Tests/Extraction/Filters/Test_VotingFilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Tests/Extraction/Filters/Test_VotingFilter.c b/Sources/Tests/Extraction/Filters/Test_VotingFilter.c index f8e31ab..cdf462a 100644 --- a/Sources/Tests/Extraction/Filters/Test_VotingFilter.c +++ b/Sources/Tests/Extraction/Filters/Test_VotingFilter.c @@ -45,7 +45,7 @@ TEST(VotingFilter, VotingFilter_regression_tests_against_sourceAfis) sprintf(inputFile, "%s.input.dat", regressionFiles[i]); - printf("File = %s\r\n", inputFile); +// printf("File = %s\r\n", inputFile); sprintf(outputFile, "%s.result.dat", regressionFiles[i]); sprintf(paramRadius, "%s.Radius.dat", regressionFiles[i]); sprintf(paramMajority, "%s.Majority.dat", regressionFiles[i]); From 9280e7326674f3f28875e718ce3a7e5a0b877637 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Wed, 4 Nov 2015 19:52:48 +0000 Subject: [PATCH 02/10] Add an end to end, image to template test. Doesn't do owt yet as we have no template structure... --- Sources/Makefile | 4 +- Sources/Tests/EndToEnd/TestRunner_EndToEnd.c | 7 +++ Sources/Tests/EndToEnd/Test_EndToEnd.c | 57 ++++++++++++++++++++ Sources/Tests/all_tests.c | 3 ++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 Sources/Tests/EndToEnd/TestRunner_EndToEnd.c create mode 100644 Sources/Tests/EndToEnd/Test_EndToEnd.c diff --git a/Sources/Makefile b/Sources/Makefile index 9a161d9..0cbd870 100644 --- a/Sources/Makefile +++ b/Sources/Makefile @@ -55,7 +55,9 @@ UTILS_SRCS_EXCLUDE = UTEST_SRCS = General/*.c General/runners/*.c \ Extraction/Filters/*.c Extraction/Filters/runners/*.c \ - DataStructures/*.c + DataStructures/*.c \ + EndToEnd/*.c + UTEST_SRCS_EXCLUDE = UTEST_SRCS += $(UTEST_EXE).c diff --git a/Sources/Tests/EndToEnd/TestRunner_EndToEnd.c b/Sources/Tests/EndToEnd/TestRunner_EndToEnd.c new file mode 100644 index 0000000..a4387e5 --- /dev/null +++ b/Sources/Tests/EndToEnd/TestRunner_EndToEnd.c @@ -0,0 +1,7 @@ +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(EndToEnd) +{ + RUN_TEST_CASE(EndToEnd, ImageToTemplate); +} diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c new file mode 100644 index 0000000..12451c7 --- /dev/null +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -0,0 +1,57 @@ +#include "Extraction/Extract.h" +#include "General/pgm.h" + +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(EndToEnd); + +static const char *inputFiles[] = +{ + "../TestImages/Person1/Bas1440999265-Hamster-0-0.png.pgm", + "../TestImages/Person1/Bas1440999265-Hamster-0-1.png.pgm", + "../TestImages/Person1/Bas1440999265-Hamster-0-2.png.pgm", + "../TestImages/Person1/Bas1440999265-Hamster-1-0.png.pgm", + "../TestImages/Person1/Bas1440999265-Hamster-1-1.png.pgm", + "../TestImages/Person1/Bas1440999265-Hamster-1-2.png.pgm" +}; + +// static const char *templateFiles[] = +// { +// "EndToEnd/Person1/Bas1440999265-Hamster-0-0.png.pgm.template", +// "EndToEnd/Person1/Bas1440999265-Hamster-0-1.png.pgm.template", +// "EndToEnd/Person1/Bas1440999265-Hamster-0-2.png.pgm.template", +// "EndToEnd/Person1/Bas1440999265-Hamster-1-0.png.pgm.template", +// "EndToEnd/Person1/Bas1440999265-Hamster-1-1.png.pgm.template", +// "EndToEnd/Person1/Bas1440999265-Hamster-1-2.png.pgm.template" +// }; + +TEST_SETUP(EndToEnd) +{ +} + +TEST_TEAR_DOWN(EndToEnd) +{ +} + +static void ImageToTemplate(const char *fileName) +{ + UInt8Array2D image = pgm_read(fileName); + + TEST_ASSERT_TRUE_MESSAGE(image.sizeX > 1, "Image Size X < 1"); + TEST_ASSERT_TRUE_MESSAGE(image.sizeY > 1, "Image Size Y < 1"); + + struct perfdata perfdata; + Extract(&image, &perfdata); + + // ::TODO:: Load some sort of template to check against the output... +} + +TEST(EndToEnd, ImageToTemplate) +{ + int length = sizeof(inputFiles) / sizeof(inputFiles[0]); + for(int i = 0; i < length; i++) + { + ImageToTemplate(inputFiles[i]); + } +} diff --git a/Sources/Tests/all_tests.c b/Sources/Tests/all_tests.c index 4872668..4555fbd 100644 --- a/Sources/Tests/all_tests.c +++ b/Sources/Tests/all_tests.c @@ -27,6 +27,9 @@ static void RunAllTests(void) printf("\nEqualizer tests\n"); RUN_TEST_GROUP(Equalizer); + + printf("\nEnd to End Image to Template tests\n"); + RUN_TEST_GROUP(EndToEnd); } int main(int argc, const char * argv[]) From dcaa23a68b3b6660fca923cd4bd0711a6db21095 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 12:11:38 +0000 Subject: [PATCH 03/10] Add a first pass at porting the Template. Also tweak a few biuts to add the new Template into the code in the right place. --- Sources/Extraction/Extract.c | 5 ++++- Sources/Extraction/Extract.h | 8 +++++--- Sources/Makefile | 3 ++- Sources/Templates/Minutia.h | 17 +++++++++++++++++ Sources/Templates/Template.c | 6 ++++++ Sources/Templates/Template.h | 18 ++++++++++++++++++ Sources/Tests/EndToEnd/Test_EndToEnd.c | 5 +++-- Sources/Tests/extract.c | 5 +++-- 8 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 Sources/Templates/Minutia.h create mode 100644 Sources/Templates/Template.c create mode 100644 Sources/Templates/Template.h diff --git a/Sources/Extraction/Extract.c b/Sources/Extraction/Extract.c index d8e7c2c..52e31a1 100644 --- a/Sources/Extraction/Extract.c +++ b/Sources/Extraction/Extract.c @@ -7,7 +7,7 @@ const int blockSize = 16; -void Extract(UInt8Array2D *image, struct perfdata *perfdata) +void Extract(UInt8Array2D *image, Template *template, perfdata *perfdata) { if (perfdata) gettimeofday(&perfdata->start, 0); Size size = Size_Construct(image->sizeX, image->sizeY); @@ -47,5 +47,8 @@ void Extract(UInt8Array2D *image, struct perfdata *perfdata) // Minutiae filtering if (perfdata) gettimeofday(&perfdata->start_filtering, 0); + // Generate Template + if (perfdata) gettimeofday(&perfdata->start_template, 0); + if (perfdata) gettimeofday(&perfdata->end, 0); } diff --git a/Sources/Extraction/Extract.h b/Sources/Extraction/Extract.h index a0c90c9..2dfebba 100644 --- a/Sources/Extraction/Extract.h +++ b/Sources/Extraction/Extract.h @@ -1,7 +1,8 @@ #include #include "General/Array.h" +#include "Templates/Template.h" -struct perfdata { +typedef struct perfdata { struct timeval start; struct timeval start_histogram; struct timeval start_segmentation; @@ -11,7 +12,8 @@ struct perfdata { struct timeval start_thinning; struct timeval start_detection; struct timeval start_filtering; + struct timeval start_template; struct timeval end; -}; +} perfdata; -void Extract(UInt8Array2D *image, struct perfdata *perfdata); +void Extract(UInt8Array2D *, Template *, perfdata *); diff --git a/Sources/Makefile b/Sources/Makefile index 3d29d52..30d24a2 100644 --- a/Sources/Makefile +++ b/Sources/Makefile @@ -47,7 +47,8 @@ UTEST_EXE = all_tests LIBAFIS_SRCS = General/*.c \ Extraction/Filters/*.c \ Extraction/Model/*.c \ - Extraction/*.c + Extraction/*.c \ + Templates/*.c LIBAFIS_SRCS_EXCLUDE = UTILS_SRCS = IO/*.c diff --git a/Sources/Templates/Minutia.h b/Sources/Templates/Minutia.h new file mode 100644 index 0000000..ef2bba7 --- /dev/null +++ b/Sources/Templates/Minutia.h @@ -0,0 +1,17 @@ +#ifndef TEMPLATES_MINUTIA_H +#define TEMPLATES_MINUTIA_H + +#include "General/Point.h" + +#include + +typedef enum {ENDING = 0, BIFURCATION = 1, OTHER = 2} MinutiaType; + +typedef struct Minutia +{ + Point position; + uint8_t direction; + MinutiaType type; +} Minutia; + +#endif diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c new file mode 100644 index 0000000..d9bfc5e --- /dev/null +++ b/Sources/Templates/Template.c @@ -0,0 +1,6 @@ +#include "Templates/Template.h" + +void AddMinitia(Template *template, Minutia *minutia) +{ + List_AddData(&template->minutiae, minutia); +} \ No newline at end of file diff --git a/Sources/Templates/Template.h b/Sources/Templates/Template.h new file mode 100644 index 0000000..ebf83e4 --- /dev/null +++ b/Sources/Templates/Template.h @@ -0,0 +1,18 @@ +#ifndef TEMPLATES_TEMPLATE_H +#define TEMPLATES_TEMPLATE_H + +#include "Templates/Minutia.h" +#include "General/List.h" +#include + +typedef struct Template +{ + int32_t originalDpi; + int32_t originalWidth; + int32_t originalHeight; + List minutiae; +} Template; + +void AddMinitia(Template *, Minutia *); + +#endif diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c index 12451c7..cecf083 100644 --- a/Sources/Tests/EndToEnd/Test_EndToEnd.c +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -41,8 +41,9 @@ static void ImageToTemplate(const char *fileName) TEST_ASSERT_TRUE_MESSAGE(image.sizeX > 1, "Image Size X < 1"); TEST_ASSERT_TRUE_MESSAGE(image.sizeY > 1, "Image Size Y < 1"); - struct perfdata perfdata; - Extract(&image, &perfdata); + perfdata perfdata; + Template template; + Extract(&image, &template, &perfdata); // ::TODO:: Load some sort of template to check against the output... } diff --git a/Sources/Tests/extract.c b/Sources/Tests/extract.c index e2f7672..4a7a6cf 100644 --- a/Sources/Tests/extract.c +++ b/Sources/Tests/extract.c @@ -30,8 +30,9 @@ int main(int argc, char* argv[]) if (image.sizeX == 1 && image.sizeY == 1) continue; - struct perfdata perfdata; - Extract(&image, &perfdata); + perfdata perfdata; + Template template; + Extract(&image, &template, &perfdata); printf("Histogram generation: %f\n", diff(perfdata.start_segmentation, perfdata.start_histogram)); printf(" Segmentation: %f\n", diff(perfdata.start_equalization, perfdata.start_segmentation)); From fa92bd94e9775d0cdf2f71e477532a80339fd337 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 17:21:12 +0000 Subject: [PATCH 04/10] Test the list --- Sources/Tests/General/Test_List.c | 80 +++++++++++++++++++ .../Tests/General/runners/TestRunner_List.c | 9 +++ Sources/Tests/all_tests.c | 18 +++-- 3 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 Sources/Tests/General/Test_List.c create mode 100644 Sources/Tests/General/runners/TestRunner_List.c diff --git a/Sources/Tests/General/Test_List.c b/Sources/Tests/General/Test_List.c new file mode 100644 index 0000000..6764455 --- /dev/null +++ b/Sources/Tests/General/Test_List.c @@ -0,0 +1,80 @@ +#include "General/List.h" +#include "General/Point.h" +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(List); + +TEST_SETUP(List) +{ +} + +TEST_TEAR_DOWN(List) +{ +} + +#define MAX_NUMBER_ELEMENTS 10000 +TEST(List, TestListWithNoData) +{ + List list = List_Construct(); + for (int i = 0; i < MAX_NUMBER_ELEMENTS; i++) + { + List_AddData(&list, (void *)(long)i); + } + TEST_ASSERT_EQUAL_INT_MESSAGE(MAX_NUMBER_ELEMENTS, List_GetCount(&list), "List is not correct size"); + while(list.head != NULL) + { + List_Remove(&list, list.head, NULL); + } + TEST_ASSERT_EQUAL_INT_MESSAGE(0, List_GetCount(&list), "List is not empty but was expected so..."); +} + +TEST(List, TestListRemoval) +{ + List list = List_Construct(); + for (int i = 0; i < MAX_NUMBER_ELEMENTS; i++) + { + List_AddData(&list, (void *)(long)i); + } + long idToRemove = (MAX_NUMBER_ELEMENTS/2); + List_RemoveData(&list, (void *) (long) idToRemove ); + TEST_ASSERT_EQUAL_INT_MESSAGE(MAX_NUMBER_ELEMENTS-1, List_GetCount(&list), "List is not right length"); + + for (ListElement *p = list.head; p != NULL; p = p->next) + { + TEST_ASSERT_NOT_EQUAL_MESSAGE(idToRemove, (long)p->data, "Found data we have removed!"); + } + + while(list.head != NULL) + { + List_Remove(&list, list.head, NULL); + } + TEST_ASSERT_EQUAL_INT_MESSAGE(0, List_GetCount(&list), "List is not empty but was expected so..."); +} + +typedef struct _fred +{ + List Points; +} FRED; + +TEST(List, TestListDyanmicMemoryAlloc) +{ + FRED data; + { + List list1 = List_Construct(); + data.Points = list1; + } + + for (int i = 0; i< MAX_NUMBER_ELEMENTS; i++) + { + void *data1 = calloc(1, sizeof(Point)); + List_AddData(&data.Points, data1); + } + + while (List_GetCount(&data.Points) > 0) + { + void *dataFound; + List_Remove(&data.Points, data.Points.head, &dataFound); + free(dataFound); + } +} \ No newline at end of file diff --git a/Sources/Tests/General/runners/TestRunner_List.c b/Sources/Tests/General/runners/TestRunner_List.c new file mode 100644 index 0000000..633c5b8 --- /dev/null +++ b/Sources/Tests/General/runners/TestRunner_List.c @@ -0,0 +1,9 @@ +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(List) +{ + RUN_TEST_CASE(List, TestListWithNoData); + RUN_TEST_CASE(List, TestListRemoval); + RUN_TEST_CASE(List, TestListDyanmicMemoryAlloc); +} diff --git a/Sources/Tests/all_tests.c b/Sources/Tests/all_tests.c index 4555fbd..2585762 100644 --- a/Sources/Tests/all_tests.c +++ b/Sources/Tests/all_tests.c @@ -9,10 +9,16 @@ static void RunAllTests(void) { printf("\nPoint tests\n"); RUN_TEST_GROUP(Point); + printf("\nArray tests\n"); RUN_TEST_GROUP(Array); + printf("\nBinaryMap tests\n"); RUN_TEST_GROUP(BinaryMap); + + printf("\nList tests\n"); + RUN_TEST_GROUP(List); + printf("\nPgm tests\n"); RUN_TEST_GROUP(Pgm); @@ -21,22 +27,22 @@ static void RunAllTests(void) printf("\nLocal histogram tests\n"); RUN_TEST_GROUP(LocalHistogram); - + printf("\nEnsure we an load serialised binary data\n"); RUN_TEST_GROUP(DataStructures); printf("\nEqualizer tests\n"); RUN_TEST_GROUP(Equalizer); - + printf("\nEnd to End Image to Template tests\n"); RUN_TEST_GROUP(EndToEnd); } int main(int argc, const char * argv[]) { - if (argc == 2) - { - chdir(argv[1]); - } + if (argc == 2) + { + chdir(argv[1]); + } return UnityMain(argc, argv, RunAllTests); } From 60aa2fffbd14cfef8a274b18e5951fab31ba3c4d Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 17:21:38 +0000 Subject: [PATCH 05/10] Fix the list... --- Sources/General/List.c | 1 + Sources/General/List.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/General/List.c b/Sources/General/List.c index b27c510..79e938e 100644 --- a/Sources/General/List.c +++ b/Sources/General/List.c @@ -75,6 +75,7 @@ void List_AddData(List *me, const void *data) else { elem->prev = me->tail; + elem->prev->next = elem; } me->tail = elem; diff --git a/Sources/General/List.h b/Sources/General/List.h index 478d35f..afed8ed 100644 --- a/Sources/General/List.h +++ b/Sources/General/List.h @@ -1,6 +1,6 @@ #ifndef GENERAL_LIST_H #define GENERAL_LIST_H - +#include #include typedef struct ListElement From c922934ca2f12be18ca615ccd8ffa16cdde2f051 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 17:22:17 +0000 Subject: [PATCH 06/10] First pass at end-to-end with output to a template. --- Sources/Templates/Template.c | 29 ++++++++- Sources/Templates/Template.h | 4 +- Sources/Tests/EndToEnd/Test_EndToEnd.c | 85 +++++++++++++++++++++----- 3 files changed, 100 insertions(+), 18 deletions(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index d9bfc5e..5ad921b 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -1,6 +1,31 @@ #include "Templates/Template.h" +#include "General/List.h" +#include +#include -void AddMinitia(Template *template, Minutia *minutia) +void Template_AddMinitia(Template *template, Minutia *minutia) { List_AddData(&template->minutiae, minutia); -} \ No newline at end of file +} + +List *Template_GetMinutiae(Template *template) +{ + return &template->minutiae; +} + +Template Template_Constuct() +{ + Template template; + template.minutiae = List_Construct(); + return template; +} + +void Template_Free(Template *template) +{ + while (List_GetCount(&template->minutiae) > 0) + { + void *dataFound; + List_Remove(&template->minutiae, template->minutiae.tail, &dataFound); + free(dataFound); + } +} diff --git a/Sources/Templates/Template.h b/Sources/Templates/Template.h index ebf83e4..0450d76 100644 --- a/Sources/Templates/Template.h +++ b/Sources/Templates/Template.h @@ -13,6 +13,8 @@ typedef struct Template List minutiae; } Template; -void AddMinitia(Template *, Minutia *); +Template Template_Constuct(void); +void Template_AddMinitia(Template *, Minutia *); +void Template_Free(Template *); #endif diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c index cecf083..28b9827 100644 --- a/Sources/Tests/EndToEnd/Test_EndToEnd.c +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -1,8 +1,10 @@ #include "Extraction/Extract.h" #include "General/pgm.h" - +#include "Templates/Template.h" #include "unity.h" #include "unity_fixture.h" +#include +#include TEST_GROUP(EndToEnd); @@ -16,16 +18,6 @@ static const char *inputFiles[] = "../TestImages/Person1/Bas1440999265-Hamster-1-2.png.pgm" }; -// static const char *templateFiles[] = -// { -// "EndToEnd/Person1/Bas1440999265-Hamster-0-0.png.pgm.template", -// "EndToEnd/Person1/Bas1440999265-Hamster-0-1.png.pgm.template", -// "EndToEnd/Person1/Bas1440999265-Hamster-0-2.png.pgm.template", -// "EndToEnd/Person1/Bas1440999265-Hamster-1-0.png.pgm.template", -// "EndToEnd/Person1/Bas1440999265-Hamster-1-1.png.pgm.template", -// "EndToEnd/Person1/Bas1440999265-Hamster-1-2.png.pgm.template" -// }; - TEST_SETUP(EndToEnd) { } @@ -34,18 +26,78 @@ TEST_TEAR_DOWN(EndToEnd) { } -static void ImageToTemplate(const char *fileName) +static void ReadTemplate(const char *expectedFileName, Template *expectedTemplate) { - UInt8Array2D image = pgm_read(fileName); + FILE *f = fopen(expectedFileName, "rb"); + + int ret = fread(&expectedTemplate->originalDpi, sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed originalDPI"); + + ret = fread(&expectedTemplate->originalHeight, sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed originalHeight"); + + ret = fread(&expectedTemplate->originalWidth, sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed originalWidth"); + + int32_t count; + ret = fread(&count, sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed on minutiae count"); + + for(int i = 0; i < count; i++) + { + Minutia *minutia = calloc(1, sizeof(Minutia)); + + ret = fread(&(minutia->direction), sizeof(int8_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed on minutia->direction"); + + ret = fread(&(minutia->position.x), sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed minutia->position.x"); + + ret = fread(&(minutia->position.y), sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed minutia->position.y"); + + ret = fread(&(minutia->type), sizeof(int32_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed on minutia->type"); + + Template_AddMinitia(expectedTemplate, minutia); + } + + /* Check end of file */ + uint8_t tmp; + ret = fread(&tmp, sizeof(uint8_t), 1, f); + TEST_ASSERT_TRUE_MESSAGE(ret == 0 && feof(f), "ReadTemplate: Bad end of file"); + + /* Close file */ + ret = fclose(f); + assert(ret != EOF); +} + +static void ImageToTemplate(const char *inputFileName, const char *expectedFileName) +{ + UInt8Array2D image = pgm_read(inputFileName); TEST_ASSERT_TRUE_MESSAGE(image.sizeX > 1, "Image Size X < 1"); TEST_ASSERT_TRUE_MESSAGE(image.sizeY > 1, "Image Size Y < 1"); perfdata perfdata; - Template template; + + Template template = Template_Constuct(); + template.minutiae = List_Construct(); + + printf("%s %s\r\n", inputFileName, expectedFileName); + + Template expectedTemplate; + expectedTemplate.minutiae = List_Construct(); + + void *dataFound = malloc(sizeof(Minutia)); + printf("Data %ld %p\r\n", sizeof(Minutia), dataFound); + Template_AddMinitia(&expectedTemplate, dataFound ); Extract(&image, &template, &perfdata); // ::TODO:: Load some sort of template to check against the output... + ReadTemplate(expectedFileName, &expectedTemplate); + +// Template_Free(&expectedTemplate); } TEST(EndToEnd, ImageToTemplate) @@ -53,6 +105,9 @@ TEST(EndToEnd, ImageToTemplate) int length = sizeof(inputFiles) / sizeof(inputFiles[0]); for(int i = 0; i < length; i++) { - ImageToTemplate(inputFiles[i]); + char templateFile[256]; + strcpy(templateFile, inputFiles[i]); + strcat(templateFile, ".template"); + ImageToTemplate(inputFiles[i], templateFile); } } From 3cf73b37c14959ed461119d7c1a7cf8df0674384 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 17:22:40 +0000 Subject: [PATCH 07/10] Some tesmplate files. These are incorrect, but are a stepping stone... --- .../Bas1440999265-Hamster-0-0.png.pgm.template | Bin 0 -> 796 bytes .../Bas1440999265-Hamster-0-1.png.pgm.template | Bin 0 -> 783 bytes .../Bas1440999265-Hamster-0-2.png.pgm.template | Bin 0 -> 770 bytes .../Bas1440999265-Hamster-1-0.png.pgm.template | Bin 0 -> 848 bytes .../Bas1440999265-Hamster-1-1.png.pgm.template | Bin 0 -> 848 bytes .../Bas1440999265-Hamster-1-2.png.pgm.template | Bin 0 -> 809 bytes 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 TestImages/Person1/Bas1440999265-Hamster-0-0.png.pgm.template create mode 100755 TestImages/Person1/Bas1440999265-Hamster-0-1.png.pgm.template create mode 100755 TestImages/Person1/Bas1440999265-Hamster-0-2.png.pgm.template create mode 100755 TestImages/Person1/Bas1440999265-Hamster-1-0.png.pgm.template create mode 100755 TestImages/Person1/Bas1440999265-Hamster-1-1.png.pgm.template create mode 100755 TestImages/Person1/Bas1440999265-Hamster-1-2.png.pgm.template diff --git a/TestImages/Person1/Bas1440999265-Hamster-0-0.png.pgm.template b/TestImages/Person1/Bas1440999265-Hamster-0-0.png.pgm.template new file mode 100755 index 0000000000000000000000000000000000000000..c0aa6829c8f9a2303be57970ae11de618d8b320c GIT binary patch literal 796 zcmXw%ODKd<0EI7W8yagnDK=h{uu?=4Lf&e~Yca@c;gKc_QbH*uvXPRByKm~M=z*g_g1*}N?xOHjDqLptPuzm{ID za65qP2CXr}Su{BWEzrAX=`^bt z-Ikq#dNd52xrB0znjQyQV1w%#b7w>G3+4n0oB7=4`SZpRMyMcgF|IYF&^D{l47qGm zwv6ewjWdI$#x}WAm_ZwSW0*M`>aQ^4P*_V~jt)#njv}}*TujRjvIhmfKE@DKv#n)I zpb&^*NP7}4Cy>;jHKs3|W}2Wm<)esRR(RKb{!gJfkzVI2H29Ijpyfvz!JOMr{ff~m z32D8|>BMMhZ#=r9VNj^O=(N?GyAb`sLa9E;{~uEKL8yef&3%B}Kq0A=p=ykp_6SrT GMEC{J9AlRN literal 0 HcmV?d00001 diff --git a/TestImages/Person1/Bas1440999265-Hamster-0-1.png.pgm.template b/TestImages/Person1/Bas1440999265-Hamster-0-1.png.pgm.template new file mode 100755 index 0000000000000000000000000000000000000000..ae22f4c056f197e96cbf11765d6257a3da653de6 GIT binary patch literal 783 zcmYk3K}eHf7{?zW2rorL=op01!Mb#qhX}exYAMWZte_e+K^N13VFi62B040a5Ge)` zL{LExixCtwL8UPvwvdT}FuZuk5fz>L{kP|X9{B(F|Gm%mz3<-V`_p4~5*5%HGiwyF z`v|s+0rt}2>U+W%Qf=PDzI3A5_#R;u>7C{??72hx4dE?PmFKW4ooKdQA>4ITrs1b*!HckCfjUHE|o zNS${&Bkr(YA}k_RLU+;CRlmyEI?_ACPqDzEex0S)fNG}?&>ZyGs1BTUsQe~8cF1X( z6{M=3;^7b7Y~>+f9?%BGqxdcFqWc_yg~p)7E#rGcrv`dZ#u?nD9<~i4e{$ zc90F0y_3=m&O1cobW#rKHX($fZmL7={avYO78!%b}vPAB<^)eK_IT2Xw%ADdYt=wQ{iYuM*bmVpW@b7Cy9MU35Nvey3EmRPL*x+I*J|}r|;GFNA`@Z+y?_O@c%(;g!3LiV?&Qi!Q zB)ii+3w+$o9kL<^lJm$%sJ7fH@)-&PM~EogB#>`VZQd>N77E@!WT9Z4d-el!VBur} z<5`GQGINQb1+sDEgN0xWvt=RsfV%!oZSC90a|^rU3{4Y+*(yRy(YrpKGzvB6T^-tE zmBc8f(}J&pN|2zorD}AYVQ95qel&v-0^0O7RHa^zFJfU}ALBvc E9;vfs^8f$< literal 0 HcmV?d00001 diff --git a/TestImages/Person1/Bas1440999265-Hamster-1-0.png.pgm.template b/TestImages/Person1/Bas1440999265-Hamster-1-0.png.pgm.template new file mode 100755 index 0000000000000000000000000000000000000000..fa19cd497893f7490f22dc482793830fa8fb91fa GIT binary patch literal 848 zcmYk5K}eHv7{>q7!8$|`RA++@kvmA_21$%ThZs^KBM%!L#vC#Xy%<_TnTAkA1hLu0 z#6#(>5y2S5)FF(Jjc_qbbZu-B)TM*z#ozPo|A7xY56|a znM@-$p^%ACjkdfge8 literal 0 HcmV?d00001 diff --git a/TestImages/Person1/Bas1440999265-Hamster-1-1.png.pgm.template b/TestImages/Person1/Bas1440999265-Hamster-1-1.png.pgm.template new file mode 100755 index 0000000000000000000000000000000000000000..153e7e3e8b36a7e9a8a063694ed598b6956a87d6 GIT binary patch literal 848 zcmXw%K}eKQ6oqe#+(e5~a3w)I(H0gsf`Wq}7#3nEx=2E0D3L@riHWF)M`cVbsiK3ozXn zAwGdr2G%Uyh8gyd$Y!kG!{SX$+{54|<}PHwZmc5BP*^EJhM+pvl1L2{RwIFZ4%Ht%4HJjCZPEl|6CI7D81NETzJp-^$1eow|*S|e*vYrZ!kI&2VP=mJ4F zi6MPZox?8V3<_=EkdJ{iJMF|YK#hI6Ku|jjTiA=^x}cux625 z%nuK#C}zpS=s!${ha=sBu0?pYi@Xi2Su%<_h5AnGJ7mklS{9`df-qi8$jf*ey-K*} zVLc!7+{4Hv=9Y)~2aJV};(jCHg?BnXV_rgPR#lGndMBmb!m|w|2!-DHso%2VmbVJApj(Fj-G2e7z@MsUARKs)mjp olMvI*rJ*+1c!Kl;3qVDA0lKBY^8i-$#+eRVT~0g6IWR3T_r}aRstDB zHuPHTuO7-UX27i^k&U*ppGff<%>7b&3{DCdTQcyxQGy1QrL07^HxLKR+sb_frNv-f z|D(I+$L)B@I)jU5%9%mDpHhpZ^;*WVBi-$#Q33|n#S~dO*OfNI)wv_>^|--GJ{L$a zxT&V(7Bwun^0kJV5d-6Ip7=s}0mMNk?VGfg19c5g%ArJ1!z-40^UG z6Ii Date: Thu, 5 Nov 2015 18:15:32 +0000 Subject: [PATCH 08/10] GAH UNITY!!!! --- Sources/Templates/Minutia.h | 4 ++-- Sources/Templates/Template.c | 8 +++---- Sources/Templates/Template.h | 2 +- Sources/Tests/EndToEnd/Test_EndToEnd.c | 31 +++++++++++++++----------- Sources/Tests/General/Test_List.c | 8 ++++--- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Sources/Templates/Minutia.h b/Sources/Templates/Minutia.h index ef2bba7..82c56e4 100644 --- a/Sources/Templates/Minutia.h +++ b/Sources/Templates/Minutia.h @@ -7,11 +7,11 @@ typedef enum {ENDING = 0, BIFURCATION = 1, OTHER = 2} MinutiaType; -typedef struct Minutia +typedef struct TemplateMinutia { Point position; uint8_t direction; MinutiaType type; -} Minutia; +} TemplateMinutia; #endif diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index 5ad921b..db14796 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -3,9 +3,9 @@ #include #include -void Template_AddMinitia(Template *template, Minutia *minutia) +void Template_AddMinuitia(Template *template, TemplateMinutia *minutia) { - List_AddData(&template->minutiae, minutia); + List_AddData(&(template->minutiae), minutia); } List *Template_GetMinutiae(Template *template) @@ -22,10 +22,10 @@ Template Template_Constuct() void Template_Free(Template *template) { - while (List_GetCount(&template->minutiae) > 0) + while (List_GetCount(&(template->minutiae)) > 0) { void *dataFound; - List_Remove(&template->minutiae, template->minutiae.tail, &dataFound); + List_Remove(&(template->minutiae), (template->minutiae.tail), &dataFound); free(dataFound); } } diff --git a/Sources/Templates/Template.h b/Sources/Templates/Template.h index 0450d76..8477ede 100644 --- a/Sources/Templates/Template.h +++ b/Sources/Templates/Template.h @@ -14,7 +14,7 @@ typedef struct Template } Template; Template Template_Constuct(void); -void Template_AddMinitia(Template *, Minutia *); +void Template_AddMinuitia(Template *, TemplateMinutia *); void Template_Free(Template *); #endif diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c index 28b9827..854a1df 100644 --- a/Sources/Tests/EndToEnd/Test_EndToEnd.c +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -45,7 +45,7 @@ static void ReadTemplate(const char *expectedFileName, Template *expectedTemplat for(int i = 0; i < count; i++) { - Minutia *minutia = calloc(1, sizeof(Minutia)); + TemplateMinutia *minutia = calloc(1, sizeof(TemplateMinutia)); ret = fread(&(minutia->direction), sizeof(int8_t), 1, f); TEST_ASSERT_TRUE_MESSAGE(ret == 1, "ReadTemplate: failed on minutia->direction"); @@ -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_AddMinitia(expectedTemplate, minutia); + Template_AddMinuitia(expectedTemplate, minutia); } /* Check end of file */ @@ -72,6 +72,17 @@ static void ReadTemplate(const char *expectedFileName, Template *expectedTemplat assert(ret != EOF); } + +static void UnityFreeTemplate(Template *template) +{ + while (List_GetCount(&template->minutiae) > 0) + { + void *dataFound; + List_Remove(&template->minutiae, template->minutiae.tail, &dataFound); + free(dataFound); + } +} + static void ImageToTemplate(const char *inputFileName, const char *expectedFileName) { UInt8Array2D image = pgm_read(inputFileName); @@ -81,23 +92,17 @@ static void ImageToTemplate(const char *inputFileName, const char *expectedFileN perfdata perfdata; - Template template = Template_Constuct(); - template.minutiae = List_Construct(); - - printf("%s %s\r\n", inputFileName, expectedFileName); - + Template template = Template_Constuct(); Template expectedTemplate; expectedTemplate.minutiae = List_Construct(); + + printf("%s %s\r\n", inputFileName, expectedFileName); - void *dataFound = malloc(sizeof(Minutia)); - printf("Data %ld %p\r\n", sizeof(Minutia), dataFound); - Template_AddMinitia(&expectedTemplate, dataFound ); Extract(&image, &template, &perfdata); - // ::TODO:: Load some sort of template to check against the output... ReadTemplate(expectedFileName, &expectedTemplate); - -// Template_Free(&expectedTemplate); + + UnityFreeTemplate(&expectedTemplate); } TEST(EndToEnd, ImageToTemplate) diff --git a/Sources/Tests/General/Test_List.c b/Sources/Tests/General/Test_List.c index 6764455..f5d949a 100644 --- a/Sources/Tests/General/Test_List.c +++ b/Sources/Tests/General/Test_List.c @@ -1,7 +1,7 @@ -#include "General/List.h" -#include "General/Point.h" #include "unity.h" #include "unity_fixture.h" +#include "General/List.h" +#include "Templates/Template.h" TEST_GROUP(List); @@ -67,7 +67,7 @@ TEST(List, TestListDyanmicMemoryAlloc) for (int i = 0; i< MAX_NUMBER_ELEMENTS; i++) { - void *data1 = calloc(1, sizeof(Point)); + void *data1 = calloc(1, sizeof(TemplateMinutia)); List_AddData(&data.Points, data1); } @@ -77,4 +77,6 @@ TEST(List, TestListDyanmicMemoryAlloc) List_Remove(&data.Points, data.Points.head, &dataFound); free(dataFound); } + + } \ No newline at end of file From 623bf1e0331799fbcb104e7f01ca9a67ca9e3872 Mon Sep 17 00:00:00 2001 From: Bob Arnott Date: Thu, 5 Nov 2015 19:03:59 +0000 Subject: [PATCH 09/10] Added comparison --- Sources/Templates/Template.c | 3 ++ Sources/Tests/EndToEnd/Test_EndToEnd.c | 40 ++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Sources/Templates/Template.c b/Sources/Templates/Template.c index db14796..cf0ac0a 100644 --- a/Sources/Templates/Template.c +++ b/Sources/Templates/Template.c @@ -16,6 +16,9 @@ List *Template_GetMinutiae(Template *template) Template Template_Constuct() { Template template; + template.originalDpi = 0; + template.originalWidth = 0; + template.originalHeight = 0; template.minutiae = List_Construct(); return template; } diff --git a/Sources/Tests/EndToEnd/Test_EndToEnd.c b/Sources/Tests/EndToEnd/Test_EndToEnd.c index 854a1df..ec703c1 100644 --- a/Sources/Tests/EndToEnd/Test_EndToEnd.c +++ b/Sources/Tests/EndToEnd/Test_EndToEnd.c @@ -93,15 +93,49 @@ static void ImageToTemplate(const char *inputFileName, const char *expectedFileN perfdata perfdata; Template template = Template_Constuct(); - Template expectedTemplate; - expectedTemplate.minutiae = List_Construct(); - + Template expectedTemplate = Template_Constuct(); + printf("%s %s\r\n", inputFileName, expectedFileName); Extract(&image, &template, &perfdata); ReadTemplate(expectedFileName, &expectedTemplate); + + printf("originalDpi %d %d\n", expectedTemplate.originalDpi, template.originalDpi); + printf("originalWidth %d %d\n", expectedTemplate.originalWidth, template.originalWidth); + printf("originalHeight %d %d\n", expectedTemplate.originalHeight, template.originalHeight); + printf("#minutiae %d %d\n", expectedTemplate.minutiae.count, template.minutiae.count); + List matching = List_Construct(); + List missingFromExpected = List_Construct(); + List missingFromTemplate= List_Construct(); + + for (ListElement *i = expectedTemplate.minutiae.head; i != NULL; i = i->next) + { + TemplateMinutia *expected = i->data; + bool found = false; + for (ListElement *j = template.minutiae.head; j != NULL; j = j->next) + { + TemplateMinutia *templateMin = i->data; + if ((templateMin->type == expected->type) && (templateMin->direction == expected->direction) && (templateMin->position.x == expected->position.x) && (templateMin->position.y == expected->position.y)) + { + List_AddData(&matching, expected); + found = true; + } + } + if (!found) + { + List_AddData(&missingFromTemplate, expected); + } + } + if (expectedTemplate.minutiae.count > 0) + { + printf("Matching = %d%%\n", matching.count * 100 / expectedTemplate.minutiae.count); + printf("Missing from template = %d%%\n", missingFromTemplate.count * 100 / expectedTemplate.minutiae.count); + printf("Missing from expected = %d%%\n", missingFromExpected.count * 100 / expectedTemplate.minutiae.count); + } + + UnityFreeTemplate(&template); UnityFreeTemplate(&expectedTemplate); } From 82c27aaf85e89dc380efc93da77ba6a8248ea7cf Mon Sep 17 00:00:00 2001 From: Alexie Staffer Date: Mon, 23 Nov 2015 20:43:58 +0000 Subject: [PATCH 10/10] Make Explicit TODO's in EndToEnd Test. --- Sources/Extraction/Extract.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Extraction/Extract.c b/Sources/Extraction/Extract.c index e533312..bd22d16 100644 --- a/Sources/Extraction/Extract.c +++ b/Sources/Extraction/Extract.c @@ -72,13 +72,16 @@ void Extract(UInt8Array2D *image, Template *template, struct perfdata *perfdata, // Minutiae detection if (perfdata) gettimeofday(&perfdata->start_detection, 0); + //TODO: wire-up minutiae detection. // Minutiae filtering if (perfdata) gettimeofday(&perfdata->start_filtering, 0); + //TODO: wire-up minutiae filtering. // Generate Template if (perfdata) gettimeofday(&perfdata->start_template, 0); - + //TODO: Generate Template from minutiae. + if (perfdata) gettimeofday(&perfdata->end, 0); // Cleanup