Skip to content

Commit 3c536ef

Browse files
committed
Merge pull request #1604 from mshabunin:decrease-tbb-dependency
2 parents b4e9c3a + d3630d0 commit 3c536ef

File tree

7 files changed

+0
-107
lines changed

7 files changed

+0
-107
lines changed

modules/dpm/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
set(the_description "Object Detection")
22

3-
#uncomment the following line to enable parallel computing
4-
#add_definitions(-DHAVE_TBB)
5-
63
ocv_define_module(dpm opencv_core opencv_imgproc opencv_objdetect OPTIONAL opencv_highgui WRAP python)
74

85
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4512) # disable warning on Win64

modules/dpm/samples/cascade_detect_camera.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ int main( int argc, char** argv )
9797
return -1;
9898
}
9999

100-
#ifdef HAVE_TBB
101-
cout << "Running with TBB" << endl;
102-
#else
103-
#ifdef _OPENMP
104-
cout << "Running with OpenMP" << endl;
105-
#else
106-
cout << "Running without OpenMP and without TBB" << endl;
107-
#endif
108-
#endif
109-
110100
Mat frame;
111101
namedWindow("DPM Cascade Detection", 1);
112102
// the color of the rectangle

modules/dpm/samples/cascade_detect_sequence.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@ int main( int argc, char** argv )
113113
if ( !readImageLists(image_list, imgFileList) )
114114
return -1;
115115

116-
#ifdef HAVE_TBB
117-
cout << "Running with TBB" << endl;
118-
#else
119-
#ifdef _OPENMP
120-
cout << "Running with OpenMP" << endl;
121-
#else
122-
cout << "Running without OpenMP and without TBB" << endl;
123-
#endif
124-
#endif
125-
126116
cv::Ptr<DPMDetector> detector = \
127117
DPMDetector::create(vector<string>(1, model_path));
128118

modules/dpm/src/dpm_cascade.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,36 +220,12 @@ void DPMCascade::computeRootPCAScores(vector< vector< Mat > > &rootScores)
220220
for (int comp = 0; comp < model.numComponents; comp++)
221221
{
222222
rootScores[comp].resize(nlevels);
223-
#ifdef HAVE_TBB // parallel computing
224223
ParalComputeRootPCAScores paralTask(pcaPyramid, model.rootPCAFilters[comp],
225224
model.pcaDim, rootScores[comp]);
226225
parallel_for_(Range(interval, nlevels), paralTask);
227-
#else
228-
#ifdef _OPENMP
229-
#pragma omp parallel for
230-
#endif
231-
for (int level = interval; level < nlevels; level++)
232-
{
233-
Mat feat = pcaPyramid[level];
234-
Mat filter = model.rootPCAFilters[comp];
235-
236-
// compute size of output
237-
int height = feat.rows - filter.rows + 1;
238-
int width = (feat.cols - filter.cols) / model.pcaDim + 1;
239-
240-
if (height < 1 || width < 1)
241-
CV_Error(CV_StsBadArg,
242-
"Invalid input, filter size should be smaller than feature size.");
243-
244-
Mat result = Mat::zeros(Size(width, height), CV_64F);
245-
convolutionEngine.convolve(feat, filter, model.pcaDim, result);
246-
rootScores[comp][level] = result;
247-
}
248-
#endif
249226
}
250227
}
251228

252-
#ifdef HAVE_TBB
253229
ParalComputeRootPCAScores::ParalComputeRootPCAScores(
254230
const vector< Mat > &pcaPyrad,
255231
const Mat &f,
@@ -279,7 +255,6 @@ void ParalComputeRootPCAScores::operator() (const Range &range) const
279255
scores[level] = result;
280256
}
281257
}
282-
#endif
283258

284259
void DPMCascade::process( vector< vector<double> > &dets)
285260
{

modules/dpm/src/dpm_cascade.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class DPMCascade
128128
std::vector< std::vector<double> > detect(Mat &image);
129129
};
130130

