FLIR One Developer / Blog / Topics / How to set temperature range on Android app?

How to set temperature range on Android app?

Home Forums FLIR developer community General discussion How to set temperature range on Android app?

This topic contains 15 replies, has 8 voices, and was last updated by Profile photo of Hao-Jan Hao-Jan 1 year, 7 months ago.

Viewing 16 posts - 1 through 16 (of 16 total)

  • Author

    Posts

  • #3668

    Profile photo of zachi
    zachi

    Participant

    I’m trying to set a temperature range so I would be able to see the visual representation only of the objects that produce heat rate between this given range.
    I managed to do so partialy within the Flir One official app on Android using the Lock Span, but I need to specify both min and max temp.

    Thanks.

    #3670

    Profile photo of Justin Lee
    Justin Lee

    Participant

    Hi Zachi

    From my understanding, you want to set the span to a certain value and thereby locking the AGC values. I do not believe that there is currently an SDK feature to do this on the FLIROne. However, if you are interested in developing for the Lepton (the sensor inside the FLIROne), there exists resources for setting minimum and maximum values with that.

    #3675

    Profile photo of Cal Loo
    Cal Loo

    Moderator

    Hi Zachi and Justin,

    To clarify, the current FLIR ONE app doesn’t let you lock the temp range in a view but it actually is possible to do so using the FLIR ONE SDK. There’s an unpublished, beta iOS app from AdvanceWorx that does so and Mike tells me that he’s confident it can also be done in Android. Just a heads up though, it isn’t a trivial task to develop the code to do this. If you want more info contact michael@advanceworx.ca.

    Cheers,

    Cal Loo
    FLIR Developer Relations Manager
    cal.loo@flir.com

    #3678

    Profile photo of Clay
    Clay

    Participant

    Here are some functions in the android FLIROneSDK that look promising.
    FrameProcessor.lockPalettes()
    FrameProcessor.unlockPalettes()

    And to check if currently locked,
    FrameProcessor.palettesLocked()

    But, when I tested these on the simulator, they did not have any affect.

    Clay

    #3679

    To clarify, the current FLIR ONE app doesn’t let you lock the temp range in a view

    the iphone app does

    Mike tells me that he’s confident it can also be done in Android.

    Im confident that nothing happened when I tested FrameProcessor.lockPalettes/unlockPalettes() in the android simulator

    #3681

    Profile photo of zachi
    zachi

    Participant

    Thanks for the replies.

    I tried the FrameProcessor.lockPalettes/unlockPalettes() in Android but it didn’t work for me too.
    Where can I find tutorials for Lepton developing?

    Thanks again.

    #3683

    Profile photo of Clay
    Clay

    Participant

    @zachi

    TL;DR
    – If you are toggling lock/unlock, try using the result of !FrameProcessor.palettesLocked() (note the NOT ‘!’ operator) when determing whether to call FrameProcessor.lockPalettes/unlockPalettes().
    – If you are just lock/unlock’ing the palettes once and it is the first time the app is run, try calling the function twice (possibly waiting until after the camera connects for the second call).

    Ok, I won’t have access to an android device for a few days, but I do have a hypothesis for you to test.

    I just parsed through the assembly of the FLIROneSDK and I am confident that the logic of FrameProcessor.palettesLocked() is REVERSED (i.e., it will return false when the palettes are locked and true when the palettes are unlocked).

    Assuming your test code looks like the following:

    void someButtonHandler() {
        if (true == FrameProcessor.palettesLocked()) {
            FrameProcessor.unlockPalettes();
        } else {
            FrameProcessor.lockPalettes();
        }
    }

    Try using
    !FrameProcessor.palettesLocked() (note the NOT ‘!’ operator)
    or
    false == FrameProcessor.palettesLocked()
    or
    true != FrameProcessor.palettesLocked()
    to decide whether to lock or unlock the palettes (whichever floats your boat).

    e.g. (‘true’ changed to ‘false’)

    void someButtonHandler() {
        if (false == FrameProcessor.palettesLocked()) {
            FrameProcessor.unlockPalettes();
        } else {
            FrameProcessor.lockPalettes();
        }
    }

    I also SUSPECT that the very first time FrameProcessor.lockPalettes/unlockPalettes() is called, there may not be any noticeable effect. So I recommend either calling FrameProcessor.unlockPalettes() when the app launches or just try toggling lock/unlock a few times.

    Clay

    #3684

    Profile photo of Thomas
    Thomas

    Participant

    I can confirm your code snippet.
    I hooked the tune button and the palettes locking works fine.
    Also at the first time of pressing the “tune” button!

        public void onTuneClicked(View v){
           /*
            if (flirOneDevice != null){
                flirOneDevice.performTuning();
            }
           */
            if (false == FrameProcessor.palettesLocked()) {
                FrameProcessor.unlockPalettes();
            } else {
                FrameProcessor.lockPalettes();
            }
    
        }

    A great improvement for the thermal image view!

    • This reply was modified 3 years, 9 months ago by Profile photo of Thomas Thomas.
    • This reply was modified 3 years, 9 months ago by Profile photo of Thomas Thomas.

    #3687

    Profile photo of zachi
    zachi

    Participant

    @Clay
    @Thomas

    Thank you guys! Iv’e managed to get palettes locked/unlocked but I still have some questions:
    1. How do I get the locked temperature value? To show a toast message for example..
    2. How can you make a cross-hair like indicator to show the selected object’s temperature (just like in the official app)?
    3. I understand the the lock/unlocked toggle sets only the MINIMUM temperature value, which means that I’ll get a representation only for the objects that are hotter than the locked temperature.
    The biggest question and the purpose of my app is – get I lock also a MAXIMUM temperature value, and see a visual representation only for objects that have a temperature value between the locked Min and MAX values? Can it be done with the Android SDK or not?

    Thanks!

    #3699

    @clay
    I tested your code and confirmed your “hypothesis”.
    I am trying to follow your explanation but I hit a wall…
    FrameProcessor’s method public static native boolean palettesLocked(); looks like a no-op:
    Java_com_flir_flironesdk_FrameProcessor_palettesLocked:
    push {r3, lr}
    blx _ZN15IditarodAppcore18getIditarodAppcoreEv
    pop.w {r3, lr}
    b.w 0x543e1c
    nop
    00543e1c:
    bx pc
    I get that FrameProcessor.palettesLocked() changes when FrameProcessor.lockPalettes/unlockPalettes() changes…
    But it looks like it branches to a method that does nothing and returns nothing. How is FrameProcessor.palettesLocked() “REVERSED” when it doesn’t returns anything???

    #3706

    Profile photo of Clay
    Clay

    Participant

    @tomas

    Thank you for verifying that for me. I am glad that you were able to get things working.

    @zachi

    1. Not through the SDK.

    2. DIY: Find an image of crosshairs, create a small view with a transparent background to display the image and some text, add the view above the thermal image, move the view wherever you want it to be, use the radiometric data to find the temperature under the crosshairs (you will need to adjust for frame size), change the text in the view to display said temperature value.

    3. I believe that it also sets a maximum temperature value. The colors that are shown are determined by the palette. Each palette defines a color to use for temperature values below the minimum and a color to use for temperature values above the maximum.

    You might not need palette locking for what you described.
    Instead, you can determine what min/max temperatures you want to use as thresholds. Then use the radiometric data to find locations of the temperatures where the value is below/above the min/max temperatures you have chosen. For each of those locations, set the alpha value of the corresponding pixel(s) in your output image to 0 (Note: you will need to adjust for different frame sizes). Then any pixel with a temperature in the range you have chosen will be visible and any outside will not.

    @intellectualjuggernaut

    Basically, the SDK appears to keep track of whether the palettes are UNLOCKED, internally. So, FrameProcessor.palettesLocked() should return ‘Not’ that.

    The function pops the stack frame before branching to a label, which implies a tail call.
    B.W is a 32-bit instruction and there are peculiarities about 32-bit encoding in thumb. But, the function does load an instance of IditarodAppcore into R0, so the intention was either to call a method (probably) or to cause a side effect of instantiating the singleton (eww).
    Looking through the methods of that class, I did not find a method that returned whether the palettes were locked. But, I did find a method that returned whether the palettes were UNLOCKED (which had zero references to it, thickening the plot).
    For the sake of argument, let us suppose that that is the method being tail called. Then, Java_com_flir_flironesdk_FrameProcessor_palettesLocked should return the logical ‘Not’ (!) of the result in order to be correct. However, if it did return the logical ‘Not’, then a tail call would not have been generated. Contraposition gives the rest.

    #6268

    Profile photo of Hao-Jan
    Hao-Jan

    Participant

    Hi,
    when I call the function FrameProcessor.palettesLocked()
    Android studio said that it is deprecated.
    And my app will crash when I call the function.
    Why ?

    • This reply was modified 1 year, 7 months ago by Profile photo of Hao-Jan Hao-Jan.

    #6270

    Profile photo of Dominique
    Dominique

    Moderator

    Hi Hao-Jan,

    Would you please tell us what sdk and hardware you are using?

    Thank you,
    Dominique Strauss

    #6272

    Profile photo of Hao-Jan
    Hao-Jan

    Participant

    Hi, Thank you to reply!
    How do I know what version of Flir One SDK I’m using? But I know it’s just download from Flir One website!
    And my android studio version is 3.0.1, compile with compileSdkVersion 26
    And my hardware is Samsung Note 5(Android version is 6)

    • This reply was modified 1 year, 7 months ago by Profile photo of Hao-Jan Hao-Jan.

    #6275

    Profile photo of Dominique
    Dominique

    Moderator

    Hi Hao-Jan,

    Which model of the FLIR One are you using?

    Does the example app or FLIR One app on your phone?
    Were you able to get frames from your app before you added that function?

    Thank you,
    Dominique
    Strauss

    #6276

    Profile photo of Hao-Jan
    Hao-Jan

    Participant

    Hi, Dominique,
    I’m using Flir One Gen 3.
    Both of the example project and my own app are in my phone, and they are able to get frames before added the function. But crash when I activate the function.
    Thank you.

    • This reply was modified 1 year, 7 months ago by Profile photo of Hao-Jan Hao-Jan.

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.