Project

General

Profile

Statistics
| Branch: | Revision:

root / rgbdslam / external / siftgpu / src / SiftGPU / GlobalUtil.h @ 9240aaa3

History | View | Annotate | Download (4.57 KB)

1 9240aaa3 Alex
////////////////////////////////////////////////////////////////////////////
2
//        File:                GlobalUtil.h
3
//        Author:                Changchang Wu
4
//        Description : 
5
//                GlobalParam:        Global parameters
6
//                ClockTimer:                Timer 
7
//                GlobalUtil:                Global Function wrapper
8
//
9
//        Copyright (c) 2007 University of North Carolina at Chapel Hill
10
//        All Rights Reserved
11
//
12
//        Permission to use, copy, modify and distribute this software and its
13
//        documentation for educational, research and non-profit purposes, without
14
//        fee, and without a written agreement is hereby granted, provided that the
15
//        above copyright notice and the following paragraph appear in all copies.
16
//
17
//        The University of North Carolina at Chapel Hill make no representations
18
//        about the suitability of this software for any purpose. It is provided
19
//        'as is' without express or implied warranty. 
20
//
21
//        Please send BUG REPORTS to ccwu@cs.unc.edu
22
//
23
////////////////////////////////////////////////////////////////////////////
24
25
26
#ifndef _GLOBAL_UTILITY_H
27
#define _GLOBAL_UTILITY_H
28
29
30
//wrapper for some shader function
31
//class ProgramGPU;
32
class LiteWindow;
33
34
class GlobalParam
35
{
36
public:
37
        static GLuint        _texTarget;
38
        static GLuint   _iTexFormat;
39
        static int                _texMaxDim;
40
        static int                _texMaxDimGL; 
41
    static int      _texMinDim;
42
        static int                _verbose;
43
        static int                _timingS;
44
        static int                _timingO;
45
        static int                _timingL;
46
        static int                _usePackedTex;
47
        static int                _BetaFilter;
48
        static int                _IsNvidia;
49
        static int                _UseCUDA;
50
    static int      _UseOpenCL;
51
        static int                _UseDynamicIndexing; 
52
        static int                _debug;
53
        static int                _MaxFilterWidth;
54
        static float        _FilterWidthFactor;
55
        static float    _OrientationWindowFactor;
56
        static float        _DescriptorWindowFactor; 
57
        static int                _MaxOrientation;
58
        static int      _OrientationPack2;
59
        static int                _ListGenGPU;
60
        static int                _ListGenSkipGPU;
61
        static int                _SupportNVFloat;
62
        static int                _SupportTextureRG;
63
        static int                _FullSupported;
64
        static float        _MaxFeaturePercent;
65
        static int                _MaxLevelFeatureNum;
66
        static int                _DescriptorPPR; 
67
        static int                _DescriptorPPT; //pixel per texture for one descriptor
68
        static int                _FeatureTexBlock;
69
        static int                _NarrowFeatureTex; //implemented but no performance improvement
70
        static int                _SubpixelLocalization;
71
        static int                _ProcessOBO; //not implemented yet
72
    static int      _TruncateMethod;
73
        static int                _PreciseBorder; //implemented
74
        static int                _UseSiftGPUEX;
75
        static int                _ForceTightPyramid;
76
        static int                _octave_min_default;
77
        static int                _octave_num_default;
78
        static int                _InitPyramidWidth;
79
        static int                _InitPyramidHeight;
80
        static int                _PreProcessOnCPU;
81
        static int                _GoodOpenGL;
82
        static int                _FixedOrientation;
83
        static int                _LoweOrigin;
84
        static int                _ExitAfterSIFT; 
85
        static int                _NormalizedSIFT;
86
        static int                _BinarySIFT;
87
        static int                _KeepExtremumSign;
88
        static int                _FeatureCountThreshold;
89
    static int      _KeyPointListForceLevel0;
90
        //for compatable with old version:
91
        static float        _OrientationExtraFactor;
92
        static float        _OrientationGaussianFactor;
93
        static float    _MulitiOrientationThreshold;
94
95
        ////////////////////////////////////////
96
        static int                                _WindowInitX;
97
        static int                                _WindowInitY;
98
        static const char*                _WindowDisplay;
99
    static int              _DeviceIndex; 
100
};
101
102
103
class ClockTimer
104
{
105
private:
106
        char _current_event[256];
107
        int  _time_start;
108
        int  _time_stop;
109
public:
110
        static int          ClockMS();
111
        static double CLOCK();
112
        static void          InitHighResolution();
113
        void StopTimer(int verb = 1);
114
        void StartTimer(const char * event, int verb=0);
115
        float  GetElapsedTime();
116
};
117
118
class GlobalUtil:public GlobalParam
119
{
120
    static ClockTimer _globalTimer;                             
121
public:
122
        inline static double CLOCK()                                {        return ClockTimer::CLOCK();                        }
123
        inline static void StopTimer()                                {        _globalTimer.StopTimer(_timingS);                        }
124
        inline static void StartTimer(const char * event)        {        _globalTimer.StartTimer(event, _timingO);        }
125
        inline static float GetElapsedTime()                {        return _globalTimer.GetElapsedTime();                }
126
127
        static void FitViewPort(int width, int height);
128
        static void SetTextureParameter();
129
        static void SetTextureParameterUS();
130
#ifdef _DEBUG
131
        static void CheckErrorsGL(const char* location = NULL);
132
#else
133
        static void inline CheckErrorsGL(const char* location = NULL){};
134
#endif
135
        static bool CheckFramebufferStatus();
136
        //initialize Opengl parameters
137
        static void InitGLParam(int NotTargetGL = 0);
138
        static void SetGLParam();
139
        static int  CreateWindowEZ();
140
        static void CleanupOpenGL();
141
    static void SetDeviceParam(int argc, char** argv);
142
    static int  CreateWindowEZ(LiteWindow* window);
143
};
144
145
146
#if defined(_MSC_VER) && _MSC_VER == 1200
147
#define max(a,b)    (((a) > (b)) ? (a) : (b))
148
#define min(a,b)    (((a) < (b)) ? (a) : (b))
149
#endif
150
151
#endif