msSys.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*******************************************************
  2. Mean Shift Analysis Library
  3. =============================================
  4. The mean shift library is a collection of routines
  5. that use the mean shift algorithm. Using this algorithm,
  6. the necessary output will be generated needed
  7. to analyze a given input set of data.
  8. Mean Shift System:
  9. ==================
  10. The Mean Shift System class provides a mechanism for the
  11. mean shift library classes to prompt progress and to
  12. time its computations. When porting the mean shift library
  13. to an application the methods of this class may be changed
  14. such that the output of the mean shift class prompts
  15. will be given to whatever hardware or software device that
  16. is desired.
  17. The prototype for the mean shift system class is provided
  18. below. Its defition is provided in "msSys.cc".
  19. The theory is described in the papers:
  20. D. Comaniciu, P. Meer: Mean Shift: A robust approach toward feature
  21. space analysis.
  22. C. Christoudias, B. Georgescu, P. Meer: Synergism in low level vision.
  23. and they are is available at:
  24. http://www.caip.rutgers.edu/riul/research/papers/
  25. Implemented by Chris M. Christoudias, Bogdan Georgescu
  26. ********************************************************/
  27. #ifndef MSSYS_H
  28. #define MSSYS_H
  29. //Include standard mean shift library type definitions
  30. #include "tdef.h"
  31. //Include standard libraries needed for msSystem prototype
  32. #include <time.h>
  33. extern void bgLogFile(const char*, ...);
  34. //Mean Shify System class prototype
  35. class msSystem {
  36. public:
  37. /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
  38. /* Class Constructor and Destructor */
  39. /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
  40. msSystem( void ); //Default Constructor
  41. ~msSystem( void ); //Class Destructor
  42. /*/\/\/\/\/\/\/\*/
  43. /* System Timer */
  44. /*\/\/\/\/\/\/\/*/
  45. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  46. //<--------------------------------------------------->|//
  47. //| |//
  48. //| Method Name: |//
  49. //| ============ |//
  50. //| * Start Timer * |//
  51. //| |//
  52. //<--------------------------------------------------->|//
  53. //| |//
  54. //| Description: |//
  55. //| ============ |//
  56. //| |//
  57. //| Initializes the system timer. The timer object |//
  58. //| synthesized by this class is initialized during |//
  59. //| construction of the msSystem class to be the |//
  60. //| current time during construction. |//
  61. //| |//
  62. //<--------------------------------------------------->|//
  63. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  64. void StartTimer( void );
  65. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  66. //<--------------------------------------------------->|//
  67. //| |//
  68. //| Method Name: |//
  69. //| ============ |//
  70. //| * Elapsed Time * |//
  71. //| |//
  72. //<--------------------------------------------------->|//
  73. //| |//
  74. //| Description: |//
  75. //| ============ |//
  76. //| |//
  77. //| Returns the amount of time elapsed in seconds |//
  78. //| from when StartTimer() was called. If |//
  79. //| StartTimer() was not called, the time returned |//
  80. //| is the time elapsed from the construction of the |//
  81. //| msSystem object. |//
  82. //| |//
  83. //| In order to create a valid kernel the following |//
  84. //| argumens must be provided this method: |//
  85. //| |//
  86. //<--------------------------------------------------->|//
  87. //| |//
  88. //| Usage: |//
  89. //| ====== |//
  90. //| TimeInSeconds = ElapsedTime() |//
  91. //| |//
  92. //<--------------------------------------------------->|//
  93. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  94. double ElapsedTime( void );
  95. /*/\/\/\/\/\/\/\/\*/
  96. /* System Output */
  97. /*\/\/\/\/\/\/\/\/*/
  98. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  99. //<--------------------------------------------------->|//
  100. //| |//
  101. //| Method Name: |//
  102. //| ============ |//
  103. //| * Prompt * |//
  104. //| |//
  105. //<--------------------------------------------------->|//
  106. //| |//
  107. //| Description: |//
  108. //| ============ |//
  109. //| |//
  110. //| Outputs to a device a character message contain- |//
  111. //| ing delimeters. These delimeters are replaced by |//
  112. //| the variable input parameters passed to prompt. |//
  113. //| (Like printf.) |//
  114. //| |//
  115. //| This method should be altered if a special |//
  116. //| device either than stderr is desired to be used |//
  117. //| as an output prompt. |//
  118. //| |//
  119. //| The arguments to this method are: |//
  120. //| |//
  121. //| <* PromptStr *> |//
  122. //| A string possibly containing delimeters that |//
  123. //| is to be output to the user. |//
  124. //| |//
  125. //| <* varArgs *> |//
  126. //| A variable set of arguments to be placed into |//
  127. //| the prompt string. |//
  128. //| |//
  129. //<--------------------------------------------------->|//
  130. //| |//
  131. //| Usage: |//
  132. //| ====== |//
  133. //| Prompt(PromptStr, varArgs) |//
  134. //| |//
  135. //<--------------------------------------------------->|//
  136. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  137. void Prompt(const char*, ...);
  138. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  139. //<--------------------------------------------------->|//
  140. //| |//
  141. //| Method Name: |//
  142. //| ============ |//
  143. //| * Progress * |//
  144. //| |//
  145. //<--------------------------------------------------->|//
  146. //| |//
  147. //| Description: |//
  148. //| ============ |//
  149. //| |//
  150. //| This method is called by the mean shift library |//
  151. //| methods during the application of a specific |//
  152. //| algorithm in which the progress of the algorithm |//
  153. //| is indicated. Its main use is for a multi-thre- |//
  154. //| aded programming envioronment. Namely, it is |//
  155. //| called fairly frequently by the mean shift |//
  156. //| library methods. It then can be used to grace- |//
  157. //| fully halt the algorithm, or to simply update |//
  158. //| a progress bar. |//
  159. //| |//
  160. //| This method depends strongly on the interface |//
  161. //| and therefore must be re-implemented to accom- |//
  162. //| odate ones needs. |//
  163. //| |//
  164. //| To facilitate a multi-threaded enviornment |//
  165. //| the prompt function returns a value that |//
  166. //| indicates to the mean shift method whether |//
  167. //| to continue execution. EL_HALT is returned |//
  168. //| when the mean shift procedure is to stop |//
  169. //| execution and EL_OKAY is returned otherwise. |//
  170. //| |//
  171. //| The arguments to this method are: |//
  172. //| |//
  173. //| <* PercentComplete *> |//
  174. //| A floating point number that indicates the perc- |//
  175. //| ent complete of the algorithm. PercentComplete |//
  176. //| takes a value between zero and one. |//
  177. //| |//
  178. //| <* SystemState *> |//
  179. //| Indicates the system state. It is EL_HALT |//
  180. //| when the mean shift method is to halt execution |//
  181. //| and it is EL_OKAY otherwise. |//
  182. //| |//
  183. //<--------------------------------------------------->|//
  184. //| |//
  185. //| Usage: |//
  186. //| ====== |//
  187. //| SystemState = Progress(PercentComplete) |//
  188. //| |//
  189. //<--------------------------------------------------->|//
  190. //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
  191. ErrorLevel Progress(float);
  192. private:
  193. //Timer object...
  194. time_t currentTime;
  195. };
  196. #endif