From c5f168d6af6b3ee55baf78d5db75b994f8dbfc02 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Fri, 15 Mar 2013 20:13:29 -0400 Subject: [PATCH] added more plugins --- sdk/plugins/algorithms.cpp | 2 +- sdk/plugins/sentence.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 sdk/plugins/sentence.cpp diff --git a/sdk/plugins/algorithms.cpp b/sdk/plugins/algorithms.cpp index cd513b2..b7a9a95 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+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+WordWise(RowWisePCA(8)+RowWiseMeanCenter+Binarize,RowWisePCA):L2"); + Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+WordWise(RowWisePCA(8)+RowWiseMeanCenter+Binarize,RowWisePCA)+Sentence:SentenceSimilarity"); // Hash Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); diff --git a/sdk/plugins/sentence.cpp b/sdk/plugins/sentence.cpp new file mode 100644 index 0000000..628cbaf --- /dev/null +++ b/sdk/plugins/sentence.cpp @@ -0,0 +1,85 @@ +#include + +using namespace cv; + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Ordered words + * \author Josh Klontz \cite jklontz + */ +class SentenceTransform : public UntrainableMetaTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + QByteArray sentence; + QDataStream stream(&sentence, QIODevice::WriteOnly); + for (int i=0; i(aData); + aRows = *reinterpret_cast(aData+4); + aColumns = *reinterpret_cast(aData+8); + aData += 12; + } else if (bWord < aWord) { + bWord = *reinterpret_cast(bData); + bRows = *reinterpret_cast(bData+4); + bColumns = *reinterpret_cast(bData+8); + bData += 12; + } else { + for (int i=0; i(aData+4*k) * *reinterpret_cast(bData+4*k); + comparisons += aRows * bRows; + } + } + + return comparisons / distance; + } +}; + +BR_REGISTER(Distance, SentenceSimilarityDistance) + +} // namespace br + +#include "sentence.moc" -- libgit2 0.21.4