131-
#ifdef HAVE_TBB
132131
/** @brief This class convolves root PCA feature pyramid
133132
* and root PCA filters in parallel using Intel Threading
134133
* Building Blocks (TBB)
@@ -151,7 +150,6 @@ class ParalComputeRootPCAScores : public ParallelLoopBody
151150
int pcaDim;
152151
std::vector< Mat > &scores;
153152
};
154-
#endif
155153
} // namespace dpm
156154
} // namespace cv
157155

modules/dpm/src/dpm_feature.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -58,65 +58,11 @@ Feature::Feature (PyramidParameter p):params(p)
5858

5959
void Feature::computeFeaturePyramid(const Mat &imageM, vector< Mat > &pyramid)
6060
{
61-
#ifdef HAVE_TBB
6261
ParalComputePyramid paralTask(imageM, pyramid, params);
6362
paralTask.initialize();
64-
// perform parallel computing
6563
parallel_for_(Range(0, params.interval), paralTask);
66-
#else
67-
CV_Assert(params.interval > 0);
68-
// scale factor between two levels
69-
params.sfactor = pow(2.0, 1.0/params.interval);
70-
const Size_<double> imSize = imageM.size();
71-
params.maxScale = 1 + (int)floor(log(min(imSize.width, imSize.height)/
72-
(float)(params.binSize*5.0))/log(params.sfactor));
73-
74-
if (params.maxScale < params.interval)
75-
{
76-
CV_Error(CV_StsBadArg, "The image is too small to create a pyramid");
77-
return;
78-
}
79-
80-
pyramid.resize(params.maxScale + params.interval);
81-
params.scales.resize(params.maxScale + params.interval);
82-
83-
#ifdef _OPENMP
84-
#pragma omp parallel for
85-
#endif
86-
for (int i = 0; i < params.interval; i++)
87-
{
88-
const double scale = (double)(1.0f/pow(params.sfactor, i));
89-
Mat imScaled;
90-
resize(imageM, imScaled, imSize * scale);
91-
// First octave at twice the image resolution
92-
computeHOG32D(imScaled, pyramid[i], params.binSize/2,
93-
params.padx + 1, params.pady + 1);
94-
95-
params.scales[i] = 2*scale;
96-
97-
// Second octave at the original resolution
98-
if (i + params.interval <= params.maxScale)
99-
computeHOG32D(imScaled, pyramid[i+params.interval],
100-
params.binSize, params.padx + 1, params.pady + 1);
101-
102-
params.scales[i+params.interval] = scale;
103-
104-
// Remaining octaves
105-
for ( int j = i + params.interval; j < params.maxScale; j += params.interval)
106-
{
107-
Mat imScaled2;
108-
Size_<double> imScaledSize = imScaled.size();
109-
resize(imScaled, imScaled2, imScaledSize*0.5);
110-
imScaled = imScaled2;
111-
computeHOG32D(imScaled2, pyramid[j+params.interval],
112-
params.binSize, params.padx + 1, params.pady + 1);
113-
params.scales[j+params.interval] = params.scales[j]*0.5;
114-
}
115-
}
116-
#endif
11764
}
11865

119-
#ifdef HAVE_TBB
12066
ParalComputePyramid::ParalComputePyramid(const Mat &inputImage, \
12167
vector< Mat > &outputPyramid,\
12268
PyramidParameter &p):
@@ -177,7 +123,6 @@ void ParalComputePyramid::operator() (const Range &range) const
177123
}
178124
}
179125
}
180-
#endif
181126

182127
void Feature::computeHOG32D(const Mat &imageM, Mat &featM, const int sbin, const int pad_x, const int pad_y)
183128
{

modules/dpm/src/dpm_feature.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class Feature
137137

138138
};
139139

140-
#ifdef HAVE_TBB
141140
/** @brief This class computes feature pyramid in parallel
142141
* using Intel Threading Building Blocks (TBB)
143142
*/
@@ -165,7 +164,6 @@ class ParalComputePyramid : public ParallelLoopBody
165164
// pyramid parameters
166165
PyramidParameter &params;
167166
};
168-
#endif
169167

170168
} // namespace dpm
171169
} // namespace cv

0 commit comments

Comments
 (0)