├── .gitignore ├── _config.yml ├── exo.png ├── logo.png ├── src ├── g.png ├── Stop.png ├── aa.png ├── exo.png ├── eye.png ├── face.png ├── logo.png ├── onon.png ├── sc.PNG ├── camera.png ├── images.jpg ├── motion.png ├── smile.jpg ├── square.png ├── appLayout.png ├── fullbody.jpg ├── fullbody.png ├── gesture.png ├── scanner.png ├── recognition.png ├── user-male-icon.png ├── face-head-logos-design-003.png ├── styles.css └── application │ ├── Main.java │ ├── OCR.java │ ├── MotionDetector.java │ ├── FaceRecognizer.java │ ├── application.css │ ├── Database.java │ ├── ColoredObjectTracker.java │ ├── FaceDetectionController.java │ ├── SquareDetector.java │ ├── SampleController.java │ ├── Sample.fxml │ └── FaceDetector.java ├── ocr_test.png ├── opencv-341.jar ├── bin ├── opencv-341.jar └── application │ ├── Main.class │ ├── logo │ └── logo.png │ ├── application.css │ ├── SampleController.class │ └── Sample.fxml ├── target └── classes │ ├── aa.png │ ├── exo.png │ ├── eye.png │ ├── g.png │ ├── Stop.png │ ├── face.png │ ├── logo.png │ ├── onon.png │ ├── smile.jpg │ ├── camera.png │ ├── fullbody.jpg │ ├── fullbody.png │ ├── gesture.png │ ├── images.jpg │ ├── motion.png │ ├── scanner.png │ ├── square.png │ ├── recognition.png │ ├── user-male-icon.png │ ├── application │ ├── Main.class │ ├── OCR.class │ ├── Database.class │ ├── FaceDetector.class │ ├── FaceRecognizer.class │ ├── MotionDetector.class │ ├── SquareDetector.class │ ├── FaceRecognizer$1.class │ ├── SampleController.class │ ├── ColoredObjectTracker.class │ ├── FaceDetectionController.class │ ├── FaceDetectionController$1.class │ ├── application.css │ └── Sample.fxml │ ├── face-head-logos-design-003.png │ └── styles.css ├── faces ├── 0-test_face_1.png ├── 0-test_face_2.png ├── 0-test_face_3.png └── 0-test_face_4.png ├── .settings ├── org.eclipse.m2e.core.prefs └── org.eclipse.jdt.core.prefs ├── .project ├── LICENSE ├── .classpath ├── pom.xml ├── face_bio.sql └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker -------------------------------------------------------------------------------- /exo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/exo.png -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/logo.png -------------------------------------------------------------------------------- /src/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/g.png -------------------------------------------------------------------------------- /ocr_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/ocr_test.png -------------------------------------------------------------------------------- /src/Stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/Stop.png -------------------------------------------------------------------------------- /src/aa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/aa.png -------------------------------------------------------------------------------- /src/exo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/exo.png -------------------------------------------------------------------------------- /src/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/eye.png -------------------------------------------------------------------------------- /src/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/face.png -------------------------------------------------------------------------------- /src/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/logo.png -------------------------------------------------------------------------------- /src/onon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/onon.png -------------------------------------------------------------------------------- /src/sc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/sc.PNG -------------------------------------------------------------------------------- /opencv-341.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/opencv-341.jar -------------------------------------------------------------------------------- /src/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/camera.png -------------------------------------------------------------------------------- /src/images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/images.jpg -------------------------------------------------------------------------------- /src/motion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/motion.png -------------------------------------------------------------------------------- /src/smile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/smile.jpg -------------------------------------------------------------------------------- /src/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/square.png -------------------------------------------------------------------------------- /src/appLayout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/appLayout.png -------------------------------------------------------------------------------- /src/fullbody.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/fullbody.jpg -------------------------------------------------------------------------------- /src/fullbody.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/fullbody.png -------------------------------------------------------------------------------- /src/gesture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/gesture.png -------------------------------------------------------------------------------- /src/scanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/scanner.png -------------------------------------------------------------------------------- /bin/opencv-341.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/bin/opencv-341.jar -------------------------------------------------------------------------------- /src/recognition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/recognition.png -------------------------------------------------------------------------------- /src/user-male-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/user-male-icon.png -------------------------------------------------------------------------------- /target/classes/aa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/aa.png -------------------------------------------------------------------------------- /target/classes/exo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/exo.png -------------------------------------------------------------------------------- /target/classes/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/eye.png -------------------------------------------------------------------------------- /target/classes/g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/g.png -------------------------------------------------------------------------------- /faces/0-test_face_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/faces/0-test_face_1.png -------------------------------------------------------------------------------- /faces/0-test_face_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/faces/0-test_face_2.png -------------------------------------------------------------------------------- /faces/0-test_face_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/faces/0-test_face_3.png -------------------------------------------------------------------------------- /faces/0-test_face_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/faces/0-test_face_4.png -------------------------------------------------------------------------------- /target/classes/Stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/Stop.png -------------------------------------------------------------------------------- /target/classes/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/face.png -------------------------------------------------------------------------------- /target/classes/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/logo.png -------------------------------------------------------------------------------- /target/classes/onon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/onon.png -------------------------------------------------------------------------------- /target/classes/smile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/smile.jpg -------------------------------------------------------------------------------- /bin/application/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/bin/application/Main.class -------------------------------------------------------------------------------- /target/classes/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/camera.png -------------------------------------------------------------------------------- /target/classes/fullbody.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/fullbody.jpg -------------------------------------------------------------------------------- /target/classes/fullbody.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/fullbody.png -------------------------------------------------------------------------------- /target/classes/gesture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/gesture.png -------------------------------------------------------------------------------- /target/classes/images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/images.jpg -------------------------------------------------------------------------------- /target/classes/motion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/motion.png -------------------------------------------------------------------------------- /target/classes/scanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/scanner.png -------------------------------------------------------------------------------- /target/classes/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/square.png -------------------------------------------------------------------------------- /bin/application/logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/bin/application/logo/logo.png -------------------------------------------------------------------------------- /target/classes/recognition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/recognition.png -------------------------------------------------------------------------------- /src/face-head-logos-design-003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/src/face-head-logos-design-003.png -------------------------------------------------------------------------------- /target/classes/user-male-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/user-male-icon.png -------------------------------------------------------------------------------- /bin/application/application.css: -------------------------------------------------------------------------------- 1 | /* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ -------------------------------------------------------------------------------- /target/classes/application/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/Main.class -------------------------------------------------------------------------------- /target/classes/application/OCR.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/OCR.class -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /bin/application/SampleController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/bin/application/SampleController.class -------------------------------------------------------------------------------- /target/classes/application/Database.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/Database.class -------------------------------------------------------------------------------- /target/classes/application/FaceDetector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/FaceDetector.class -------------------------------------------------------------------------------- /target/classes/application/FaceRecognizer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/FaceRecognizer.class -------------------------------------------------------------------------------- /target/classes/application/MotionDetector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/MotionDetector.class -------------------------------------------------------------------------------- /target/classes/application/SquareDetector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/SquareDetector.class -------------------------------------------------------------------------------- /target/classes/face-head-logos-design-003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/face-head-logos-design-003.png -------------------------------------------------------------------------------- /target/classes/application/FaceRecognizer$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/FaceRecognizer$1.class -------------------------------------------------------------------------------- /target/classes/application/SampleController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/SampleController.class -------------------------------------------------------------------------------- /target/classes/application/ColoredObjectTracker.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/ColoredObjectTracker.class -------------------------------------------------------------------------------- /target/classes/application/FaceDetectionController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/FaceDetectionController.class -------------------------------------------------------------------------------- /target/classes/application/FaceDetectionController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anupsarkar-dev/ExoVisix/HEAD/target/classes/application/FaceDetectionController$1.class -------------------------------------------------------------------------------- /bin/application/Sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | .aaa 4 | { 5 | 6 | -fx-min-height: 60px; 7 | 8 | -fx-min-width: 90px; 9 | 10 | -fx-background-image: url("logo/onon.png"); 11 | 12 | -fx-background-size: 50px 50px; 13 | 14 | -fx-background-repeat: no-repeat; 15 | 16 | -fx-background-position: center 8px; 17 | } -------------------------------------------------------------------------------- /target/classes/styles.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | .aaa 4 | { 5 | 6 | -fx-min-height: 60px; 7 | 8 | -fx-min-width: 90px; 9 | 10 | -fx-background-image: url("logo/onon.png"); 11 | 12 | -fx-background-size: 50px 50px; 13 | 14 | -fx-background-repeat: no-repeat; 15 | 16 | -fx-background-position: center 8px; 17 | } -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExoVisix 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.xtext.ui.shared.xtextBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.m2e.core.maven2Nature 26 | org.eclipse.xtext.ui.shared.xtextNature 27 | org.eclipse.jdt.core.javanature 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Anup Kumar Sarkar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | BigBong 4 | GhostEyeFX 5 | 0.0.1-SNAPSHOT 6 | 7 | src 8 | 9 | 10 | src 11 | 12 | **/*.java 13 | 14 | 15 | 16 | 17 | 18 | maven-compiler-plugin 19 | 3.5.1 20 | 21 | 1.8 22 | 1.8 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.bytedeco 33 | javacv-platform 34 | 1.3.2 35 | 36 | 37 | mysql 38 | mysql-connector-java 39 | 5.1.14 40 | 41 | 42 | org.bytedeco.javacpp-presets 43 | tesseract-platform 44 | 3.04.01-1.3 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/application/Main.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import javafx.application.Application; 4 | import javafx.stage.Stage; 5 | import javafx.scene.Scene; 6 | import javafx.scene.image.Image; 7 | import javafx.scene.image.ImageView; 8 | import javafx.scene.layout.BorderPane; 9 | import javafx.fxml.FXML; 10 | import javafx.fxml.FXMLLoader; 11 | 12 | // One man's constants is another mans variable. 13 | // Think twice but code once. 14 | // Happy Coding :) 15 | 16 | /******************************************************** 17 | * e x o V i s i x | The GhostEye * 18 | * Anup Kumar Sarkar * 19 | * me.anup.sarkar@gmail.com * 20 | * fb.com/i.am.anup.aronno * 21 | * * 22 | *********************************************************/ 23 | 24 | //Feel Free to communicate 25 | 26 | public class Main extends Application { 27 | 28 | 29 | @Override 30 | public void start(Stage primaryStage) { 31 | try { 32 | BorderPane root = (BorderPane)FXMLLoader.load(getClass().getResource("Sample.fxml")); 33 | Scene scene = new Scene(root,1350,720); 34 | 35 | scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); 36 | primaryStage.getIcons().add(new Image("logo.png")); 37 | primaryStage.setTitle("e x o V i s i x | Smart & Intelligent Computer Vision Solution "); 38 | 39 | primaryStage.setScene(scene); 40 | primaryStage.show(); 41 | } catch(Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | 46 | public static void main(String[] args) { 47 | launch(args); 48 | 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /face_bio.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.2.11 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: Nov 09, 2017 at 05:34 PM 7 | -- Server version: 5.6.21 8 | -- PHP Version: 5.6.3 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8 */; 18 | 19 | -- 20 | -- Database: `ghostEye` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Table structure for table `face_bio` 27 | -- 28 | 29 | CREATE TABLE IF NOT EXISTS `face_bio` ( 30 | `id` int(11) NOT NULL, 31 | `code` int(10) NOT NULL, 32 | `first_name` varchar(30) NOT NULL, 33 | `last_name` varchar(20) NOT NULL, 34 | `reg` int(10) NOT NULL, 35 | `age` int(10) NOT NULL, 36 | `section` varchar(20) NOT NULL 37 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; 38 | 39 | -- 40 | -- Indexes for dumped tables 41 | -- 42 | 43 | -- 44 | -- Indexes for table `face_bio` 45 | -- 46 | ALTER TABLE `face_bio` 47 | ADD PRIMARY KEY (`id`); 48 | 49 | -- 50 | -- AUTO_INCREMENT for dumped tables 51 | -- 52 | 53 | -- 54 | -- AUTO_INCREMENT for table `face_bio` 55 | -- 56 | ALTER TABLE `face_bio` 57 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1; 58 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 59 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 60 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 61 | -------------------------------------------------------------------------------- /src/application/OCR.java: -------------------------------------------------------------------------------- 1 | package application; 2 | import org.bytedeco.javacpp.*; 3 | 4 | import static org.bytedeco.javacpp.lept.*; 5 | import static org.bytedeco.javacpp.tesseract.*; 6 | import java.awt.Font; 7 | import java.awt.FontFormatException; 8 | import java.awt.GraphicsEnvironment; 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | 13 | 14 | 15 | public class OCR 16 | { 17 | public String init() throws FontFormatException 18 | { 19 | try { 20 | GraphicsEnvironment ge = 21 | GraphicsEnvironment.getLocalGraphicsEnvironment(); 22 | ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("f2.ttf"))); 23 | } catch (IOException e) { 24 | //Handle exception 25 | } 26 | 27 | BytePointer outText; 28 | 29 | TessBaseAPI api=new TessBaseAPI(); 30 | 31 | 32 | 33 | 34 | //to use tesseract api,at first you have to install tesseract with desired language training data on your system.After That you have to mention 35 | //the installation folder. 36 | if(api.Init("C:/tessdata", "eng") != 0) 37 | { 38 | System.out.println("could not initialize tesseract"); 39 | System.exit(1); 40 | 41 | } 42 | 43 | // 44 | 45 | //For Bengali Language 46 | /* if(api.Init("C:/tesseract-ocr/tessdata", "ben") != 0) 47 | { 48 | System.out.println("could not initialize tesseract"); 49 | System.exit(1); 50 | 51 | }*/ 52 | 53 | //read an image from default location for ocr output 54 | PIX image=pixRead("ocr_test.png"); 55 | if(image==null) 56 | { 57 | System.err.println("Could not opened the image or Image not found "); 58 | 59 | } 60 | 61 | api.SetImage(image); 62 | 63 | outText=api.GetUTF8Text(); 64 | 65 | 66 | String output= outText.getString(); 67 | 68 | api.End(); 69 | outText.deallocate(); 70 | pixDestroy(image); 71 | 72 | return output; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/application/MotionDetector.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import org.bytedeco.javacpp.*; 5 | import org.bytedeco.javacpp.opencv_core.IplImage; 6 | import org.bytedeco.javacv.*; 7 | import static org.bytedeco.javacpp.opencv_core.*; 8 | import static org.bytedeco.javacpp.opencv_imgproc.*; 9 | 10 | import java.awt.Color; 11 | import java.awt.Font; 12 | import java.awt.Graphics2D; 13 | 14 | 15 | 16 | public class MotionDetector { 17 | 18 | 19 | public void init( IplImage frame,Graphics2D g2 ) throws Exception { 20 | 21 | OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); 22 | IplImage image = null; 23 | IplImage prevImage = null; 24 | IplImage diff = null; 25 | 26 | CanvasFrame canvasFrame = new CanvasFrame("Motion Detector"); 27 | canvasFrame.setCanvasSize(frame.width(), frame.height()); 28 | 29 | CvMemStorage storage = CvMemStorage.create(); 30 | 31 | while (canvasFrame.isVisible() && (frame != null)) { 32 | cvClearMemStorage(storage); 33 | 34 | cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2); 35 | if (image == null) { 36 | image = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1); 37 | cvCvtColor(frame, image, CV_RGB2GRAY); 38 | } else { 39 | prevImage = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1); 40 | prevImage = image; 41 | image = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1); 42 | cvCvtColor(frame, image, CV_RGB2GRAY); 43 | } 44 | 45 | if (diff == null) { 46 | diff = IplImage.create(frame.width(), frame.height(), IPL_DEPTH_8U, 1); 47 | } 48 | 49 | if (prevImage != null) { 50 | // perform ABS difference 51 | cvAbsDiff(image, prevImage, diff); 52 | // do some threshold for wipe away useless details 53 | cvThreshold(diff, diff, 64, 255,CV_THRESH_BINARY); 54 | 55 | 56 | canvasFrame.showImage(converter.convert(diff)); 57 | 58 | 59 | 60 | 61 | // recognize contours 62 | CvSeq contour = new CvSeq(null); 63 | cvFindContours(diff, storage, contour, Loader.sizeof(CvContour.class), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); 64 | 65 | while (contour != null && !contour.isNull()) { 66 | if (contour.elem_size() > 0) { 67 | CvBox2D box = cvMinAreaRect2(contour, storage); 68 | 69 | g2.setColor(Color.RED); 70 | 71 | g2.setFont(new Font("Arial Black", Font.BOLD, 20)); 72 | 73 | String name = "Motion Detected !"; 74 | 75 | g2.drawString(name, (int) (50), (50)); 76 | 77 | // test intersection 78 | if (box != null) { 79 | CvPoint2D32f center = box.center(); 80 | CvSize2D32f size = box.size(); 81 | 82 | } 83 | } 84 | contour = contour.h_next(); 85 | } 86 | } 87 | } 88 | 89 | canvasFrame.dispose(); 90 | } 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/application/FaceRecognizer.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.io.File; 4 | import java.io.FilenameFilter; 5 | import java.nio.IntBuffer; 6 | 7 | import static org.bytedeco.javacpp.opencv_core.*; 8 | 9 | import static org.bytedeco.javacpp.opencv_face.createLBPHFaceRecognizer; 10 | import org.bytedeco.javacpp.opencv_core.Mat; 11 | import org.bytedeco.javacpp.opencv_core.MatVector; 12 | 13 | import org.bytedeco.javacpp.opencv_face.*; 14 | 15 | 16 | 17 | import static org.bytedeco.javacpp.opencv_imgcodecs.*; 18 | import static org.bytedeco.javacpp.opencv_imgproc.*; 19 | 20 | import static org.bytedeco.javacpp.opencv_imgcodecs.imread; 21 | import static org.bytedeco.javacpp.opencv_imgcodecs.CV_LOAD_IMAGE_GRAYSCALE; 22 | 23 | import org.bytedeco.javacpp.IntPointer; 24 | import org.bytedeco.javacpp.BytePointer; 25 | import org.bytedeco.javacpp.DoublePointer; 26 | 27 | public class FaceRecognizer { 28 | 29 | LBPHFaceRecognizer faceRecognizer; 30 | 31 | public File root; 32 | MatVector images; 33 | Mat labels; 34 | 35 | public void init() { 36 | // mention the directory the faces has been saved 37 | String trainingDir = "./faces"; 38 | 39 | root = new File(trainingDir); 40 | 41 | FilenameFilter imgFilter = new FilenameFilter() { 42 | public boolean accept(File dir, String name) { 43 | name = name.toLowerCase(); 44 | return name.endsWith(".jpg") || name.endsWith(".pgm") || name.endsWith(".png"); 45 | } 46 | }; 47 | 48 | File[] imageFiles = root.listFiles(imgFilter); 49 | 50 | this.images = new MatVector(imageFiles.length); 51 | 52 | this.labels = new Mat(imageFiles.length, 1, CV_32SC1); 53 | IntBuffer labelsBuf = labels.createBuffer(); 54 | 55 | int counter = 0; 56 | // reading face images from the folder 57 | 58 | for (File image : imageFiles) { 59 | Mat img = imread(image.getAbsolutePath(), CV_LOAD_IMAGE_GRAYSCALE); 60 | 61 | // extracting unique face code from the face image names 62 | /* 63 | this unique face will be used to fetch all other information from 64 | I dont put face data on database. 65 | I just store face indexes on database. 66 | 67 | For example: 68 | When you train a new face to the system suppose person named ABC. 69 | Now this person named ABC has 10(can be more or less) face image which 70 | will be saved in the project folder named "/Faces" using a naming convention such as 71 | 1_ABC1.jpg 72 | 1_ABC2.jpg 73 | 1_ABC3.jpg 74 | ....... 75 | 1_ABC10.jpg 76 | 77 | The initial value of the file name is the index key in the database table of that person. 78 | the key 1 will be used to fetch data from database. 79 | 80 | */ 81 | int label = Integer.parseInt(image.getName().split("\\-")[0]); 82 | 83 | images.put(counter, img); 84 | 85 | labelsBuf.put(counter, label); 86 | 87 | counter++; 88 | } 89 | 90 | // face training 91 | //this.faceRecognizer = createLBPHFaceRecognizer(); 92 | this.faceRecognizer = createLBPHFaceRecognizer(); 93 | 94 | 95 | this.faceRecognizer.train(images, labels); 96 | 97 | } 98 | 99 | public int recognize(IplImage faceData) { 100 | 101 | Mat faces = cvarrToMat(faceData); 102 | 103 | cvtColor(faces, faces, CV_BGR2GRAY); 104 | 105 | IntPointer label = new IntPointer(1); 106 | DoublePointer confidence = new DoublePointer(0); 107 | 108 | 109 | this.faceRecognizer.predict(faces, label, confidence); 110 | 111 | 112 | int predictedLabel = label.get(0); 113 | 114 | 115 | 116 | //System.out.println(confidence.get(0)); 117 | 118 | 119 | 120 | //Confidence value less than 60 means face is known 121 | //Confidence value greater than 60 means face is unknown 122 | if(confidence.get(0) > 60) 123 | { 124 | //System.out.println("-1"); 125 | return -1; 126 | } 127 | 128 | return predictedLabel; 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/application/application.css: -------------------------------------------------------------------------------- 1 | /* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ 2 | 3 | 4 | 5 | 6 | .aaa 7 | { 8 | 9 | -fx-min-height: 60px; 10 | 11 | -fx-min-width: 90px; 12 | 13 | -fx-background-image: url("../onon.png"); 14 | 15 | -fx-background-size: 50px 50px; 16 | 17 | -fx-background-repeat: no-repeat; 18 | 19 | -fx-background-position: center 7px; 20 | } 21 | 22 | #savef 23 | { 24 | 25 | -fx-min-height: 60px; 26 | 27 | -fx-min-width: 90px; 28 | 29 | 30 | -fx-background-image: url("../face.png"); 31 | 32 | -fx-background-size: 50px 50px; 33 | 34 | -fx-background-repeat: no-repeat; 35 | 36 | -fx-background-position: center 7px; 37 | } 38 | 39 | .recog 40 | { 41 | 42 | -fx-min-height: 60px; 43 | 44 | -fx-min-width: 90px; 45 | 46 | 47 | -fx-background-image: url("../recognition.png"); 48 | 49 | -fx-background-size: 50px 50px; 50 | 51 | -fx-background-repeat: no-repeat; 52 | 53 | -fx-background-position: center 7px; 54 | } 55 | 56 | 57 | 58 | 59 | .motion 60 | { 61 | 62 | -fx-min-height: 60px; 63 | 64 | -fx-min-width: 90px; 65 | 66 | 67 | -fx-background-image: url("../motion.png"); 68 | 69 | -fx-background-size: 50px 50px; 70 | 71 | -fx-background-repeat: no-repeat; 72 | 73 | -fx-background-position: center 7px; 74 | } 75 | 76 | .stop2 77 | { 78 | 79 | -fx-min-height: 60px; 80 | 81 | -fx-min-width: 90px; 82 | 83 | 84 | -fx-background-image: url("../stop.png"); 85 | 86 | -fx-background-size: 50px 50px; 87 | 88 | -fx-background-repeat: no-repeat; 89 | 90 | -fx-background-position: center 7px; 91 | } 92 | 93 | .stop1 94 | { 95 | 96 | -fx-min-height: 60px; 97 | 98 | -fx-min-width: 90px; 99 | 100 | 101 | -fx-background-image: url("../stop.png"); 102 | 103 | -fx-background-size: 50px 50px; 104 | 105 | -fx-background-repeat: no-repeat; 106 | 107 | -fx-background-position: center 7px; 108 | } 109 | 110 | .ocr 111 | { 112 | 113 | -fx-min-height: 60px; 114 | 115 | -fx-min-width: 90px; 116 | 117 | 118 | -fx-background-image: url("../scanner.png"); 119 | 120 | -fx-background-size: 50px 50px; 121 | 122 | -fx-background-repeat: no-repeat; 123 | 124 | -fx-background-position: center 7px; 125 | } 126 | .capture 127 | { 128 | 129 | -fx-min-height: 45px; 130 | 131 | -fx-min-width: 90px; 132 | 133 | 134 | -fx-background-image: url("../camera.png"); 135 | 136 | -fx-background-size: 40px 30px; 137 | 138 | -fx-background-repeat: no-repeat; 139 | 140 | -fx-background-position: center 7px; 141 | } 142 | .gesture 143 | { 144 | 145 | -fx-min-height: 60px; 146 | 147 | -fx-min-width: 90px; 148 | 149 | 150 | -fx-background-image: url("../gesture.png"); 151 | 152 | -fx-background-size: 50px 50px; 153 | 154 | -fx-background-repeat: no-repeat; 155 | 156 | -fx-background-position: center 7px; 157 | } 158 | 159 | .eye 160 | { 161 | 162 | -fx-min-height: 60px; 163 | 164 | -fx-min-width: 90px; 165 | 166 | 167 | -fx-background-image: url("../eye.png"); 168 | 169 | -fx-background-size: 45px 40px; 170 | 171 | -fx-background-repeat: no-repeat; 172 | 173 | -fx-background-position: center 7px; 174 | } 175 | .sqr 176 | { 177 | 178 | -fx-min-height: 60px; 179 | 180 | -fx-min-width: 90px; 181 | 182 | 183 | -fx-background-image: url("../square.png"); 184 | 185 | -fx-background-size: 50px 50px; 186 | 187 | -fx-background-repeat: no-repeat; 188 | 189 | -fx-background-position: center 7px; 190 | } 191 | 192 | .upperbody 193 | { 194 | 195 | -fx-min-height: 60px; 196 | 197 | -fx-min-width: 90px; 198 | 199 | 200 | -fx-background-image: url("../aa.png"); 201 | 202 | -fx-background-size: 50px 50px; 203 | 204 | -fx-background-repeat: no-repeat; 205 | 206 | -fx-background-position: center 7px; 207 | } 208 | .fullbody 209 | { 210 | 211 | -fx-min-height: 50px; 212 | 213 | -fx-min-width: 90px; 214 | 215 | 216 | -fx-background-image: url("../fullbody.png"); 217 | 218 | 219 | -fx-background-size: 50px 40px; 220 | 221 | -fx-background-repeat: no-repeat; 222 | 223 | -fx-background-position: center 7px; 224 | } 225 | 226 | .smiles 227 | { 228 | 229 | -fx-min-height: 60px; 230 | 231 | -fx-min-width: 90px; 232 | 233 | 234 | -fx-background-image: url("../smile.jpg"); 235 | 236 | -fx-background-size: 50px 50px; 237 | 238 | -fx-background-repeat: no-repeat; 239 | 240 | -fx-background-position: center 7px; 241 | } 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /target/classes/application/application.css: -------------------------------------------------------------------------------- 1 | /* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ 2 | 3 | 4 | 5 | 6 | .aaa 7 | { 8 | 9 | -fx-min-height: 60px; 10 | 11 | -fx-min-width: 90px; 12 | 13 | -fx-background-image: url("../onon.png"); 14 | 15 | -fx-background-size: 50px 50px; 16 | 17 | -fx-background-repeat: no-repeat; 18 | 19 | -fx-background-position: center 7px; 20 | } 21 | 22 | #savef 23 | { 24 | 25 | -fx-min-height: 60px; 26 | 27 | -fx-min-width: 90px; 28 | 29 | 30 | -fx-background-image: url("../face.png"); 31 | 32 | -fx-background-size: 50px 50px; 33 | 34 | -fx-background-repeat: no-repeat; 35 | 36 | -fx-background-position: center 7px; 37 | } 38 | 39 | .recog 40 | { 41 | 42 | -fx-min-height: 60px; 43 | 44 | -fx-min-width: 90px; 45 | 46 | 47 | -fx-background-image: url("../recognition.png"); 48 | 49 | -fx-background-size: 50px 50px; 50 | 51 | -fx-background-repeat: no-repeat; 52 | 53 | -fx-background-position: center 7px; 54 | } 55 | 56 | 57 | 58 | 59 | .motion 60 | { 61 | 62 | -fx-min-height: 60px; 63 | 64 | -fx-min-width: 90px; 65 | 66 | 67 | -fx-background-image: url("../motion.png"); 68 | 69 | -fx-background-size: 50px 50px; 70 | 71 | -fx-background-repeat: no-repeat; 72 | 73 | -fx-background-position: center 7px; 74 | } 75 | 76 | .stop2 77 | { 78 | 79 | -fx-min-height: 60px; 80 | 81 | -fx-min-width: 90px; 82 | 83 | 84 | -fx-background-image: url("../stop.png"); 85 | 86 | -fx-background-size: 50px 50px; 87 | 88 | -fx-background-repeat: no-repeat; 89 | 90 | -fx-background-position: center 7px; 91 | } 92 | 93 | .stop1 94 | { 95 | 96 | -fx-min-height: 60px; 97 | 98 | -fx-min-width: 90px; 99 | 100 | 101 | -fx-background-image: url("../stop.png"); 102 | 103 | -fx-background-size: 50px 50px; 104 | 105 | -fx-background-repeat: no-repeat; 106 | 107 | -fx-background-position: center 7px; 108 | } 109 | 110 | .ocr 111 | { 112 | 113 | -fx-min-height: 60px; 114 | 115 | -fx-min-width: 90px; 116 | 117 | 118 | -fx-background-image: url("../scanner.png"); 119 | 120 | -fx-background-size: 50px 50px; 121 | 122 | -fx-background-repeat: no-repeat; 123 | 124 | -fx-background-position: center 7px; 125 | } 126 | .capture 127 | { 128 | 129 | -fx-min-height: 45px; 130 | 131 | -fx-min-width: 90px; 132 | 133 | 134 | -fx-background-image: url("../camera.png"); 135 | 136 | -fx-background-size: 40px 30px; 137 | 138 | -fx-background-repeat: no-repeat; 139 | 140 | -fx-background-position: center 7px; 141 | } 142 | .gesture 143 | { 144 | 145 | -fx-min-height: 60px; 146 | 147 | -fx-min-width: 90px; 148 | 149 | 150 | -fx-background-image: url("../gesture.png"); 151 | 152 | -fx-background-size: 50px 50px; 153 | 154 | -fx-background-repeat: no-repeat; 155 | 156 | -fx-background-position: center 7px; 157 | } 158 | 159 | .eye 160 | { 161 | 162 | -fx-min-height: 60px; 163 | 164 | -fx-min-width: 90px; 165 | 166 | 167 | -fx-background-image: url("../eye.png"); 168 | 169 | -fx-background-size: 45px 40px; 170 | 171 | -fx-background-repeat: no-repeat; 172 | 173 | -fx-background-position: center 7px; 174 | } 175 | .sqr 176 | { 177 | 178 | -fx-min-height: 60px; 179 | 180 | -fx-min-width: 90px; 181 | 182 | 183 | -fx-background-image: url("../square.png"); 184 | 185 | -fx-background-size: 50px 50px; 186 | 187 | -fx-background-repeat: no-repeat; 188 | 189 | -fx-background-position: center 7px; 190 | } 191 | 192 | .upperbody 193 | { 194 | 195 | -fx-min-height: 60px; 196 | 197 | -fx-min-width: 90px; 198 | 199 | 200 | -fx-background-image: url("../aa.png"); 201 | 202 | -fx-background-size: 50px 50px; 203 | 204 | -fx-background-repeat: no-repeat; 205 | 206 | -fx-background-position: center 7px; 207 | } 208 | .fullbody 209 | { 210 | 211 | -fx-min-height: 50px; 212 | 213 | -fx-min-width: 90px; 214 | 215 | 216 | -fx-background-image: url("../fullbody.png"); 217 | 218 | 219 | -fx-background-size: 50px 40px; 220 | 221 | -fx-background-repeat: no-repeat; 222 | 223 | -fx-background-position: center 7px; 224 | } 225 | 226 | .smiles 227 | { 228 | 229 | -fx-min-height: 60px; 230 | 231 | -fx-min-width: 90px; 232 | 233 | 234 | -fx-background-image: url("../smile.jpg"); 235 | 236 | -fx-background-size: 50px 50px; 237 | 238 | -fx-background-repeat: no-repeat; 239 | 240 | -fx-background-position: center 7px; 241 | } 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /src/application/Database.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.sql.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | class Database { 8 | public int code; 9 | 10 | public String fname; 11 | public String Lname; 12 | public int reg; 13 | public int age; 14 | public String sec; 15 | 16 | public final String Database_name = "ghosteye"; 17 | public final String Database_user = "root"; 18 | public final String Database_pass = ""; 19 | 20 | public Connection con; 21 | 22 | public boolean init() throws SQLException { 23 | try { 24 | Class.forName("com.mysql.jdbc.Driver"); 25 | 26 | try { 27 | this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + Database_name, Database_user, 28 | Database_pass); 29 | } catch (SQLException e) { 30 | 31 | System.out.println("Error: Database Connection Failed ! Please check the connection Setting"); 32 | 33 | return false; 34 | 35 | } 36 | 37 | } catch (ClassNotFoundException e) { 38 | 39 | e.printStackTrace(); 40 | 41 | return false; 42 | } 43 | 44 | return true; 45 | } 46 | 47 | public void insert() { 48 | String sql = "INSERT INTO face_bio (code, first_name, last_name, reg, age , section) VALUES (?, ?, ?, ?,?,?)"; 49 | 50 | PreparedStatement statement = null; 51 | try { 52 | statement = con.prepareStatement(sql); 53 | } catch (SQLException e1) { 54 | // TODO Auto-generated catch block 55 | e1.printStackTrace(); 56 | } 57 | 58 | try { 59 | 60 | statement.setInt(1, this.code); 61 | statement.setString(2, this.fname); 62 | 63 | statement.setString(3, this.Lname); 64 | statement.setInt(4, this.reg); 65 | statement.setInt(5, this.age); 66 | statement.setString(6, this.sec); 67 | 68 | int rowsInserted = statement.executeUpdate(); 69 | if (rowsInserted > 0) { 70 | System.out.println("A new face data was inserted successfully!"); 71 | } 72 | } catch (SQLException e) { 73 | // TODO Auto-generated catch block 74 | e.printStackTrace(); 75 | } 76 | 77 | } 78 | 79 | public ArrayList getUser(int inCode) throws SQLException { 80 | 81 | ArrayList user = new ArrayList(); 82 | 83 | try { 84 | 85 | Database app = new Database(); 86 | 87 | String sql = "select * from face_bio where code=" + inCode + " limit 1"; 88 | 89 | Statement s = con.createStatement(); 90 | 91 | ResultSet rs = s.executeQuery(sql); 92 | 93 | while (rs.next()) { 94 | 95 | /* 96 | * app.setCode(rs.getInt(2)); app.setFname(rs.getString(3)); 97 | * app.setLname(rs.getString(4)); app.setReg(rs.getInt(5)); 98 | * app.setAge(rs.getInt(6)); app.setSec(rs.getString(7)); 99 | */ 100 | 101 | user.add(0, Integer.toString(rs.getInt(2))); 102 | user.add(1, rs.getString(3)); 103 | user.add(2, rs.getString(4)); 104 | user.add(3, Integer.toString(rs.getInt(5))); 105 | user.add(4, Integer.toString(rs.getInt(6))); 106 | user.add(5, rs.getString(7)); 107 | 108 | /* 109 | * System.out.println(app.getCode()); 110 | * System.out.println(app.getFname()); 111 | * System.out.println(app.getLname()); 112 | * System.out.println(app.getReg()); 113 | * System.out.println(app.getAge()); 114 | * System.out.println(app.getSec()); 115 | */ 116 | 117 | // nString="Name:" + rs.getString(3)+" "+rs.getString(4) + 118 | // "\nReg:" + app.getReg() +"\nAge:"+app.getAge() +"\nSection:" 119 | // +app.getSec() ; 120 | 121 | // System.out.println(nString); 122 | } 123 | 124 | con.close(); // closing connection 125 | } catch (Exception e) { 126 | e.getStackTrace(); 127 | } 128 | return user; 129 | } 130 | 131 | public void db_close() throws SQLException 132 | { 133 | try { 134 | con.close(); 135 | } catch (SQLException e) { 136 | // TODO Auto-generated catch block 137 | e.printStackTrace(); 138 | } 139 | } 140 | 141 | 142 | public int getCode() { 143 | return code; 144 | } 145 | 146 | public void setCode(int code) { 147 | this.code = code; 148 | } 149 | 150 | public String getFname() { 151 | return fname; 152 | } 153 | 154 | public void setFname(String fname) { 155 | this.fname = fname; 156 | } 157 | 158 | public String getLname() { 159 | return Lname; 160 | } 161 | 162 | public void setLname(String lname) { 163 | Lname = lname; 164 | } 165 | 166 | public int getReg() { 167 | return reg; 168 | } 169 | 170 | public void setReg(int reg) { 171 | this.reg = reg; 172 | } 173 | 174 | public int getAge() { 175 | return age; 176 | } 177 | 178 | public void setAge(int age) { 179 | this.age = age; 180 | } 181 | 182 | public String getSec() { 183 | return sec; 184 | } 185 | 186 | public void setSec(String sec) { 187 | this.sec = sec; 188 | } 189 | 190 | } 191 | -------------------------------------------------------------------------------- /src/application/ColoredObjectTracker.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import java.awt.AWTException; 5 | import java.awt.Color; 6 | import java.awt.Graphics; 7 | import java.awt.Robot; 8 | import java.awt.image.BufferedImage; 9 | import javax.swing.JPanel; 10 | 11 | import org.bytedeco.javacpp.opencv_core.CvScalar; 12 | import org.bytedeco.javacpp.opencv_core.IplImage; 13 | import org.bytedeco.javacpp.opencv_imgproc.CvMoments; 14 | import org.bytedeco.javacv.CanvasFrame; 15 | import org.bytedeco.javacv.FrameGrabber; 16 | import org.bytedeco.javacv.Java2DFrameConverter; 17 | import org.bytedeco.javacv.OpenCVFrameConverter; 18 | 19 | import static org.bytedeco.javacpp.opencv_core.*; 20 | import static org.bytedeco.javacpp.opencv_imgcodecs.*; 21 | import static org.bytedeco.javacpp.opencv_imgproc.*; 22 | 23 | public class ColoredObjectTracker implements Runnable { 24 | 25 | 26 | final int INTERVAL = 1;// 1sec 27 | final int CAMERA_NUM = 0; // Default camera for this time 28 | FrameGrabber grabber; 29 | OpenCVFrameConverter.ToIplImage converter ; 30 | IplImage img; 31 | 32 | /** 33 | * Correct the color range- it depends upon the object, camera quality, 34 | * environment. 35 | */ 36 | static CvScalar rgba_min = cvScalar(0, 0, 130, 0);// RED wide dabur birko 37 | static CvScalar rgba_max = cvScalar(80, 80, 255, 0); 38 | 39 | IplImage image; 40 | CanvasFrame canvas ; 41 | CanvasFrame path ; 42 | int ii = 0; 43 | JPanel jp = new JPanel(); 44 | 45 | public void init() { 46 | // canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); 47 | 48 | canvas = new CanvasFrame("Web Cam Live"); 49 | path = new CanvasFrame("Detection"); 50 | //path.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); 51 | path.setContentPane(jp); 52 | } 53 | 54 | public void run() { 55 | try { 56 | grabber = FrameGrabber.createDefault(CAMERA_NUM); 57 | converter = new OpenCVFrameConverter.ToIplImage(); 58 | grabber.start(); 59 | 60 | int posX = 0; 61 | int posY = 0; 62 | while (true) { 63 | img = converter.convert(grabber.grab()); 64 | if (img != null) { 65 | // show image on window 66 | cvFlip(img, img, 1);// l-r = 90_degrees_steps_anti_clockwise 67 | canvas.showImage(converter.convert(img)); 68 | IplImage detectThrs = getThresholdImage(img); 69 | 70 | CvMoments moments = new CvMoments(); 71 | cvMoments(detectThrs, moments, 1); 72 | 73 | double mom10 = cvGetSpatialMoment(moments, 1, 0); 74 | double mom01 = cvGetSpatialMoment(moments, 0, 1); 75 | double area = cvGetCentralMoment(moments, 0, 0); 76 | posX = (int) (mom10 / area); 77 | posY = (int) (mom01 / area); 78 | // only if its a valid position 79 | if (posX > 0 && posY > 0) { 80 | paint(img, posX, posY); 81 | } 82 | } 83 | // Thread.sleep(INTERVAL); 84 | } 85 | } catch (Exception e) { 86 | } 87 | } 88 | 89 | private void paint(IplImage img, int posX, int posY) { 90 | Graphics g = jp.getGraphics(); 91 | path.setSize(img.width(), img.height()); 92 | g.clearRect(0, 0, img.width(), img.height()); 93 | g.setColor(Color.RED); 94 | 95 | Robot mouseControler = null ; // For moving mouse pointer 96 | try { 97 | mouseControler = new Robot(); 98 | } catch (AWTException e) { 99 | e.printStackTrace(); 100 | } 101 | 102 | 103 | mouseControler.mouseMove(posX,posY); 104 | 105 | g.fillOval(posX, posY, 40, 40); 106 | g.drawString("Detected Here", posX, posY); 107 | g.drawOval(posX, posY, 40, 40); 108 | System.out.println("X,Y: "+ posX + " , " + posY); 109 | 110 | } 111 | 112 | private IplImage getThresholdImage(IplImage orgImg) { 113 | IplImage imgThreshold = cvCreateImage(cvGetSize(orgImg), 8, 1); 114 | // 115 | cvInRangeS(orgImg, rgba_min, rgba_max, imgThreshold);// red 116 | 117 | cvSmooth(imgThreshold, imgThreshold, CV_MEDIAN, 15,0,0,0); 118 | //cvSaveImage(++ii + "dsmthreshold.jpg", imgThreshold); 119 | return imgThreshold; 120 | } 121 | 122 | 123 | public IplImage Equalize(BufferedImage bufferedimg) { 124 | Java2DFrameConverter converter1 = new Java2DFrameConverter(); 125 | OpenCVFrameConverter.ToIplImage converter2 = new OpenCVFrameConverter.ToIplImage(); 126 | IplImage iploriginal = converter2.convert(converter1.convert(bufferedimg)); 127 | IplImage srcimg = IplImage.create(iploriginal.width(), iploriginal.height(), IPL_DEPTH_8U, 1); 128 | IplImage destimg = IplImage.create(iploriginal.width(), iploriginal.height(), IPL_DEPTH_8U, 1); 129 | cvCvtColor(iploriginal, srcimg, CV_BGR2GRAY); 130 | cvEqualizeHist(srcimg, destimg); 131 | return destimg; 132 | } 133 | public void stop() { 134 | img=null; 135 | 136 | 137 | try { 138 | grabber.stop(); 139 | } catch (org.bytedeco.javacv.FrameGrabber.Exception e) { 140 | 141 | e.printStackTrace(); 142 | } 143 | try { 144 | grabber.release(); 145 | } catch (org.bytedeco.javacv.FrameGrabber.Exception e) { 146 | 147 | e.printStackTrace(); 148 | } 149 | grabber = null; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # e x o V i s i x 2 |

