Usage

Main.FaceDetection.HaarLikeObjectType
mutable 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::F
Main.FaceDetection.HaarLikeObjectMethod
HaarLikeObject(
    feature_type::Tuple{Integer, Integer},
    position::Tuple{Integer, Integer},
    width::Integer,
    height::Integer,
    threshold::Integer,
    polarity::Integer
) -> HaarLikeObject
Main.FaceDetection.create_featuresMethod
create_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 image
  • img_width::Integer: The width of the image
  • min_feature_width::Integer: The minimum width of the feature (used for computation efficiency purposes)
  • max_feature_width::Integer: The maximum width of the feature
  • min_feature_height::Integer: The minimum height of the feature
  • max_feature_height::Integer: The maximum height of the feature

Returns

  • features::AbstractArray: an array of Haar-like features found for an image
Main.FaceDetection.determine_feature_sizeMethod
determine_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 images
  • neg_training_path::String: the path to the negative training images

Returns

  • max_feature_width::Integer: the maximum width of the feature
  • max_feature_height::Integer: the maximum height of the feature
  • min_feature_height::Integer: the minimum height of the feature
  • min_feature_width::Integer: the minimum width of the feature
  • min_size_img::Tuple{Integer, Integer}: the minimum-sized image in the image directories
Main.FaceDetection.ensemble_voteMethod
ensemble_vote(int_img::IntegralArray, classifiers::AbstractArray) -> Integer

Classifies 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 classified
  • classifiers::Vector{HaarLikeObject}: List of classifiers

Returns

  • vote::Int8 1 ⟺ sum of classifier votes > 0 0 otherwise
Main.FaceDetection.ensemble_vote_allMethod
ensemble_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; OR image_path::String: Path to images dir
  • classifiers::Vector{HaarLikeObject}: List of classifiers

Returns

votes::Vector{Int8}: A list of assigned votes (see ensemble_vote).

Main.FaceDetection.get_facenessMethod
get_faceness(feature::HaarLikeObject{I, F}, int_img::IntegralArray{T, N}) -> Number

Get facelikeness for a given feature.

Arguments

  • feature::HaarLikeObject: given Haar-like feature (parameterised replacement of Python's self)
  • int_img::IntegralArray: Integral image array

Returns

  • score::Number: Score for given feature
Main.FaceDetection.get_scoreMethod
get_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's self)
  • int_img::AbstractArray: Integral image array

Returns

  • score::Number: Score for given feature
Main.FaceDetection.get_voteMethod
get_vote(feature::HaarLikeObject, int_img::IntegralArray) -> Integer

Get vote of this feature for given integral image.

Arguments

  • feature::HaarLikeObject: given Haar-like feature
  • int_img::IntegralArray: Integral image array

Returns

  • vote::Integer: 1 ⟺ this feature votes positively -1 otherwise
Main.FaceDetection.load_imageMethod
load_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
Main.FaceDetection.sum_regionMethod
sum_region(
	integral_image_arr::AbstractArray,
	top_left::Tuple{Int,Int},
	bottom_right::Tuple{Int,Int}
) -> Number

Arguments

  • iA::IntegralArray{T, N}: The intermediate Integral Image
  • top_left::NTuple{N, Int}: coordinates of the rectangle's top left corner
  • bottom_right::NTuple{N, Int}: coordinates of the rectangle's bottom right corner

Returns

  • sum::T The sum of all pixels in the given rectangle defined by the parameters top_left and bottom_right