t-oster / VisiCam

A Java application, that turns a webcam into a VisiCut compatible network camera with marker detection and perspective correction. Uses OpenCV through JavaCV
Other
36 stars 12 forks source link

"libjniopencv_core.so: cannot open shared object file: No such file or directory" #3

Closed peteruithoven closed 10 years ago

peteruithoven commented 10 years ago

After trying the following installation method

sudo apt-get update
sudo apt-get install libopencv-dev
sudo apt-get install python-opencv
sudo apt-get install ant
sudo apt-get install openjdk-7-jdk

Maybe the right java needs to be selected?
sudo update-alternatives --config java
select: "/usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java"

Install the camera, see:
http://www.raspberrypi.org/camera

cd ~
git clone https://github.com/t-oster/VisiCam.git
cd VisiCam
sudo cp javacv-pi/javacv.jar javacv-bin/
ant jar
java -jar dist/VisiCam.jar

Configure it to use the pi camera:
Goto: localhost:8080/configPage.html
Check "CustomCapture"
CaptureCommand: raspistill -o image.jpg
CaptureResult: image.jpg

And press save I have the following in the terminal:

Listening on http://192.168.1.165:8080. Hit Enter to stop.

Responding to discovery packets on UDP:8888
Exception in thread "Thread-7" java.lang.UnsatisfiedLinkError: /tmp/javacpp860851686547/libjniopencv_core.so: /tmp/javacpp860851686547/libjniopencv_core.so: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1953)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1878)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1839)
    at java.lang.Runtime.load0(Runtime.java:795)
    at java.lang.System.load(System.java:1061)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:422)
    at com.googlecode.javacpp.Loader.load(Loader.java:372)
    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:91)
    at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:170)
    at com.t_oster.visicam.CameraController.takeSnapshot(CameraController.java:53)
    at com.t_oster.visicam.VisiCamServer.serveRawImage(VisiCamServer.java:126)
    at com.t_oster.visicam.VisiCamServer.serve(VisiCamServer.java:137)
    at gr.ktogias.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:443)
    at java.lang.Thread.run(Thread.java:724)

I'm probably missing something around opencv... I'll also be looking into this myself some more.

peteruithoven commented 10 years ago

After building (ant jar) I also moved the .jar's from javacv-pi to dist/lib, but this also doesn't seem to help. Precise commands:

sudo cp lib/javacv-pi/javacv.jar dist/lib/
sudo cp lib/javacv-pi/javacv-linux-arm.jar dist/lib/
peteruithoven commented 10 years ago

What I don't understand is that OpenCVFrameGrabber.start is called... And because of the error it can't save the settings, so it will never try the Custom CaptureCommand.

Could not save settings to /home/pi/VisiCam/visicam.conf
Settings will be reset after restart

I'm going to try the webcam capture branch

peteruithoven commented 10 years ago

It might be a permissions thing, I'm noticing I always have to use sudo, even for a "git pull" for example.

peteruithoven commented 10 years ago

Alright, I think the error was caused by the master branch it's openCV image capture. It didn't get to using my customcommand because openCV capture was probably the default. Next to that I had a access issue, so after changing the owner and group to pi I could finally save settings. Now it's actually taking pictures, but it can't find them afterwards... I used:

CaptureCommand: raspistill -o image.jpg
CaptureResult: image.jpg

and

CaptureCommand: raspistill -o ~/image.jpg
CaptureResult: ~/image.jpg

and

CaptureCommand: raspistill -o ~/VisiCam/image.jpg
CaptureResult: ~/VisiCam/image.jpg
peteruithoven commented 10 years ago

Can't really explain it, but now it can... screen shot 2013-11-08 at 1 49 40 am

