Skip to content

Commit

Permalink
Merge pull request #423 from biometrics/openbr_1_0
Browse files Browse the repository at this point in the history
Openbr 1 0
  • Loading branch information
jklontz committed Sep 7, 2015
2 parents 559d019 + 1af9c6c commit ccb5845
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 21 deletions.
30 changes: 21 additions & 9 deletions docs/docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ A hacker's guide to building, editing, and running OpenBR.

$ git clone https://github.com/biometrics/openbr.git
$ cd openbr
$ git checkout 0.5
$ git checkout 1.0
$ git submodule init
$ git submodule update

Expand Down Expand Up @@ -71,8 +71,14 @@ A hacker's guide to building, editing, and running OpenBR.
$ sudo cpack -G TGZ

10. (Optional) Build OpenBR documentation!
1. Build the docs

Need to rewrite this step for the new docs!
$ pip install mkdocs
$ cd openbr/docs
$ sh build_docs.sh
$ mkdocs serve

2. Navigate to `http://127.0.0.1:8000` in your browser to view the docs.

---

Expand All @@ -83,13 +89,13 @@ Need to rewrite this step for the new docs!
2. [Download CMake 3.0.2](http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz)

$ cd ~/Downloads
$ tar -xf cmake-2.8.11.2.tar.gz
$ cd cmake-2.8.11.2
$ tar -xf cmake-3.0.2.tar.gz
$ cd cmake-3.0.2
$ ./configure
$ make -j4
$ sudo make install
$ cd ..
$ rm -rf cmake-2.8.11.2*
$ rm -rf cmake-3.0.2*

3. [Download OpenCV 2.4.11](http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download)

Expand All @@ -110,7 +116,7 @@ Need to rewrite this step for the new docs!

$ git clone https://github.com/biometrics/openbr.git
$ cd openbr
$ git checkout 0.5
$ git checkout 1.0
$ git submodule init
$ git submodule update

Expand Down Expand Up @@ -148,8 +154,14 @@ Need to rewrite this step for the new docs!


10. (Optional) Build OpenBR documentation!
1. Build the docs

$ pip install mkdocs
$ cd openbr/docs
$ sh build_docs.sh
$ mkdocs serve

Need to remake this step with the new docs!
2. Navigate to `http://127.0.0.1:8000` in your browser to view the docs.

---

Expand Down Expand Up @@ -184,7 +196,7 @@ Need to remake this step with the new docs!
$ cd /c
$ git clone https://github.com/biometrics/openbr.git
$ cd openbr
$ git checkout 0.5
$ git checkout 1.0
$ git submodule init
$ git submodule update

Expand Down Expand Up @@ -265,7 +277,7 @@ Need to remake this step with the new docs!

$ git clone https://github.com/biometrics/openbr.git
$ cd openbr
$ git checkout 0.5
$ git checkout 1.0
$ git submodule init
$ git submodule update

Expand Down
4 changes: 2 additions & 2 deletions openbr/plugins/cmake/dlib.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set(BR_WITH_DLIB ON CACHE BOOL "Build with DLib")
set(BR_WITH_DLIB OFF CACHE BOOL "Build with DLib")

