4 #include "_lsvm_tbbversion.h"
9 class ScoreComputation : public tbb::task
12 const CvLSVMFilterObject **filters;
14 const CvLSVMFeaturePyramid *H;
18 const float scoreThreshold;
20 const int *procLevels;
24 CvPoint ****partsDisplacement;
27 ScoreComputation(const CvLSVMFilterObject **_filters, int _n,
28 const CvLSVMFeaturePyramid *_H,
29 float _b, int _maxXBorder, int _maxYBorder,
30 float _scoreThreshold, int _kLevels, const int *_procLevels,
31 float **_score, CvPoint ***_points, int *_kPoints,
32 CvPoint ****_partsDisplacement) :
33 n(_n), b(_b), maxXBorder(_maxXBorder),
34 maxYBorder(_maxYBorder), scoreThreshold(_scoreThreshold),
35 kLevels(_kLevels), score(_score), points(_points),
36 partsDisplacement(_partsDisplacement), kPoints(_kPoints)
40 procLevels = _procLevels;
45 int i, level, partsLevel, res;
46 for (i = 0; i < kLevels; i++)
48 level = procLevels[i];
49 partsLevel = level - LAMBDA;//H->lambda;
50 res = thresholdFunctionalScoreFixedLevel(
51 filters, n, H, level, b,
52 maxXBorder, maxYBorder, scoreThreshold, &(score[partsLevel]),
53 points[partsLevel], &(kPoints[partsLevel]),
54 partsDisplacement[partsLevel]);
55 if (res != LATENT_SVM_OK)
65 // Computation score function using TBB tasks
68 // int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
69 const CvLSVMFeatureMap *H, const float b,
70 const int maxXBorder, const int maxYBorder,
71 const float scoreThreshold,
72 int *kLevels, int **procLevels,
74 float **score, CvPoint ***points,
76 CvPoint ****partsDisplacement);
78 // filters - the set of filters (the first element is root filter,
79 the other - part filters)
80 // n - the number of part filters
81 // H - feature pyramid
82 // b - linear term of the score function
83 // maxXBorder - the largest root filter size (X-direction)
84 // maxYBorder - the largest root filter size (Y-direction)
85 // scoreThreshold - score threshold
86 // kLevels - array that contains number of levels processed
88 // procLevels - array that contains lists of levels processed
90 // threadsNum - the number of created threads
92 // score - score function values that exceed threshold
93 // points - the set of root filter positions (in the block space)
94 // kPoints - number of root filter positions
95 // partsDisplacement - displacement of part filters (in the block space)
99 int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
100 const CvLSVMFeaturePyramid *H, const float b,
101 const int maxXBorder, const int maxYBorder,
102 const float scoreThreshold,
103 int *kLevels, int **procLevels,
104 const int threadsNum,
105 float **score, CvPoint ***points,
107 CvPoint ****partsDisplacement)
109 tbb::task_list tasks;
111 for (i = 0; i < threadsNum; i++)
113 ScoreComputation& sc =
114 *new(tbb::task::allocate_root()) ScoreComputation(filters, n, H, b,
115 maxXBorder, maxYBorder, scoreThreshold, kLevels[i], procLevels[i],
116 score, points, kPoints, partsDisplacement);
119 tbb::task::spawn_root_and_wait(tasks);
120 return LATENT_SVM_OK;