Hot questions for Using Ubuntu in opencv

Question:

I am new to use opencv to detect different parts of body just like Ear,Neck,Wrist,Face,etc....

Faces and ear can be detected from the camera But I need to detect the remaining parts of body..

How to detect them ?

I tried the all given haarcascade_XXX.xml files but I can't found any haarcascade_neck.xml or haarcascade_wrist.xml files though I can detect them.

I don't know what to do please help me....

Thanks in advance...


Answer:

I had the similar problem..tried many ways to do it but still no accurate. Solution I have tried 1>Get the chin point from ASM detector(With MUCT database) to detect chin point and by biometric calculation just add the half height of rectangle detected from Haarcascade of face. 2>Train your own ASM for the neck detection.You need to collect samples of the images and train it.Use Haarcasade for upper body part detection.Plenty of tutorial are available to train the ASM.

But let me remind you both are approximate solution,it may fail for most of the cases.

Question:

I wrote a java code to open an app and do some changes in it using sikulix api. The code works fine on windows but it gets this error on linux ubuntu:

[error] RunTimeAPI: loadLib: opencv_java not usable: 
java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path
[error] RunTimeAPI:  *** terminating: problem with native library: opencv_java

I downloaded opencv-4.1.0 and built it then copied the generated opencv-410.jar and libopencv_java410.so files into the lib directory of the project but the error exists yet.


Answer:

I created a link to libopencv_java410.so in /usr/lib/ and the problem is solved!

Question:

I saw many questions like this one but I couldn't get any answer.. I installed opencv2.4.9 as in this tutorial: http://www.samontab.com/web/2014/06/installing-opencv-2-4-9-in-ubuntu-14-04-lts/#comment-35200 and everything went OK. When I tried running my Java project in Eclipse I run into this error:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path

I saw in another answer that I need to set opencv in the user libraries but I don't have a "opencv/build/java" folder and I already try to set it to the path where the .jar file is in it. I have no idea what to do.. Any thought?


Answer:

Check your Native library location configuration:

  • Goto Eclipse -> Window -> Preferences:

    make sure path is like: /opencv-2.4.9/build/java/x64

Question:

I tried adding the FaceRecognition wrapper for Opencv in java after this example. I had some issues since I'm trying to do this on Ubuntu, but I was able to create the .so file in the end.

Still I can't use it since I get the error:

/usr/lib/jvm/java-7-openjdk-amd64/bin/java: symbol lookup error: /home/vlad/workspace/HelloJNI/jni/libRecognizer.so: undefined symbol: _ZN2cv24createLBPHFaceRecognizerEiiiid

My makefile looks like this:

# Define a variable for classpath
CLASS_PATH = ../bin

# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)

all : libRecognizer.so

# $@ matches the target, $< matches the first dependancy
libRecognizer.so : facerec.cpp
    g++ -fPIC -o $@ -shared -Wl,-rpath, -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" $<
    #cc -fPIC -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" -Wl, -shared -o $@ 

# $@ matches the target, $< matches the first dependancy
#HelloJNI.o : HelloJNI.c HelloJNI.h
#   gcc -m64 -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" -c $< -o $@

# $* matches the target filename without the extension
LBPHFaceRecognizer.h : LBPHFaceRecognizer.class
    javah -classpath $(CLASS_PATH):../jni/opencv-249.jar $*

clean :
    rm LBPHFaceRecognizer.h LBPHFaceRecognizer.o libRecognizer.so

I tried "ldd" and "libopencv_java249.so" seems to be there:

vlad@woow-1022:~/workspace/HelloJNI/jni$ ldd libRecognizer.so 
    linux-vdso.so.1 =>  (0x00007fff969fe000)
    /home/vlad/workspace/HelloJNI/jni/libopencv_java249.so (0x00007fb24797a000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb247658000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb247441000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb24723d000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb24701f000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb246e16000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb246b10000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb24674a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb248ed1000)

So I really don't know what to try next...

UPDATE:

I ended up doing something like this in the terminal:

g++ -L/usr/lib/jni -fPIC -o libRecognizer.so -shared -Wl,-rpath, -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" facerec.cpp -lopencv_java249

so for /usr/lib/jni/libopencv_java249.so I had to add -L/usr/lib/jni and -lopencv_java249


Answer:

I ended up doing something like this in the terminal:

g++ -L/usr/lib/jni -fPIC -o libRecognizer.so -shared -Wl,-rpath, -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" facerec.cpp -lopencv_java249

Question:

I followed this tutorial and I got stuck at the "make all" step.

I got the following error:

javah -classpath ../bin HelloJNI
gcc -m64 -Wl,--add-stdcall-alias -shared -o libHello.so HelloJNI.o
/usr/bin/ld: unrecognized option '--add-stdcall-alias'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
make: *** [libHello.so] Error 1

makefile looks like this:

    # Define a variable for classpath
CLASS_PATH = ../bin

# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)

all : libHello.so

# $@ matches the target, $< matches the first dependancy
libHello.so : HelloJNI.o
    gcc -m64 -Wl,--add-stdcall-alias -shared -o $@ $<

# $@ matches the target, $< matches the first dependancy
HelloJNI.o : HelloJNI.c HelloJNI.h
    gcc -m64 -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" -c $< -o $@

# $* matches the target filename without the extension
HelloJNI.h : HelloJNI.class
    javah -classpath $(CLASS_PATH) $*

clean :
    rm HelloJNI.h HelloJNI.o libHello.so

I tried just removing --add-stdcall-alias, and got:

gcc -m64 -Wl, -shared -o libHello.so HelloJNI.o
/usr/bin/ld: cannot find : No such file or directory
/usr/bin/ld: HelloJNI.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
HelloJNI.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libHello.so] Error 1

I tried adding -fPIC, but I got the same error.


Answer:

I ended up doing something like this from the terminal:

g++ -L/usr/lib/jni -fPIC -o libRecognizer.so -shared -Wl,-rpath, -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux" facerec.cpp -lopencv_java249

so what this says is that I needed to link the library libopencv_java249.so and I was able to do that through -L/usr/lib/jni and -lopencv_java249

"/usr/lib/jni" is the path to the library.