Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Matti Viljamaa
Hello,

I want to use ImageJ in a C++ program. However, I found the GUI pretty useful as it is, but since it’s in Java, then I’m not sure, whether I can use it, because
my program has to be in C++.

And I don’t want to rewrite the GUI, since it’s done already.

What are my options?

BR, Matti

Lähetetty Windows 10:n Sähköpostista



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Curtis Rueden
Hi Matti,

> What are my options?

A. Link to libjvm from C++ and invoke Java code via the JNI Invocation API
[1]. Beware platform-specific issues such as starting AWT from the main
thread on macOS, though [2].

B. GraalVM. See "Top 10 Things To Do With GraalVM" [3], particularly items
3, 7 and 8.

C. Spawn java as another process from C++ to run ImageJ.

D. Use the ImageJ Server [4] to communicate with ImageJ from C++ via a REST
API.

Why does your program have to be in C++?

Regards,
Curtis

[1] https://docs.oracle.com/javase/8/docs/technotes/
guides/jni/spec/invocation.html
[2] https://developer.apple.com/legacy/library/technotes/
tn2147/_index.html#//apple_ref/doc/uid/DTS10003827-CH1-THREADED_INVOCATION
[3] https://medium.com/graalvm/graalvm-ten-things-12d9111f307d
[4] https://imagej.net/Server

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Wed, May 23, 2018 at 2:41 PM, Matti Viljamaa <[hidden email]>
wrote:

> Hello,
>
> I want to use ImageJ in a C++ program. However, I found the GUI pretty
> useful as it is, but since it’s in Java, then I’m not sure, whether I can
> use it, because
> my program has to be in C++.
>
> And I don’t want to rewrite the GUI, since it’s done already.
>
> What are my options?
>
> BR, Matti
>
> Lähetetty Windows 10:n Sähköpostista
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Matti Viljamaa
Thank you.

Well, because other libraries that I rely on require C++. It’s not even that I could use them as foreign functions in Java, but rather my program has to run as a C++ program.

This has also got me thinking that ImageJ might not serve me that well. Unless I rewrite the GUI.
But then I could use other libs as well, like OpenCV, ITK, …

GUI writing bugs me, because if it’s done once, then I find it waste of time having to basically rewrite nearly the same thing, just in a different framework.

BR, Matti

> Curtis Rueden <[hidden email]> kirjoitti 23.5.2018 kello 23.05:
>
> Hi Matti,
>
>> What are my options?
>
> A. Link to libjvm from C++ and invoke Java code via the JNI Invocation API
> [1]. Beware platform-specific issues such as starting AWT from the main
> thread on macOS, though [2].
>
> B. GraalVM. See "Top 10 Things To Do With GraalVM" [3], particularly items
> 3, 7 and 8.
>
> C. Spawn java as another process from C++ to run ImageJ.
>
> D. Use the ImageJ Server [4] to communicate with ImageJ from C++ via a REST
> API.
>
> Why does your program have to be in C++?
>
> Regards,
> Curtis
>
> [1] https://docs.oracle.com/javase/8/docs/technotes/
> guides/jni/spec/invocation.html
> [2] https://developer.apple.com/legacy/library/technotes/
> tn2147/_index.html#//apple_ref/doc/uid/DTS10003827-CH1-THREADED_INVOCATION
> [3] https://medium.com/graalvm/graalvm-ten-things-12d9111f307d
> [4] https://imagej.net/Server
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
> Did you know ImageJ has a forum? http://forum.imagej.net/
>
>
> On Wed, May 23, 2018 at 2:41 PM, Matti Viljamaa <[hidden email]>
> wrote:
>
>> Hello,
>>
>> I want to use ImageJ in a C++ program. However, I found the GUI pretty
>> useful as it is, but since it’s in Java, then I’m not sure, whether I can
>> use it, because
>> my program has to be in C++.
>>
>> And I don’t want to rewrite the GUI, since it’s done already.
>>
>> What are my options?
>>
>> BR, Matti
>>
>> Lähetetty Windows 10:n Sähköpostista
>>
>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Curtis Rueden
In reply to this post by Curtis Rueden
Hi Matti,

> GUI writing bugs me, because if it’s done once, then I find it waste
> of time having to basically rewrite nearly the same thing, just in a
> different framework.

That issue extends far beyond only GUIs. It is a quintessential frustration
of being a programmer, in my view.

Seriously, check out GraalVM. Here is an excerpt from their polyglot guide
[1]:

> Often developers have to make uncomfortable compromises that require them
to
> rewrite their software in other languages. For example:

> * “That library is not available in my language. I need to rewrite it.”
> * “That language would be the perfect fit for my problem, but we cannot
run
>   it in our environment.”
> * “That problem is already solved in my language, but the language is too
>   slow.”

> With GraalVM we aim to allow developers to freely choose the right
language
> for the task at hand without making compromises.

Regards,
Curtis

[1] https://www.graalvm.org/docs/reference-manual/polyglot/

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Wed, May 23, 2018 at 3:20 PM, Matti Viljamaa <[hidden email]>
wrote:

