00001 00002 // File: GlobalUtil.h 00003 // Author: Changchang Wu 00004 // Description : 00005 // GlobalParam: Global parameters 00006 // ClockTimer: Timer 00007 // GlobalUtil: Global Function wrapper 00008 // 00009 // Copyright (c) 2007 University of North Carolina at Chapel Hill 00010 // All Rights Reserved 00011 // 00012 // Permission to use, copy, modify and distribute this software and its 00013 // documentation for educational, research and non-profit purposes, without 00014 // fee, and without a written agreement is hereby granted, provided that the 00015 // above copyright notice and the following paragraph appear in all copies. 00016 // 00017 // The University of North Carolina at Chapel Hill make no representations 00018 // about the suitability of this software for any purpose. It is provided 00019 // 'as is' without express or implied warranty. 00020 // 00021 // Please send BUG REPORTS to ccwu@cs.unc.edu 00022 // 00024 00025 00026 #ifndef _GLOBAL_UTILITY_H 00027 #define _GLOBAL_UTILITY_H 00028 00029 00030 //wrapper for some shader function 00031 //class ProgramGPU; 00032 class LiteWindow; 00033 00034 class GlobalParam 00035 { 00036 public: 00037 static GLuint _texTarget; 00038 static GLuint _iTexFormat; 00039 static int _texMaxDim; 00040 static int _texMaxDimGL; 00041 static int _texMinDim; 00042 static int _verbose; 00043 static int _timingS; 00044 static int _timingO; 00045 static int _timingL; 00046 static int _usePackedTex; 00047 static int _BetaFilter; 00048 static int _IsNvidia; 00049 static int _UseCUDA; 00050 static int _UseOpenCL; 00051 static int _UseDynamicIndexing; 00052 static int _debug; 00053 static int _MaxFilterWidth; 00054 static float _FilterWidthFactor; 00055 static float _OrientationWindowFactor; 00056 static float _DescriptorWindowFactor; 00057 static int _MaxOrientation; 00058 static int _OrientationPack2; 00059 static int _ListGenGPU; 00060 static int _ListGenSkipGPU; 00061 static int _SupportNVFloat; 00062 static int _SupportTextureRG; 00063 static int _FullSupported; 00064 static float _MaxFeaturePercent; 00065 static int _MaxLevelFeatureNum; 00066 static int _DescriptorPPR; 00067 static int _DescriptorPPT; //pixel per texture for one descriptor 00068 static int _FeatureTexBlock; 00069 static int _NarrowFeatureTex; //implemented but no performance improvement 00070 static int _SubpixelLocalization; 00071 static int _ProcessOBO; //not implemented yet 00072 static int _TruncateMethod; 00073 static int _PreciseBorder; //implemented 00074 static int _UseSiftGPUEX; 00075 static int _ForceTightPyramid; 00076 static int _octave_min_default; 00077 static int _octave_num_default; 00078 static int _InitPyramidWidth; 00079 static int _InitPyramidHeight; 00080 static int _PreProcessOnCPU; 00081 static int _GoodOpenGL; 00082 static int _FixedOrientation; 00083 static int _LoweOrigin; 00084 static int _ExitAfterSIFT; 00085 static int _NormalizedSIFT; 00086 static int _BinarySIFT; 00087 static int _KeepExtremumSign; 00088 static int _FeatureCountThreshold; 00089 static int _KeyPointListForceLevel0; 00090 //for compatable with old version: 00091 static float _OrientationExtraFactor; 00092 static float _OrientationGaussianFactor; 00093 static float _MulitiOrientationThreshold; 00094 00096 static int _WindowInitX; 00097 static int _WindowInitY; 00098 static const char* _WindowDisplay; 00099 static int _DeviceIndex; 00100 }; 00101 00102 00103 class ClockTimer 00104 { 00105 private: 00106 char _current_event[256]; 00107 int _time_start; 00108 int _time_stop; 00109 public: 00110 static int ClockMS(); 00111 static double CLOCK(); 00112 static void InitHighResolution(); 00113 void StopTimer(int verb = 1); 00114 void StartTimer(const char * event, int verb=0); 00115 float GetElapsedTime(); 00116 }; 00117 00118 class GlobalUtil:public GlobalParam 00119 { 00120 static ClockTimer _globalTimer; 00121 public: 00122 inline static double CLOCK() { return ClockTimer::CLOCK(); } 00123 inline static void StopTimer() { _globalTimer.StopTimer(_timingS); } 00124 inline static void StartTimer(const char * event) { _globalTimer.StartTimer(event, _timingO); } 00125 inline static float GetElapsedTime() { return _globalTimer.GetElapsedTime(); } 00126 00127 static void FitViewPort(int width, int height); 00128 static void SetTextureParameter(); 00129 static void SetTextureParameterUS(); 00130 #ifdef _DEBUG 00131 static void CheckErrorsGL(const char* location = NULL); 00132 #else 00133 static void inline CheckErrorsGL(const char* location = NULL){}; 00134 #endif 00135 static bool CheckFramebufferStatus(); 00136 //initialize Opengl parameters 00137 static void InitGLParam(int NotTargetGL = 0); 00138 static void SetGLParam(); 00139 static int CreateWindowEZ(); 00140 static void CleanupOpenGL(); 00141 static void SetDeviceParam(int argc, char** argv); 00142 static int CreateWindowEZ(LiteWindow* window); 00143 }; 00144 00145 00146 #if defined(_MSC_VER) && _MSC_VER == 1200 00147 #define max(a,b) (((a) > (b)) ? (a) : (b)) 00148 #define min(a,b) (((a) < (b)) ? (a) : (b)) 00149 #endif 00150 00151 #endif 00152