if(${BR_WITH_DLIB})
ExternalProject_Add(dlib
URL https://github.com/davisking/dlib/releases/download/v18.16/dlib-18.16.tar.bz2
URL http://downloads.sourceforge.net/project/dclib/dlib/v18.16/dlib-18.16.tar.bz2
URL_MD5 e9e5449bc25370afce2d254327afac99
SOURCE_DIR "${PROJECT_SOURCE_DIR}/3rdparty/dlib-18.16"
CONFIGURE_COMMAND ""
Expand Down
20 changes: 13 additions & 7 deletions openbr/plugins/core/algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,29 @@ class AlgorithmsInitializer : public Initializer
void initialize() const
{
// Face
Globals->abbreviations.insert("FaceRecognition", "FaceDetection+FaceRecognitionRegistration+<FaceRecognitionExtraction>+<FaceRecognitionEmbedding>+<FaceRecognitionQuantization>+SetMetadata(AlgorithmID,-1):Unit(ByteL1)");
Globals->abbreviations.insert("FaceRecognition", "FaceRecognition_1_0");

Globals->abbreviations.insert("FaceRecognition_1_0", "FR_Detect+(FR_Eyes+FR_Represent)/(FR_Eyebrows+FR_Represent)/(FR_Mouth+FR_Represent)/(FR_Nose+FR_Represent)/(FR_Face+FR_Represent+ScaleMat(2.0))+Cat+LDA(768)+Normalize(L2):Dist(L2)");
Globals->abbreviations.insert("FR_Eyes", "(CropFromLandmarks([30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],paddingVertical=.8,paddingHorizontal=.2)+Resize(24,48))");
Globals->abbreviations.insert("FR_Eyebrows", "(CropFromLandmarks([16,17,18,19,20,21,22,23,24,25,26,27],paddingVertical=.8,paddingHorizontal=.2)+Resize(24,48))");
Globals->abbreviations.insert("FR_Mouth", "(CropFromLandmarks([59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])+Resize(24,48))");
Globals->abbreviations.insert("FR_Nose", "(CropFromLandmarks([16,17,18,19,20,21,22,23,24,25,26,27],padding=3)+Resize(36,36))");
Globals->abbreviations.insert("FR_Face", "(Crop(24,24,88,88)+Resize(44,44))");
Globals->abbreviations.insert("FR_Detect", "(FaceDetection+Stasm+Rename(StasmLeftEye,Affine_1,true)+Rename(StasmRightEye,Affine_0,true)+Affine(136,136,0.35,0.35,warpPoints=true))");
Globals->abbreviations.insert("FR_Represent", "((DenseHOG/DenseLBP)+Cat+LDA(.98)+Normalize(L2))");

Globals->abbreviations.insert("GenderClassification", "FaceDetection+Expand+FaceClassificationRegistration+Expand+<FaceClassificationExtraction>+<GenderClassifier>+Discard");
Globals->abbreviations.insert("AgeRegression", "FaceDetection+Expand+FaceClassificationRegistration+Expand+<FaceClassificationExtraction>+<AgeRegressor>+Discard");
Globals->abbreviations.insert("FaceQuality", "Open+Expand+Cascade(FrontalFace)+ASEFEyes+Affine(64,64,0.25,0.35)+ImageQuality+Cvt(Gray)+DFFS+Discard");
Globals->abbreviations.insert("MedianFace", "Open+Expand+Cascade(FrontalFace)+ASEFEyes+Affine(256,256,0.37,0.45)+Center(Median)");
Globals->abbreviations.insert("BlurredFaceDetection", "Open+LimitSize(1024)+SkinMask/(Cvt(Gray)+GradientMask)+And+Morph(Erode,16)+LargestConvexArea");
Globals->abbreviations.insert("DrawFaceDetection", "Open+Cascade(FrontalFace)+Expand+ASEFEyes+Draw(inPlace=true)");
Globals->abbreviations.insert("ShowFaceDetection", "DrawFaceDetection+Contract+First+Show+Discard");
Globals->abbreviations.insert("DownloadFaceRecognition", "Download+Open+ROI+Cvt(Gray)+Cascade(FrontalFace)+FaceRecognitionRegistration+<FaceRecognitionExtraction>+<FaceRecognitionEmbedding>+<FaceRecognitionQuantization>+SetMetadata(AlgorithmID,-1):Unit(ByteL1)");
Globals->abbreviations.insert("OpenBR", "FaceRecognition");
Globals->abbreviations.insert("GenderEstimation", "GenderClassification");
Globals->abbreviations.insert("AgeEstimation", "AgeRegression");
Globals->abbreviations.insert("FaceRecognition2", "{PP5Register+Affine(128,128,0.25,0.35)+Cvt(Gray)}+(Gradient+HistBin(0,360,9,true))/(Blur(1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2,true)+HistBin(0,10,10,true))+Merge+Integral+RecursiveIntegralSampler(4,2,8,LDA(.98)+Normalize(L1))+Cat+PCA(768)+Normalize(L1)+Quantize:UCharL1");
Globals->abbreviations.insert("CropFace", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.25,0.35)");
Globals->abbreviations.insert("4SF", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.33,0.45)+(Grid(10,10)+SIFTDescriptor(12)+ByRow)/(Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59))+PCA(0.95)+Cat+Normalize(L2)+Dup(12)+RndSubspace(0.05,1)+LDA(0.98)+Cat+PCA(0.95)+Normalize(L1)+Quantize:NegativeLogPlusOne(ByteL1)");
Globals->abbreviations.insert("4SF", "Open+Cvt(Gray)+Cascade(FrontalFace)+ASEFEyes+Affine(128,128,0.33,0.45)+(Grid(10,10)+SIFTDescriptor(12)+ByRow)/(Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59))+PCA(0.95)+Cat+Normalize(L2)+Dup(12)+RndSubspace(0.05,1)+LDA(0.98)+Cat+PCA(0.95)+Normalize(L1):NegativeLogPlusOne(ByteL1)");

// Video
Globals->abbreviations.insert("DisplayVideo", "FPSLimit(30)+Show(false,[FrameNumber])+Discard");
Expand Down Expand Up @@ -92,9 +101,6 @@ class AlgorithmsInitializer : public Initializer
Globals->abbreviations.insert("DenseSIFT", "(Grid(10,10)+SIFTDescriptor(12)+ByRow)");
Globals->abbreviations.insert("DenseSIFT2", "(Grid(5,5)+SIFTDescriptor(12)+ByRow)");
Globals->abbreviations.insert("FaceRecognitionRegistration", "ASEFEyes+Affine(88,88,0.25,0.35)");
Globals->abbreviations.insert("FaceRecognitionExtraction", "(Mask+DenseSIFT/DenseLBP+DownsampleTraining(PCA(0.95),instances=1)+Normalize(L2)+Cat)");
Globals->abbreviations.insert("FaceRecognitionEmbedding", "(Dup(12)+RndSubspace(0.05,1)+DownsampleTraining(LDA(0.98),instances=-2)+Cat+DownsampleTraining(PCA(768),instances=1))");
Globals->abbreviations.insert("FaceRecognitionQuantization", "(Normalize(L1)+Quantize)");
Globals->abbreviations.insert("FaceClassificationRegistration", "ASEFEyes+Affine(56,72,0.33,0.45)");
Globals->abbreviations.insert("FaceClassificationExtraction", "((Grid(7,7)+SIFTDescriptor(8)+ByRow)/DenseLBP+DownsampleTraining(PCA(0.95),instances=-1, inputVariable=Gender)+Cat)");
Globals->abbreviations.insert("AgeRegressor", "DownsampleTraining(Center(Range),instances=-1, inputVariable=Age)+DownsampleTraining(SVM(RBF,EPS_SVR,inputVariable=Age),instances=100, inputVariable=Age)");
Expand Down
9 changes: 8 additions & 1 deletion openbr/plugins/imgproc/cropfromlandmarks.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <openbr/plugins/openbr_internal.h>
#include <openbr/core/opencvutils.h>

using namespace cv;

Expand Down Expand Up @@ -43,7 +44,13 @@ class CropFromLandmarksTransform : public UntrainableTransform
int padW = qRound((maxX - minX) * (paddingHorizontal / 2));
int padH = qRound((maxY - minY) * (paddingVertical / 2));

dst = Mat(src, Rect(minX - padW, minY - padH, (maxX - minX + 1) + padW * 2, (maxY - minY + 1) + padH * 2));
QRectF rect(minX - padW, minY - padH, (maxX - minX + 1) + padW * 2, (maxY - minY + 1) + padH * 2);
if (rect.x() < 0) rect.setX(0);
if (rect.y() < 0) rect.setY(0);
if (rect.x() + rect.width() > src.m().cols) rect.setWidth(src.m().cols - rect.x());
if (rect.y() + rect.width() > src.m().rows) rect.setHeight(src.m().rows - rect.y());

dst = Mat(src, OpenCVUtils::toRect(rect));
}
};