3 | Logo 4 |

5 | 6 | ExoVisix is a Smart Computer Vision Application with various functionalities. I have tried to put as many Machine Learning tools as possible into one single Application for greater productivity. 7 | 8 | ## KEY FEATURES 9 | * Auto Attendance system Using Real Time Face Recognition 10 | * Face Trainer 11 | * Motion Detection 12 | * OCR (Optical Character Reader) 13 | * Gesture Control(Controlling Mouse Pointer Using Finger or Red Colored Object) 14 | * Rectangle Shape Detection 15 | * Trained Faces Image Gallery View 16 | * Eye Detection 17 | * Persistent Storage for Trained Faces Image Using Database 18 | 19 | ## TECHNOLOGY USED 20 | * Core Java 21 | * JavaCV (wrapper of Opencv ) 22 | * JavaFX 23 | * MySQL 24 | * Maven 25 | * Tesseract OCR Framework 26 | ## USER INTERFACE 27 | ExoVisix UI 28 | 29 | # Installation Guide 30 | 31 | 32 | ### Video Guide 33 | 34 | 35 | [![IMAGE ALT TEXT](./src/sc.PNG)](https://www.youtube.com/embed/Wzwc4RUJs1Y "Video Title") 36 | 37 | ### IDE 38 | ```bash 39 | I have developed this project using Eclipse Neon. So I highly recommend you to use this particular IDE. 40 | ``` 41 | 42 | ## Maven Dependencies 43 | ```xml 44 | 45 | org.bytedeco 46 | javacv-platform 47 | 1.3.2 48 | 49 | 50 | 51 | mysql 52 | mysql-connector-java 53 | 5.1.14 54 | 55 | 56 | 57 | org.bytedeco.javacpp-presets 58 | tesseract-platform 59 | 3.04.01-1.3 60 | 61 | 62 | ``` 63 | 64 | ### Required Software 65 | To properly run this Application on your System, At first you need to download and install the following software: 66 | 67 | * An implementation of **Java SE** 7 or newer: 68 | * **JDK** http://www.oracle.com/technetwork/java/javase/downloads/index.html 69 | 70 | * An implementation of **JavaFX**: (Follow The Installation Instruction) 71 | * **JavaFX** https://docs.oracle.com/javafx/2/installation/jfxpub-installation.htm 72 | 73 | * An implementation of **JavaCV**: (Follow The Installation Instruction) 74 | * **JavaCV** https://github.com/bytedeco/javacv 75 | 76 | * An implementation of **MySQL Database**: 77 | * **XAMPP** https://www.apachefriends.org/download.html 78 | 79 | * To Connect MySQL with Java, You will need a connector: (Follow the installation instruction) 80 | * **MySQL Connector Java** https://dev.mysql.com/downloads/connector/j/5.1.html 81 | 82 | * An implementation of **JavaFX Scene Builder**: (Follow The Installation Instruction) 83 | * **JavaFX Scene Builder** https://docs.oracle.com/javafx/scenebuilder/1/installation_1-0/jsbpub-installation_1-0.htm 84 | 85 | 86 | Finally, please make sure everything has the same bitness: **32-bit and 64-bit modules do not mix under any circumstances**. 87 | 88 | # Configuration Settings 89 | #### ExoVision may not work properly Without these settings 90 | #### Before executing the App, you have to make some change to below mentioned files... 91 | 92 | ## Database Settings 93 | * Open MySQL on XAMPP then Create a New Database & name it **ghostEye** 94 | * Now import attached **face_bio.sql** to the **ghostEye** Database 95 | * Or Create a New Schema(Table) 96 | ```sql 97 | 98 | CREATE TABLE IF NOT EXISTS `face_bio` ( 99 | `id` int(11) NOT NULL, 100 | `code` int(10) NOT NULL, 101 | `first_name` varchar(30) NOT NULL, 102 | `last_name` varchar(20) NOT NULL, 103 | `reg` int(10) NOT NULL, 104 | `age` int(10) NOT NULL, 105 | `section` varchar(20) NOT NULL 106 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; 107 | 108 | 109 | ALTER TABLE `face_bio` 110 | ADD PRIMARY KEY (`id`); 111 | 112 | ALTER TABLE `face_bio` 113 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1; 114 | 115 | ``` 116 | 117 | * Now Open src/application/Database.java and provide your MySQL DB credintials 118 | ```java 119 | package application; 120 | 121 | import java.sql.*; 122 | import java.util.ArrayList; 123 | import java.util.List; 124 | 125 | class Database { 126 | public int code; 127 | 128 | public String fname; 129 | public String Lname; 130 | public int reg; 131 | public int age; 132 | public String sec; 133 | 134 | public final String Database_name = "Your Database"; 135 | public final String Database_user = "Your Database user Name"; 136 | public final String Database_pass = "Your Database Password"; 137 | 138 | . 139 | . 140 | . 141 | ``` 142 | ## OCR Settings 143 | * To use tesseract api,at first you have to install tesseract with desired language training data on your system.After That you have to mention the installation folder. 144 | 145 | ```java 146 | Now goto src/application/OCR.java ,in line 36 provide your tesseract installation directory name. 147 | ``` 148 | 149 | # Tips 150 | * When you going to train a new face try to capture at least 10 pictures of a single person in different angle.keep it in mind that the more number of training image in different angle and posture, the more accurate will be face recognition. 151 | * After everything done ,kindly empty the **faces** folder.There is a test_face image.You have to delete it. 152 | 153 | # Please Note: 154 | Please Keep it in mind ,sometimes the face recognition algorithm provides wrong output if a person is not trained or unknown to the system.The reason behind this is that the face recognition algorithm guess the face with the nearest match.when it does not find any match ,the system pick any face with a nearest match.this is why it sometimes provides wrong output. 155 | 156 | # Video Tutorial 157 | * Visit https://www.youtube.com/watch?v=6UnBZFvY8HE&t=3s 158 | 159 | 160 | # LICENCE 161 | 162 | ```licence 163 | 164 | MIT License 165 | 166 | Copyright (c) 2017 Anup Kumar Sarkar 167 | 168 | Permission is hereby granted, free of charge, to any person obtaining a copy 169 | of this software and associated documentation files (the "Software"), to deal 170 | in the Software without restriction, including without limitation the rights 171 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 172 | copies of the Software, and to permit persons to whom the Software is 173 | furnished to do so, subject to the following conditions: 174 | 175 | The above copyright notice and this permission notice shall be included in all 176 | copies or substantial portions of the Software. 177 | 178 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 179 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 180 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 181 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 182 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 183 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 184 | SOFTWARE. 185 | 186 | ``` 187 | 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /src/application/FaceDetectionController.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import java.io.ByteArrayInputStream; 5 | import java.util.concurrent.Executors; 6 | import java.util.concurrent.ScheduledExecutorService; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | import org.opencv.core.Mat; 10 | import org.opencv.core.MatOfByte; 11 | import org.opencv.core.MatOfRect; 12 | import org.opencv.core.Rect; 13 | import org.opencv.core.Scalar; 14 | import org.opencv.core.Size; 15 | import org.opencv.imgcodecs.Imgcodecs; 16 | import org.opencv.imgproc.Imgproc; 17 | import org.opencv.objdetect.CascadeClassifier; 18 | import org.opencv.objdetect.Objdetect; 19 | import org.opencv.videoio.VideoCapture; 20 | 21 | import javafx.event.Event; 22 | import javafx.fxml.FXML; 23 | import javafx.scene.control.Button; 24 | import javafx.scene.control.CheckBox; 25 | import javafx.scene.image.Image; 26 | import javafx.scene.image.ImageView; 27 | 28 | 29 | public class FaceDetectionController 30 | { 31 | // FXML buttons 32 | @FXML 33 | private Button cameraButton; 34 | // the FXML area for showing the current frame 35 | @FXML 36 | private ImageView originalFrame; 37 | // checkboxes for enabling/disabling a classifier 38 | @FXML 39 | private CheckBox haarClassifier; 40 | @FXML 41 | private CheckBox lbpClassifier; 42 | 43 | // a timer for acquiring the video stream 44 | private ScheduledExecutorService timer; 45 | // the OpenCV object that performs the video capture 46 | private VideoCapture capture; 47 | // a flag to change the button behavior 48 | private boolean cameraActive; 49 | 50 | // face cascade classifier 51 | private CascadeClassifier faceCascade; 52 | private int absoluteFaceSize; 53 | 54 | 55 | protected void init() 56 | { 57 | this.capture = new VideoCapture(); 58 | 59 | 60 | this.faceCascade = new CascadeClassifier(); 61 | this.absoluteFaceSize = 0; 62 | } 63 | 64 | 65 | @FXML 66 | protected void startCamera() 67 | { 68 | // set a fixed width for the frame 69 | originalFrame.setFitWidth(600); 70 | // preserve image ratio 71 | originalFrame.setPreserveRatio(true); 72 | 73 | if (!this.cameraActive) 74 | { 75 | // disable setting checkboxes 76 | this.haarClassifier.setDisable(true); 77 | this.lbpClassifier.setDisable(true); 78 | 79 | // start the video capture 80 | this.capture.open(0); 81 | 82 | // is the video stream available? 83 | if (this.capture.isOpened()) 84 | { 85 | this.cameraActive = true; 86 | 87 | // grab a frame every 33 ms (30 frames/sec) 88 | Runnable frameGrabber = new Runnable() { 89 | 90 | @Override 91 | public void run() 92 | { 93 | Image imageToShow = grabFrame(); 94 | originalFrame.setImage(imageToShow); 95 | } 96 | }; 97 | 98 | this.timer = Executors.newSingleThreadScheduledExecutor(); 99 | this.timer.scheduleAtFixedRate(frameGrabber, 0, 33, TimeUnit.MILLISECONDS); 100 | 101 | // update the button content 102 | this.cameraButton.setText("Stop Camera"); 103 | } 104 | else 105 | { 106 | // log the error 107 | System.err.println("Failed to open the camera connection..."); 108 | } 109 | } 110 | else 111 | { 112 | // the camera is not active at this point 113 | this.cameraActive = false; 114 | // update again the button content 115 | this.cameraButton.setText("Start Camera"); 116 | // enable classifiers checkboxes 117 | this.haarClassifier.setDisable(false); 118 | this.lbpClassifier.setDisable(false); 119 | 120 | // stop the timer 121 | try 122 | { 123 | this.timer.shutdown(); 124 | this.timer.awaitTermination(33, TimeUnit.MILLISECONDS); 125 | } 126 | catch (InterruptedException e) 127 | { 128 | // log the exception 129 | System.err.println("Exception in stopping the frame capture, trying to release the camera now... " + e); 130 | } 131 | 132 | // release the camera 133 | this.capture.release(); 134 | // clean the frame 135 | this.originalFrame.setImage(null); 136 | } 137 | } 138 | 139 | /** 140 | * Get a frame from the opened video stream (if any) 141 | * 142 | * @return the {@link Image} to show 143 | */ 144 | private Image grabFrame() 145 | { 146 | // init everything 147 | Image imageToShow = null; 148 | Mat frame = new Mat(); 149 | 150 | // check if the capture is open 151 | if (this.capture.isOpened()) 152 | { 153 | try 154 | { 155 | // read the current frame 156 | this.capture.read(frame); 157 | 158 | // if the frame is not empty, process it 159 | if (!frame.empty()) 160 | { 161 | // face detection 162 | this.detectAndDisplay(frame); 163 | 164 | // convert the Mat object (OpenCV) to Image (JavaFX) 165 | imageToShow = mat2Image(frame); 166 | } 167 | 168 | } 169 | catch (Exception e) 170 | { 171 | // log the (full) error 172 | System.err.println("ERROR: " + e); 173 | } 174 | } 175 | 176 | return imageToShow; 177 | } 178 | 179 | /** 180 | * Method for face detection and tracking 181 | * 182 | * @param frame 183 | * it looks for faces in this frame 184 | */ 185 | private void detectAndDisplay(Mat frame) 186 | { 187 | MatOfRect faces = new MatOfRect(); 188 | Mat grayFrame = new Mat(); 189 | 190 | // convert the frame in gray scale 191 | Imgproc.cvtColor(frame, grayFrame, Imgproc.COLOR_BGR2GRAY); 192 | // equalize the frame histogram to improve the result 193 | Imgproc.equalizeHist(grayFrame, grayFrame); 194 | 195 | // compute minimum face size (20% of the frame height, in our case) 196 | if (this.absoluteFaceSize == 0) 197 | { 198 | int height = grayFrame.rows(); 199 | if (Math.round(height * 0.2f) > 0) 200 | { 201 | this.absoluteFaceSize = Math.round(height * 0.2f); 202 | } 203 | } 204 | 205 | // detect faces 206 | this.faceCascade.detectMultiScale(grayFrame, faces, 1.1, 2, 0 | Objdetect.CASCADE_SCALE_IMAGE, 207 | new Size(this.absoluteFaceSize, this.absoluteFaceSize), new Size()); 208 | 209 | // each rectangle in faces is a face: draw them! 210 | Rect[] facesArray = faces.toArray(); 211 | for (int i = 0; i < facesArray.length; i++) 212 | { 213 | Imgproc.rectangle(frame, facesArray[i].tl(), facesArray[i].br(), new Scalar(7, 255, 90), 4); 214 | System.out.println(facesArray[i].tl()); 215 | System.out.println(facesArray[i].br()); 216 | } 217 | 218 | 219 | 220 | 221 | } 222 | 223 | 224 | @FXML 225 | protected void haarSelected(Event event) 226 | { 227 | // check whether the lpb checkbox is selected and deselect it 228 | if (this.lbpClassifier.isSelected()) 229 | this.lbpClassifier.setSelected(false); 230 | 231 | this.checkboxSelection("resources/haarcascades/haarcascade_frontalcatface.xml"); 232 | } 233 | 234 | 235 | @FXML 236 | protected void lbpSelected(Event event) 237 | { 238 | // check whether the haar checkbox is selected and deselect it 239 | if (this.haarClassifier.isSelected()) 240 | this.haarClassifier.setSelected(false); 241 | 242 | this.checkboxSelection("resources/lbpcascades/lbpcascade_frontalface.xml"); 243 | } 244 | 245 | /** 246 | * Method for loading a classifier trained set from disk 247 | * 248 | * @param classifierPath 249 | * the path on disk where a classifier trained set is located 250 | */ 251 | 252 | private void checkboxSelection(String classifierPath) 253 | { 254 | // load the classifier(s) 255 | this.faceCascade.load(classifierPath); 256 | 257 | // now the video capture can start 258 | this.cameraButton.setDisable(false); 259 | } 260 | 261 | /** 262 | * Convert a Mat object (OpenCV) in the corresponding Image for JavaFX 263 | * 264 | * @param frame 265 | * the {@link Mat} representing the current frame 266 | * @return the {@link Image} to show 267 | */ 268 | private Image mat2Image(Mat frame) 269 | { 270 | // create a temporary buffer 271 | MatOfByte buffer = new MatOfByte(); 272 | // encode the frame in the buffer, according to the PNG format 273 | Imgcodecs.imencode(".png", frame, buffer); 274 | // build and return an Image created from the image encoded in the 275 | // buffer 276 | return new Image(new ByteArrayInputStream(buffer.toArray())); 277 | } 278 | 279 | } 280 | -------------------------------------------------------------------------------- /src/application/SquareDetector.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import javax.swing.JFrame; 4 | 5 | import org.bytedeco.javacpp.*; 6 | import org.bytedeco.javacpp.opencv_core.CvContour; 7 | import org.bytedeco.javacpp.opencv_core.CvMemStorage; 8 | import org.bytedeco.javacpp.opencv_core.CvPoint; 9 | import org.bytedeco.javacpp.opencv_core.CvSeq; 10 | import org.bytedeco.javacpp.opencv_core.CvSize; 11 | import org.bytedeco.javacpp.opencv_core.CvSlice; 12 | import org.bytedeco.javacpp.opencv_core.IplImage; 13 | import org.bytedeco.javacv.*; 14 | 15 | import javafx.scene.image.ImageView; 16 | import static org.bytedeco.javacpp.helper.opencv_core.CV_RGB; 17 | import static org.bytedeco.javacpp.opencv_core.*; 18 | import static org.bytedeco.javacpp.opencv_imgproc.*; 19 | import org.bytedeco.javacv.OpenCVFrameGrabber; 20 | 21 | public class SquareDetector { 22 | 23 | Java2DFrameConverter paintConverter = new Java2DFrameConverter(); 24 | IplImage frame; 25 | ImageView frameShow; 26 | public Exception exception = null; 27 | public IplImage grabbedImage = null, grayImage = null, smallImage = null; 28 | public CanvasFrame canvass = new CanvasFrame("Webcam"); 29 | 30 | // use default camera 31 | public OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);; 32 | 33 | public void setFrameShow(ImageView frameShow) { 34 | this.frameShow = frameShow; 35 | } 36 | 37 | public void setFrame(IplImage frame) { 38 | this.frame = frame; 39 | } 40 | 41 | int thresh = 50; 42 | IplImage img = null; 43 | IplImage img0 = null; 44 | CvMemStorage storage = null; 45 | CvMemStorage storage2 = null; 46 | String wndname = "Square Detection Demo"; 47 | 48 | // Java spesific 49 | 50 | OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); 51 | 52 | // helper function: 53 | // finds a cosine of angle between vectors 54 | // from pt0->pt1 and from pt0->pt2 55 | double angle(CvPoint pt1, CvPoint pt2, CvPoint pt0) { 56 | double dx1 = pt1.x() - pt0.x(); 57 | double dy1 = pt1.y() - pt0.y(); 58 | double dx2 = pt2.x() - pt0.x(); 59 | double dy2 = pt2.y() - pt0.y(); 60 | 61 | return (dx1 * dx2 + dy1 * dy2) / Math.sqrt((dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2) + 1e-10); 62 | } 63 | 64 | // returns sequence of squares detected on the image. 65 | // the sequence is stored in the specified memory storage 66 | CvSeq findSquares4(IplImage img, CvMemStorage storage) { 67 | // Java translation: moved into loop 68 | // CvSeq contours = new CvSeq(); 69 | int i, c, l, N = 11; 70 | CvSize sz = cvSize(img.width() & -2, img.height() & -2); 71 | IplImage timg = cvCloneImage(img); // make a copy of input image 72 | IplImage gray = cvCreateImage(sz, 8, 1); 73 | IplImage pyr = cvCreateImage(cvSize(sz.width() / 2, sz.height() / 2), 8, 3); 74 | IplImage tgray = null; 75 | // Java translation: moved into loop 76 | // CvSeq result = null; 77 | // double s = 0.0, t = 0.0; 78 | 79 | // create empty sequence that will contain points - 80 | // 4 points per square (the square's vertices) 81 | CvSeq squares = cvCreateSeq(0, Loader.sizeof(CvSeq.class), Loader.sizeof(CvPoint.class), storage); 82 | 83 | // select the maximum ROI in the image 84 | // with the width and height divisible by 2 85 | cvSetImageROI(timg, cvRect(0, 0, sz.width(), sz.height())); 86 | 87 | // down-scale and upscale the image to filter out the noise 88 | cvPyrDown(timg, pyr, 7); 89 | cvPyrUp(pyr, timg, 7); 90 | tgray = cvCreateImage(sz, 8, 1); 91 | 92 | // find squares in every color plane of the image 93 | for (c = 0; c < 3; c++) { 94 | // extract the c-th color plane 95 | cvSetImageCOI(timg, c + 1); 96 | cvCopy(timg, tgray); 97 | 98 | // try several threshold levels 99 | for (l = 0; l < N; l++) { 100 | // hack: use Canny instead of zero threshold level. 101 | // Canny helps to catch squares with gradient shading 102 | if (l == 0) { 103 | // apply Canny. Take the upper threshold from slider 104 | // and set the lower to 0 (which forces edges merging) 105 | cvCanny(tgray, gray, 0, thresh, 5); 106 | // dilate canny output to remove potential 107 | // holes between edge segments 108 | cvDilate(gray, gray, null, 1); 109 | } else { 110 | // apply threshold if l!=0: 111 | // tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0 112 | cvThreshold(tgray, gray, (l + 1) * 255 / N, 255, CV_THRESH_BINARY); 113 | } 114 | 115 | // find contours and store them all as a list 116 | // Java translation: moved into the loop 117 | CvSeq contours = new CvSeq(); 118 | cvFindContours(gray, storage, contours, Loader.sizeof(CvContour.class), CV_RETR_LIST, 119 | CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0)); 120 | 121 | // test each contour 122 | while (contours != null && !contours.isNull()) { 123 | // approximate contour with accuracy proportional 124 | // to the contour perimeter 125 | // Java translation: moved into the loop 126 | CvSeq result = cvApproxPoly(contours, Loader.sizeof(CvContour.class), storage, CV_POLY_APPROX_DP, 127 | cvContourPerimeter(contours) * 0.02, 0); 128 | // square contours should have 4 vertices after 129 | // approximation 130 | // relatively large area (to filter out noisy contours) 131 | // and be convex. 132 | // Note: absolute value of an area is used because 133 | // area may be positive or negative - in accordance with the 134 | // contour orientation 135 | if (result.total() == 4 && Math.abs(cvContourArea(result, CV_WHOLE_SEQ, 0)) > 1000 136 | && cvCheckContourConvexity(result) != 0) { 137 | 138 | // Java translation: moved into loop 139 | double s = 0.0, t = 0.0; 140 | 141 | for (i = 0; i < 5; i++) { 142 | // find minimum angle between joint 143 | // edges (maximum of cosine) 144 | if (i >= 2) { 145 | // Java translation: 146 | // Comment from the HoughLines.java sample code: 147 | // " Based on JavaCPP, the equivalent of the C 148 | // code: 149 | // CvPoint* line = 150 | // (CvPoint*)cvGetSeqElem(lines,i); 151 | // CvPoint first=line[0]; 152 | // CvPoint second=line[1]; 153 | // is: 154 | // Pointer line = cvGetSeqElem(lines, i); 155 | // CvPoint first = new 156 | // CvPoint(line).position(0); 157 | // CvPoint second = new 158 | // CvPoint(line).position(1); 159 | // " 160 | // ... so after some trial and error this seem 161 | // to work 162 | // t = fabs(angle( 163 | // (CvPoint*)cvGetSeqElem( result, i ), 164 | // (CvPoint*)cvGetSeqElem( result, i-2 ), 165 | // (CvPoint*)cvGetSeqElem( result, i-1 ))); 166 | t = Math.abs(angle(new CvPoint(cvGetSeqElem(result, i)), 167 | new CvPoint(cvGetSeqElem(result, i - 2)), 168 | new CvPoint(cvGetSeqElem(result, i - 1)))); 169 | s = s > t ? s : t; 170 | } 171 | } 172 | 173 | // if cosines of all angles are small 174 | // (all angles are ~90 degree) then write quandrange 175 | // vertices to resultant sequence 176 | if (s < 0.3) 177 | for (i = 0; i < 4; i++) { 178 | cvSeqPush(squares, cvGetSeqElem(result, i)); 179 | } 180 | } 181 | 182 | // take the next contour 183 | contours = contours.h_next(); 184 | } 185 | } 186 | } 187 | 188 | // release all the temporary images 189 | cvReleaseImage(gray); 190 | cvReleaseImage(pyr); 191 | cvReleaseImage(tgray); 192 | cvReleaseImage(timg); 193 | 194 | return squares; 195 | } 196 | 197 | // the function draws all the squares in the image 198 | void drawSquares(IplImage img, CvSeq squares) { 199 | 200 | // Java translation: Here the code is somewhat different from the C 201 | // version. 202 | // I was unable to get straight forward CvPoint[] arrays 203 | // working with "reader" and the "CV_READ_SEQ_ELEM". 204 | 205 | // CvSeqReader reader = new CvSeqReader(); 206 | 207 | IplImage cpy = cvCloneImage(img); 208 | int i = 0; 209 | 210 | // Used by attempt 3 211 | // Create a "super"-slice, consisting of the entire sequence of squares 212 | CvSlice slice = new CvSlice(squares); 213 | 214 | // initialize reader of the sequence 215 | // cvStartReadSeq(squares, reader, 0); 216 | 217 | // read 4 sequence elements at a time (all vertices of a square) 218 | for (i = 0; i < squares.total(); i += 4) { 219 | CvPoint rect = new CvPoint(4); 220 | IntPointer count = new IntPointer(1).put(4); 221 | // get the 4 corner slice from the "super"-slice 222 | cvCvtSeqToArray(squares, rect, slice.start_index(i).end_index(i + 4)); 223 | 224 | cvPolyLine(cpy, rect.position(0), count, 1, 1, CV_RGB(0, 255, 0), 3, CV_AA, 0); 225 | 226 | // Frame frame =converter.convert(cpy); 227 | // canvass.showImage(converter.convert(cpy)); 228 | 229 | /* 230 | * BufferedImage image = paintConverter.getBufferedImage(frame, 2.2 231 | * ); 232 | * 233 | * 234 | * WritableImage display = SwingFXUtils.toFXImage(image, null); 235 | * 236 | * 237 | * frameShow.setImage(display); 238 | */ 239 | 240 | // return frame; 241 | // canvas.showImage(converter.convert(cpy)); 242 | 243 | } 244 | canvass.showImage(converter.convert(cpy)); 245 | 246 | cvReleaseImage(cpy); 247 | } 248 | 249 | public void loop() { 250 | // canvass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 251 | 252 | storage2 = CvMemStorage.create(); 253 | 254 | try { 255 | 256 | storage = cvCreateMemStorage(0); 257 | 258 | try { 259 | grabber.start(); 260 | } catch (org.bytedeco.javacv.FrameGrabber.Exception e1) { 261 | // TODO Auto-generated catch block 262 | e1.printStackTrace(); 263 | } 264 | 265 | // get framerate 266 | double frameRate = grabber.getFrameRate(); 267 | long wait = (long) (1000 / (frameRate == 0 ? 10 : frameRate)); 268 | 269 | // keep capturing 270 | while (true) { 271 | Thread.sleep(wait); 272 | grabbedImage = converter.convert(grabber.grab()); 273 | 274 | // drawSquares(grabbedImage, findSquares4(grabbedImage, 275 | // storage2)); 276 | 277 | // canvas.showImage(converter.convert(grabbedImage)); 278 | // show grabbed image 279 | 280 | cvClearMemStorage(storage2); 281 | cvClearMemStorage(storage); 282 | 283 | if (grabbedImage != null) { 284 | 285 | // canvas.showImage(converter.convert(grabbedImage)); 286 | 287 | drawSquares(grabbedImage, findSquares4(grabbedImage, storage)); 288 | } 289 | 290 | } 291 | 292 | // show stack trace 293 | } catch (Exception e) { 294 | e.printStackTrace(); 295 | } 296 | } 297 | 298 | } 299 | -------------------------------------------------------------------------------- /src/application/SampleController.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import javafx.scene.control.Button; 4 | import javafx.scene.control.ContentDisplay; 5 | import javafx.scene.control.Label; 6 | import javafx.scene.control.ListView; 7 | 8 | import javafx.scene.control.ProgressIndicator; 9 | import javafx.collections.FXCollections; 10 | import javafx.collections.ObservableList; 11 | import javafx.fxml.FXML; 12 | import javafx.geometry.Insets; 13 | import javafx.scene.control.TextField; 14 | import javafx.scene.control.TitledPane; 15 | import javafx.scene.image.Image; 16 | import javafx.scene.image.ImageView; 17 | import javafx.scene.layout.AnchorPane; 18 | import javafx.scene.layout.TilePane; 19 | import javafx.scene.paint.Stop; 20 | import javafx.scene.text.Text; 21 | import javafx.scene.text.TextFlow; 22 | 23 | import java.awt.FontFormatException; 24 | import java.io.File; 25 | import java.io.FileInputStream; 26 | import java.io.FileNotFoundException; 27 | import java.sql.SQLException; 28 | import java.time.Instant; 29 | import java.util.ArrayList; 30 | 31 | import application.FaceDetector; 32 | import application.Database; 33 | import application.OCR; 34 | import application.Database; 35 | 36 | public class SampleController { 37 | 38 | //********************************************************************************************** 39 | //Mention The file location path where the face will be saved & retrieved 40 | 41 | public String filePath="./faces"; 42 | 43 | 44 | //********************************************************************************************** 45 | @FXML 46 | private Button startCam; 47 | @FXML 48 | private Button stopBtn; 49 | @FXML 50 | private Button motionBtn; 51 | @FXML 52 | private Button eyeBtn; 53 | @FXML 54 | private Button shapeBtn; 55 | @FXML 56 | private Button upperBodyBtn; 57 | @FXML 58 | private Button fullBodyBtn; 59 | @FXML 60 | private Button smileBtn; 61 | @FXML 62 | private Button gesture; 63 | @FXML 64 | private Button gestureStop; 65 | @FXML 66 | private Button saveBtn; 67 | @FXML 68 | private Button ocrBtn; 69 | @FXML 70 | private Button capBtn; 71 | @FXML 72 | private Button recogniseBtn; 73 | @FXML 74 | private Button stopRecBtn; 75 | @FXML 76 | private ImageView frame; 77 | @FXML 78 | private ImageView motionView; 79 | @FXML 80 | private AnchorPane pdPane; 81 | @FXML 82 | private TitledPane dataPane; 83 | @FXML 84 | private TextField fname; 85 | @FXML 86 | private TextField lname; 87 | @FXML 88 | private TextField code; 89 | @FXML 90 | private TextField reg; 91 | @FXML 92 | private TextField sec; 93 | @FXML 94 | private TextField age; 95 | @FXML 96 | public ListView logList; 97 | @FXML 98 | public ListView output; 99 | @FXML 100 | public ProgressIndicator pb; 101 | @FXML 102 | public Label savedLabel; 103 | @FXML 104 | public Label warning; 105 | @FXML 106 | public Label title; 107 | @FXML 108 | public TilePane tile; 109 | @FXML 110 | public TextFlow ocr; 111 | //********************************************************************************************** 112 | FaceDetector faceDetect = new FaceDetector(); //Creating Face detector object 113 | ColoredObjectTracker cot = new ColoredObjectTracker(); //Creating Color Object Tracker object 114 | Database database = new Database(); //Creating Database object 115 | 116 | OCR ocrObj = new OCR(); 117 | ArrayList user = new ArrayList(); 118 | ImageView imageView1; 119 | 120 | public static ObservableList event = FXCollections.observableArrayList(); 121 | public static ObservableList outEvent = FXCollections.observableArrayList(); 122 | 123 | public boolean enabled = false; 124 | public boolean isDBready = false; 125 | 126 | 127 | //********************************************************************************************** 128 | public void putOnLog(String data) { 129 | 130 | Instant now = Instant.now(); 131 | 132 | String logs = now.toString() + ":\n" + data; 133 | 134 | event.add(logs); 135 | 136 | logList.setItems(event); 137 | 138 | } 139 | 140 | @FXML 141 | protected void startCamera() throws SQLException { 142 | 143 | //******************************************************************************************* 144 | //initializing objects from start camera button event 145 | faceDetect.init(); 146 | 147 | faceDetect.setFrame(frame); 148 | 149 | faceDetect.start(); 150 | 151 | if (!database.init()) { 152 | 153 | putOnLog("Error: Database Connection Failed ! "); 154 | 155 | } else { 156 | isDBready = true; 157 | putOnLog("Success: Database Connection Succesful ! "); 158 | } 159 | 160 | //******************************************************************************************* 161 | //Activating other buttons 162 | startCam.setVisible(false); 163 | eyeBtn.setDisable(false); 164 | stopBtn.setVisible(true); 165 | //ocrBtn.setDisable(false); 166 | capBtn.setDisable(false); 167 | motionBtn.setDisable(false); 168 | gesture.setDisable(false); 169 | saveBtn.setDisable(false); 170 | 171 | if (isDBready) { 172 | recogniseBtn.setDisable(false); 173 | } 174 | 175 | dataPane.setDisable(false); 176 | // shapeBtn.setDisable(false); 177 | smileBtn.setDisable(false); 178 | fullBodyBtn.setDisable(false); 179 | upperBodyBtn.setDisable(false); 180 | 181 | if (stopRecBtn.isDisable()) { 182 | stopRecBtn.setDisable(false); 183 | } 184 | //******************************************************************************************* 185 | 186 | 187 | tile.setPadding(new Insets(15, 15, 55, 15)); 188 | tile.setHgap(30); 189 | 190 | //********************************************************************************************** 191 | //Picture Gallary 192 | 193 | String path = filePath; 194 | 195 | File folder = new File(path); 196 | File[] listOfFiles = folder.listFiles(); 197 | 198 | //Image reader from the mentioned folder 199 | for (final File file : listOfFiles) { 200 | 201 | imageView1 = createImageView(file); 202 | tile.getChildren().addAll(imageView1); 203 | } 204 | putOnLog(" Real Time WebCam Stream Started !"); 205 | 206 | //********************************************************************************************** 207 | } 208 | int count = 0; 209 | 210 | @FXML 211 | protected void faceRecognise() { 212 | 213 | 214 | faceDetect.setIsRecFace(true); 215 | // printOutput(faceDetect.getOutput()); 216 | 217 | recogniseBtn.setText("Get Face Data"); 218 | 219 | //Getting detected faces 220 | user = faceDetect.getOutput(); 221 | 222 | if (count > 0) { 223 | 224 | //Retrieved data will be shown in Fetched Data pane 225 | String t = "********* Face Data: " + user.get(1) + " " + user.get(2) + " *********"; 226 | 227 | outEvent.add(t); 228 | 229 | String n1 = "First Name\t\t:\t" + user.get(1); 230 | 231 | outEvent.add(n1); 232 | 233 | output.setItems(outEvent); 234 | 235 | String n2 = "Last Name\t\t:\t" + user.get(2); 236 | 237 | outEvent.add(n2); 238 | 239 | output.setItems(outEvent); 240 | 241 | String fc = "Face Code\t\t:\t" + user.get(0); 242 | 243 | outEvent.add(fc); 244 | 245 | output.setItems(outEvent); 246 | 247 | String r = "Reg no\t\t\t:\t" + user.get(3); 248 | 249 | outEvent.add(r); 250 | 251 | output.setItems(outEvent); 252 | 253 | String a = "Age \t\t\t\t:\t" + user.get(4); 254 | 255 | outEvent.add(a); 256 | 257 | output.setItems(outEvent); 258 | String s = "Section\t\t\t:\t" + user.get(5); 259 | 260 | outEvent.add(s); 261 | 262 | output.setItems(outEvent); 263 | 264 | } 265 | 266 | count++; 267 | 268 | putOnLog("Face Recognition Activated !"); 269 | 270 | stopRecBtn.setDisable(false); 271 | 272 | } 273 | 274 | @FXML 275 | protected void stopRecognise() { 276 | 277 | faceDetect.setIsRecFace(false); 278 | faceDetect.clearOutput(); 279 | 280 | this.user.clear(); 281 | 282 | recogniseBtn.setText("Recognise Face"); 283 | 284 | stopRecBtn.setDisable(true); 285 | 286 | putOnLog("Face Recognition Deactivated !"); 287 | 288 | } 289 | 290 | @FXML 291 | protected void startMotion() { 292 | 293 | faceDetect.setMotion(true); 294 | putOnLog("motion Detector Activated !"); 295 | 296 | } 297 | 298 | @FXML 299 | protected void saveFace() throws SQLException { 300 | 301 | //Input Validation 302 | if (fname.getText().trim().isEmpty() || reg.getText().trim().isEmpty() || code.getText().trim().isEmpty()) { 303 | 304 | new Thread(() -> { 305 | 306 | try { 307 | warning.setVisible(true); 308 | 309 | Thread.sleep(2000); 310 | 311 | warning.setVisible(false); 312 | 313 | } catch (InterruptedException ex) { 314 | } 315 | 316 | }).start(); 317 | 318 | } else { 319 | //Progressbar 320 | pb.setVisible(true); 321 | 322 | savedLabel.setVisible(true); 323 | 324 | new Thread(() -> { 325 | 326 | try { 327 | 328 | faceDetect.setFname(fname.getText()); 329 | 330 | faceDetect.setFname(fname.getText()); 331 | faceDetect.setLname(lname.getText()); 332 | faceDetect.setAge(Integer.parseInt(age.getText())); 333 | faceDetect.setCode(Integer.parseInt(code.getText())); 334 | faceDetect.setSec(sec.getText()); 335 | faceDetect.setReg(Integer.parseInt(reg.getText())); 336 | 337 | database.setFname(fname.getText()); 338 | database.setLname(lname.getText()); 339 | database.setAge(Integer.parseInt(age.getText())); 340 | database.setCode(Integer.parseInt(code.getText())); 341 | database.setSec(sec.getText()); 342 | database.setReg(Integer.parseInt(reg.getText())); 343 | 344 | database.insert(); 345 | 346 | javafx.application.Platform.runLater(new Runnable(){ 347 | 348 | @Override 349 | public void run() { 350 | pb.setProgress(100); 351 | } 352 | }); 353 | 354 | 355 | 356 | 357 | savedLabel.setVisible(true); 358 | Thread.sleep(2000); 359 | 360 | javafx.application.Platform.runLater(new Runnable(){ 361 | 362 | @Override 363 | public void run() { 364 | pb.setVisible(false); 365 | } 366 | }); 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | javafx.application.Platform.runLater(new Runnable(){ 375 | 376 | @Override 377 | public void run() { 378 | savedLabel.setVisible(false); 379 | } 380 | }); 381 | 382 | } catch (InterruptedException ex) { 383 | } 384 | 385 | }).start(); 386 | 387 | faceDetect.setSaveFace(true); 388 | 389 | } 390 | 391 | } 392 | 393 | @FXML 394 | protected void stopCam() throws SQLException { 395 | 396 | faceDetect.stop(); 397 | 398 | startCam.setVisible(true); 399 | stopBtn.setVisible(false); 400 | 401 | /* this.saveFace=true; */ 402 | 403 | putOnLog("Cam Stream Stopped!"); 404 | 405 | recogniseBtn.setDisable(true); 406 | saveBtn.setDisable(true); 407 | dataPane.setDisable(true); 408 | stopRecBtn.setDisable(true); 409 | eyeBtn.setDisable(true); 410 | smileBtn.setDisable(true); 411 | fullBodyBtn.setDisable(true); 412 | upperBodyBtn.setDisable(true); 413 | 414 | database.db_close(); 415 | putOnLog("Database Connection Closed"); 416 | isDBready=false; 417 | } 418 | 419 | @FXML 420 | protected void ocrStart() { 421 | 422 | try { 423 | 424 | Text text1 = new Text(ocrObj.init()); 425 | 426 | text1.setStyle("-fx-font-size: 14; -fx-fill: blue;"); 427 | 428 | ocr.getChildren().add(text1); 429 | 430 | } catch (FontFormatException e) { 431 | 432 | e.printStackTrace(); 433 | } 434 | 435 | } 436 | 437 | @FXML 438 | protected void capture() { 439 | 440 | faceDetect.setOcrMode(true); 441 | 442 | } 443 | 444 | @FXML 445 | protected void startGesture() { 446 | 447 | faceDetect.stop(); 448 | cot.init(); 449 | 450 | Thread th = new Thread(cot); 451 | th.start(); 452 | 453 | gesture.setVisible(false); 454 | gestureStop.setVisible(true); 455 | 456 | } 457 | 458 | @FXML 459 | protected void startEyeDetect() { 460 | 461 | faceDetect.setEyeDetection(true); 462 | eyeBtn.setDisable(true); 463 | 464 | } 465 | 466 | @FXML 467 | protected void upperBodyStart() { 468 | 469 | faceDetect.setUpperBody(true); 470 | ; 471 | upperBodyBtn.setDisable(true); 472 | 473 | } 474 | 475 | @FXML 476 | protected void fullBodyStart() { 477 | 478 | faceDetect.setFullBody(true); 479 | fullBodyBtn.setDisable(true); 480 | 481 | } 482 | 483 | @FXML 484 | protected void smileStart() { 485 | 486 | faceDetect.setSmile(true); 487 | smileBtn.setDisable(true); 488 | 489 | } 490 | 491 | @FXML 492 | protected void stopGesture() { 493 | 494 | cot.stop(); 495 | faceDetect.start(); 496 | 497 | gesture.setVisible(true); 498 | gestureStop.setVisible(false); 499 | 500 | } 501 | 502 | @FXML 503 | protected void shapeStart() { 504 | 505 | // faceDetect.stop(); 506 | 507 | SquareDetector shapeFrame = new SquareDetector(); 508 | shapeFrame.loop(); 509 | 510 | } 511 | 512 | private ImageView createImageView(final File imageFile) { 513 | 514 | try { 515 | final Image img = new Image(new FileInputStream(imageFile), 120, 0, true, true); 516 | imageView1 = new ImageView(img); 517 | 518 | imageView1.setStyle("-fx-background-color: BLACK"); 519 | imageView1.setFitHeight(120); 520 | 521 | imageView1.setPreserveRatio(true); 522 | imageView1.setSmooth(true); 523 | imageView1.setCache(true); 524 | 525 | } catch (FileNotFoundException e) { 526 | e.printStackTrace(); 527 | } 528 | 529 | return imageView1; 530 | } 531 | 532 | } 533 | -------------------------------------------------------------------------------- /src/application/Sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 30 | 34 | 59 | 79 | 84 | 89 | 96 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 149 | 154 | 155 | 156 | 161 | 166 | 167 | 168 | 169 | 174 | 179 | 180 | 181 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 |
276 | -------------------------------------------------------------------------------- /target/classes/application/Sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 30 | 34 | 59 | 79 | 84 | 89 | 96 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 149 | 154 | 155 | 156 | 161 | 166 | 167 | 168 | 169 | 174 | 179 | 180 | 181 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 |
276 | -------------------------------------------------------------------------------- /src/application/FaceDetector.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import application.FaceRecognizer; 4 | import java.awt.BasicStroke; 5 | 6 | import java.awt.Color; 7 | import java.awt.Font; 8 | import java.awt.Graphics2D; 9 | import java.awt.image.BufferedImage; 10 | import java.io.File; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | import java.io.OutputStream; 14 | import java.sql.SQLException; 15 | import java.time.Instant; 16 | import java.util.ArrayList; 17 | 18 | import javax.imageio.ImageIO; 19 | 20 | import org.bytedeco.javacpp.FlyCapture2.ImageMetadata; 21 | import org.bytedeco.javacpp.Loader; 22 | import org.bytedeco.javacpp.opencv_objdetect; 23 | import org.bytedeco.javacpp.helper.opencv_core; 24 | import org.bytedeco.javacpp.opencv_core.Mat; 25 | import org.bytedeco.javacv.CanvasFrame; 26 | import org.bytedeco.javacv.Frame; 27 | import org.bytedeco.javacv.FrameGrabber; 28 | import org.bytedeco.javacv.Java2DFrameConverter; 29 | import org.bytedeco.javacv.OpenCVFrameConverter; 30 | import org.bytedeco.javacv.OpenCVFrameGrabber; 31 | import static org.bytedeco.javacpp.opencv_core.*; 32 | import static org.bytedeco.javacpp.opencv_imgproc.*; 33 | import static org.bytedeco.javacpp.opencv_imgcodecs.*; 34 | import static org.bytedeco.javacpp.opencv_objdetect.*; 35 | 36 | import javafx.collections.FXCollections; 37 | import javafx.collections.ObservableList; 38 | import javafx.embed.swing.SwingFXUtils; 39 | import javafx.fxml.FXML; 40 | import javafx.scene.chart.PieChart.Data; 41 | import javafx.scene.control.Label; 42 | import javafx.scene.control.ListView; 43 | import javafx.scene.image.ImageView; 44 | import javafx.scene.image.WritableImage; 45 | import application.Database; 46 | import application.MotionDetector; 47 | import application.ColoredObjectTracker; 48 | import application.SquareDetector; 49 | 50 | public class FaceDetector implements Runnable { 51 | 52 | Database database = new Database(); 53 | ArrayList user; 54 | 55 | FaceRecognizer faceRecognizer = new FaceRecognizer(); 56 | MotionDetector motionDetector = new MotionDetector(); 57 | OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage(); 58 | Java2DFrameConverter paintConverter = new Java2DFrameConverter(); 59 | ArrayList output = new ArrayList(); 60 | 61 | @FXML 62 | public Label ll; 63 | private Exception exception = null; 64 | 65 | private int count = 0; 66 | public String classiferName; 67 | public File classifierFile; 68 | 69 | 70 | public boolean saveFace = false; 71 | public boolean isRecFace = false; 72 | public boolean isOutput = false; 73 | public boolean isOcrMode = false; 74 | public boolean isMotion = false; 75 | public boolean isEyeDetection = false; 76 | public boolean isSmile = false; 77 | public boolean isUpperBody = false; 78 | public boolean isFullBody = false; 79 | private boolean stop = false; 80 | 81 | private CvHaarClassifierCascade classifier = null; 82 | private CvHaarClassifierCascade classifierEye = null; 83 | private CvHaarClassifierCascade classifierSideFace = null; 84 | private CvHaarClassifierCascade classifierUpperBody = null; 85 | private CvHaarClassifierCascade classifierFullBody = null; 86 | private CvHaarClassifierCascade classifierSmile = null; 87 | private CvHaarClassifierCascade classifierEyeglass = null; 88 | 89 | 90 | public CvMemStorage storage = null; 91 | private FrameGrabber grabber = null; 92 | private IplImage grabbedImage = null, temp, temp2, grayImage = null, smallImage = null; 93 | public ImageView frames2; 94 | public ImageView frames; 95 | 96 | 97 | private CvSeq faces = null; 98 | private CvSeq eyes = null; 99 | private CvSeq smile = null; 100 | private CvSeq upperBody = null; 101 | private CvSeq sideface = null; 102 | private CvSeq fullBody = null; 103 | 104 | 105 | 106 | int recogniseCode; 107 | public int code; 108 | public int reg; 109 | public int age; 110 | 111 | public String fname; //first name 112 | public String Lname; //last name 113 | public String sec; //section 114 | public String name; 115 | 116 | public void init() { 117 | faceRecognizer.init(); 118 | 119 | setClassifier("haar/haarcascade_frontalface_alt.xml"); 120 | setClassifierEye("haar/haarcascade_eye.xml"); 121 | setClassifierEyeGlass("haar/haarcascade_eye_tree_eyeglasses.xml"); 122 | setClassifierSideFace("haar/haarcascade_profileface.xml"); 123 | setClassifierFullBody("haar/haarcascade_fullbody.xml"); 124 | setClassifierUpperBody("haar/haarcascade_upperbody.xml"); 125 | setClassifierSmile("haar/haarcascade_smile.xml"); 126 | 127 | } 128 | 129 | public void start() { 130 | try { 131 | new Thread(this).start(); 132 | } catch (Exception e) { 133 | if (exception == null) { 134 | exception = e; 135 | 136 | } 137 | } 138 | } 139 | 140 | public void run() { 141 | try { 142 | try { 143 | grabber = OpenCVFrameGrabber.createDefault(0); //parameter 0 default camera , 1 for secondary 144 | 145 | grabber.setImageWidth(700); 146 | grabber.setImageHeight(700); 147 | grabber.start(); 148 | 149 | grabbedImage = grabberConverter.convert(grabber.grab()); 150 | 151 | storage = CvMemStorage.create(); 152 | } catch (Exception e) { 153 | if (grabber != null) 154 | grabber.release(); 155 | grabber = new OpenCVFrameGrabber(0); 156 | grabber.setImageWidth(700); 157 | grabber.setImageHeight(700); 158 | grabber.start(); 159 | grabbedImage = grabberConverter.convert(grabber.grab()); 160 | 161 | } 162 | int count = 15; 163 | grayImage = cvCreateImage(cvGetSize(grabbedImage), 8, 1); //converting image to grayscale 164 | 165 | //reducing the size of the image to speed up the processing 166 | smallImage = cvCreateImage(cvSize(grabbedImage.width() / 4, grabbedImage.height() / 4), 8, 1); 167 | 168 | stop = false; 169 | 170 | while (!stop && (grabbedImage = grabberConverter.convert(grabber.grab())) != null) { 171 | 172 | Frame frame = grabberConverter.convert(grabbedImage); 173 | BufferedImage image = paintConverter.getBufferedImage(frame, 2.2 / grabber.getGamma()); 174 | Graphics2D g2 = image.createGraphics(); 175 | 176 | if (faces == null) { 177 | cvClearMemStorage(storage); 178 | 179 | //creating a temporary image 180 | temp = cvCreateImage(cvGetSize(grabbedImage), grabbedImage.depth(), grabbedImage.nChannels()); 181 | 182 | cvCopy(grabbedImage, temp); 183 | 184 | cvCvtColor(grabbedImage, grayImage, CV_BGR2GRAY); 185 | cvResize(grayImage, smallImage, CV_INTER_AREA); 186 | 187 | //cvHaarDetectObjects(image, cascade, storage, scale_factor, min_neighbors, flags, min_size, max_size) 188 | faces = cvHaarDetectObjects(smallImage, classifier, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING); 189 | //face detection 190 | 191 | CvPoint org = null; 192 | if (grabbedImage != null) { 193 | 194 | if (isEyeDetection) { //eye detection logic 195 | eyes = cvHaarDetectObjects(smallImage, classifierEye, storage, 1.1, 3, 196 | CV_HAAR_DO_CANNY_PRUNING); 197 | 198 | if (eyes.total() == 0) { 199 | eyes = cvHaarDetectObjects(smallImage, classifierEyeglass, storage, 1.1, 3, 200 | CV_HAAR_DO_CANNY_PRUNING); 201 | 202 | } 203 | 204 | printResult(eyes, eyes.total(), g2); 205 | 206 | } 207 | 208 | if (isFullBody) { //full body detection logic 209 | fullBody = cvHaarDetectObjects(smallImage, classifierFullBody, storage, 1.1, 3, 210 | CV_HAAR_DO_CANNY_PRUNING); 211 | 212 | if (fullBody.total() > 0) { 213 | printResult(fullBody, fullBody.total(), g2); 214 | } 215 | 216 | } 217 | 218 | if (isUpperBody) { 219 | try { 220 | upperBody = cvHaarDetectObjects(smallImage, classifierUpperBody, storage, 1.1, 3, 221 | CV_HAAR_DO_CANNY_PRUNING); 222 | 223 | if (upperBody.total() > 0) { 224 | printResult(upperBody, upperBody.total(), g2); 225 | } 226 | 227 | } catch (Exception e) { 228 | 229 | e.printStackTrace(); 230 | } 231 | } 232 | 233 | if (isSmile) { 234 | try { 235 | smile = cvHaarDetectObjects(smallImage, classifierSmile, storage, 1.1, 3, 236 | CV_HAAR_DO_CANNY_PRUNING); 237 | 238 | if (smile != null) { 239 | printResult(smile, smile.total(), g2); 240 | } 241 | } catch (Exception e) { 242 | 243 | e.printStackTrace(); 244 | } 245 | 246 | } 247 | 248 | if (isOcrMode) { 249 | try { 250 | 251 | OutputStream os = new FileOutputStream("captures.png"); 252 | ImageIO.write(image, "PNG", os); 253 | } catch (IOException e) { 254 | 255 | e.printStackTrace(); 256 | } 257 | } 258 | 259 | isOcrMode = false; 260 | 261 | if (faces.total() == 0) { 262 | faces = cvHaarDetectObjects(smallImage, classifierSideFace, storage, 1.1, 3, 263 | CV_HAAR_DO_CANNY_PRUNING); 264 | 265 | } 266 | 267 | if (faces != null) { 268 | g2.setColor(Color.green); 269 | g2.setStroke(new BasicStroke(2)); 270 | int total = faces.total(); 271 | 272 | for (int i = 0; i < total; i++) { 273 | 274 | //printing rectange box where face detected frame by frame 275 | CvRect r = new CvRect(cvGetSeqElem(faces, i)); 276 | g2.drawRect((r.x() * 4), (r.y() * 4), (r.width() * 4), (r.height() * 4)); 277 | 278 | CvRect re = new CvRect((r.x() * 4), r.y() * 4, (r.width() * 4), r.height() * 4); 279 | 280 | cvSetImageROI(temp, re); 281 | 282 | // File f = new File("captures.png"); 283 | 284 | org = new CvPoint(r.x(), r.y()); 285 | 286 | if (isRecFace) { 287 | String names="Unknown Person!"; 288 | this.recogniseCode = faceRecognizer.recognize(temp); 289 | 290 | //getting recognised user from the database 291 | 292 | if(recogniseCode != -1) 293 | { 294 | database.init(); 295 | user = new ArrayList(); 296 | user = database.getUser(this.recogniseCode); 297 | this.output = user; 298 | 299 | names = user.get(1) + " " + user.get(2); 300 | } 301 | 302 | //printing recognised person name into the frame 303 | g2.setColor(Color.WHITE); 304 | g2.setFont(new Font("Arial Black", Font.BOLD, 20)); 305 | 306 | g2.drawString(names, (int) (r.x() * 6.5), r.y() * 4); 307 | 308 | } 309 | 310 | if (saveFace) { //saving captured face to the disk 311 | //keep it in mind that face code should be unique to each person 312 | String fName = "faces/" + code + "-" + fname + "_" + Lname + "_" + count + ".jpg"; 313 | cvSaveImage(fName, temp); 314 | count++; 315 | 316 | } 317 | 318 | } 319 | this.saveFace = false; 320 | faces = null; 321 | } 322 | 323 | WritableImage showFrame = SwingFXUtils.toFXImage(image, null); 324 | 325 | javafx.application.Platform.runLater(new Runnable(){ 326 | 327 | @Override 328 | public void run() { 329 | frames.setImage(showFrame); 330 | } 331 | }); 332 | 333 | if (isMotion) { 334 | new Thread(() -> { 335 | 336 | try { 337 | 338 | motionDetector.init(grabbedImage, g2); 339 | 340 | } catch (InterruptedException ex) { 341 | } catch (Exception e) { 342 | 343 | e.printStackTrace(); 344 | } 345 | 346 | }).start(); 347 | 348 | } 349 | isMotion = false; 350 | 351 | } 352 | cvReleaseImage(temp); 353 | } 354 | 355 | } 356 | 357 | } catch (Exception e) { 358 | if (exception == null) { 359 | exception = e; 360 | 361 | } 362 | } 363 | } 364 | 365 | public void stop() { 366 | stop = true; 367 | 368 | grabbedImage = grayImage = smallImage = null; 369 | try { 370 | grabber.stop(); 371 | } catch (org.bytedeco.javacv.FrameGrabber.Exception e) { 372 | 373 | e.printStackTrace(); 374 | } 375 | try { 376 | grabber.release(); 377 | } catch (org.bytedeco.javacv.FrameGrabber.Exception e) { 378 | 379 | e.printStackTrace(); 380 | } 381 | grabber = null; 382 | } 383 | 384 | public void setClassifier(String name) { 385 | 386 | try { 387 | 388 | setClassiferName(name); 389 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 390 | 391 | if (classifierFile == null || classifierFile.length() <= 0) { 392 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 393 | } 394 | 395 | // Preload the opencv_objdetect module to work around a known bug. 396 | Loader.load(opencv_objdetect.class); 397 | classifier = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 398 | classifierFile.delete(); 399 | if (classifier.isNull()) { 400 | throw new IOException("Could not load the classifier file."); 401 | } 402 | 403 | } catch (Exception e) { 404 | if (exception == null) { 405 | exception = e; 406 | 407 | } 408 | } 409 | 410 | } 411 | 412 | public void setClassifierEye(String name) { 413 | 414 | try { 415 | 416 | classiferName = name; 417 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 418 | 419 | if (classifierFile == null || classifierFile.length() <= 0) { 420 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 421 | } 422 | 423 | // Preload the opencv_objdetect module to work around a known bug. 424 | Loader.load(opencv_objdetect.class); 425 | classifierEye = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 426 | classifierFile.delete(); 427 | if (classifier.isNull()) { 428 | throw new IOException("Could not load the classifier file."); 429 | } 430 | 431 | } catch (Exception e) { 432 | if (exception == null) { 433 | exception = e; 434 | 435 | } 436 | } 437 | 438 | } 439 | 440 | public void setClassifierSmile(String name) { 441 | 442 | try { 443 | 444 | setClassiferName(name); 445 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 446 | 447 | if (classifierFile == null || classifierFile.length() <= 0) { 448 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 449 | } 450 | 451 | // Preload the opencv_objdetect module to work around a known bug. 452 | Loader.load(opencv_objdetect.class); 453 | classifierSmile = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 454 | classifierFile.delete(); 455 | if (classifier.isNull()) { 456 | throw new IOException("Could not load the classifier file."); 457 | } 458 | 459 | } catch (Exception e) { 460 | if (exception == null) { 461 | exception = e; 462 | 463 | } 464 | } 465 | 466 | } 467 | 468 | public void printResult(CvSeq data, int total, Graphics2D g2) { 469 | for (int j = 0; j < total; j++) { 470 | CvRect eye = new CvRect(cvGetSeqElem(eyes, j)); 471 | 472 | g2.drawOval((eye.x() * 4), (eye.y() * 4), (eye.width() * 4), (eye.height() * 4)); 473 | 474 | } 475 | } 476 | 477 | public void setClassifierSideFace(String name) { 478 | 479 | try { 480 | 481 | classiferName = name; 482 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 483 | 484 | if (classifierFile == null || classifierFile.length() <= 0) { 485 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 486 | } 487 | 488 | // Preload the opencv_objdetect module to work around a known bug. 489 | Loader.load(opencv_objdetect.class); 490 | classifierSideFace = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 491 | classifierFile.delete(); 492 | if (classifier.isNull()) { 493 | throw new IOException("Could not load the classifier file."); 494 | } 495 | 496 | } catch (Exception e) { 497 | if (exception == null) { 498 | exception = e; 499 | 500 | } 501 | } 502 | 503 | } 504 | 505 | public void setClassifierFullBody(String name) { 506 | 507 | try { 508 | 509 | setClassiferName(name); 510 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 511 | 512 | if (classifierFile == null || classifierFile.length() <= 0) { 513 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 514 | } 515 | 516 | // Preload the opencv_objdetect module to work around a known bug. 517 | Loader.load(opencv_objdetect.class); 518 | classifierFullBody = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 519 | classifierFile.delete(); 520 | if (classifier.isNull()) { 521 | throw new IOException("Could not load the classifier file."); 522 | } 523 | 524 | } catch (Exception e) { 525 | if (exception == null) { 526 | exception = e; 527 | 528 | } 529 | } 530 | 531 | } 532 | 533 | public void setClassifierEyeGlass(String name) { 534 | 535 | try { 536 | 537 | setClassiferName(name); 538 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 539 | 540 | if (classifierFile == null || classifierFile.length() <= 0) { 541 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 542 | } 543 | 544 | // Preload the opencv_objdetect module to work around a known bug. 545 | Loader.load(opencv_objdetect.class); 546 | classifierEyeglass = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 547 | classifierFile.delete(); 548 | if (classifier.isNull()) { 549 | throw new IOException("Could not load the classifier file."); 550 | } 551 | 552 | } catch (Exception e) { 553 | if (exception == null) { 554 | exception = e; 555 | 556 | } 557 | } 558 | 559 | } 560 | 561 | public void setClassifierUpperBody(String name) { 562 | 563 | try { 564 | 565 | classiferName = name; 566 | classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); 567 | 568 | if (classifierFile == null || classifierFile.length() <= 0) { 569 | throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); 570 | } 571 | 572 | // Preload the opencv_objdetect module to work around a known bug. 573 | Loader.load(opencv_objdetect.class); 574 | classifierUpperBody = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); 575 | classifierFile.delete(); 576 | if (classifier.isNull()) { 577 | throw new IOException("Could not load the classifier file."); 578 | } 579 | 580 | } catch (Exception e) { 581 | if (exception == null) { 582 | exception = e; 583 | 584 | } 585 | } 586 | 587 | } 588 | 589 | public String getClassiferName() { 590 | return classiferName; 591 | } 592 | 593 | public void setClassiferName(String classiferName) { 594 | this.classiferName = classiferName; 595 | } 596 | 597 | public void setFrames2(ImageView frames2) { 598 | this.frames2 = frames2; 599 | } 600 | 601 | public void setSmile(boolean isSmile) { 602 | this.isSmile = isSmile; 603 | } 604 | 605 | public void setUpperBody(boolean isUpperBody) { 606 | this.isUpperBody = isUpperBody; 607 | } 608 | 609 | public void setFullBody(boolean isFullBody) { 610 | this.isFullBody = isFullBody; 611 | } 612 | 613 | public boolean isEyeDetection() { 614 | 615 | return isEyeDetection; 616 | } 617 | 618 | public void setEyeDetection(boolean isEyeDetection) { 619 | this.isEyeDetection = isEyeDetection; 620 | } 621 | 622 | public boolean getOcrMode() { 623 | return isOcrMode; 624 | } 625 | 626 | public void setOcrMode(boolean isOcrMode) { 627 | this.isOcrMode = isOcrMode; 628 | } 629 | 630 | public void destroy() { 631 | } 632 | 633 | public boolean isMotion() { 634 | return isMotion; 635 | } 636 | 637 | public void setMotion(boolean isMotion) { 638 | this.isMotion = isMotion; 639 | } 640 | 641 | public ArrayList getOutput() { 642 | return output; 643 | } 644 | 645 | public void clearOutput() { 646 | this.output.clear(); 647 | } 648 | 649 | public void setOutput(ArrayList output) { 650 | this.output = output; 651 | } 652 | 653 | public int getRecogniseCode() { 654 | return recogniseCode; 655 | } 656 | 657 | public void setRecogniseCode(int recogniseCode) { 658 | this.recogniseCode = recogniseCode; 659 | } 660 | 661 | public int getCode() { 662 | return code; 663 | } 664 | 665 | public void setCode(int code) { 666 | this.code = code; 667 | } 668 | 669 | public String getFname() { 670 | return fname; 671 | } 672 | 673 | public void setFname(String fname) { 674 | this.fname = fname; 675 | } 676 | 677 | public String getLname() { 678 | return Lname; 679 | } 680 | 681 | public void setLname(String lname) { 682 | Lname = lname; 683 | } 684 | 685 | public int getReg() { 686 | return reg; 687 | } 688 | 689 | public void setReg(int reg) { 690 | this.reg = reg; 691 | } 692 | 693 | public int getAge() { 694 | return age; 695 | } 696 | 697 | public void setAge(int age) { 698 | this.age = age; 699 | } 700 | 701 | public String getSec() { 702 | return sec; 703 | } 704 | 705 | public void setSec(String sec) { 706 | this.sec = sec; 707 | } 708 | 709 | public void setFrame(ImageView frame) { 710 | this.frames = frame; 711 | } 712 | 713 | public void setSaveFace(Boolean f) { 714 | this.saveFace = f; 715 | } 716 | 717 | public Boolean getIsRecFace() { 718 | return isRecFace; 719 | } 720 | 721 | public void setIsRecFace(Boolean isRecFace) { 722 | this.isRecFace = isRecFace; 723 | } 724 | 725 | 726 | } 727 | --------------------------------------------------------------------------------