@@ -50,11 +50,6 @@ A previous and less efficient version of the algorithm can be found:
50
50
*/
51
51
52
52
#include " precomp.hpp"
53
- // #include <opencv2/opencv.hpp>
54
-
55
- #ifdef HAVE_OPENMP
56
- #include < omp.h>
57
- #endif
58
53
59
54
using namespace cv ;
60
55
using namespace std ;
@@ -101,7 +96,6 @@ class EstimateCovariance{
101
96
int nc;
102
97
int pr;
103
98
int pc;
104
- int threads;
105
99
106
100
std::vector<Combination> combinationsTable;
107
101
};
@@ -110,13 +104,6 @@ class EstimateCovariance{
110
104
111
105
EstimateCovariance::EstimateCovariance (int pr_, int pc_){
112
106
pr=pr_; pc=pc_;
113
-
114
- #ifdef HAVE_OPENMP
115
- threads=omp_get_num_procs ();
116
- omp_set_num_threads (threads);
117
- #else
118
- threads=1 ;
119
- #endif
120
107
}
121
108
122
109
EstimateCovariance::~EstimateCovariance (){
@@ -178,47 +165,19 @@ void EstimateCovariance::computeEstimateCovariance(Mat inputData,Mat outputData)
178
165
179
166
void EstimateCovariance::iterateCombinations (Mat inputData,Mat outputData)
180
167
{
181
- int combsPerCPU = combinationCount ()/threads;
182
- int remainder = combinationCount ()%threads;
183
- if (remainder>0 )
184
- combsPerCPU++;
185
-
186
- #ifdef HAVE_OPENMP
187
- #pragma omp parallel
188
- #endif
189
- {
190
- int idx;
191
- int combs;
192
- #ifdef HAVE_OPENMP
193
- int thread_id= omp_get_thread_num ();
194
- #else
195
- int thread_id=0 ;
196
- #endif
197
- int startComb;
198
- if (remainder > thread_id){
199
- combs=combsPerCPU;
200
- startComb=(thread_id)*combsPerCPU;
201
- }
202
- else {
203
- combs=combsPerCPU-1 ;
204
- startComb=remainder*combsPerCPU+(thread_id-remainder)*(combsPerCPU-1 );
205
- }
206
-
207
- Mat outputVector (pr*pc,1 , DataType<std::complex<float > >::type);
208
-
209
- std::vector<int > finalMatPosR (pr*pc,0 );
210
- std::vector<int > finalMatPosC (pr*pc,0 );
211
-
212
- for (idx=0 ; idx<combs; idx++){
213
- outputVector.setTo (Scalar (0 ,0 ));
214
- for (unsigned x=0 ; x<finalMatPosR.size (); x++)
215
- finalMatPosR[x]=0 ;
216
- for (unsigned x=0 ; x<finalMatPosC.size (); x++)
217
- finalMatPosC[x]=0 ;
218
- computeOneCombination (startComb++, inputData, outputData,
219
- outputVector,finalMatPosR, finalMatPosC);
220
- }
221
-
168
+ Mat outputVector (pr*pc,1 , DataType<std::complex<float > >::type);
169
+
170
+ std::vector<int > finalMatPosR (pr*pc,0 );
171
+ std::vector<int > finalMatPosC (pr*pc,0 );
172
+ int combs=combinationCount ();
173
+ for (int idx=0 ; idx<combs; idx++){
174
+ outputVector.setTo (Scalar (0 ,0 ));
175
+ for (unsigned x=0 ; x<finalMatPosR.size (); x++)
176
+ finalMatPosR[x]=0 ;
177
+ for (unsigned x=0 ; x<finalMatPosC.size (); x++)
178
+ finalMatPosC[x]=0 ;
179
+ computeOneCombination (idx++, inputData, outputData,
180
+ outputVector,finalMatPosR, finalMatPosC);
222
181
}
223
182
}
224
183
0 commit comments