Opencv native location set up for java-eclipse linux based - java

I am trying to setup a java based opencv program to run on raspberry-pi.I installed opencv-2.4.8 on my raspberry-pi. I also installed eclipse to set up opencv.The problem is i am not able to link native libraries for my opencv-2.4.8 jar file in eclipse.
Eclipse is running fine with raspberry-pi and i am able to compile and run simple java programs.From where to link the native library for opencv2.4.8 jar file.
I checked my opencv folder and it is having the following structure.
MY OpenCV Folder
Opencv release folder
Found the following opencv .so files in usr/local/lib folder of my pi. Is this is what i should link to my native library. But there are many .so files also.
The output console with the error is as follows. sorry the screenshot skipped unsatisfied link error..

I had the same error which come up like this. I have an application that I have to run. I build and install opencv and try to run but I see that error like you. For solving this issue I replace old opencv_*jar with built one in opencv directory. You have to use jar file that you have just built.
..../opencv/build/bin/opencv-2410.jar
I thing old jar looks for different native path.

I had the same issue. I set my Native Lib Location to {OpenCV directory}/{Build directory}/lib and things worked fine.

Related

Set up OpenNLP: Text Detection using the Vision java API

Set up OpenNLP
Download Tokenizer data and save it to this directory.
wget http://opennlp.sourceforge.net/models-1.5/en-token.bin
This is what Google asks me at here
I got no clue what OpenNLP is so I google it.
This is what Apache says on their Setup OpenNLP page:
If you have an IDE installed such as NetBeans or Eclipse installed, it
will make your development easier. However, follow on for the brave.
I got Intellij NetBeans, how do I set it up?
When building with maven in Intellij and attempting to run this sample, this is the error that I get:
java.io.FileNotFoundException: en-token.bin (The system cannot find the file specified)
When I try to continue with Google doc I fail in this line:
java -cp target/vision-text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp data/
With an error:
Error: Could not find or load main class com.google.cloud.vision.samples.text.TextApp
It looks like all you need from OpenNLP is that Tokeniser .bin file - this is just a binary file that the library uses to tokeise text (e.g. split sentences into words). It would appear like there is nothing else you need from that library - If you look in the google vision pom file(https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/vision/text/pom.xml) you will see they have a dependency on the OpenNLP JAR, so here you are just grabbing the pre-trained resource for that library.
Assuming you have cloned that GitHub repo, and have successfuly run the maven command they mention:
mvn clean compile assembly:single
Then that downloaded file (en-token.bin) should be copied to the root of the project directory (the same location as the pom.xml and where you are running the java command).
If the setup is like that then it should work ok.

UnsatisfiedLinkError Java with Rxtx library

I am trying to communicate to Arduino with Java, so I'm using the rxtx library. I've downloaded the library and placed the respective files in my java project's folder. I put the rxtxxjar in a lib folder in the java project's folder, and I left the serial.jnlib straight into the java project's folder. I've taken the SerialTest code off of the arduino website, and I've tried to run it but I keep getting the UnsatisfiedLinkError. I've researched this question, and I've seen people saying basically the following in different ways:
Go to Project -> properties -> Java build path ->Find your .jar. Click
on + to open the JAR's properties. Select Native library location and
edit it to point to RXTX's shared library (.DLL, .so, .dylib).
However, I have no idea how to do the pointing to the shared library, especially since I don't see any .dll, .so, or .dylib file, and I cannot use the .jnlib because it is greyed out. Also on a smaller note, by my .jar is that just the project? I work in Eclipse Java EE.
You can use
System.load("Absolute path to your jni library");
This works fine on my project.

Unable to load library 'libtesseract302' in Play project

I'm trying to use tess4j in a play project. I have put tess4j.jar, libtesseract302.dll and liblept168.dll in play project lib folder and setting java.library.path and jna.library.path when starting play server like this:
play -Djava.library.path=lib -Djna.library.path=lib start
Note that i have used 64-bit dlls which have been released here: https://github.com/charlesw/tesseract/tree/master/src/lib/TesseractOcr/x64. This link has been stated in Tess4j official website as well.
But still, i'm getting " Unable to load library 'libtesseract302'" exception. I tried to set the absolute path of lib folder too, nothing works.
Any help would be much appreciated.
Thanks.
For using Tess4j try putting the libtesseract302.dll in the Project Folder and not in the lib Folder.
That is how it worked in my project.
But The error can be a result from various situations other than the location of .dll file
This problem may arise when -
You are trying run Tess4j on a 64 bit JVM instead of 32 bit, it gives the same error inspite of placing the .dll files into the perfect location
You do not have Microsoft Visual C++ 2008 redistributable installed (Specifically 2008)
http://www.microsoft.com/en-in/download/details.aspx?id=29
After fixing all these it should work
Put the JAR in the classpath. java.library.path is for the native libraries (.dll, .so, .dylib).

Java project won't compile to a JAR correctly for Android

in an app I'm working on I have an issue with a Java library which is here - https://github.com/kennydude/Boid-Twitter-API
When I run ant android which builds an Android package it builds fine and Eclipse can read the Jar fine.
But on my device it says that dalvik cannot locate any of the classes and eventually throws a ClassDef Exception.
I have used Jars before, so I'm wondering if it's my ant file that's broken
I would open your app project in eclipse (the one that depends on the Java library that is not found at run-time) and add the jar file the Java library produced to its build path. Then execute
android -s update project -p .
in the same directory as your apps' Manifest.xml file in order do generate ant build files.
After this, you should be able to build your app using ant by doing
ant debug
or
ant release
I fixed it by ensuring Ant was compiling to 1.6 of Java which is my target in Eclipse for the application.
Perhaps you're not placing your jar in the libs directory as opposed to lib directory? Here's a similar issue Java (Android) - class not found exception
First of all to build an apk with ant for Android you have to use ant debug or ant release, i don't know what ant android does and why you are using it but this command is not part of the standard approach to ant for Android, that's for sure.
Ant is just a building tools, if a developer provide a building solution in ant, does not mean that his application is for Android.
Under Android everything that is not a native library is converted in a DEX object, which is something similar to bytecode for the Dalvik, there is no jar or other container in your app.
This question may be helpful for you Adding a library/JAR to an Eclipse Android project .
There are a lot of conceptual errors in this topic, you probably want to study the Android platform before using it.

FreeTTS Portability Issue

I'm writing an application that makes use of Java's speech API and FreeTTS. The application works fine when I run it from the Netbeans IDE, but when I try to run it from a jar file on my local machine or on other machines, I get the following error:
"java.lang.NoClassDefFoundError: com/sun/speech/freetts/VoiceManager"
Is there any way for me to include the FreeTTS files in my jar file so it can run anywhere?
Any help would be greatly appreciated.
i had the same problem and i found this page:
http://ondra.zizka.cz/stranky/programovani/java/misc/freetts-line-unavailable-classcastexception-kevinvoicedirectory-error-opening-zipfile.texy
I did the easy way, which was to add the freetts installation to my dist folder, change the manifest of my jar on where to find the jsapi.jar, freetts.jar etc. and it is worked. I am just distributing freetts inside my folder.
The hard way is on the link above.

Categories