Expand Down
37 changes: 37 additions & 0 deletions openbr/plugins/imgproc/scalemat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright 2015 Rank One Computing
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <opencv2/imgproc/imgproc.hpp>

#include <openbr/plugins/openbr_internal.h>

using namespace cv;

namespace br
{

/*!
* \ingroup transforms
* \brief Scales the mat values by provided factor
* \author Brendan Klare \cite bklare
*/
class ScaleMatTransform : public UntrainableTransform
{
Q_OBJECT

Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false)
BR_PROPERTY(float, scaleFactor, 1.)

void project(const Template &src, Template &dst) const
{
dst = src * scaleFactor;
}
};

BR_REGISTER(Transform, ScaleMatTransform)

} // namespace br

#include "imgproc/scalemat.moc"
17 changes: 17 additions & 0 deletions scripts/BTASTutorial/representation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [ ! -f meds.mask ]; then
br -makeMask ../../data/MEDS/sigset/MEDS_frontal_target.xml ../../data/MEDS/sigset/MEDS_frontal_query.xml meds.mask
fi

PIXEL_ALG="Open+Cvt(Gray)+Cascade+ASEFEyes+Affine(88,88,0.25,0.35)+Blur(1)+Cat+Normalize(L2):Dist(L2)"
LBP_ALG="Open+Cvt(Gray)+Cascade+ASEFEyes+Affine(88,88,0.25,0.35)+Blur(1)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59)+Normalize(L1)+Cat+Normalize(L2):Dist(L2)"
ALG="Open+Cvt(Gray)+Cascade+ASEFEyes+Affine(88,88,0.25,0.35)+Blur(1)+LBP(1,2)+RectRegions(8,8,6,6)+Hist(59)+Normalize(L1)+Cat+LDA(0.95)+Normalize(L2):Dist(L2)"

