oconnorhorrill / Face-Recognition

Implementation of java face recogniser with OpenCV with windows .dll and .jar
Apache License 2.0
14 stars 16 forks source link

code in netbeans #2

Open oconnorhorrill opened 8 years ago

oconnorhorrill commented 8 years ago

facerecognition

sa94my commented 7 years ago

i was hoping you could help me on this this error appears as soon as the program runs ,and the camera doesn't open java.lang.NullPointerException at userrecognition.FXController.trainModel(FXController.java:263) at userrecognition.FXController.init(FXController.java:115) at userrecognition.Main.start(Main.java:49) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745)

oconnorhorrill commented 7 years ago

That’s annoying. Its late night here so I can’t try to replicate the issue. Are you trying the windows version or running this on Linux? I’ve not seen this runtime error before. When you run the app, does the FX gui come up, and then it crashes when you start the camera? If Windows, I presume you have openCV and the DLL correctly located.

sa94my commented 7 years ago

first of all i can't explain how grateful i'm for your quick response and i'm trying the windows version,and both openCV and the DLL are correctly located the gui comes up , it doesn't crash i mean it remains open but the error is displayed in the output window and when i start the camera it shows even more errors related to the classifier like this

OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp, line 1639 ERROR: CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp:1639: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale ]

sa94my commented 7 years ago

if i may ask did you use jdk 8 developing this program ? the first problem might be related to Init() method , and i tried searching about it but all i could understand is that due to changing syntax in jdk 8 it might give null output (pardon me for poor description i'm still a beginner) all i could found about the second one is that the classifier doesn't exit where the code implies , my question is does the dependency of folders matter ? my configuration is (src,lib) src->(resources,userrecognition)

oconnorhorrill commented 7 years ago

Hi sa94my, error indicates the issue is with openCV and not the java code. You’ll find even slightly different versions of openCV will cause issues. From what I see here I check you have the haar classifier in the right location and make sure you have set the OpenCV enviroment variable and add it to the systems path. There’s good docs here.

sa94my commented 7 years ago

Hi oconnorhorrill i managed to solve the first error by installing jdk 64-bit instead of the 32-bit one i had , because the DLL you edited wasn't being used as the JVM ran the 32-bit one -Djava.library.path="C:\opencv\build\java\x86" so i figured i needed to change my jdk version and now i'm working on the second error which appears when i start the camera ,hope you can give me some guidelines

oconnorhorrill commented 7 years ago

Thanks for the feedback. It’s always like this when loading a github app onto a machine.

What kind of machine are you running this on. OpenCV should be able to detect your camera

sa94my commented 7 years ago

it did detect the camera inside FXcontroller.java -> haarSelected method i changed the path in this.checkboxSelection to the absolute path on my pc and now the camera starts

conidering the output I've got to line 294 what should i do in this line ?

also ; it detects my face but says (prediction=unknown confidence=(random number))

oconnorhorrill commented 7 years ago

What does it say about line 294 in the log?

sa94my commented 7 years ago

it's in the output window you used a println statement in line 287 System.out.println("I've got to line 294"); likely this line BasicFaceRecognizer faceRecognizer = Face.createFisherFaceRecognizer(0,1500);

i know i asked too many questions but hopefully this will be the last one
faceRecognizer.save("traineddata"); where is this traineddata file ?? and if i'm supposed to create it what type of file should i create ? and thank you very much for tolerating me

oconnorhorrill commented 7 years ago

Yes, I keep forgetting to delete the comment on line 287

No you don’t need to save the data with this app. If it is detecting your face but not recognising you take a look at what is in your resource folder, how many images of you are there and do you have any image different from you (something to compare with). What camera are you using? You will find openCV is hopelessly reliant on lighting conditions.

sa94my commented 7 years ago

i thank you so much for your collaboration ,the app is now working , all i had to do was to change paths of the folders in the code

oconnorhorrill commented 7 years ago

Pleased you got it going sa94my. Any comments on how your implementation is performing re: face recognition?

Don’t forget to add a star if this was useful.