Using tess4j, ghostscript and Java with Eclipse on mac - java

I am trying to get tess4j working in a simple test application to perform OCR on a pdf file but receive the following error and cannot fathom out how to resolve it:
Exception in thread "main" java.lang.RuntimeException: Unable to load library 'gs': dlopen(libgs.dylib, 9): image not found
Please download, install GPL Ghostscript from http://sourceforge.net/projects/ghostscript/files and/or set the appropriate environment variable.
at net.sourceforge.vietocr.PdfUtilities.convertPdf2Tiff(Unknown Source)
at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at Test.main(Test.java:11)
I have got eclipse to print out my path file as it sees it and it contains /usr/loca/bin/gs (checked as correct with which gs) as needed and I can happily run gs from the terminal. Any ideas on how to get this working?
The code is shown in the image at https://dl.dropboxusercontent.com/u/61920208/Screen%20Shot%202013-09-02%20at%2013.44.24.png
Thanks in advance for any help

As per the suggestion, reinstalling ghostsrcipt (via ports rather than the dmg)sorted this out for me.

Related

Geotools "Failed to load the GDAL native libs." at runtime, OK in Eclipse

I'm trying to run the GeoTools ImageLab.java exmaple. It works fine inside Eclipse and I'm using Maven as in the instructions. I'm trying to load a GeoTIFF. But when I use Eclipse to build a runnable jar file and run that from a DOS command line I get:
Jun 11, 2018 6:49:57 PM it.geosolutions.imageio.gdalframework.GDALUtilities loadGDAL
WARNING: Failed to load the GDAL native libs. This is not a problem unless you need to use the GDAL plugins: they won't be enabled.
java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsupportedOperationException: Trying to get a reader from an unknown format.
at org.geotools.coverage.grid.io.UnknownFormat.getReader(UnknownFormat.java:53)
at org.geotools.tutorial.raster.ImageLab.displayLayers(ImageLab.java:103)
at org.geotools.tutorial.raster.ImageLab.getLayersAndDisplay(ImageLab.java:87)
at org.geotools.tutorial.raster.ImageLab.main(ImageLab.java:61)
The JNI reference makes me think I need a gdal dll file, but I'm having trouble finding one if that's the case.
All help appreciated! Thanks in advance.
If you are using the gt-imageio-ext-gdal module then you will need to make sure that the JVM can see your gdal libraries and that they are the exact version expected by the module. There are detailed instructions on how to install that on the related GeoServer page.
However, for a simple GeoTiff there is no need for GDAL as this is handled by the gt-geotiff module.
Finally, if you are trying to build a single jar application you should make sure you have read and understood this FAQ entry.

java.lang.UnsatisfiedLinkError while calling a dll from java

I have a java programm which needs a .jar and a .dll file. If running the java programm from command line it works. Running it out of eclipse I get the following error:
java.lang.UnsatisfiedLinkError: com.osisoft.rdsa.RDSAChannel.GetDASVersion(J)S
at com.osisoft.rdsa.RDSAChannel.GetDASVersion(Native Method)
at com.osisoft.rdsa.RDSAChannel.<init>(RDSAChannel.java:58)
at com.osisoft.rdsa.NativeRDSA.create(NativeRDSA.java:185)
at com.osisoft.rdsa.NativeRDSA.create(NativeRDSA.java:127)
at com.osisoft.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:75)
at com.osisoft.jdbc.DriverExtension.connect(DriverExtension.java:121)
at com.osisoft.jdbc.Driver.connect(Driver.java:261)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at testclients.jtesterbase.JTesterBase.connect(JTesterBase.java:417)
at testclients.jtesterbase.JTesterBase.init(JTesterBase.java:182)
at testclients.jtesterbase.JTesterBase.main(JTesterBase.java:552)
what is the problem?
The .dll file is in C:\Windows\system\32\RDSAWrapper64.dll, so it has already be in the java.lang search path.
What environment changes between executing on console and executing in eclipse?
Has somebody some tips. I tried to fix it for hours.
Thanks so much for your help.

Unsatisfied Link Error BluetoothStackBlueSoleil

I'm trying to use bluetooth for a java application, I'm on Windows 7 64bit.
I'm following this example
http://luugiathuy.com/2011/02/android-java-bluetooth/
Turned out I had problem with the bluecove.jar proposed on that site, so I found this thread
http://code.google.com/p/bluecove/issues/detail?id=109
telling me to get this .jar:
http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.62/
Alright then!
But now, I'm facing a new error (yaay...):
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: com.intel.bluetooth.BluetoothStackBlueSoleil.getLibraryVersion()I
at com.intel.bluetooth.BluetoothStackBlueSoleil.getLibraryVersion(Native Method)
at com.intel.bluetooth.BlueCoveImpl.setBluetoothStack(BlueCoveImpl.java:964)
at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:502)
at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:69)
at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1044)
at java.security.AccessController.doPrivileged(Native Method)
at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1042)
at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1035)
at javax.bluetooth.LocalDevice.getLocalDeviceInstance(LocalDevice.java:75)
at javax.bluetooth.LocalDevice.getLocalDevice(LocalDevice.java:95)
at BTThread.waitForConnection(BTThread.java:35)
at BTThread.run(BTThread.java:23)
at java.lang.Thread.run(Unknown Source)
So.. would anyone have any idea why?
The BluetoothStackBlueSoleil seems to be in the .jar I downloaded, so I don't get the unstatisfied link error...
Thanks for any help
I solved my problem by removing Bluesoleil from my computer and installing different Bluetooth drivers.
I think the problem was that there was native methods that you needed to build. You have to compile the native code from the JNI folder using the Android NDK. ndk-build etc
Just in case you see the problem again.