br -path $DATA/MEDS -algorithm "${PIXEL_ALG}" -compare ../../data/MEDS/sigset/MEDS_frontal_target.xml ../../data/MEDS/sigset/MEDS_frontal_query.xml meds.mtx -eval meds.mtx meds.mask Algorithm_Dataset/pixels_MEDS.csv
br -path $DATA/MEDS -algorithm "${ALG}" -compare ../../data/MEDS/sigset/MEDS_frontal_target.xml ../../data/MEDS/sigset/MEDS_frontal_query.xml meds.mtx -eval meds.mtx meds.mask Algorithm_Dataset/LBP_MEDS.csv

br -path $DATA/LFW-original -algorithm "${ALG}" -train ../../data/LFW/sigset/LFW.xml representLDA.model
br -path $DATA/MEDS -algorithm representLDA.model -compare ../../data/MEDS/sigset/MEDS_frontal_target.xml ../../data/MEDS/sigset/MEDS_frontal_query.xml meds.mtx -eval meds.mtx meds.mask Algorithm_Dataset/LDA_MEDS.csv

br -plot Algorithm_Dataset/* btasResults.pdf
27 changes: 27 additions & 0 deletions scripts/evalFaceRecognition-BLUFR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#input algorithm string as argument
ALGORITHM=$1

if [ ! -f evalFaceRecognition-BLUFR.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/docs/install/index.html"
exit
fi

# Get the data
./downloadDatasets.sh

if [ ! -e Algorithm_Split ]; then
mkdir Algorithm_Split
fi

for i in `seq 1 10`; do
br -algorithm ${ALGORITHM} -path ../data/LFW/img -train ../data/LFW/sigset/BLUFR/split${i}/train${i}.xml -compare ../data/LFW/sigset/BLUFR/split${i}/gallery${i}.xml ../data/LFW/sigset/BLUFR/split${i}/probe${i}.xml Algorithm_Split/newAlgorithm_BLUFR${i}.eval
done

br -plot Algorithm_Split/* BLUFR.pdf[smooth=Split]
2 changes: 1 addition & 1 deletion share/openbr/plotting/plot_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ plotTable <- function(tableData=NULL, name=NULL, labels=NULL) {
input = tableData$Y
}
mat <- matrix(input, nrow=length(labels), ncol=length(algs), byrow=FALSE)
colnames(mat) <- algs
colnames(mat) <- algs[order(tolower(algs))]
rownames(mat) <- labels
table <- as.table(mat)
if (csv) {
Expand Down

0 comments on commit ccb5845

Please sign in to comment.