SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
cvd_timer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the CVD Library.
3 
4  Copyright (C) 2005 The Authors
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
22 //
23 // A timer class designed for dealing with timestamps
24 // CK Nov 2002
25 //
27 
28 #include "timer.h"
29 #include <iostream>
30 #include <sys/time.h> //gettimeofday
31 
32 namespace CVD {
33 
34 unsigned long long get_time_of_day_us()
35 {
36  struct timeval tv;
37  gettimeofday(&tv,NULL);
38  return (unsigned long long)tv.tv_sec*1000000+tv.tv_usec;
39 }
40 
42 {
44 }
45 
47 {
48  unsigned long long temp = get_time_of_day_us();
49  double elapsed = (temp - startTime) / 1000000.0;
50  startTime = temp;
51  return elapsed;
52 }
53 
55 {
56  return (get_time_of_day_us()-startTime)/1000000.0;
57 }
58 
59 // Conv from units of nanosecs (specifically for v4l2 : kernel 2.4
60 double cvd_timer::conv_ntime(signed long long time)
61 {
62  time=time/1000; // now in us
63 
64  return (time-startTime)/1000000.0;
65 }
66 
67 // Conv from units of nanosecs (specifically for v4l2 : kernel 2.6
68 // Let the overloading mecnanism sort out the difference in the
69 // headers from 2.4 hee, hee, hee
70 double cvd_timer::conv_ntime(const struct timeval& tv)
71 {
72  double time = tv.tv_sec + tv.tv_usec*1e-6;
73  return time-startTime / 1e6;
74 }
75 
76 double get_time_of_day()
77 {
78  return get_time_of_day_us()/1000000.0;
79 }
80 
81 
83 
84 }
double conv_ntime(signed long long time)
Definition: cvd_timer.cpp:60
double get_time()
How many seconds have elapsed since the start time?
Definition: cvd_timer.cpp:54
double reset()
Sets the start time to the current time.
Definition: cvd_timer.cpp:46
cvd_timer timer
Definition: cvd_timer.cpp:82
Definition: abs.h:24
unsigned long long get_time_of_day_us()
Definition: cvd_timer.cpp:34
cvd_timer()
Create a timer, and set the start time to be now.
Definition: cvd_timer.cpp:41
unsigned long long startTime
Definition: timer.h:73
double get_time_of_day()
Definition: cvd_timer.cpp:76