7Zip-JBinding UnsatisfiedLinkError

I've looked through a number of the UnsatisfiedLinkError threads on here and nothing seems to quite fit my problem.
I am trying to get this api working: 7ZipBind
However I am having an issue, and cant get the thing to work. I am running some of its example code from the commandline like so:
C:>java -classpath
"/sevenzipTest.jar;/sevenzipjbinding-AllWindows.jar;\sevenzipjbinding.jar"
com.poc.sevenzip.SevenZipSimple c:\archive\test.zip
However when I try to run it I get the error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Users\XXXX\AppData\Local\Temp\SevenZipJBinding-9640553\lib7-Zip-JBinding.dll: Can't
find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJARIntern(SevenZip.java:428)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJAR(SevenZip.java:235)
at net.sf.sevenzipjbinding.SevenZip.ensureLibraryIsInitialized(SevenZip.java:578)
at net.sf.sevenzipjbinding.SevenZip.openInArchive(SevenZip.java:567)
at com.poc.sevenzip.SevenZipSimple.runZip(SevenZipSimple.java:25)
at com.poc.sevenzip.SevenZipSimple.main(SevenZipSimple.java:64
What I am confused about, is why it says it cant locate the libraries (dll files), when the libraries are stored within the <file_path>/sevenzipjbinding-AllWindows.jar file... I am obviously not doing something correct here, and was hoping some1 can give me some pointers.
Cheers
The bug fix was released. Please, use version 1.06rc or above.
Download URL:
All versions
4.65-1.06rc-extr-only
The following instructions are for Windows x86 and 7 Zip JBinding version 4.65-1.05 RC. Download the following DLLs.
libstdc++-6.dll
libgcc_s_dw2-1.dll
gpsvc.dll
sysntfy.dll
Add the DLLs into the Windows-x86 directory in sevenzipjbinding-AllPlatforms.jar. Then append the following lines to sevenzipjbinding-lib.properties in the Windows-x86 directory in the jar.
sevenzipjbinding.libname.3=gpsvc.dll
sevenzipjbinding.libname.4=libgcc_s_dw2-1.dll
sevenzipjbinding.libname.5=libstdc++-6.dll
sevenzipjbinding.libname.6=sysntfy.dll
Instead of modifying the jar file, one could put the DLLs in the PATH (not classpath).
In order to figure this out, I extracted lib7-Zip-JBinding.dll from sevenzipjbinding-AllPlatforms.jar. I then opened the file in Dependency Walker.

Javacv UnsatisfiedLinkError in windows 7

In my project I want to capture image from my webcam.
I configured step by step following the instructions from this "OpenCV-JavaCV : eclipse project configuration windows 7" blog post.
After configuration is finished, i tested samples codes and the application found my webcam
SETUP: Setting up device 0
SETUP: Namuga 1.3M Webcam
SETUP: Couldn't find preview pin using SmartTee
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.
and then i got an error which is .dll error.
I use windows 7 x64.
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: C:\Users\Administrator\AppData\Local\Temp\javacpp153028723186\jniopencv_core.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:418)
at com.googlecode.javacpp.Loader.load(Loader.java:368)
at com.googlecode.javacpp.Loader.load(Loader.java:315)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:334)
at com.googlecode.javacpp.Loader.load(Loader.java:315)
at com.googlecode.javacv.cpp.opencv_core$CvArr.<clinit>(opencv_core.java:158)
at com.googlecode.javacv.VideoInputFrameGrabber.grab(VideoInputFrameGrabber.java:158)
at GrabberShow.run(GrabberShow.java:24)
at java.lang.Thread.run(Unknown Source)
How can i solve this problem?
Check whether your Opencv version and JavaCv versions are matching each other. You can check that on the readme file on javacv-bin it specifically say about the required version of the opencv.
Unsatisfied link means that not all native code libraries required by jniopencv_core.dll could be found.
Did you deploy them all or just jniopencv_core.dll?
I faced this problem on Windows XP and Windows 7, and this is how I fixed it on both platforms, using Netbeans 7.2:
Install all required software:
FFmpeg (32-bit shared): Zeranoe FFmpeg offers win32 builds. Download and extract ffmpeg-20121020-git-04bf2e7-win32-shared.7z. Place its content at C:\ffmpeg.
Note: make sure C:\ffmpeg\bin is a valid path.
OpenCV 2.4.2 (32-bit): download OpenCV-2.4.2.exe and extract it. Place its content at C:\opencv.
Note: make sure C:\opencv\build\x86\vc10\bin is valid path.
JavaCV 0.2: download javacv-0.2-bin.zip and extract it. Move the extracted folder to C:\javacv-bin.
Microsoft Visual C++ redistributable package (32-bit): download and install vcredist_x86.exe.
Configure the environment:
Edit the environment variable PATH and append the following paths at the end:
C:\ffmpeg\bin;C:\opencv\build\x86\vc10\bin
Now you ready to create a new Netbeans project and test your application. But before you compile it,dDon't forget to right-click the Libraries folder at the pProjects window* and click Add Jar/FOLDER to select all the .jar files located at C:\javacv-bin.
Make sure you have the vm arg -Djava.library.path=<path-to-native> that points to the directory with your dlls.

Categories