[pHash-support] Java usage of pHash.java
Sebastian Gallese
sebastiangallese at gmail.com
Mon Jan 11 09:30:13 PST 2010
Hi Evan,
I'm unsure of how I should use pHash with Java. Do you have some
basic test code or demo code to show me the basic usage?
For example, right now I'm trying to call on pHash to get a hash from an image.
I threw the file from pHash-0.7.2/bindings/java/pHash.java into a
package in Eclipse.
http://github.com/sgallese/sgallese/tree/master/src/pHashTest/
As you can see from the above code, I have phash.java side by side
with PHashTest.java in a package caled pHashTest
In PHashTest.java, I just wanted to instantiate pHash, so I have the
following code:
package pHashTest;
public class PHashTest {
public static void main(String[] args) {
pHash mypHash = new pHash();
}
}
I kept getting the error "java.lang.UnsatisfiedLinkError: no pHash-jni
in java.library.path" so I searched for pHash-jni on my system and
found these:
/usr/local/include/pHash-jni.h
/usr/local/lib/libpHash-jni.so
/usr/local/lib/libpHash-jni.so.0
/usr/local/lib/libpHash-jni.so.0.0.0
/usr/local/lib/libpHash-jni.la
/usr/local/lib/libpHash-jni.a
In Eclipse, I then went to run -> run configurations -> Environment
(tab) and I set LD_LIBRARY_PATH to /usr/local/lib/
Then I tried to initiate a pHash object again (i.e., pHash mypHash =
new pHash(); ) and I'd get the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/usr/local/lib/libpHash-jni.so.0.0.0:
/usr/local/lib/libpHash-jni.so.0.0.0: undefined symbol:
_ZL17ph_free_datapointP12ph_datapoint
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at pHashTest.pHash.<clinit>(pHash.java:47)
at pHashTest.PHashTest.main(PHashTest.java:6)
I figured I'd then try to make an ImageHash object using the code
ImageHash mypHash = new ImageHash("/home/kdge/Pictures/cc.jpg");
but ImageHash would not take a string in its constructor.
Any help is greatly appreciated!
Thanks,
Seb
More information about the pHash-support
mailing list