This project implements a face recognition system using Java and OpenCV. The application captures video from a webcam and detects faces in real time.
Check out the video in /static folder for a demo of the application.
- Java Development Kit (JDK): Make sure you have JDK 11 or higher installed.
- Apache Maven: Used for project management and dependencies.
- OpenCV: Ensure you have OpenCV installed and the Java bindings are set up.
-
Clone the Repository:
git clone https://github.com/Raccoon254/java-opencv-face-recognition-authentication.git FaceRecognition cd FaceRecognition
-
Install Dependencies: The project uses Maven to manage dependencies. You can download the required libraries by running:
mvn clean package
-
Configure OpenCV:
- Download OpenCV from the official OpenCV website.
- Extract the OpenCV package.
- Set the
java.library.path
to the OpenCV Java libraries directory when running the application.
-
Compile and Package: After installing dependencies, ensure the project builds successfully:
mvn clean package
-
Run the Application: Use the following command to run the application:
java -Djava.library.path=C:\OPENCV\opencv\build\java\x64 -cp target/JavaFaceRecognition-1.0-SNAPSHOT-shaded.jar org.raccoon.Main
Replace
C:\OPENCV\opencv\build\java\x64
with the path to your OpenCV Java libraries.
face.xml
: This is the Haar Cascade classifier file used for face detection. It is loaded dynamically at runtime.src/main/java/org/raccoon/Main.java
: The main class containing the application logic.pom.xml
: Maven configuration file that defines dependencies and build settings.
- If you encounter issues with loading
face.xml
, ensure that the file is included in thesrc/main/resources
directory. - Make sure your camera is accessible and not used by another application.