Commit ca4f10d5926ad1cd7ff04e3f82bf120f29208b62
1 parent
bbfa70e5
serialization fixes
Showing
3 changed files
with
37 additions
and
4 deletions
openbr/plugins/algorithms.cpp
| ... | ... | @@ -42,7 +42,7 @@ class AlgorithmsInitializer : public Initializer |
| 42 | 42 | Globals->abbreviations.insert("OpenBR", "FaceRecognition"); |
| 43 | 43 | Globals->abbreviations.insert("GenderEstimation", "GenderClassification"); |
| 44 | 44 | Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); |
| 45 | - Globals->abbreviations.insert("FaceRecognitionHoG", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(64,64,0.25,0.35)+Gradient+Bin(0,360,8,true)+Merge+Integral+IntegralSampler+ProductQuantization(2,L1,true):ProductQuantization(true)"); | |
| 45 | + Globals->abbreviations.insert("FaceRecognitionHoG", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+Gradient+Bin(0,360,9,true)+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.95)+Normalize(L1)+Div(3)+ProductQuantization(3,L1,true)[fraction=0.2]):ProductQuantization(true)"); | |
| 46 | 46 | |
| 47 | 47 | // Generic Image Processing |
| 48 | 48 | Globals->abbreviations.insert("SIFT", "Open+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); | ... | ... |
openbr/plugins/integral.cpp
| ... | ... | @@ -248,7 +248,7 @@ class RecursiveIntegralSamplerTransform : public Transform |
| 248 | 248 | void store(QDataStream &stream) const |
| 249 | 249 | { |
| 250 | 250 | transform->store(stream); |
| 251 | - stream << (subTransform == NULL); | |
| 251 | + stream << (subTransform != NULL); | |
| 252 | 252 | if (subTransform != NULL) |
| 253 | 253 | subTransform->store(stream); |
| 254 | 254 | } | ... | ... |
openbr/plugins/quantize.cpp
| ... | ... | @@ -247,7 +247,7 @@ QVector<Mat> ProductQuantizationLUTs; |
| 247 | 247 | /*! |
| 248 | 248 | * \ingroup distances |
| 249 | 249 | * \brief Distance in a product quantized space \cite jegou11 |
| 250 | - * \author Josh Klontz | |
| 250 | + * \author Josh Klontz \cite jklontz | |
| 251 | 251 | */ |
| 252 | 252 | class ProductQuantizationDistance : public Distance |
| 253 | 253 | { |
| ... | ... | @@ -278,6 +278,36 @@ class ProductQuantizationDistance : public Distance |
| 278 | 278 | BR_REGISTER(Distance, ProductQuantizationDistance) |
| 279 | 279 | |
| 280 | 280 | /*! |
| 281 | + * \ingroup distances | |
| 282 | + * \brief Recurively computed distance in a product quantized space | |
| 283 | + * \author Josh Klontz \cite jklontz | |
| 284 | + */ | |
| 285 | +class RecursiveProductQuantizationDistance : public Distance | |
| 286 | +{ | |
| 287 | + Q_OBJECT | |
| 288 | + | |
| 289 | + float compare(const Template &a, const Template &b) const | |
| 290 | + { | |
| 291 | + float distance = 0; | |
| 292 | + for (int i=0; i<a.size(); i++) { | |
| 293 | + const int elements = a[i].total()-sizeof(quint16); | |
| 294 | + uchar *aData = a[i].data; | |
| 295 | + uchar *bData = b[i].data; | |
| 296 | + quint16 index = *reinterpret_cast<quint16*>(aData); | |
| 297 | + aData += sizeof(quint16); | |
| 298 | + bData += sizeof(quint16); | |
| 299 | + | |
| 300 | + const float *lut = (const float*)ProductQuantizationLUTs[index].data; | |
| 301 | + for (int j=0; j<elements; j++) | |
| 302 | + distance += lut[j*256*256 + aData[j]*256+bData[j]]; | |
| 303 | + } | |
| 304 | + return distance; | |
| 305 | + } | |
| 306 | +}; | |
| 307 | + | |
| 308 | +BR_REGISTER(Distance, RecursiveProductQuantizationDistance) | |
| 309 | + | |
| 310 | +/*! | |
| 281 | 311 | * \ingroup transforms |
| 282 | 312 | * \brief Product quantization \cite jegou11 |
| 283 | 313 | * \author Josh Klontz \cite jklontz |
| ... | ... | @@ -461,7 +491,10 @@ private: |
| 461 | 491 | |
| 462 | 492 | void load(QDataStream &stream) |
| 463 | 493 | { |
| 464 | - stream >> index >> centers >> ProductQuantizationLUTs[index]; | |
| 494 | + stream >> index >> centers; | |
| 495 | + while (ProductQuantizationLUTs.size() <= index) | |
| 496 | + ProductQuantizationLUTs.append(Mat()); | |
| 497 | + stream >> ProductQuantizationLUTs[index]; | |
| 465 | 498 | } |
| 466 | 499 | }; |
| 467 | 500 | ... | ... |