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

Build with BundleCeres for windows system #66

Open
wants to merge 3 commits 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
6 changes: 5 additions & 1 deletion src/BundleCeres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#if defined(_WIN32) || defined(_WIN64)
#include "time_unix.h"
#else
#include <sys/time.h>

#endif
#include "matrix.h"
#include "qsort.h"
#include "util.h"
Expand All @@ -19,6 +22,7 @@

#include <ceres/ceres.h>
#include "snavely_reprojection_error.h"
#include "ceres/rotation.h"

#include <omp.h>

Expand Down
22 changes: 22 additions & 0 deletions src/time_unix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "time_unix.h"

int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
// until 00:00:00 January 1, 1970
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);

SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;

GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;

tp->tv_sec = (long)((time - EPOCH) / 10000000L);
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
return 0;
}
17 changes: 17 additions & 0 deletions src/time_unix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
//original
//https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64

#undef ERROR

// MSVC defines this in winsock2.h!?
typedef struct timeval {
long tv_sec;
long tv_usec;
} timeval;

int gettimeofday(struct timeval * tp, struct timezone * tzp);