diff --git a/sdk/plugins/algorithms.cpp b/sdk/plugins/algorithms.cpp index 28efccc..f8ca61d 100644 --- a/sdk/plugins/algorithms.cpp +++ b/sdk/plugins/algorithms.cpp @@ -50,7 +50,7 @@ class AlgorithmsInitializer : public Initializer Globals->abbreviations.insert("SmallSIFT", "Open+LimitSize(512)+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); Globals->abbreviations.insert("SmallSURF", "Open+LimitSize(512)+KeyPointDetector(SURF)+KeyPointDescriptor(SURF):KeyPointMatcher(BruteForce)"); Globals->abbreviations.insert("ColorHist", "Open+LimitSize(512)!EnsureChannels(3)+SplitChannels+Hist(256,0,8)+Cat+Normalize(L1):L2"); - Globals->abbreviations.insert("IHH", "Open+SplitChannels/(Cvt(Gray)+Gradient+Bin(0,6.283,8,true))+Integral+Merge+IntegralSampler"); + Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat:L2"); // Hash Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); diff --git a/sdk/plugins/cvt.cpp b/sdk/plugins/cvt.cpp index 6fd9b4d..b48ed56 100644 --- a/sdk/plugins/cvt.cpp +++ b/sdk/plugins/cvt.cpp @@ -160,6 +160,63 @@ class EnsureChannelsTransform : public UntrainableTransform BR_REGISTER(Transform, EnsureChannelsTransform) +/*! + * \ingroup transforms + * \brief Normalized RG color space. + * \author Josh Klontz \cite jklontz + */ +class RGTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + if (src.m().type() != CV_8UC3) + qFatal("Expected CV_8UC3 images."); + + const Mat &m = src.m(); + Mat R(m.size(), CV_8UC1); // R / (R+G+B) + Mat G(m.size(), CV_8UC1); // G / (R+G+B) + + for (int i=0; i(i,j); + uchar& b = v[0]; + uchar& g = v[1]; + uchar& r = v[2]; + + R.at(i, j) = saturate_cast(255.0*r/(r+g+b)); + G.at(i, j) = saturate_cast(255.0*g/(r+g+b)); + } + + dst.append(R); + dst.append(G); + } +}; + +BR_REGISTER(Transform, RGTransform) + +/*! + * \ingroup transforms + * \brief dst = a*src+b + * \author Josh Klontz \cite jklontz + */ +class MAddTransform : public UntrainableTransform +{ + Q_OBJECT + Q_PROPERTY(double a READ get_a WRITE set_a RESET reset_a STORED false) + Q_PROPERTY(double b READ get_b WRITE set_b RESET reset_b STORED false) + BR_PROPERTY(double, a, 1) + BR_PROPERTY(double, b, 0) + + void project(const Template &src, Template &dst) const + { + src.m().convertTo(dst.m(), src.m().depth(), a, b); + } +}; + +BR_REGISTER(Transform, MAddTransform) + } // namespace br #include "cvt.moc" diff --git a/sdk/plugins/hist.cpp b/sdk/plugins/hist.cpp index 1a94431..0372e54 100644 --- a/sdk/plugins/hist.cpp +++ b/sdk/plugins/hist.cpp @@ -83,13 +83,13 @@ class BinTransform : public UntrainableTransform void project(const Template &src, Template &dst) const { - src.m().convertTo(dst, bins > 256 ? CV_16U : CV_8U, bins/(max-min)); + src.m().convertTo(dst, bins > 256 ? CV_16U : CV_8U, bins/(max-min), -0.5 /* floor */); if (!split) return; Mat input = dst; QList outputs; outputs.reserve(bins); for (int i=0; i #include +#include "core/opencvutils.h" + using namespace cv; namespace br @@ -26,25 +28,25 @@ BR_REGISTER(Transform, IntegralTransform) /*! * \ingroup transforms - * \brief Sliding window object recognition from a multi-channel intergral image. + * \brief Sliding window feature extraction from a multi-channel intergral image. * \author Josh Klontz \cite jklontz */ -class IntegralSampler : public UntrainableTransform +class IntegralSamplerTransform : public UntrainableTransform { Q_OBJECT Q_PROPERTY(int scales READ get_scales WRITE set_scales RESET reset_scales STORED false) Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false) Q_PROPERTY(float stepFactor READ get_stepFactor WRITE set_stepFactor RESET reset_stepFactor STORED false) Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false) - BR_PROPERTY(int, scales, 1) - BR_PROPERTY(float, scaleFactor, 1.25) + BR_PROPERTY(int, scales, 3) + BR_PROPERTY(float, scaleFactor, 2) BR_PROPERTY(float, stepFactor, 0.25) BR_PROPERTY(int, minSize, 8) void project(const Template &src, Template &dst) const { typedef Eigen::Map< const Eigen::Matrix > InputDescriptor; - typedef Eigen::Map< Eigen::Matrix > OutputDescriptor; + typedef Eigen::Map< Eigen::Matrix > OutputDescriptor; const Mat &m = src.m(); if (m.depth() != CV_32S) qFatal("Expected CV_32S matrix depth."); const int channels = m.channels(); @@ -53,16 +55,16 @@ class IntegralSampler : public UntrainableTransform int descriptors = 0; int currentSize = min(m.rows, m.cols)-1; for (int scale=0; scale()/(currentSize*currentSize); index++; } } @@ -82,12 +84,11 @@ class IntegralSampler : public UntrainableTransform if (currentSize < minSize) break; } - dst.m() = n; } }; -BR_REGISTER(Transform, IntegralSampler) +BR_REGISTER(Transform, IntegralSamplerTransform) /*! * \ingroup transforms