Usage
FaceDetection.HaarLikeObject — Typemutable struct HaarLikeObject{I <: Integer, F <: AbstractFloat}
Struct representing a Haar-like feature.
feature_type::Tuple{I, I}
position::Tuple{I, I}
top_left::Tuple{I, I}
bottom_right::Tuple{I, I}
width::I
height::I
threshold::I
polarity::I
weight::FFaceDetection.HaarLikeObject — MethodHaarLikeObject(
feature_type::Tuple{Integer, Integer},
position::Tuple{Integer, Integer},
width::Integer,
height::Integer,
threshold::Integer,
polarity::Integer
) -> HaarLikeObjectFaceDetection.create_features — Methodcreate_features(
img_height::Int, img_width::Int,
min_feature_width::Int,
max_feature_width::Int,
min_feature_height::Int,
max_feature_height::Int
) -> Array{HaarLikeObject, 1}Iteratively creates the Haar-like feautures
Arguments
img_height::Integer: The height of the imageimg_width::Integer: The width of the imagemin_feature_width::Integer: The minimum width of the feature (used for computation efficiency purposes)max_feature_width::Integer: The maximum width of the featuremin_feature_height::Integer: The minimum height of the featuremax_feature_height::Integer: The maximum height of the feature
Returns
features::AbstractArray: an array of Haar-like features found for an image
FaceDetection.determine_feature_size — Methoddetermine_feature_size(
pictures::Vector{String}
) -> Tuple{Integer, Integer, Integer, Integer, Tuple{Integer, Integer}}
determine_feature_size(
pos_training_path::String,
neg_training_path::String
) -> Tuple{Integer, Integer, Integer, Integer, Tuple{Integer, Integer}}Takes images and finds the best feature size for the image size.
Arguments
pictures::Vector{String}: a list of paths to the images
OR
pos_training_path::String: the path to the positive training imagesneg_training_path::String: the path to the negative training images
Returns
max_feature_width::Integer: the maximum width of the featuremax_feature_height::Integer: the maximum height of the featuremin_feature_height::Integer: the minimum height of the featuremin_feature_width::Integer: the minimum width of the featuremin_size_img::Tuple{Integer, Integer}: the minimum-sized image in the image directories
FaceDetection.ensemble_vote — Methodensemble_vote(int_img::IntegralArray, classifiers::AbstractArray) -> IntegerClassifies given integral image (IntegralArray) using given classifiers. I.e., if the sum of all classifier votes is greater 0, the image is classified positively (1); else it is classified negatively (0). The threshold is 0, because votes can be +1 or -1.
That is, the final strong classifier is
\[h(x) = \begin{cases} 1&\text{if }\sum_{t=1}^{T}\alpha_{th_{t(x)}}\geq\frac{1}{2}\sum_{t=1}^{T}\alpha_t\\ 0&\text{otherwise} \end{cases} \text{ where }\alpha_t = \log{\left(\frac{1}{\beta_t}\right)}\]
Arguments
int_img::IntegralArray{T, N}: Integral image to be classifiedclassifiers::Vector{HaarLikeObject}: List of classifiers
Returns
vote::Int81 ⟺ sum of classifier votes > 0 0 otherwise
FaceDetection.ensemble_vote_all — Methodensemble_vote_all(images::Vector{String}, classifiers::Vector{HaarLikeObject}) -> Vector{Int8}
ensemble_vote_all(image_path::String, classifiers::Vector{HaarLikeObject}) -> Vector{Int8}Given a path to images, loads images then classifies votes using given classifiers. I.e., if the sum of all classifier votes is greater 0, the image is classified positively (1); else it is classified negatively (0). The threshold is 0, because votes can be +1 or -1.
Arguments
images::Vector{String}: list of paths to images; ORimage_path::String: Path to images dirclassifiers::Vector{HaarLikeObject}: List of classifiers
Returns
votes::Vector{Int8}: A list of assigned votes (see ensemble_vote).
FaceDetection.get_faceness — Methodget_faceness(feature::HaarLikeObject{I, F}, int_img::IntegralArray{T, N}) -> NumberGet facelikeness for a given feature.
Arguments
feature::HaarLikeObject: given Haar-like feature (parameterised replacement of Python'sself)int_img::IntegralArray: Integral image array
Returns
score::Number: Score for given feature
FaceDetection.get_score — Methodget_score(feature::HaarLikeObject, int_img::AbstractArray) -> Tuple{Number, Number}Get score for given integral image array. This is the feature cascade.
Arguments
feature::HaarLikeObject: given Haar-like feature (parameterised replacement of Python'sself)int_img::AbstractArray: Integral image array
Returns
score::Number: Score for given feature
FaceDetection.get_vote — Methodget_vote(feature::HaarLikeObject, int_img::IntegralArray) -> IntegerGet vote of this feature for given integral image.
Arguments
feature::HaarLikeObject: given Haar-like featureint_img::IntegralArray: Integral image array
Returns
vote::Integer: 1 ⟺ this feature votes positively -1 otherwise
FaceDetection.load_image — Methodload_image(image_path::String) -> Array{Float64, N}Loads an image as gray_scale
Arguments
image_path::String: Path to an image
Returns
IntegralArray{Float64, N}: An array of floating point values representing the image
FaceDetection.sum_region — Methodsum_region(
integral_image_arr::AbstractArray,
top_left::Tuple{Int,Int},
bottom_right::Tuple{Int,Int}
) -> NumberArguments
iA::IntegralArray{T, N}: The intermediate Integral Imagetop_left::NTuple{N, Int}: coordinates of the rectangle's top left cornerbottom_right::NTuple{N, Int}: coordinates of the rectangle's bottom right corner
Returns
sum::TThe sum of all pixels in the given rectangle defined by the parameterstop_leftandbottom_right