Java OpenCV Facial Recognition

asked 2014-06-24 07:11:30 -0500

gunmania0 gravatar image

updated 2014-06-24 07:14:29 -0500

berak gravatar image

Hi All,

I'm writing a facial recognition program in Java. I've looked on the "Open CV known issues" and discovered that functions to create an instance of the FaceRecognizer class haven't been mapped.

Is there any way round this issue?

edit retag flag offensive close merge delete

Comments

1

see here

berak gravatar imageberak ( 2014-06-24 07:25:57 -0500 )edit

@berak Cheers, I'll try that, if I have any problems I'll return! Thanks!

gunmania0 gravatar imagegunmania0 ( 2014-06-24 07:33:00 -0500 )edit

@berak How do I put the cpp file into a .so file, should I place it into the OpenCV files and then rebuild? If that's the case, where would I put the cpp file?

gunmania0 gravatar imagegunmania0 ( 2014-06-24 07:36:53 -0500 )edit
  • you will have to compile it using gcc or cl. (similar to any opencv cpp sample program. only difference is, that the output is a dll/so not an executable)

  • no, that's not part of the opencv codebase, put it in it's own folder

berak gravatar imageberak ( 2014-06-24 07:41:23 -0500 )edit

@berak Sorry to be a pain, I don't program in C++! Could you give me an example gcc command to build the .so file? Also it's saying jni.h can't be found, so i assume i need to give it an additional link to where it is? (I'm on mac)

gunmania0 gravatar imagegunmania0 ( 2014-06-24 07:50:53 -0500 )edit
  • it's not you, who is a pain, more like this is a painful process.
  • jni.h should be in your java sdk /include

something similar to:

g++ facerec.cpp -I/your/opencv/includes -I/jdk/include -L/path/to/opencvlibs -lopencv_contrib -lopencv_core -lopencv_ml -dl -o facerec.so

(the -dl makes an so of it)

berak gravatar imageberak ( 2014-06-24 07:56:24 -0500 )edit

@berak This is what i've got

>g++ facerec.cpp -I/mypath/opencv-2.4.9/build/include -I/System/Library/Frameworks/JavaVM.framework/Headers/ -I/mypath/opencv-2.4.9/build/lib -lopencv_contrib -lopencv_core -lopencv_ml -dl -o facerec.so

Yet i'm still getting missing symbols specifically std::terminate()

gunmania0 gravatar imagegunmania0 ( 2014-06-24 08:20:26 -0500 )edit

sorry but no idea about apple here

berak gravatar imageberak ( 2014-06-24 08:22:50 -0500 )edit

@berak the issue was resolved by adding -c it was looking for a main method. So now do i add it to my eclipse project as a library same as when I did OpenCV?

gunmania0 gravatar imagegunmania0 ( 2014-06-24 08:33:32 -0500 )edit

sorry, but imho -c only compiles, but does not link it .

and again, i only tried on win, and all i had to do was to drop the resulting dll into the eclipse project folder.

berak gravatar imageberak ( 2014-06-24 08:42:09 -0500 )edit