Commit 8467a6d59b92d5879028963e8966c6414aaca3f3
Merge branch 'master' into dlib
Showing
5 changed files
with
53 additions
and
6 deletions
openbr/openbr_plugin.h
| @@ -1178,7 +1178,7 @@ public: | @@ -1178,7 +1178,7 @@ public: | ||
| 1178 | 1178 | ||
| 1179 | virtual ~Transform() {} | 1179 | virtual ~Transform() {} |
| 1180 | static Transform *make(QString str, QObject *parent); /*!< \brief Make a transform from a string. */ | 1180 | static Transform *make(QString str, QObject *parent); /*!< \brief Make a transform from a string. */ |
| 1181 | - static QSharedPointer<Transform> fromAlgorithm(const QString &algorithm, bool preprocess=true); /*!< \brief Retrieve an algorithm's transform. If preprocess is true, attaches a stream transform as the root of the algorithm*/ | 1181 | + static QSharedPointer<Transform> fromAlgorithm(const QString &algorithm, bool preprocess=false); /*!< \brief Retrieve an algorithm's transform. If preprocess is true, attaches a stream transform as the root of the algorithm*/ |
| 1182 | static QSharedPointer<Transform> fromComparison(const QString &algorithm); | 1182 | static QSharedPointer<Transform> fromComparison(const QString &algorithm); |
| 1183 | 1183 | ||
| 1184 | virtual Transform *clone() const; /*!< \brief Copy the transform. */ | 1184 | virtual Transform *clone() const; /*!< \brief Copy the transform. */ |
openbr/plugins/cvt.cpp
| @@ -115,7 +115,18 @@ class ScaleTransform : public UntrainableTransform | @@ -115,7 +115,18 @@ class ScaleTransform : public UntrainableTransform | ||
| 115 | 115 | ||
| 116 | void project(const Template &src, Template &dst) const | 116 | void project(const Template &src, Template &dst) const |
| 117 | { | 117 | { |
| 118 | - resize(src, dst, Size(src.m().cols*scaleFactor,src.m().rows*scaleFactor)); | 118 | + resize(src, dst, Size(src.m().cols*scaleFactor,src.m().rows*scaleFactor)); |
| 119 | + | ||
| 120 | + QList<QRectF> rects = src.file.rects(); | ||
| 121 | + for (int i=0; i<rects.size(); i++) | ||
| 122 | + rects[i] = QRectF(rects[i].topLeft()*scaleFactor,rects[i].bottomRight()*scaleFactor); | ||
| 123 | + dst.file.setRects(rects); | ||
| 124 | + | ||
| 125 | + QList<QPointF> points = src.file.points(); | ||
| 126 | + for (int i=0; i<points.size(); i++) | ||
| 127 | + points[i] = points[i] * scaleFactor; | ||
| 128 | + dst.file.setPoints(points); | ||
| 129 | + | ||
| 119 | } | 130 | } |
| 120 | }; | 131 | }; |
| 121 | 132 |
openbr/plugins/edge.cpp
0 → 100644
| 1 | +#include "openbr_internal.h" | ||
| 2 | + | ||
| 3 | +#include "opencv2/imgproc/imgproc.hpp" | ||
| 4 | + | ||
| 5 | +using namespace cv; | ||
| 6 | + | ||
| 7 | +namespace br | ||
| 8 | +{ | ||
| 9 | + | ||
| 10 | +/*! | ||
| 11 | + * \ingroup transforms | ||
| 12 | + * \brief Warpper to OpenCV Canny edge detector | ||
| 13 | + * \author Scott Klum \cite sklum | ||
| 14 | + */ | ||
| 15 | +class CannyTransform : public UntrainableTransform | ||
| 16 | +{ | ||
| 17 | + Q_OBJECT | ||
| 18 | + Q_PROPERTY(double threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false) | ||
| 19 | + Q_PROPERTY(double aperatureSize READ get_aperatureSize WRITE set_aperatureSize RESET reset_aperatureSize STORED false) | ||
| 20 | + Q_PROPERTY(bool L2Gradient READ get_L2Gradient WRITE set_L2Gradient RESET reset_L2Gradient STORED false) | ||
| 21 | + BR_PROPERTY(double, threshold, 5) | ||
| 22 | + BR_PROPERTY(double, aperatureSize, 3) | ||
| 23 | + BR_PROPERTY(bool, L2Gradient, false) | ||
| 24 | + | ||
| 25 | + void project(const Template &src, Template &dst) const | ||
| 26 | + { | ||
| 27 | + Canny(src,dst, threshold, 3*threshold, aperatureSize, L2Gradient); | ||
| 28 | + } | ||
| 29 | +}; | ||
| 30 | + | ||
| 31 | +BR_REGISTER(Transform, CannyTransform) | ||
| 32 | + | ||
| 33 | +} // namespace br | ||
| 34 | + | ||
| 35 | +#include "edge.moc" |
openbr/plugins/random.cpp
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | #include <numeric> | 17 | #include <numeric> |
| 18 | 18 | ||
| 19 | #include <opencv2/imgproc/imgproc.hpp> | 19 | #include <opencv2/imgproc/imgproc.hpp> |
| 20 | + | ||
| 20 | #include "openbr_internal.h" | 21 | #include "openbr_internal.h" |
| 21 | 22 | ||
| 22 | #include "openbr/core/common.h" | 23 | #include "openbr/core/common.h" |
| @@ -164,7 +165,7 @@ class RndSampleTransform : public UntrainableMetaTransform | @@ -164,7 +165,7 @@ class RndSampleTransform : public UntrainableMetaTransform | ||
| 164 | void project(const TemplateList &src, TemplateList &dst) const | 165 | void project(const TemplateList &src, TemplateList &dst) const |
| 165 | { | 166 | { |
| 166 | foreach(const Template &t, src) { | 167 | foreach(const Template &t, src) { |
| 167 | - QPointF point = t.file.points()[0]; | 168 | + QPointF point = t.file.points()[pointIndex]; |
| 168 | QRectF region(point.x()-sampleRadius, point.y()-sampleRadius, sampleRadius*2, sampleRadius*2); | 169 | QRectF region(point.x()-sampleRadius, point.y()-sampleRadius, sampleRadius*2, sampleRadius*2); |
| 169 | 170 | ||
| 170 | if (region.x() < 0 || | 171 | if (region.x() < 0 || |
| @@ -184,6 +185,7 @@ class RndSampleTransform : public UntrainableMetaTransform | @@ -184,6 +185,7 @@ class RndSampleTransform : public UntrainableMetaTransform | ||
| 184 | labelCount << 0; | 185 | labelCount << 0; |
| 185 | 186 | ||
| 186 | while (std::accumulate(labelCount.begin(),labelCount.end(),0.0) < (sampleOverlapBands.size()-1)*samplesPerOverlapBand) { | 187 | while (std::accumulate(labelCount.begin(),labelCount.end(),0.0) < (sampleOverlapBands.size()-1)*samplesPerOverlapBand) { |
| 188 | + | ||
| 187 | float x = rand() % (sampleFactor*sampleRadius) + region.x() - sampleFactor/2*sampleRadius; | 189 | float x = rand() % (sampleFactor*sampleRadius) + region.x() - sampleFactor/2*sampleRadius; |
| 188 | float y = rand() % (sampleFactor*sampleRadius) + region.y() - sampleFactor/2*sampleRadius; | 190 | float y = rand() % (sampleFactor*sampleRadius) + region.y() - sampleFactor/2*sampleRadius; |
| 189 | 191 | ||
| @@ -192,13 +194,13 @@ class RndSampleTransform : public UntrainableMetaTransform | @@ -192,13 +194,13 @@ class RndSampleTransform : public UntrainableMetaTransform | ||
| 192 | 194 | ||
| 193 | QRectF negativeLocation = QRectF(x, y, sampleRadius*2, sampleRadius*2); | 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 | for (int k = 0; k<sampleOverlapBands.size()-1; k++) { | 199 | for (int k = 0; k<sampleOverlapBands.size()-1; k++) { |
| 198 | if (overlap >= sampleOverlapBands.at(k) && overlap < sampleOverlapBands.at(k+1) && labelCount[k] < samplesPerOverlapBand) { | 200 | if (overlap >= sampleOverlapBands.at(k) && overlap < sampleOverlapBands.at(k+1) && labelCount[k] < samplesPerOverlapBand) { |
| 199 | Mat m(t.m(),OpenCVUtils::toRect(negativeLocation)); | 201 | Mat m(t.m(),OpenCVUtils::toRect(negativeLocation)); |
| 200 | dst.append(Template(t.file, m)); | 202 | dst.append(Template(t.file, m)); |
| 201 | - float label = classification ? 0 : pow(overlap,overlapPower); | 203 | + float label = classification ? 0 : overlap; |
| 202 | dst.last().file.set(inputVariable, label); | 204 | dst.last().file.set(inputVariable, label); |
| 203 | labelCount[k]++; | 205 | labelCount[k]++; |
| 204 | } | 206 | } |
share/openbr/cmake/FindLibLinear.cmake
| 1 | find_path(LibLinear_DIR linear.h ${CMAKE_SOURCE_DIR}/3rdparty/*) | 1 | find_path(LibLinear_DIR linear.h ${CMAKE_SOURCE_DIR}/3rdparty/*) |
| 2 | 2 | ||
| 3 | -message(${LibLinear_DIR}) | ||
| 4 | mark_as_advanced(LibLinear_DIR) | 3 | mark_as_advanced(LibLinear_DIR) |
| 5 | include_directories(${LibLinear_DIR}) | 4 | include_directories(${LibLinear_DIR}) |
| 6 | include_directories(${LibLinear_DIR}/blas) | 5 | include_directories(${LibLinear_DIR}/blas) |