Home

This is a Julia implementation of Viola-Jones' Object Detection algorithm. Although there is an OpenCV port in Julia, it seems to be ill-maintained. As this algorithm was created for commercial use, there seem to be few widely-used or well-documented implementations of it on GitHub. The implementation this repository is based off is Simon Hohberg's Pythonic repository, as it seems to be well written (and the most starred Python implementation on GitHub, though this is not necessarily a good measure). Julia and Python alike are easy to read and write in — my thinking was that this would be easy enough to replicate in Julia, except for Pythonic classes, where I would have to use structs (or at least easier to replicate from than, for example, C++ or JS — two other highly-starred repositories.).

Important Note

I implore collaboration. I am an undergraduate student with no formal education in computer science (or computer vision of any form for that matter); I am certain this code can be refined/optimised by better programmers than myself. This package is still maturing, and as such there are some things I would still like to implement. Please, help me out if you like!

How it works

In an over-simplified manner, the Viola-Jones algorithm has some four stages:

  1. Takes an image, converts it into an array of intensity values (i.e., in grey-scale), and constructs an Integral Image, such that for every element in the array, the Integral Image element is the sum of all elements above and to the left of it. This makes calculations easier for step 2.
  2. Finds Haar-like Features from Integral Image.
  3. There is now a training phase using sets of faces and non-faces. This phase uses something called Adaboost (short for Adaptive Boosting). Boosting is one method of Ensemble Learning. There are other Ensemble Learning methods like Bagging, Stacking, &c.. The differences between Bagging, Boosting, Stacking are:
    • Bagging uses equal weight voting. Trains each model with a random drawn subset of training set.
    • Boosting trains each new model instance to emphasize the training instances that previous models mis-classified. Has better accuracy comparing to bagging, but also tends to overfit.
    • Stacking trains a learning algorithm to combine the predictions of several other learning algorithms.

Despite this method being developed at the start of the century, it is blazingly fast compared to some machine learning algorithms, and still widely used.

  1. Finally, this algorithm uses Cascading Classifiers to identify faces. (See page 12 of the original paper for the specific cascade).

For a better explanation, read the paper from 2001, or see the Wikipedia page on this algorithm.

Adding FaceDetection.jl

