Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added time functions for windows platform #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 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,15 @@
#include <glob.h>


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


namespace bf = boost::filesystem;

Expand Down Expand Up @@ -121,24 +129,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 +168,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
9 changes: 8 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,14 @@
#define UTILS_H_

#include <iostream>
#include <sys/time.h>
#if defined(_WIN32)
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.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,15 @@
#include <opencv2/viz.hpp>


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


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