Skip to content

Shorotshishir/FaceDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Detection

A .NET console application for real-time face and eye detection using OpenCV and machine learning models. This project leverages Haar Cascade classifiers and YuNet ONNX models for accurate facial feature detection.

Features

  • Face Detection: Detect faces in images and video streams using Haar Cascade and YuNet models
  • Eye Detection: Locate eyes within detected faces
  • Multi-Framework Support: Runs on .NET 9.0 and .NET 10.0
  • OpenCV Integration: Uses OpenCvSharp4 for robust computer vision capabilities
  • ONNX Model Support: Includes pre-trained YuNet model for high-accuracy detection

Prerequisites

  • .NET Runtime: .NET 9.0 or .NET 10.0
  • System Requirements:
    • Windows (due to OpenCvSharp4.runtime.win dependency)
    • Minimum 256MB RAM
    • Webcam or image files for processing

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd FaceDetection
  2. Restore dependencies:

    dotnet restore
  3. Build the project:

    dotnet build

Usage

Running the Application

dotnet run --project FaceDetection.csproj

Or if already built:

dotnet FaceDetection.dll

Project Structure

FaceDetection/
├── Program.cs                           # Main application entry point
├── FaceDetection.csproj                 # Project configuration
├── data/
│   ├── haarcascade_frontalface_alt.xml  # Haar Cascade for frontal face detection
│   ├── haarcascade_eye.xml              # Haar Cascade for eye detection
│   └── face_detection_yunet_2023mar.onnx # YuNet ONNX model for face detection
└── README.md                            # This file

Technology Stack

  • Language: C# (.NET 10/9)
  • Computer Vision: OpenCvSharp4 (v4.13.0.20260308)
  • Models:
    • Haar Cascade Classifiers (frontal face & eye detection)
    • YuNet ONNX Model (deep learning-based face detection)
  • Runtime: .NET Runtime for Windows

Dependencies

Package Version
OpenCvSharp4 4.13.0.20260308
OpenCvSharp4.Extensions 4.13.0.20260308
OpenCvSharp4.runtime.win 4.13.0.20260302

Configuration

All data files (XML classifiers and ONNX models) are automatically copied to the output directory during build. Ensure the data/ folder structure is maintained for proper operation.

Performance Notes

  • YuNet ONNX model provides higher accuracy but requires more computational resources
  • Haar Cascade classifiers are faster and suitable for real-time applications
  • Consider frame resizing for video input optimization

Development Roadmap

  • Project setup with OpenCV bindings
  • Import appropriate libraries
  • Find all connected cameras to the machine
  • Show camera data in a Canvas UI
  • Store camera data to disk
  • Store camera frame metadata
  • Switch between multiple cameras
  • Implement multi-face tracking

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Create a feature branch for your changes
  2. Maintain code consistency with the existing codebase
  3. Test thoroughly before submitting
  4. Update documentation as needed

Troubleshooting

Missing Data Files: Ensure the data/ directory and all XML/ONNX files are present in the output directory.

OpenCV Runtime Issues: Verify that OpenCvSharp4.runtime.win is properly installed and compatible with your system.

Performance Issues: Consider reducing image resolution or adjusting detection parameters for better performance.

References

About

A face detection application in dotnet

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages