gitmyhub

pigo

Go ★ 4.7k updated 1y ago

Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go.

Pigo is a Go library for detecting faces in images. Given a photo, it can locate faces, find where the pupils and eyes are, and identify specific points on facial features like the corners of the mouth or the bridge of the nose. It works as both an importable library for Go programs and as a standalone command-line tool.

The project exists because most face detection tools available for Go are wrappers around C or C++ libraries such as OpenCV. Using those wrappers requires installing those external libraries, which can be complicated, and the process of crossing from Go code into C code adds latency. Pigo is written entirely in Go with no external dependencies, so it installs with a single command and runs without any additional setup.

The detection method is based on a published research technique called Pixel Intensity Comparison-based Object detection, which compares brightness values across small regions of an image to classify whether a region contains a face. This approach does not require the image to be preprocessed or converted into special data structures before analysis. The library can also detect faces that are tilted or rotated within the image plane by accepting an angle parameter.

Pupil and eye localization was added in version 1.2.0, based on a separate published method for finding eye positions. Facial landmark detection, added in version 1.3.0, identifies specific points across the face using another academic technique. Both capabilities work on still images and can run in real time when paired with a video source.

The library can be compiled to WebAssembly, which lets it run directly in a web browser without a server. Pre-built binaries are available for users who do not want to install Go. Command-line flags control minimum and maximum face sizes, the marker shape drawn around detected faces, a threshold for merging overlapping detections, and optional JSON output of detection coordinates.