From 08ea142e9e428bbfdf8e61acfef86f8accc8e0f9 Mon Sep 17 00:00:00 2001 From: Shreyas Patel Date: Sun, 10 Apr 2016 12:04:50 +0530 Subject: [PATCH] Added time functions for windows platform --- common/utils/utils.h | 43 +++++++++++++------ .../detection/ODCADRecognizer2DLocal.cpp | 2 - .../detection/simple_ransac_detection/Utils.h | 7 ++- .../main_detection_image_wo_k.cpp | 8 +++- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/common/utils/utils.h b/common/utils/utils.h index 0bee4314..791cbedf 100644 --- a/common/utils/utils.h +++ b/common/utils/utils.h @@ -5,7 +5,6 @@ #ifndef OPENDETECTION_UTILS_H #define OPENDETECTION_UTILS_H -#include #include #include #include @@ -17,6 +16,13 @@ #include +#if defined(_WIN32) + #define WIN32_LEAN_AND_MEAN + #include +#else + #include +#endif + namespace bf = boost::filesystem; @@ -121,13 +127,29 @@ namespace od class Timer { private: - - timeval startTime; - + double duration_; + public: +#if defined(_WIN32) + double tStart, tEnd, duration; - double duration_; + void start() + { + tStart = timeGetTime(); + } + double stop() + { + tEnd = timeGetTime(); + duration = tEnd - tStart; + duration_ = duration; + return duration; + } +#else + struct timeval startTime, endTime; + long seconds, useconds; + double duration; + void start() { gettimeofday(&startTime, NULL); @@ -135,10 +157,6 @@ namespace od double stop() { - timeval endTime; - long seconds, useconds; - double duration; - gettimeofday(&endTime, NULL); seconds = endTime.tv_sec - startTime.tv_sec; @@ -148,10 +166,11 @@ namespace od duration_ = duration; return duration; } - - +#endif double getDuration() - { return duration_; } + { + return duration_; + } static void printTime(double duration) { diff --git a/detectors/local2D/detection/ODCADRecognizer2DLocal.cpp b/detectors/local2D/detection/ODCADRecognizer2DLocal.cpp index 078f82a2..add8637c 100644 --- a/detectors/local2D/detection/ODCADRecognizer2DLocal.cpp +++ b/detectors/local2D/detection/ODCADRecognizer2DLocal.cpp @@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include -#include // PnP Tutorial #include "simple_ransac_detection/Mesh.h" diff --git a/detectors/local2D/detection/simple_ransac_detection/Utils.h b/detectors/local2D/detection/simple_ransac_detection/Utils.h index 29ff27af..537f30c6 100644 --- a/detectors/local2D/detection/simple_ransac_detection/Utils.h +++ b/detectors/local2D/detection/simple_ransac_detection/Utils.h @@ -9,7 +9,12 @@ #define UTILS_H_ #include -#include +#if defined(_WIN32) + #define WIN32_LEAN_AND_MEAN + #include +#else + #include +#endif #include "PnPProblem.h" #include "Model.h" diff --git a/detectors/local2D/detection/simple_ransac_detection/main_detection_image_wo_k.cpp b/detectors/local2D/detection/simple_ransac_detection/main_detection_image_wo_k.cpp index c8e0f96a..105b7322 100644 --- a/detectors/local2D/detection/simple_ransac_detection/main_detection_image_wo_k.cpp +++ b/detectors/local2D/detection/simple_ransac_detection/main_detection_image_wo_k.cpp @@ -18,7 +18,13 @@ #include -#include +#if defined(_WIN32) + #define WIN32_LEAN_AND_MEAN + #include +#else + #include +#endif + // PnP Tutorial #include "Mesh.h"