Commit b249c3fb4794c6e82584059a7e8094c2b07ffc35
1 parent
048d7085
trying kernel hash algorithm
Showing
2 changed files
with
37 additions
and
1 deletions
openbr/plugins/algorithms.cpp
| @@ -43,7 +43,7 @@ class AlgorithmsInitializer : public Initializer | @@ -43,7 +43,7 @@ class AlgorithmsInitializer : public Initializer | ||
| 43 | Globals->abbreviations.insert("GenderEstimation", "GenderClassification"); | 43 | Globals->abbreviations.insert("GenderEstimation", "GenderClassification"); |
| 44 | Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); | 44 | Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); |
| 45 | Globals->abbreviations.insert("FaceRecognition2", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+(Gradient+Bin(0,360,9,true))/(Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+Bin(0,10,10,true))+Merge+Integral+RecursiveIntegralSampler(4,2,8,Center(Hellinger)+LDA(.95)+Normalize(L1)+Div(3)+ProductQuantization(3,L1,true)[fraction=0.2]):RecursiveProductQuantization"); | 45 | Globals->abbreviations.insert("FaceRecognition2", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+(Gradient+Bin(0,360,9,true))/(Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+Bin(0,10,10,true))+Merge+Integral+RecursiveIntegralSampler(4,2,8,Center(Hellinger)+LDA(.95)+Normalize(L1)+Div(3)+ProductQuantization(3,L1,true)[fraction=0.2]):RecursiveProductQuantization"); |
| 46 | - Globals->abbreviations.insert("FaceRecognitionHoG", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+Bin(0,10,10,true)+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.95)+Normalize(L1)+Div(3)+ProductQuantization(3,L1,true)[fraction=0.2]):RecursiveProductQuantization"); | 46 | + Globals->abbreviations.insert("FaceRecognitionHoG", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+Gradient+Bin(0,360,9)+KernelHash(9,81)+Bin(0,81,81,true)+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.95)+Normalize(L1)+Div(3)+ProductQuantization(3,L1,true)[fraction=0.2]):RecursiveProductQuantization"); |
| 47 | 47 | ||
| 48 | // Generic Image Processing | 48 | // Generic Image Processing |
| 49 | Globals->abbreviations.insert("SIFT", "Open+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); | 49 | Globals->abbreviations.insert("SIFT", "Open+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); |
openbr/plugins/hash.cpp
| @@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
| 18 | #include "openbr_internal.h" | 18 | #include "openbr_internal.h" |
| 19 | #include "openbr/core/qtutils.h" | 19 | #include "openbr/core/qtutils.h" |
| 20 | 20 | ||
| 21 | +using namespace cv; | ||
| 22 | + | ||
| 21 | namespace br | 23 | namespace br |
| 22 | { | 24 | { |
| 23 | 25 | ||
| @@ -54,6 +56,40 @@ private: | @@ -54,6 +56,40 @@ private: | ||
| 54 | 56 | ||
| 55 | BR_REGISTER(Transform, CryptographicHashTransform) | 57 | BR_REGISTER(Transform, CryptographicHashTransform) |
| 56 | 58 | ||
| 59 | +/*! | ||
| 60 | + * \ingroup transforms | ||
| 61 | + * \brief Kernel hash | ||
| 62 | + * \author Josh Klontz \cite jklontz | ||
| 63 | + */ | ||
| 64 | +class KernelHashTransform : public UntrainableTransform | ||
| 65 | +{ | ||
| 66 | + Q_OBJECT | ||
| 67 | + Q_PROPERTY(uchar dimsIn READ get_dimsIn WRITE set_dimsIn RESET reset_dimsIn STORED false) | ||
| 68 | + Q_PROPERTY(uchar dimsOut READ get_dimsOut WRITE set_dimsOut RESET reset_dimsOut STORED false) | ||
| 69 | + BR_PROPERTY(uchar, dimsIn, 8) | ||
| 70 | + BR_PROPERTY(uchar, dimsOut, 7) | ||
| 71 | + | ||
| 72 | + void project(const Template &src, Template &dst) const | ||
| 73 | + { | ||
| 74 | + if (src.m().type() != CV_8UC1) | ||
| 75 | + qFatal("Expected 8UC1 input."); | ||
| 76 | + | ||
| 77 | + dst = Mat::zeros(src.m().rows, src.m().cols, CV_8UC1); | ||
| 78 | + const uchar *srcData = src.m().data; | ||
| 79 | + uchar *dstData = dst.m().data; | ||
| 80 | + const int step = src.m().cols; | ||
| 81 | + for (int i=0; i<src.m().rows; i++) | ||
| 82 | + for (int j=0; j<src.m().cols-1; j++) { | ||
| 83 | + dstData[i*step+j] = (uint(pow(float(dimsIn),1.f))*srcData[i *step+j] | ||
| 84 | + /*+ uint(pow(float(dimsIn),2.f))*srcData[(i+1)*step+j]*/ | ||
| 85 | + + uint(pow(float(dimsIn),0.f))*srcData[i *step+(j+1)] | ||
| 86 | + /*+ uint(pow(float(dimsIn),0.f))*srcData[(i+1)*step+(j+1)]*/) % dimsOut; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | +}; | ||
| 90 | + | ||
| 91 | +BR_REGISTER(Transform, KernelHashTransform) | ||
| 92 | + | ||
| 57 | } // namespace br | 93 | } // namespace br |
| 58 | 94 | ||
| 59 | #include "hash.moc" | 95 | #include "hash.moc" |