Skip to content

Commit

Permalink
Added time functions for windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas29 committed Apr 10, 2016
1 parent 7ff138b commit 08ea142
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
43 changes: 31 additions & 12 deletions common/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef OPENDETECTION_UTILS_H
#define OPENDETECTION_UTILS_H

#include <sys/time.h>
#include <boost/preprocessor.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
Expand All @@ -17,6 +16,13 @@
#include <glob.h>


#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/time.h>
#endif


namespace bf = boost::filesystem;

Expand Down Expand Up @@ -121,24 +127,36 @@ 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);
}

double stop()
{
timeval endTime;
long seconds, useconds;
double duration;

gettimeofday(&endTime, NULL);

seconds = endTime.tv_sec - startTime.tv_sec;
Expand All @@ -148,10 +166,11 @@ namespace od
duration_ = duration;
return duration;
}


#endif
double getDuration()
{ return duration_; }
{
return duration_;
}

static void printTime(double duration)
{
Expand Down
2 changes: 0 additions & 2 deletions detectors/local2D/detection/ODCADRecognizer2DLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <opencv2/video/tracking.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/viz.hpp>
#include <sys/time.h>
#include <common/utils/utils.h>

// PnP Tutorial
#include "simple_ransac_detection/Mesh.h"
Expand Down
7 changes: 6 additions & 1 deletion detectors/local2D/detection/simple_ransac_detection/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#define UTILS_H_

#include <iostream>
#include <sys/time.h>
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/time.h>
#endif

#include "PnPProblem.h"
#include "Model.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
#include <opencv2/viz.hpp>


#include <sys/time.h>
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/time.h>
#endif


// PnP Tutorial
#include "Mesh.h"
Expand Down

0 comments on commit 08ea142

Please sign in to comment.