diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 70b5f2c..284b0be 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -15,6 +15,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include +#include #include #include #include @@ -443,7 +444,9 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) newTemplates.insert(i+1, allPartitionTemplate); } } else { - newTemplates[i].file.set("Partition", rand() % crossValidate); + const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.subject().toLatin1(), QCryptographicHash::Md5); + // Select the right 8 hex characters so that it can be represented as a 64 bit integer without overflow + newTemplates[i].file.set("Partition", md5.toHex().right(8).toULongLong(0, 16) % crossValidate); } } } diff --git a/openbr/plugins/ct8.cpp b/openbr/plugins/ct8.cpp index a48fb24..98c1063 100644 --- a/openbr/plugins/ct8.cpp +++ b/openbr/plugins/ct8.cpp @@ -422,8 +422,14 @@ struct CT8Compare : public Distance, if (!srcA.m().data || !srcB.m().data) return score; try { + static QMutex mutex; + QMutexLocker locker(&mutex); + + // Internally Cognitec keeps a total count of the allocated templates, + // it seems that this reference count update is not thread safe FRsdk::FIR firA = firBuilder->build( (FRsdk::Byte *) srcA.m().data, srcA.m().cols); FRsdk::FIR firB = firBuilder->build( (FRsdk::Byte *) srcB.m().data, srcB.m().cols); + score = (float)facialMatchingEngine->compare(firA, firB); } catch (std::exception &e) { qFatal("CT8Compare Exception: %s", e.what()); diff --git a/openbr/plugins/output.cpp b/openbr/plugins/output.cpp index c294c0d..4ec68f0 100644 --- a/openbr/plugins/output.cpp +++ b/openbr/plugins/output.cpp @@ -203,7 +203,7 @@ class mtxOutput : public Output if (!f.open(QFile::ReadWrite)) qFatal("Unable to open %s for modifying.", qPrintable(file)); for (int i=0; iblockSize+i)*targetFiles.size()+(columnBlock*Globals->blockSize))); + f.seek(headerSize + sizeof(float)*(quint64(rowBlock*Globals->blockSize+i)*targetFiles.size()+(columnBlock*Globals->blockSize))); f.write((const char*)blockScores.row(i).data, sizeof(float)*blockScores.cols); } f.close(); diff --git a/scripts/enrollFaces.sh b/scripts/enrollFaces.sh deleted file mode 100755 index 4652873..0000000 --- a/scripts/enrollFaces.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -if [ ! -f enrollFaces.sh ]; then - echo "Run this script from the scripts folder!" - exit -fi - -if ! hash br 2>/dev/null; then - echo "Can't find 'br'. Did you forget to build and install OpenBR? Here's some help: http://openbiometrics.org/doxygen/latest/installation.html" - exit -fi - -DATA_ROOT=/Volumes/Seagate -GALLERY_ROOT=/Volumes/Seagate - -for ALGORITHM in PP5 -do - - for SIGSET in CUFS_photo CUFS_sketch - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/CUFS -enroll ../data/CUFS/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in CUFSF_photo CUFSF_sketch - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/CUFSF -enroll ../data/CUFSF/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in fa fb fc dup1 dup2 - do - br -algorithm ${ALGORITHM} -path "${DATA_ROOT}/FERET/dvd2/gray_feret_cd1/data/images/;${DATA_ROOT}/FERET/dvd2/gray_feret_cd2/data/images/" -enroll ../data/FERET/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in FRGC-1 FRGC-2 FRGC-4_target FRGC-4_query - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/FRGC2 -enroll ../data/FRGC/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in HFB_NIR HFB_VIS - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/HFB -enroll ../data/HFB/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in LFW - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/LFW -enroll ../data/LFW/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in MEDS_frontal_all - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/MEDS -enroll ../data/MEDS/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - - for SIGSET in PCSO_2x10k - do - br -algorithm ${ALGORITHM} -path ${DATA_ROOT}/PCSO -enroll ../data/PCSO/sigset/${SIGSET}.xml ${GALLERY_ROOT}/galleries/${ALGORITHM}_${SIGSET}.gal - done - -done \ No newline at end of file