> Thank you.
>
> Well, because other libraries that I rely on require C++. It’s not even
> that I could use them as foreign functions in Java, but rather my program
> has to run as a C++ program.
>
> This has also got me thinking that ImageJ might not serve me that well.
> Unless I rewrite the GUI.
> But then I could use other libs as well, like OpenCV, ITK, …
>
> GUI writing bugs me, because if it’s done once, then I find it waste of
> time having to basically rewrite nearly the same thing, just in a different
> framework.
>
> BR, Matti
>
> > Curtis Rueden <[hidden email]> kirjoitti
> 23.5.2018 kello 23.05:
> >
> > Hi Matti,
> >
> >> What are my options?
> >
> > A. Link to libjvm from C++ and invoke Java code via the JNI Invocation
> API
> > [1]. Beware platform-specific issues such as starting AWT from the main
> > thread on macOS, though [2].
> >
> > B. GraalVM. See "Top 10 Things To Do With GraalVM" [3], particularly
> items
> > 3, 7 and 8.
> >
> > C. Spawn java as another process from C++ to run ImageJ.
> >
> > D. Use the ImageJ Server [4] to communicate with ImageJ from C++ via a
> REST
> > API.
> >
> > Why does your program have to be in C++?
> >
> > Regards,
> > Curtis
> >
> > [1] https://docs.oracle.com/javase/8/docs/technotes/
> > guides/jni/spec/invocation.html
> > [2] https://developer.apple.com/legacy/library/technotes/
> > tn2147/_index.html#//apple_ref/doc/uid/DTS10003827-CH1-
> THREADED_INVOCATION
> > [3] https://medium.com/graalvm/graalvm-ten-things-12d9111f307d
> > [4] https://imagej.net/Server
> >
> > --
> > Curtis Rueden
> > LOCI software architect - https://loci.wisc.edu/software
> > ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
> > Did you know ImageJ has a forum? http://forum.imagej.net/
> >
> >
> > On Wed, May 23, 2018 at 2:41 PM, Matti Viljamaa <
> [hidden email]>
> > wrote:
> >
> >> Hello,
> >>
> >> I want to use ImageJ in a C++ program. However, I found the GUI pretty
> >> useful as it is, but since it’s in Java, then I’m not sure, whether I
> can
> >> use it, because
> >> my program has to be in C++.
> >>
> >> And I don’t want to rewrite the GUI, since it’s done already.
> >>
> >> What are my options?
> >>
> >> BR, Matti
> >>
> >> Lähetetty Windows 10:n Sähköpostista
> >>
> >>
> >>
> >> ---
> >> This email has been checked for viruses by Avast antivirus software.
> >> https://www.avast.com/antivirus
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Robert Dougherty
In reply to this post by Matti Viljamaa
Matti,

I've had good luck in Windows with JNA.  I write the C++ parts as C functions and export them in a DLL. An interface maps the C functions to Java functions, and JNA seems to do a reasonable job of translating the arguments, which probably should be kept simple to avoid stressing it. I've been able to use openCV and several other libraries this way.

Bob
 
On May 23, 2018, at 12:41 PM, Matti Viljamaa wrote:

> Hello,
>
> I want to use ImageJ in a C++ program. However, I found the GUI pretty useful as it is, but since it’s in Java, then I’m not sure, whether I can use it, because
> my program has to be in C++.
>
> And I don’t want to rewrite the GUI, since it’s done already.
>
> What are my options?
>
> BR, Matti
>
> Lähetetty Windows 10:n Sähköpostista
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Robert Dougherty, Ph.D.
President, OptiNav, Inc.
1414 127th Place NE #106
Bellevue, WA 98005
Tel. (425)891-4883
FAX (425)467-1119
www.optinav.com
[hidden email]

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can ImageJ GUI (not library) be embedded into C++ somehow without rewriting the GUI?

Fred Damen
Greetings Bob,

This sounds perfect for a future project of mine.  Would you happen to have an
example of passing in / returning an ImagePlus; even code snippets would be
greatly appreciated, even if it is just the ImageProcessor, etc.

Thanks in advance,

Fred

On Wed, May 23, 2018 3:40 pm, Robert Dougherty wrote:

> Matti,
>
> I've had good luck in Windows with JNA.  I write the C++ parts as C functions
> and export them in a DLL. An interface maps the C functions to Java functions,
> and JNA seems to do a reasonable job of translating the arguments, which
> probably should be kept simple to avoid stressing it. I've been able to use
> openCV and several other libraries this way.
>
> Bob
>
> On May 23, 2018, at 12:41 PM, Matti Viljamaa wrote:
>
>> Hello,
>>
>> I want to use ImageJ in a C++ program. However, I found the GUI pretty
>> useful as it is, but since it’s in Java, then I’m not sure, whether I can
>> use it, because
>> my program has to be in C++.
>>
>> And I don’t want to rewrite the GUI, since it’s done already.
>>
>> What are my options?
>>
>> BR, Matti
>>
>> Lähetetty Windows 10:n Sähköpostista
>>
>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> Robert Dougherty, Ph.D.
> President, OptiNav, Inc.
> 1414 127th Place NE #106
> Bellevue, WA 98005
> Tel. (425)891-4883
> FAX (425)467-1119
> www.optinav.com
> [hidden email]
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html