diff --git a/src/cv/saliency.cpp b/src/cv/saliency.cpp index 32fbb4a5..9c3123db 100644 --- a/src/cv/saliency.cpp +++ b/src/cv/saliency.cpp @@ -7,6 +7,7 @@ #include #include "utilities/logging.hpp" + #define REGULAR_TARGET 1 #define MANNIKIN 2 @@ -25,6 +26,7 @@ Saliency::Saliency(std::string modelPath) { catch (const c10::Error& e) { LOG_F(ERROR, "error loading the model %s", e.msg().c_str()); } + } std::vector Saliency::salience(cv::Mat image) { diff --git a/tests/integration/cv_matching.cpp b/tests/integration/cv_matching.cpp index c9554c5d..95501366 100644 --- a/tests/integration/cv_matching.cpp +++ b/tests/integration/cv_matching.cpp @@ -7,6 +7,7 @@ #include "cv/matching.hpp" #include "utilities/constants.hpp" +#include "utilities/common.hpp" // Download these test images by running "make pull_matching_test_images" or from the test.zip here https://drive.google.com/drive/u/1/folders/1opXBWx6bBF7J3-JSFtrhfFIkYis9qhGR // Or, any cropped not-stolen images will work @@ -79,7 +80,10 @@ int main(int argc, char* argv[]) { cv::Mat ref4 = cv::imread(refImagePath4); referenceImages.push_back(std::make_pair(ref4, BottleDropIndex(1))); + auto startLoad = getUnixTime_ms().count(); Matching matcher(bottlesToDrop, referenceImages, modelPath); + auto endLoad = getUnixTime_ms().count(); + LOG_F(INFO, "time to load: %lu milliseconds", endLoad - startLoad); cv::Mat image = cv::imread(imageMatchPath); Bbox dummyBox(0, 0, 0, 0); CroppedTarget cropped = { @@ -95,15 +99,21 @@ int main(int argc, char* argv[]) { false }; + auto startMatch = getUnixTime_ms().count(); MatchResult result = matcher.match(cropped); + auto endMatch = getUnixTime_ms().count(); LOG_F(INFO, "\nTRUE MATCH TEST:\nClosest is bottle at index %d\nThe similarity is %.3f\n", int(result.bottleDropIndex), result.distance); + auto startMatchFalse = getUnixTime_ms().count(); MatchResult resultFalse = matcher.match(croppedFalse); + auto endMatchFalse = getUnixTime_ms().count(); LOG_F(INFO, "\nFALSE MATCH TEST:\nClosest is bottle at index %d\nThe similarity is %.3f\n", int(resultFalse.bottleDropIndex), resultFalse.distance); + LOG_F(INFO, "time to match: %lu milliseconds", + (endMatch - startMatch + endMatchFalse - startMatchFalse)/2); return 0; } \ No newline at end of file diff --git a/tests/integration/cv_saliency.cpp b/tests/integration/cv_saliency.cpp index f3a5c14c..3366e252 100644 --- a/tests/integration/cv_saliency.cpp +++ b/tests/integration/cv_saliency.cpp @@ -5,6 +5,7 @@ #include #include "cv/saliency.hpp" +#include "utilities/common.hpp" #include "loguru.hpp" // expected arguments: @@ -18,11 +19,18 @@ int main(int argc, const char* argv[]) { // convert image to tensor const char* modelPath = argv[1]; + auto startLoad = getUnixTime_ms().count(); Saliency sal(modelPath); + auto endLoad = getUnixTime_ms().count(); + LOG_F(INFO, "time to load: %u milliseconds", endLoad - startLoad); + const char* imgPath = argv[2]; cv::Mat img = cv::imread(imgPath, cv::IMREAD_COLOR); + auto startSalience = getUnixTime_ms().count(); std::vector predictions = sal.salience(img); + auto endSalience = getUnixTime_ms().count(); + LOG_F(INFO, "time to saliency: %u milliseconds", endSalience - startSalience); img = cv::imread(imgPath, cv::IMREAD_COLOR);