From 9ed05fa7300331431e81b317c43ae51e8d156423 Mon Sep 17 00:00:00 2001 From: Davis King Date: Thu, 29 Jan 2015 17:51:18 -0500 Subject: [PATCH] Made the timestamper use timeGetTime() instead of GetTickCount() on windows since timeGetTime() is more accurate. --- dlib/CMakeLists.txt | 4 ++-- dlib/misc_api/misc_api_kernel_1.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt index 1ca8d4f07..f14cf9f65 100644 --- a/dlib/CMakeLists.txt +++ b/dlib/CMakeLists.txt @@ -136,9 +136,9 @@ if (NOT TARGET dlib) # we want to link to the right stuff depending on our platform. if (WIN32 AND NOT CYGWIN) ############################################################################### if (DLIB_NO_GUI_SUPPORT) - set (dlib_needed_libraries ws2_32) + set (dlib_needed_libraries ws2_32 winmm) else() - set (dlib_needed_libraries ws2_32 comctl32 gdi32 imm32) + set (dlib_needed_libraries ws2_32 winmm comctl32 gdi32 imm32) endif() elseif(APPLE) ############################################################################ find_library(pthreadlib pthread) diff --git a/dlib/misc_api/misc_api_kernel_1.cpp b/dlib/misc_api/misc_api_kernel_1.cpp index 9ca509453..773579180 100644 --- a/dlib/misc_api/misc_api_kernel_1.cpp +++ b/dlib/misc_api/misc_api_kernel_1.cpp @@ -13,6 +13,11 @@ #include "../windows_magic.h" #include +// tell visual studio to link to the library needed to call timeGetTime() +#ifdef _MSC_VER +#pragma comment (lib, "winmm.lib") +#endif + #ifdef __BORLANDC__ // Apparently the borland compiler doesn't define this. #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) @@ -89,7 +94,7 @@ namespace dlib get_timestamp ( ) const { - unsigned long temp = GetTickCount(); + unsigned long temp = timeGetTime(); if (temp >= last_time) { last_time = temp;