From f7dddb1fc7f2da3c3f51b5e8d5334007cd520caa Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 16 Feb 2015 11:40:02 -0500 Subject: [PATCH] Sample bug fixes/tweaks --- openbr/plugins/random.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openbr/plugins/random.cpp b/openbr/plugins/random.cpp index a38071d..9a0d397 100644 --- a/openbr/plugins/random.cpp +++ b/openbr/plugins/random.cpp @@ -17,6 +17,7 @@ #include #include + #include "openbr_internal.h" #include "openbr/core/common.h" @@ -164,7 +165,7 @@ class RndSampleTransform : public UntrainableMetaTransform void project(const TemplateList &src, TemplateList &dst) const { foreach(const Template &t, src) { - QPointF point = t.file.points()[0]; + QPointF point = t.file.points()[pointIndex]; QRectF region(point.x()-sampleRadius, point.y()-sampleRadius, sampleRadius*2, sampleRadius*2); if (region.x() < 0 || @@ -184,6 +185,7 @@ class RndSampleTransform : public UntrainableMetaTransform labelCount << 0; while (std::accumulate(labelCount.begin(),labelCount.end(),0.0) < (sampleOverlapBands.size()-1)*samplesPerOverlapBand) { + float x = rand() % (sampleFactor*sampleRadius) + region.x() - sampleFactor/2*sampleRadius; float y = rand() % (sampleFactor*sampleRadius) + region.y() - sampleFactor/2*sampleRadius; @@ -192,13 +194,13 @@ class RndSampleTransform : public UntrainableMetaTransform QRectF negativeLocation = QRectF(x, y, sampleRadius*2, sampleRadius*2); - float overlap = QtUtils::overlap(region, negativeLocation); + float overlap = pow(QtUtils::overlap(region, negativeLocation),overlapPower); for (int k = 0; k= sampleOverlapBands.at(k) && overlap < sampleOverlapBands.at(k+1) && labelCount[k] < samplesPerOverlapBand) { Mat m(t.m(),OpenCVUtils::toRect(negativeLocation)); dst.append(Template(t.file, m)); - float label = classification ? 0 : pow(overlap,overlapPower); + float label = classification ? 0 : overlap; dst.last().file.set(inputVariable, label); labelCount[k]++; } -- libgit2 0.21.4