How to run FiJi at Raspberry Pi 3

headless
raspberry-pi
Tags: #<Tag:0x00007fd54223a8d8> #<Tag:0x00007fd54223a3b0>

#1

Hi all,

I’ve decided to write a new post after trying (without success) to install and run FiJi at Raspberry Pi. The below link was my first guide:

It didn’t work, so i’ve started from zero.

Steps:

  1. Download 64 bits Linux from http://imagej.net/Fiji
  2. Check Java 8 is installed at Rasberry Pi

Next steps?
How can we run Fiji from command line (–headless)?

I’m afraid that there’s not enough information abour this topic. Thanks in advance!


#2

Dear @legramo,

could you take a look at http://imagej.net/Headless and see if that helps with your issues? There are some rough edges around the headless mode, if you depend on ImageJ1.

Will you require a user interface for what you want to do?

Best,
Stefan


#3

Dear @strelfrich,

Thanks for your response. As far as i don’t the need the user interface, i’d like to execute fiji from command line. The goal is to obtain the NDVI factor after processing some images token from the RPi camera. I’ve already achieved this goal using Windows + Fiji + PhotoManager Plugin, but i don’t know how to solve it using a raspberry pi.

The first step is to run FiJi at the RPi, and i’m not even able to do it from the command line…

First of all, did i download the FiJi’s right version (with Java 8)? How can i run it? Thanks!

./ImageJ-linux64 --ij2 --headless
bash: ./ImageJ-linux64 cannot execute binary file: Exec format error


#4

Download the No JRE Fiji and install Java 8 on your Raspberry Pi. Then, head over to the thread that you have already linked to:

Curtis posted a link to a script that you can use instead of the ImageJ-linux64 binary if you have downloaded a Fiji without a bundled JVM:

$ wget https://raw.githubusercontent.com/imagej/imagej/2bfd8a23a5ff427fabe12ea3f7114604e8485a75/bin/ImageJ.sh
$ chmod u+x ImageJ.sh
$ /bin/bash ImageJ.sh --headless

Don’t have access to my RPi at the moment, so you’ll have to check if it works.


#5

I started a Raspberry Pi wiki page, based on information from the linked forum thread. The ImageJ web site is a wiki, so please flesh it out if you have additional tips, needed steps, etc.


#6

I don’t have one of these for testing, but do have a Jetson TX1 that has a 64-bit ARM processor like the RP3. I tried building the native launcher but found that the maven native compiler plugin doesn’t support ARM64. ImageJ.sh does work, but note that the Oracle version of Java 8 is headless only so you’ll have to use OpenJDK’s version. With the Oracle version ImageJ.sh will start but eventually quit without ever loading the GUI (the error output is suppressed).


#7

So you do have a screen attached / X11 running and are looking to get Fiji running with a user interface?


#8

Sure, i will flesh it out the wiki once the RPi is working fine :slight_smile:


#9

This is the current situation. FiJi GUI works fine (but not headless) at Raspberry Pi 3 if you follow the next steps:

  1. Install Java 8
    How to
  2. Use this FiJi version
    Download
  3. Use this script in order to run Fiji
    $ wget https://raw.githubusercontent.com/imagej/imagej/2bfd8a23a5ff427fabe12ea3f7114604e8485a75/bin/ImageJ.sh
    $ chmod u+x ImageJ.sh
    $ /bin/bash ImageJ.sh
    

BUT, it doesn’t work headless from command line…

root@raspberrypi:/home/pi/Fiji.app# /bin/bash ImageJ.sh --headless
Java HotSpot(TM) Client VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
java.lang.IllegalArgumentException: Cannot handle app name in ij.gui.YesNoCancelDialog's public <init>(java.awt.Frame parent, java.lang.String title, java.lang.String msg)
	at net.imagej.patcher.CodeHacker.replaceAppNameInCall(CodeHacker.java:446)
	at net.imagej.patcher.LegacyExtensions.insertAppNameHooks(LegacyExtensions.java:419)
	at net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:291)
	at net.imagej.patcher.LegacyInjector.inject(LegacyInjector.java:308)
	at net.imagej.patcher.LegacyInjector.injectHooks(LegacyInjector.java:109)
	at net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:101)
	at net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:495)
	at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:397)
	at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:376)
	at net.imagej.legacy.LegacyService.<clinit>(LegacyService.java:134)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
	at java.lang.Class.newInstance(Class.java:433)
	at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:302)
	at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
	at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
	at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:340)
	at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
	at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
	at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
	at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
	at org.scijava.Context.<init>(Context.java:278)
	at org.scijava.Context.<init>(Context.java:234)
	at org.scijava.Context.<init>(Context.java:174)
	at org.scijava.Context.<init>(Context.java:160)
	at net.imagej.ImageJ.<init>(ImageJ.java:77)
	at net.imagej.Main.launch(Main.java:61)
	at net.imagej.Main.main(Main.java:68)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:279)
	at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:186)
	at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:77)
Caused by: javassist.CannotCompileException: No code replaced!
	at net.imagej.patcher.CodeHacker$EagerExprEditor.instrument(CodeHacker.java:1280)
	at net.imagej.patcher.CodeHacker.replaceAppNameInCall(CodeHacker.java:443)
	... 36 more

Any suggestions? Thanks in advance


#10

I think this error is not specific to the Pi, but rather the latest version of ImageJ 1.x. You can try downgrading to an earlier version of ImageJ1 using the command Help :arrow_forward: Update ImageJ…. See also this PR which @stelfrich already filed to address the issue.

To troubleshoot what ImageJ is doing while booting up headless, you can try pressing Ctrl+\ while the console has the keyboard focus, and it should emit a Java thread dump. If you do this several times, you might be able to see where the program is stuck.


Fiji(ImageJ) takes too long to load (on linux), together with a lengthy error message
#11

Thanks for your contribution @ctrueden . Unfortunately i’ve been unable to downgrade imageJ from the updater, would you mind to provide us more details about how to manage it? Thanks


#12

Did you use the Help :arrow_forward: Update ImageJ… command (and not Help :arrow_forward: Update)? It should look similar to this:


#13

@imagejan, you were completely right, thanks! After downgrading ImageJ to v1.50 using using the command Help :arrow_forward: Update ImageJ, it seems that --headless works (the fails dissapear):

root@raspberrypi:/home/pi/Fiji.app# /bin/bash ImageJ.sh --headless
Java HotSpot™ Client VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot™ Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

The next step would be to execute the Photomonitoring plugin as i do from the GUI (open an image, photomonitoring plugin, single image index processing from displayed image, etc…). These are the guides that i’ve deal with:
https://imagej.nih.gov/ij/docs/guide/146-18.html
https://imagej.net/Headless#Running_scripts_in_headless_mode

But the steps are not to clear… could any of you provide us a good example about how to open and process an image with a plugin (photomonitoring if it’s possible) from the command line? Thanks.


#14

Did you read these guides?

If it’s still not clear, please post what you have tried, and what doesn’t work, so we can help improve it.

I do agree that it would be good to offer a simple and clear headless example here. I do not have time to write one myself right now, but perhaps we could converge on one together here.