From e88d243637375c6ca3371b6e8210943c6820cb40 Mon Sep 17 00:00:00 2001 From: Jared Bruni Date: Sat, 29 Aug 2020 19:30:37 -0700 Subject: [PATCH] updated test program --- tests/test-filters.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/test-filters.cpp b/tests/test-filters.cpp index 32c69f38..0d209bb7 100644 --- a/tests/test-filters.cpp +++ b/tests/test-filters.cpp @@ -1,7 +1,9 @@ /* Test If Basic Filters are working. */ #include +#include #include"ac.h" +#include int main(int argc, char **argv) { cv::Mat test_image; @@ -14,8 +16,12 @@ int main(int argc, char **argv) { } } - if(argc == 2) + int wait_val = 0; + + if(argc >= 2) test_image = cv::imread(argv[1]); + if(argc >= 3) + wait_val = atoi(argv[2]); if(test_image.empty()) { std::cerr << "Error image could not be loaded.\n"; @@ -27,20 +33,49 @@ int main(int argc, char **argv) { // initialize libacidcam ac::fill_filter_map(); ac::setMaxAllocated(1500); + std::fstream file; + file.open("output.txt", std::ios::out); + if(!file.is_open()) { + std::cerr << "Error couldn't open file\n"; + exit(0); + } // print out library version std::cout << "Library Version: " << ac::getVersion() << "\n"; for(unsigned int i = 0; i < ac::solo_filter.size()-2; ++i) { std::cout << "[" << i << "/" << ac::solo_filter.size() << "] - Testing Filter: " << ac::solo_filter[i] << "\n"; + bool add = true; + for(int j = 0; j < 30; ++j) { cv::Mat test_image_copy = test_image_sized.clone(); + std::chrono::time_point now = + std::chrono::system_clock::now(); ac::CallFilter(ac::solo_filter[i], test_image_copy); if(j == 29) { //std::ostringstream stream; //stream << "./images/" << ac::solo_filter[i] << ".png"; //cv::imwrite(stream.str(), test_image_copy); } + + std::chrono::time_point nowx = + std::chrono::system_clock::now(); + auto m = std::chrono::duration_cast(nowx-now).count(); + if(wait_val == 0 || m < wait_val) { + add = true; + } + else { + add = false; + std::cout << "to slow..\n"; + break; + } } + std::cout << "Passed...\n"; + if(add == true) { + std::cout << "This one is Fast enough\n"; + file << ac::solo_filter[i] << "\n"; + } else { + std::cout << "This one is not fast enough\n"; + } ac::release_all_objects(); std::cout << "Cleared Frames...\n"; }