julia> using Pkg
julia> Pkg.add("FaceDetection") Updating registry at `~/.julia/registries/General.toml` Resolving package versions... Installed TiledIteration ───────── v0.3.1 Installed Xorg_libXcomposite_jll ─ v0.4.5+4 Installed GTK3_jll ─────────────── v3.24.31+0 Installed at_spi2_core_jll ─────── v2.34.0+4 Installed EllipsisNotation ─────── v1.8.0 Installed GtkReactive ──────────── v1.0.6 Installed Gtk ──────────────────── v1.3.0 Installed adwaita_icon_theme_jll ─ v3.33.93+0 Installed Xorg_libXtst_jll ─────── v1.2.3+4 Installed libpng_jll ───────────── v1.6.44+0 Installed at_spi2_atk_jll ──────── v2.34.1+4 Installed StatsBase ────────────── v0.33.21 Installed Dbus_jll ─────────────── v1.14.10+0 Installed Images ───────────────── v0.25.3 Installed ATK_jll ──────────────── v2.38.0+0 Installed AxisAlgorithms ───────── v1.0.1 Installed Reactive ─────────────── v0.8.3 Installed IntervalSets ─────────── v0.5.4 Installed ImageMorphology ──────── v0.3.2 Installed WoodburyMatrices ─────── v0.5.6 Installed ImageTransformations ─── v0.9.5 Installed Interpolations ───────── v0.14.0 Installed ImageView ────────────── v0.10.15 Installed FaceDetection ────────── v1.1.0 Updating `~/work/FaceDetection.jl/FaceDetection.jl/docs/Project.toml` [00808967] ~ FaceDetection v1.2.0 `~/work/FaceDetection.jl/FaceDetection.jl` ⇒ v1.1.0 Updating `~/work/FaceDetection.jl/FaceDetection.jl/docs/Manifest.toml` ⌃ [13072b0f] ↓ AxisAlgorithms v1.1.0 ⇒ v1.0.1 [d1d4a3ce] - BitFlags v0.1.9 [62783981] - BitTwiddlingConvenienceFunctions v0.1.6 [2a0fbf3d] - CPUSummary v0.2.6 [fb6a15b2] - CloseOpenIntervals v0.1.13 [187b0558] - ConstructionBase v1.5.8 [adafc99b] - CpuId v0.3.1 [da5c29d0] + EllipsisNotation v1.8.0 [00808967] ~ FaceDetection v1.2.0 `~/work/FaceDetection.jl/FaceDetection.jl` ⇒ v1.1.0 [4c0ca9eb] + Gtk v1.3.0 [9db2cae5] - Gtk4 v0.7.0 [8710efd8] - GtkObservables v2.1.3 [27996c0f] + GtkReactive v1.0.6 [2c695a8d] - HistogramThresholding v0.3.1 [3e5b6fbb] - HostCPUFeatures v0.1.17 [cbc4b850] - ImageBinarization v0.3.1 [89d5987c] - ImageCorners v0.1.3 ⌅ [787d08f9] ↓ ImageMorphology v0.4.5 ⇒ v0.3.2 ⌅ [02fcd773] ↓ ImageTransformations v0.10.1 ⇒ v0.9.5 ⌅ [86fae568] ↓ ImageView v0.12.6 ⇒ v0.10.15 ⌅ [916415d5] ↓ Images v0.26.1 ⇒ v0.25.3 ⌅ [a98d9a8b] ↓ Interpolations v0.15.1 ⇒ v0.14.0 ⌅ [8197267c] ↓ IntervalSets v0.7.10 ⇒ v0.5.4 [10f19ff3] - LayoutPointers v0.1.17 [bdcacae8] - LoopVectorization v0.12.171 [d125e4d3] - ManualMemory v0.1.8 [d4071afc] - MultiChannelColors v0.1.3 [510215fc] - Observables v0.5.5 [1d0040c9] - PolyesterWeave v0.2.2 [f27b6e38] - Polynomials v4.0.11 [a223df75] + Reactive v0.8.3 [3cdcf5f2] - RecipesBase v1.3.4 [94e857df] - SIMDTypes v0.1.0 [476501e8] - SLEEFPirates v0.6.43 [efcf1570] - Setfield v1.1.1 ⌅ [2913bbd2] ↓ StatsBase v0.34.3 ⇒ v0.33.21 [8290d209] - ThreadingUtilities v0.5.2 ⌅ [06e1c1a7] ↓ TiledIteration v0.5.0 ⇒ v0.3.1 [3d5dd08c] - VectorizationBase v0.21.71 ⌅ [efce3f68] ↓ WoodburyMatrices v1.0.0 ⇒ v0.5.6 [7b86fcea] + ATK_jll v2.38.0+0 [ee1fde0b] + Dbus_jll v1.14.10+0 [77ec8976] + GTK3_jll v3.24.31+0 [6ebb71f1] - GTK4_jll v4.14.5+0 [75302f13] - Graphene_jll v1.10.6+0 [3c9796d7] + Xorg_libXcomposite_jll v0.4.5+4 [b6f176f1] + Xorg_libXtst_jll v1.2.3+4 ⌅ [b437f822] ↓ adwaita_icon_theme_jll v43.0.1+0 ⇒ v3.33.93+0 [de012916] + at_spi2_atk_jll v2.34.1+4 [0fc3237b] + at_spi2_core_jll v2.34.0+4 [b53b4c65] ↑ libpng_jll v1.6.40+0 ⇒ v1.6.44+0 [9fa8497b] - Future v1.11.0 Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` Precompiling project... 1050.8 ms ✓ TiledIteration 1203.7 ms ✓ Dbus_jll 1354.8 ms ✓ WoodburyMatrices 1285.6 ms ✓ libpng_jll 1522.9 ms ✓ Reactive 1277.5 ms ✓ adwaita_icon_theme_jll 1244.6 ms ✓ ATK_jll 1398.1 ms ✓ Xorg_libXtst_jll 1177.8 ms ✓ Xorg_libXcomposite_jll 924.1 ms ✓ EllipsisNotation 1213.9 ms ✓ AxisAlgorithms 1402.4 ms ✓ libsixel_jll 3580.0 ms ✓ StatsBase 1355.3 ms ✓ OpenJpeg_jll 1494.7 ms ✓ gdk_pixbuf_jll 1311.3 ms ✓ Cairo_jll 3035.7 ms ✓ ImageMorphology 1331.1 ms ✓ at_spi2_core_jll 1385.7 ms ✓ IntervalSets 1361.1 ms ✓ ImageMagick_jll 1507.0 ms ✓ HarfBuzz_jll 3124.9 ms ✓ Interpolations 1527.1 ms ✓ at_spi2_atk_jll 1521.3 ms ✓ Pango_jll 5442.5 ms ✓ Sixel 1554.1 ms ✓ Librsvg_jll 8432.8 ms ✓ PNGFiles 4112.0 ms ✓ ImageTransformations 1680.9 ms ✓ GTK3_jll 2464.6 ms ✓ Cairo 6710.3 ms ✓ ImageMagick 11688.0 ms ✓ Gtk ✗ GtkReactive ✗ ImageView 96805.0 ms ✓ Images 3212.1 ms ✓ FaceDetection 34 dependencies successfully precompiled in 116 seconds. 223 already precompiled. 10 dependencies precompiled but different versions are currently loaded. Restart julia to access the new versions 1 dependency had output during precompilation: ┌ Interpolations │ WARNING: method definition for checkbounds at /home/runner/.julia/packages/Interpolations/USkTk/src/Interpolations.jl:454 declares type variable N but does not use it. │ WARNING: method definition for checkbounds at /home/runner/.julia/packages/Interpolations/USkTk/src/Interpolations.jl:457 declares type variable N but does not use it. │ WARNING: method definition for GriddedInterpolation at /home/runner/.julia/packages/Interpolations/USkTk/src/gridded/gridded.jl:37 declares type variable pad but does not use it. │ WARNING: method definition for GriddedInterpolation at /home/runner/.julia/packages/Interpolations/USkTk/src/gridded/gridded.jl:60 declares type variable pad but does not use it. │ WARNING: method definition for interpolate! at /home/runner/.julia/packages/Interpolations/USkTk/src/deprecations.jl:30 declares type variable TWeights but does not use it. └

Index