Commit f7dddb1fc7f2da3c3f51b5e8d5334007cd520caa
1 parent
71885f41
Sample bug fixes/tweaks
Showing
1 changed file
with
5 additions
and
3 deletions
openbr/plugins/random.cpp
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | #include <numeric> |
| 18 | 18 | |
| 19 | 19 | #include <opencv2/imgproc/imgproc.hpp> |
| 20 | + | |
| 20 | 21 | #include "openbr_internal.h" |
| 21 | 22 | |
| 22 | 23 | #include "openbr/core/common.h" |
| ... | ... | @@ -164,7 +165,7 @@ class RndSampleTransform : public UntrainableMetaTransform |
| 164 | 165 | void project(const TemplateList &src, TemplateList &dst) const |
| 165 | 166 | { |
| 166 | 167 | foreach(const Template &t, src) { |
| 167 | - QPointF point = t.file.points()[0]; | |
| 168 | + QPointF point = t.file.points()[pointIndex]; | |
| 168 | 169 | QRectF region(point.x()-sampleRadius, point.y()-sampleRadius, sampleRadius*2, sampleRadius*2); |
| 169 | 170 | |
| 170 | 171 | if (region.x() < 0 || |
| ... | ... | @@ -184,6 +185,7 @@ class RndSampleTransform : public UntrainableMetaTransform |
| 184 | 185 | labelCount << 0; |
| 185 | 186 | |
| 186 | 187 | while (std::accumulate(labelCount.begin(),labelCount.end(),0.0) < (sampleOverlapBands.size()-1)*samplesPerOverlapBand) { |
| 188 | + | |
| 187 | 189 | float x = rand() % (sampleFactor*sampleRadius) + region.x() - sampleFactor/2*sampleRadius; |
| 188 | 190 | float y = rand() % (sampleFactor*sampleRadius) + region.y() - sampleFactor/2*sampleRadius; |
| 189 | 191 | |
| ... | ... | @@ -192,13 +194,13 @@ class RndSampleTransform : public UntrainableMetaTransform |
| 192 | 194 | |
| 193 | 195 | QRectF negativeLocation = QRectF(x, y, sampleRadius*2, sampleRadius*2); |
| 194 | 196 | |
| 195 | - float overlap = QtUtils::overlap(region, negativeLocation); | |
| 197 | + float overlap = pow(QtUtils::overlap(region, negativeLocation),overlapPower); | |
| 196 | 198 | |
| 197 | 199 | for (int k = 0; k<sampleOverlapBands.size()-1; k++) { |
| 198 | 200 | if (overlap >= sampleOverlapBands.at(k) && overlap < sampleOverlapBands.at(k+1) && labelCount[k] < samplesPerOverlapBand) { |
| 199 | 201 | Mat m(t.m(),OpenCVUtils::toRect(negativeLocation)); |
| 200 | 202 | dst.append(Template(t.file, m)); |
| 201 | - float label = classification ? 0 : pow(overlap,overlapPower); | |
| 203 | + float label = classification ? 0 : overlap; | |
| 202 | 204 | dst.last().file.set(inputVariable, label); |
| 203 | 205 | labelCount[k]++; |
| 204 | 206 | } | ... | ... |