Dear all,
Time, and help, permitting I am trying to write a plugin that can interface with external programs ("libraries"). Basically, I would like to control our SEM through ImageJ, ultimately in an automated fashion. Our SEM's documentation says that it's control software has "a dll library through which external control is routed. This provides a documented set of functions which third-party applications can use to control the SEM." There is a library for both 16 bit or 32 bit interfacing, which have an associated header file. I am a little out of depth here and really have no idea at present whether such a thing is feasible!? Does anyone have any experience, pointers, suggestions in doing such things? Alternatively, does anyone know of any competent coders who may be able to do this for us (with potential payment)? If they do, they can contact me off-list. Thanks, Andy |
Hi Andy,
I assuming that you are using Windows - right? (But AFAIK what I say below also applies when trying to call any native libs in Linux, Mac and other OSses) Nevertheless, calling external non-Java libraries is not that easy, because you need to go through the so called Java Native Interface JNI. To make things worse, you simply cannot translate the caller list that your library has (which is described by the header file for C - for example) to a corresponding list in Java and call the function. This works only for outgoing (from Java to Native) scalar parameters and the call will add two extra parameters that your DLL will need to handle resp. will not understand. This is because both adress spaces of Java and native app are disjunct, you cannot simply hand over pointers to arrays and so on. So calling a native function from Java usually would mean writing a new wrapper for any new function that handles that special case, which involevs calling special functions from the native (DLL) side back into the JNI (using the two extra parameters) to copy and convert (do "marshalling") any complex arguments as pointers/references and feeding back data from native to Java. Pretty bothersome. However, there is help, I know of at least 2 commercial helper applications that claim to do the conversion automatically. If you know Matlab, it´s very similar to Matlabs DLL call mechanism, where you hand over the argument list to a special dll cal interface. The similarity is there because also Matlab also has a virtual machine architecture with JIT compilation and so on. (Sorry I don´t have the reference to those commercial applications handy, I´m just now on trip in China, I will add this later) Some time ago I proposed here that a project could/should be started on developing an independent, free alternative for such a DLL caller, I would be happy to join if there is any interest in starting this. Mit freundliche Grüßen / Sincerely Dr. Joachim Wesner Leica Microsystems CMS GmbH Abteilung FTO Ernst-Leitz-Straße 17-37 | 35578 Wetzlar (Germany) Tel. +49 6441 29 2611 | Fax +49 6441 29 2700 Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht Wetzlar HRB 2432 Geschäftsführer: Dr. Martin Haase | Colin Davis | Dr. Wolf-Otto Reuter http://www.leica-microsystems.com Andy Weller <[hidden email] .CH> An Gesendet von: [hidden email] ImageJ Interest Kopie Group <[hidden email]. Thema GOV> Interfacing with external programs 22.05.2007 00:46 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> Dear all, Time, and help, permitting I am trying to write a plugin that can interface with external programs ("libraries"). Basically, I would like to control our SEM through ImageJ, ultimately in an automated fashion. Our SEM's documentation says that it's control software has "a dll library through which external control is routed. This provides a documented set of functions which third-party applications can use to control the SEM." There is a library for both 16 bit or 32 bit interfacing, which have an associated header file. I am a little out of depth here and really have no idea at present whether such a thing is feasible!? Does anyone have any experience, pointers, suggestions in doing such things? Alternatively, does anyone know of any competent coders who may be able to do this for us (with potential payment)? If they do, they can contact me off-list. Thanks, Andy ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Andy Weller
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 > Time, and help, permitting I am trying to write a plugin that can > interface with external programs ("libraries"). The keyword here is (or was?*) Java Native Interface (JNI), such as specified here http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/jniTOC.html Links to tutorials and the like can be found e.g. at the bottom of http://java.sun.com/products/jdk/faq/jnifaq.html or through google. It's rather easy to use if you once follow a tutorial. The ImageJ plugin I wrote using JNI-calls is not very minimalistic, but for what it's worth the source is here: http://www.msc.univ-paris-diderot.fr/~daerr/progs/index#ScionFGAkiz HTH, Adrian * seems I can't find the Java Native Interface specification of Java 1.5 or 1.6; maybe just searching the wrong places. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGUvf7UKl/wQSyHWgRAnj3AJ9snqylZFxZIOs9qeRRhr3Xx3zuaACbBWxm Lq9/qGuRloDdG3hAert/xPo= =L/u4 -----END PGP SIGNATURE----- |
Hi,
Another technology that might be worth checking out is IKVM.NET, a JVM implementation for .NET and Mono. It can compile Java bytecode into CLI (i.e., convert JAR to DLL), which lets you use Java code within a .NET application, or compile a Java application into a .NET executable. So Java with C, C++ or C# is really straightforward, as long as it is managed code. The implementation supports most of Java 1.4 right now, excluding AWT and Swing, though support for AWT/Swing has been improving a lot lately. http://www.ikvm.net/ http://weblog.ikvm.net/CommentView.aspx?guid=e8206772-da68-4753-bb05-1ff5e4a90a8d I have not tried ImageJ with IKVM.NET, but it might be worth a shot, as it should be very quick to test. -Curtis On 5/22/07, Adrian Daerr <[hidden email]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > Time, and help, permitting I am trying to write a plugin that can > > interface with external programs ("libraries"). > > The keyword here is (or was?*) Java Native Interface (JNI), such as > specified here > > http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/jniTOC.html > > Links to tutorials and the like can be found e.g. at the bottom of > > http://java.sun.com/products/jdk/faq/jnifaq.html > > or through google. It's rather easy to use if you once follow a > tutorial. The ImageJ plugin I wrote using JNI-calls is not very > minimalistic, but for what it's worth the source is here: > > http://www.msc.univ-paris-diderot.fr/~daerr/progs/index#ScionFGAkiz > > HTH, > Adrian > > * seems I can't find the Java Native Interface specification of Java 1.5 > or 1.6; maybe just searching the wrong places. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGUvf7UKl/wQSyHWgRAnj3AJ9snqylZFxZIOs9qeRRhr3Xx3zuaACbBWxm > Lq9/qGuRloDdG3hAert/xPo= > =L/u4 > -----END PGP SIGNATURE----- > |
In reply to this post by Andy Weller
Dear all,
I have a macro that initiates with: setBatchMode(false); then switches to: setBatchMode(true); after some manual editing. However, during the macro I measure some Fourier descriptors and I can't seem to close the "Curvature values" window?! In my macro I have: if(isOpen("Curvature values")) { selectWindow("Curvature values"); run("Close"); } but this doesn't help. I end up with many, many "Curvature values" windows open. Any ideas? Is there a function to close ALL windows? I am using 1.39p under Ubuntu. Thanks, Andy |
Alternatively is it possible to set setBatchMode(true) for the whole
macro, but "display" (show?) an image, do something manual to it, then close it for the macro to continue (with ALL windows closed)? Thanks. Andy Weller wrote: > Dear all, > > I have a macro that initiates with: > setBatchMode(false); > > then switches to: > setBatchMode(true); > > after some manual editing. > > However, during the macro I measure some Fourier descriptors and I can't > seem to close the "Curvature values" window?! In my macro I have: > if(isOpen("Curvature values")) { > selectWindow("Curvature values"); > run("Close"); > } > > but this doesn't help. I end up with many, many "Curvature values" > windows open. > > Any ideas? Is there a function to close ALL windows? > > I am using 1.39p under Ubuntu. > > Thanks, Andy |
Free forum by Nabble | Edit this page |