#VisiCam Configuration
#Fri Nov 08 00:40:02 UTC 2013
markerSearchfields[3][y]=0.8
markerSearchfields[2][x]=0
markerSearchfields[1][height]=0.2
markerSearchfields[2][width]=0.2
captureCommand=raspistill -o visicam-capture.jpg
markerSearchfields[1][width]=0.2
markerSearchfields[0][y]=0
markerSearchfields[2][y]=0.8
markerSearchfields[1][x]=0.8
markerSearchfields[2][height]=0.2
inputHeight=1050
markerSearchfields[3][width]=0.2
markerSearchfields[0][height]=0.2
markerSearchfields[0][width]=0.2
cameraIndex=0
markerSearchfields[3][x]=0.8
outputHeight=1050
captureResult=visicam-capture.jpg
markerSearchfields[1][y]=0
markerSearchfields[0][x]=0
inputWidth=1680
markerSearchfields[3][height]=0.2
outputWidth=1680
peteruithoven commented 10 years ago

Conclusion: When you want to use a custom capture command you can ignore the error. When you save your custom command settings the error should disappear.

peteruithoven commented 10 years ago

I'm now getting the same error when it's looking for the markers:

Taking Snapshot...
Finding markers...
Exception in thread "Thread-33" java.lang.UnsatisfiedLinkError: /tmp/javacpp395248136172/libjniopencv_core.so: /tmp/javacpp395248136172/libjniopencv_core.so: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1953)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1878)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1839)
    at java.lang.Runtime.load0(Runtime.java:795)
    at java.lang.System.load(System.java:1061)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:422)
    at com.googlecode.javacpp.Loader.load(Loader.java:372)
    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    at com.googlecode.javacv.cpp.opencv_core$CvArr.<clinit>(opencv_core.java:158)
    at com.t_oster.visicam.CameraController.findMarker(CameraController.java:103)
    at com.t_oster.visicam.VisiCamServer.serveTransformedImage(VisiCamServer.java:175)
    at com.t_oster.visicam.VisiCamServer.serve(VisiCamServer.java:141)
    at gr.ktogias.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:443)
    at java.lang.Thread.run(Thread.java:724)

So I guess copying the Raspberry Pi specific javacv.jar and javacv-linux-arm.jar wasn't enough. I'll look into installing opencv some more.

peteruithoven commented 10 years ago

I followed the following tutorial to install opencv and I can compile and run the sample application. http://thinkrpi.wordpress.com/2013/04/05/step-3-install-softwares-for-webcam-and-computer-vision/

peteruithoven commented 10 years ago

If I understand the following, javacpp.jar contains paths to opencv. https://code.google.com/p/javacv/source/browse/src/main/java/com/googlecode/javacv/cpp/opencv_core.java#131 No clue how to figure out what the opencv path is of the javacpp.jar I'm using.

I also understand people have bin using javacv on Arch Linux (like mentioned in the readme) and they've compiled it themselves. I also read that you shouldn't use the debian repository installation when you want to compile it yourself, because it's very hard to remove the links it sets.

peteruithoven commented 10 years ago

I tried following the following tutorial to compile opencv, but no luck, also it... takes... ages... http://salaboy.com/2013/06/14/using-javacv-in-the-raspberry-pi-linux-arm/ So I've installed Arch linux and I'm trying my luck with that.

peteruithoven commented 10 years ago

I'm now pretty sure it failed because it ran out of space. (of course it didn't display this, it gave some vague compiler error. I used a 4GB memory, with the standard Raspbian. So now I'm trying with a 8GB card.

peteruithoven commented 10 years ago

This helped, opencv finally compiled.

peteruithoven commented 10 years ago

YES! Working on the Raspberry Pi, running Raspbian. screen shot 2013-11-20 at 11 52 26 am

After compiling and installing opencv I could compile javacp (this didn't work and didn't give useful feedback on Arch Linux), I then copied the created files to VisiCam using the following commands. cp ~/javacv/target/javacv-linux-arm.jar ~/VisiCam/dist/lib/ cp ~/javacv/target/javacv.jar ~/VisiCam/dist/lib/ cp ~/javacv/target/javacpp.jar ~/VisiCam/dist/lib/