Wrapping C++ code with SWIG to be used in Processing.org - java

I'd like to use some C++ libraries in a Processing project but I am not sure how to do it (I am completely newbie in Processing and Java).
The way I proceeded is by using SWIG to create a shared library (.so) that can be then loaded (using the System.load command) in a Java application in the same way as explained in the tutorial:
http://www.swig.org/tutorial.html
This might be a super basic question, but my doubt is (I have not been able to find a solution in Google or Stackoverflow) how do I import this library into Processing?
Using the example provided in the link, neither:
# I compiled the library with .so rather than .dll, I am using Mac OS X
System.load("/path/to/example.so")
nor
# Putting the example.so file in the library folder
System.loadLibrary("example")
seem to actually import the library. When I try to do something like:
double var = example.fact(5);
Processing complains saying that "Cannot find anything named example". Could you help me with this? Any hint or resource that explains on how to import .so libraries in Processing would be greatly appreciated.
Many thanks!
#Tryskele

Related

How to access gRPC server in matlab?

We have moved our DataAccess logic to Microservice and it is currently implemented as gRPC with C++ and we are able to utilize that in C# client and C++ client.
Now we have to make use of this DataAccess grpc in Matlab client(legacy). So, i'm trying to find a way to access gRPC from Matlab and found that there is no official support for this.
I found two solutions,
Using Java
I have tried as suggested in this thread. i have created a sample grpc client java using Eclipse. but when i try to access that class/methods from matlab, i'm facing below issue,
Java exception occurred:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
at io.grpc.Metadata$Key.validateName(Metadata.java:630)
at io.grpc.Metadata$Key.<init>(Metadata.java:638)
at io.grpc.Metadata$Key.<init>(Metadata.java:568)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:743)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:738)
at io.grpc.Metadata$Key.of(Metadata.java:594)
at io.grpc.Metadata$Key.of(Metadata.java:590)
at io.grpc.internal.GrpcUtil.<clinit>(GrpcUtil.java:84)
at io.grpc.internal.AbstractManagedChannelImplBuilder.<clinit>(AbstractManagedChannelImplBuilder.java:83)
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:37)
at io.grpc.netty.NettyChannelProvider.builderForAddress(NettyChannelProvider.java:23)
at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:37)
it was discussed here,and it says it is not possible anymore. Can anyone let me know whether this is possible now or i am missing something?
Using Matlab Proto Compiler [Farsounder]
Next i have tried to use Farsounder solution v2.5.0 for creating stub files based on this.
Only after creating protoc.exe, I realized it was for Proto V2. So, now i'm trying use Protov3Matlab.
But the build instructions are not clear here and it has one cmake file and i dont know how to run it. Can anyone help me build this for windows environment?
I'm new to Java and Matlab, sorry if i have missed any obvious things.
Thanks in advance.
I was able to create protoc.exe.
Steps:
Checked out latest protobuf source.
Updated the source with farsounder matlab source and cmake file.
Followed https://github.com/protocolbuffers/protobuf/blob/master/cmake/README.md build the source.

Windows FileChooser Or Save File Dialog Handling Using JACOB Or JNA

I need to access the windows native file upload and save window using java.
Though it is not possible only using java so I try this using jacob and JNA library.
Actually I also need to handle the any type of pop up message from OS.
There are lots of any other approach using java robot,sikuli,autoit but i want to stick(learn)
on jacob or jna.
Can any body help me regarding this problem.Any code snippet on this, helpful for me not only that if some body told me how to get hwnd ID dword ID which is need to pass into the different methods that also be useful for me.
Im guessing you were referring to CFileDialog or OpenFileDialog, well that can be accomplished via JNI and a native DLL which you need to compile yourself, which is somewhat easy:
create a C++ DLL - project in visual studio, i'd recommend using MFC - methods which are called via C-functions, that'll make everything MUCH easier since you wont need to re-invent the wheel and create WindowProcs yourself and whatnot - MFC does all of that transparently. You could also create a CLR-DLL which uses WinForms but thats a bit more complex. Do yourself a favor and disregard anything about MinGW, GCC or even any other OSS-solution if you want to create native windows ... that'll give you headaches, trust me. Within windows, you will need to use microsoft-libraries if you want to create Microsoft-compatible user interfaces, everything else is very error-prone.
include jni.h which is found in your JDK-library
write a JNI-compatible method signature
compile
declare compatible, native methods in java
compile
try to run your java project
report back, i shall help you to some extent if you run into any problems
JNI howto

Use Processing PDE files within Java?

I have a working Java code that I would like to visualize using processing. I also found the tutorial on how to include processing within eclipse and am also already able to create a canvas, etc.
What I want to do now is to actually do the visualization. I found a nice project that is exactly what I need. However, the author provides PDE files.
How can I include PDE files in my java project? Is that even possible?
The PDE files that are available in that project are simply text files. You can either use them in your code directly, or better yet, try to understand what they're doing and adapt the code to your own purposes.
But to answer your question, you don't include PDE files in a Java project. You included the Processing library jars on your classpath, which give you access to things like the PApplet class. Then you can include a PApplet (which is just like a Processing sketch, in fact a Processing sketch is a PApplet) in your Java application and pass it whatever information you want.
More info here: http://processing.org/tutorials/eclipse/

Convert C++ OpenCV code to Java

I have a C/C++ OpenCV source code (which works fine) and I am rewritting it in Java using OpenCV (not JavaCV). I cannot find the correspoding Java class for CvBGCodeBookModel.
I have searched thoroughly the OpenCV-Java site and many results from Google, I have also looked in many files in the OpenCV directory for any clues.
The closest that I have found is class Algorithm
(http://docs.opencv.org/java/2.4.2/org/opencv/core/Algorithm.html &
http://docs.opencv.org/java/org/opencv/core/Algorithm.html )
but I cannot find how to use some methods e.g.:
- cvBGCodeBookUpdate
- cvBGCodeBookClearStale
- cvBGCodeBookDiff
(The program was not initially written by me and I do not fully understand it but I have managed to add some functionality in the C/C++ version. If you need the source code inform me.)
Can anyone help me?
Thanks in advance

AccessBridgeDebug.h missing?

I'm at my wits end with this Java Bridge, after trying to force it to do what I want in C# I've abandoned the idea and started to stagger my way through Visual C++, however I'm running into constant problems which I'm slowly resolving. Except this one!
I'm missing an include file called AccessBridgeDebug.h. << TL:DR read here.
I can't even compile ANYTHING that uses the includes for AccessBridge because they all reference the debug file, and it just flat out does not come with the package I downloaded, or the one prior to it on the website. Google yields 0 results for the search term "AccessBridgeDebug.h" which has caused me to realise I rely on google far too much.
Please, someone, help.
For those who have the same problem, the solution was fairly simple. The Java Access Bridge 2.0.2 only contains updated files, not the entire package. Furthermore, there is no readily available download link to the 2.0.2 full installer.
To fix it, go here: https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html#accessbridge-2.0.1-oth-JPR (Located accessbridge-2_0_1-manual_install\src\bridge\src\AccessBridgeDebug.h)
And download the 2.0.1 full source. All the missing header/c++ files can be found in here.

Categories

Resources