Skip to main content

CAPA - Craniofacial Analysis & Prediction Architecture SDK

Project description

CAPA SDK

Craniofacial Analysis & Prediction Architecture

A Python SDK for advanced craniofacial analysis based on 15+ peer-reviewed scientific papers.

Features

  • WD Analysis: Bizygomatic width measurement and classification
  • Forehead Analysis: Frontal inclination angle measurement
  • Morphology Analysis: Face shape classification and facial proportions
  • Neoclassical Canons: Classical facial proportion analysis
  • Multi-Angle Support: Combine results from multiple images
  • Quality Control: Adaptive quality assessment and validation

Installation

pip install capa-sdk

Or install from source:

git clone https://github.com/yarel2l/capa-sdk.git
cd capa-sdk
pip install -e .

Dependencies

  • Python 3.9+
  • OpenCV
  • dlib
  • MediaPipe
  • face-recognition
  • scikit-learn
  • scipy
  • numpy
  • Pillow
  • matplotlib

Required Model File

Download the dlib 68-point facial landmark model:

wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2

Quick Start

from capa import CoreAnalyzer

# Initialize analyzer
analyzer = CoreAnalyzer()

# Analyze an image
result = analyzer.analyze_image("photo.jpg")

# Access results
if result.wd_result:
    print(f"WD Value: {result.wd_result.wd_value:.3f}")
    print(f"Classification: {result.wd_result.primary_classification.value}")

if result.forehead_result:
    print(f"Forehead Angle: {result.forehead_result.forehead_geometry.slant_angle_degrees:.1f}")

if result.morphology_result:
    print(f"Face Shape: {result.morphology_result.shape_classification.primary_shape.value}")

# Always shutdown when done
analyzer.shutdown()

Analysis Modes

from capa import CoreAnalyzer, AnalysisConfiguration, AnalysisMode

config = AnalysisConfiguration(
    mode=AnalysisMode.STANDARD,  # FAST, STANDARD, THOROUGH, SCIENTIFIC
    enable_wd_analysis=True,
    enable_forehead_analysis=True,
    enable_morphology_analysis=True,
)

analyzer = CoreAnalyzer(config=config)

Multi-Angle Analysis

from capa import MultiAngleAnalyzer, AngleSpecification

analyzer = MultiAngleAnalyzer()

angle_specs = [
    AngleSpecification(angle_type='frontal', image_path='front.jpg'),
    AngleSpecification(angle_type='profile', image_path='side.jpg'),
]

result = analyzer.analyze_multiple_angles(
    angle_specs=angle_specs,
    subject_id="subject_001"
)

print(f"Combined Confidence: {result.combined_confidence*100:.1f}%")
analyzer.shutdown()

Using Individual Modules

from capa.modules import WDAnalyzer, ForeheadAnalyzer, MorphologyAnalyzer
import cv2

image = cv2.imread("photo.jpg")

# WD Analysis only
wd_analyzer = WDAnalyzer()
wd_result = wd_analyzer.analyze(image)

# Forehead Analysis only
forehead_analyzer = ForeheadAnalyzer()
forehead_result = forehead_analyzer.analyze(image)

# Morphology Analysis only
morphology_analyzer = MorphologyAnalyzer()
morphology_result = morphology_analyzer.analyze(image)

Scientific Foundation

CAPA is built on 15+ peer-reviewed scientific papers. All referenced papers are included in the data/ folder for easy access.

WD Analysis (Bizygomatic Width)

Paper Local PDF
Bizygomatic Width and Personality Traits of the Relational Field View PDF
Bizygomatic Width and its Association with Social and Personality Traits in Males View PDF
Association between self-reported impulsiveness and gray matter volume View PDF

Forehead Analysis (Frontal Inclination)

Paper Local PDF
The Slant of the Forehead as a Craniofacial Feature of Impulsiveness View PDF
Correlation between Impulsiveness, Cortical Thickness and Slant of The Forehead View PDF
La impulsividad y su asociacion con la inclinacion de la frente View PDF
Frontonasal dysmorphology in bipolar disorder by 3D laser surface imaging View PDF

Morphology Analysis (Face Shape)

Paper Local PDF
The validity of eight neoclassical facial canons in the Turkish adults View PDF
Evaluation of Face Shape in Turkish Individuals View PDF
Accuracy and precision of a 3D anthropometric facial analysis View PDF
Determinacion del Indice Facial Total y Cono Facial View PDF

Neoclassical Canons

Paper Local PDF
Assessing Facial Beauty of Sabah Ethnic Groups Using Farkas Principles View PDF

Additional Morphology Papers

Paper Local PDF
Morphology Studies View PDF 1 / View PDF 2

External References

  • Farkas, L.G. (1994). Anthropometry of the Head and Face. Raven Press, New York.
  • Gonzalez-Jose, R. et al. (2005). Functional-craniology approach to the influence of economic strategy on skull morphology. American Journal of Physical Anthropology.
  • Kolar, J.C. & Salter, E.M. (1997). Craniofacial Anthropometry: Practical Measurement of the Head and Face for Clinical, Surgical, and Research Use. Charles C Thomas Publisher.

API Reference

Main Classes

Class Description
CoreAnalyzer Main orchestrator for comprehensive analysis
MultiAngleAnalyzer Multi-angle analysis coordinator
ResultsIntegrator Combines results from multiple sources

Scientific Modules

Module Description
WDAnalyzer Bizygomatic width analysis
ForeheadAnalyzer Frontal inclination analysis
MorphologyAnalyzer Face shape classification
NeoclassicalCanonsAnalyzer Classical proportion analysis

Result Types

Type Description
ComprehensiveAnalysisResult Complete analysis result
WDResult WD analysis result
ForeheadResult Forehead analysis result
MorphologyResult Morphology analysis result

Examples

See the examples/ directory for complete usage examples:

  • basic_analysis.py - Simple single-image analysis
  • multi_angle_analysis.py - Multi-angle analysis
  • individual_modules.py - Using modules directly

License

MIT License

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

Disclaimer

This SDK provides measurements and classifications based on peer-reviewed scientific research. Results should be interpreted by qualified professionals and should not be used as the sole basis for any clinical, psychological, or employment decisions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

capa_sdk-1.0.0.tar.gz (154.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capa_sdk-1.0.0-py3-none-any.whl (156.3 kB view details)

Uploaded Python 3

File details

Details for the file capa_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: capa_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 154.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for capa_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b689f5a60e5629f8906be807aab8f0ae56f332b10e659d92a5b50fecbd89bcac
MD5 7bf5b858fc8d506934877e0437818ced
BLAKE2b-256 fc024b5b8f039ba3f4d7a9e99cb2d0094d21ac0d4cf835042037654cc4a4a855

See more details on using hashes here.

File details

Details for the file capa_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: capa_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 156.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for capa_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af89ab4697fd268e7069b6aad9ff29782dafc5fa7a79c86d521e6f3c11fbbfea
MD5 2a1a6871a42b09b241ff7e2ad11ae2b1
BLAKE2b-256 6114edf3c854aac7f1b2adc3f52772ab754993c7aaece6daf9dbf68862c3e669

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page