segmentation
All Data Structures Namespaces Files Functions Variables Modules Pages
msSysPrompt.cpp
1 /*******************************************************
2 
3  Mean Shift Analysis Library
4  =============================================
5 
6  The mean shift library is a collection of routines
7  that use the mean shift algorithm. Using this algorithm,
8  the necessary output will be generated needed
9  to analyze a given input set of data.
10 
11  Mean Shift System:
12  ==================
13 
14  The Mean Shift System class provides a mechanism for the
15  mean shift library classes to prompt progress and to
16  time its computations. When porting the mean shift library
17  to an application the methods of this class may be changed
18  such that the output of the mean shift class prompts
19  will be given to whatever hardware or software device that
20  is desired.
21 
22  The definition for the mean shift system class is provided
23  below. Its prototype is provided in "msSys.cc".
24 
25 The theory is described in the papers:
26 
27  D. Comaniciu, P. Meer: Mean Shift: A robust approach toward feature
28  space analysis.
29 
30  C. Christoudias, B. Georgescu, P. Meer: Synergism in low level vision.
31 
32 and they are is available at:
33  http://www.caip.rutgers.edu/riul/research/papers/
34 
35 Implemented by Chris M. Christoudias, Bogdan Georgescu
36 ********************************************************/
37 
39 // Command Line Version:
40 // This version of mean shift system is written for the command
41 // line version of EDISON.
43 
44 //include the msSystem class prototype
45 #include "segm/msSys.h"
46 
47 //include needed system libraries
48 #include <time.h>
49 #include <stdio.h>
50 #include <stdarg.h>
51 #include <stdlib.h>
52 
53 //define bgLog
54 bool CmCDisplayProgress;
55 void bgLog(const char *PromptStr, ...)
56 {
57  //obtain argument list using ANSI standard...
58  va_list argList;
59  va_start(argList, PromptStr);
60 
61  //print the output string to stderr using
62  if(CmCDisplayProgress) vfprintf(stdout, PromptStr, argList);
63  va_end(argList);
64 
65  //done.
66  return;
67 }
68 
69 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
70 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
71 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PUBLIC METHODS @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
72 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
73 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
74 
75  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
76  /*** Class Constructor and Destructor ***/
77  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
78 
79 /*******************************************************/
80 /*Class Constructor */
81 /*******************************************************/
82 /*Constructs a mean shift system object. */
83 /*******************************************************/
84 /*Post: */
85 /* - an msSystem object has been properly init- */
86 /* ialized. */
87 /*******************************************************/
88 
89 msSystem::msSystem( void )
90 {
91 
92  //initialize currentTime
93  currentTime = clock();
94 
95  //done.
96 
97 }
98 
99 /*******************************************************/
100 /*Class Destructor */
101 /*******************************************************/
102 /*Destroys a mean shift system object. */
103 /*******************************************************/
104 /*Post: */
105 /* - an msSystem object has been properly dest- */
106 /* royed. */
107 /*******************************************************/
108 
109 msSystem::~msSystem( void )
110 {
111  /* do nothing */
112 }
113 
114  /*/\/\/\/\/\/\/\/\/\*/
115  /*** System Timer ***/
116  /*\/\/\/\/\/\/\/\/\/*/
117 
118 /*******************************************************/
119 /*Start Timer */
120 /*******************************************************/
121 /*Sets the mean shift system time to the current */
122 /*system time. */
123 /*******************************************************/
124 /*Post: */
125 /* - the mean shift system time has been set to */
126 /* the current system time. */
127 /*******************************************************/
128 
129 void msSystem::StartTimer( void )
130 {
131 
132  //set msSystem time to system time
133  currentTime = clock();
134 
135  //done.
136  return;
137 
138 }
139 
140 /*******************************************************/
141 /*Elapsed Time */
142 /*******************************************************/
143 /*Returns the amount of time in seconds since the */
144 /*mean shift system time was last set. */
145 /*******************************************************/
146 /*Post: */
147 /* - the amount of time in seconds since the mean */
148 /* shift system time was last set is returned. */
149 /*******************************************************/
150 
151 double msSystem::ElapsedTime( void )
152 {
153 
154  //return the amount of time elapsed in seconds
155  //since the msSystem time was last set...
156  return ((double) (clock() - currentTime))/(CLOCKS_PER_SEC);
157 
158 }
159 
160  /*/\/\/\/\/\/\/\/\/\/\*/
161  /*** System Output ***/
162  /*\/\/\/\/\/\/\/\/\/\/*/
163 
164 /*******************************************************/
165 /*Prompt */
166 /*******************************************************/
167 /*Output a text message to the user. */
168 /*******************************************************/
169 /*Pre: */
170 /* - PromptStr is a string containing delimeters */
171 /* that is to be output to the user. */
172 /* - a variable set of arguments is also passed */
173 /* to this method that are used to replace */
174 /* the delimeters contained by PromptStr */
175 /*Post: */
176 /* - the delimeters of PromptStr have been */
177 /* replaced accordingly using the variable */
178 /* set of arguments and the resulting string */
179 /* has been output to the user. */
180 /*******************************************************/
181 
182 void msSystem::Prompt(const char *PromptStr, ...)
183 {
184 
185  //obtain argument list using ANSI standard...
186  va_list argList;
187  va_start(argList, PromptStr);
188 
189  //print the output string to stderr using
190  if(CmCDisplayProgress) vfprintf(stdout, PromptStr, argList);
191  va_end(argList);
192 
193  //done.
194  return;
195 
196 }
197 
198 /*******************************************************/
199 /*Progress */
200 /*******************************************************/
201 /*The progress of a specific algorithm of the mean */
202 /*shift library is output to the user. */
203 /*******************************************************/
204 /*Pre: */
205 /* - percentComplete indicates the percentage */
206 /* of the algorithm that has executed and is */
207 /* a floating point number from zero to one */
208 /*Post: */
209 /* - the percentComplete has been noted by the */
210 /* interface (possibly to update a progress */
211 /* bar). */
212 /* - if the thread executing the mean shift code */
213 /* must halt execution msSYS_HALT is returned, */
214 /* msSYS_OK is returned otherwise */
215 /*******************************************************/
216 
218 //NOTE: This implementation is specific to EDISON. In order
219 // for one to port the mean shift class to another project
220 // or program one must re-implement this method.
222 
223 ErrorLevel msSystem::Progress(float percentComplete)
224 {
225  return EL_OKAY;
226 }
227 
228 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
229 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
230 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ END OF CLASS DEFINITION @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
231 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
232 /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/