Commit 4dc9416defb5bf3cde50339040a408bce51b1b8b
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
2 changed files
with
21 additions
and
17 deletions
openbr/plugins/core/likely.cpp
| ... | ... | @@ -11,7 +11,8 @@ namespace br |
| 11 | 11 | * \ingroup transforms |
| 12 | 12 | * \brief Generic interface to Likely JIT compiler |
| 13 | 13 | * |
| 14 | - * www.liblikely.org | |
| 14 | + * - [Homepage](www.liblikely.org) | |
| 15 | + * - [API Documentation](https://s3.amazonaws.com/liblikely/doxygen/index.html) | |
| 15 | 16 | * \author Josh Klontz \cite jklontz |
| 16 | 17 | */ |
| 17 | 18 | class LikelyTransform : public Transform | ... | ... |
share/openbr/likely/face_recognition.tex
| ... | ... | @@ -21,6 +21,7 @@ As Likely is a literate programming language, this document is both the source c |
| 21 | 21 | \end{abstract} |
| 22 | 22 | |
| 23 | 23 | \section{Compilation} |
| 24 | +\label{sec:compilation} | |
| 24 | 25 | This document is a valid \LaTeX\ file that can be rendered for reading by humans. |
| 25 | 26 | |
| 26 | 27 | \begin{verbatim} |
| ... | ... | @@ -34,9 +35,10 @@ $ likely -p 'data := "path/to/training/data.lm".read-matrix' \ |
| 34 | 35 | face_recognition.tex face_recognition.o |
| 35 | 36 | \end{verbatim} |
| 36 | 37 | |
| 37 | -Note that the outputted \emph{face\_recognition.o} native object file exposes its functionality through a C-compatible signature. | |
| 38 | +Note that the outputted \texttt{face\_recognition.o} native object file exposes its functionality through a C-compatible signature. | |
| 38 | 39 | |
| 39 | 40 | \begin{verbatim} |
| 41 | +#include <likely.h> | |
| 40 | 42 | likely_mat face_recognition(likely_const_mat src); |
| 41 | 43 | \end{verbatim} |
| 42 | 44 | |
| ... | ... | @@ -50,10 +52,12 @@ face-recognition := |
| 50 | 52 | \end{likely} |
| 51 | 53 | |
| 52 | 54 | Throughout the remainder of this document we will append additional steps to this function, building up the entire algorithm one transformation at a time. |
| 53 | -It is the responsibility of each section in this document to update the \emph{face-recognition} function and the training data. | |
| 54 | -In this way the sections maintain independence, and the algorithm can be changed by inserting, removing, or editing sections of this document. | |
| 55 | +It is the responsibility of each section in this document to update the \texttt{face-recognition} function and the training \texttt{data}. | |
| 56 | +It is in this way that the sections maintain independence, and the algorithm can be changed by inserting, removing, or editing sections of this document. | |
| 57 | +Remember that the \emph{Likely Language Reference}\footnote{https://s3.amazonaws.com/liblikely/latex/standard.pdf} is a good resource to consult if you are uncertain about the meaning of some code. | |
| 55 | 58 | |
| 56 | -Note that the remainder of this document assumes that the global variable \emph{data} is defined, and contains the appropriate training samples. | |
| 59 | +Note that the remainder of this document assumes that the global variable | |
| 60 | +\texttt{data} is defined, and contains the appropriate training samples. | |
| 57 | 61 | |
| 58 | 62 | \begin{likely} |
| 59 | 63 | "Number of training samples:" |
| ... | ... | @@ -73,19 +77,18 @@ Such a normalization has been observed to improve accuracy when comparing featur |
| 73 | 77 | normalize-l2 := |
| 74 | 78 | src :-> |
| 75 | 79 | { |
| 76 | - norm := (new f32T src.channels 1 src.rows src.frames null) | |
| 77 | - (norm src) :=> | |
| 80 | + dst := src.imitate | |
| 81 | + len := src.columns | |
| 82 | + ((src.channels 1 src.rows src.frames) | |
| 83 | + dst src len) :=> | |
| 78 | 84 | { |
| 79 | - add-squared-element := | |
| 80 | - x :-> | |
| 81 | - norm :<- (+ norm src.f32.sq) | |
| 82 | - (iter add-squared-element src.columns) | |
| 83 | - norm :<- (/ 1 (sqrt norm)) | |
| 85 | + norm := 0.(cast src).$ | |
| 86 | + (iter (-> x (<- norm (+ norm src.sq))) | |
| 87 | + len) | |
| 88 | + norm := (/ 1 (sqrt norm)) | |
| 89 | + (iter (-> x (<- dst (* src norm))) | |
| 90 | + len) | |
| 84 | 91 | } |
| 85 | - | |
| 86 | - dst := src.imitate | |
| 87 | - (dst src norm) :=> | |
| 88 | - dst :<- (* src norm) | |
| 89 | 92 | } |
| 90 | 93 | \end{likely} |
| 91 | 94 | |
| ... | ... | @@ -149,7 +152,7 @@ data.columns |
| 149 | 152 | \end{likely} |
| 150 | 153 | |
| 151 | 154 | \section{Entry Point} |
| 152 | -The entry point to the outside world is a single C function \texttt{face\_recognition} that takes as input a \texttt{likely\_mat} (the input image) and outputs a new \texttt{likely\_mat} (the feature vector). | |
| 155 | +Recall from section \ref{sec:compilation} that the entry point to the outside world is a single C function \texttt{face\_recognition} that takes as input a \texttt{likely\_mat} (the input image) and outputs a new \texttt{likely\_mat} (the feature vector). Now that we have finished defining \texttt{face-recognition} we can finally export this symbol. | |
| 153 | 156 | |
| 154 | 157 | \begin{likely} |
| 155 | 158 | (extern u8X "face_recognition" f32X face-recognition) | ... | ... |