Hardware Sensor Signal Import

acquisition
imagej
Tags: #<Tag:0x00007fb87ab9f868> #<Tag:0x00007fb87ab9f6b0>

#1

How do you interface any hardware signal into ImageJ?
@nicost
If you have for example a signal at http://127.0.0.1:4444/Sensor/Signal/Subsignal returning a number that one wants to add to the log or results sheet or use in some calculations.


#2

Typical you would use some kind of webapi. There are several powerful webapis available.

In Java (or using a scripting language) a simple example would be:

or:

You can also use diverse Java libs for this.


#3

The straightest forward seemed to use the core example. Setting the URL variable and then connection.getInputStream()
This should print the Temperature.

macro "Temperature" { 
import java.net.*;
import java.io.*;
URLConnection connection = new URL("http://127.0.0.1:4444/bySerial/METEOMK1-ABCDEF/api/temperature/currentRawValue").openConnection();
InputStream response = connection.getInputStream();
print(response)
}

I get a Macro error “Undefined variable”.
Then I tried to include
import java.net.;
import java.io.
;
still Undefined variable
Try to change the language to JAVA gives me “java.lang.NullPointerException”
Then I searched for “running JAVA code from inside IJ1 macro language macro” in this forum and then on google.

I found:


There I read “using Java in the script editor is plagued with problems”
in
https://imagej.nih.gov/ij/developer/macro/macros.html
I read “There are two ways to add functions implemented as Java code” and then things get complicated.
I am still studying these references and all the links but if there is any another way that does not involve JAVA that would be much preferred.
I want to just say:

myURL= "http://127.0.0.1:4444/bySerial/METEOMK1-ABCDEF/api/temperature/currentRawValue"; 
TemperatureString = get.myURL…