FLIR One Developer / Blog / Topics / unable to get absolute temperature from image type ThermalRadiometricKelvinImage

unable to get absolute temperature from image type ThermalRadiometricKelvinImage

Home Forums FLIR developer community General discussion unable to get absolute temperature from image type ThermalRadiometricKelvinImage

This topic contains 8 replies, has 5 voices, and was last updated by Profile photo of Gavin Gavin 1 month, 2 weeks ago.

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

  • Author

    Posts

  • #7657

    Profile photo of ford
    ford

    Participant

    Hello everybody

    Recently I’m working on my smartphone with flir one device and I’m also a beginner in java and android APPs, my problem is when I use the codes below to get ThermalRadiometricKelvinImage and I use debug mode to see the value of thermalPixels and thermalPixelData, and all the value of them are always 21313. If anyone can help me solve this problem, I will be very grateful. Here is my code:

    package com.example.ford.flir_test;

    import android.Manifest;
    import android.content.pm.PackageManager;
    import android.graphics.Bitmap;
    import android.graphics.Color;
    import android.os.Environment;
    import android.support.v4.app.ActivityCompat;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.TextView;

    import com.flir.flironesdk.Device;
    import com.flir.flironesdk.Frame;
    import com.flir.flironesdk.FrameProcessor;
    import com.flir.flironesdk.RenderedImage;

    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.EnumSet;

    import static android.Manifest.permission.INTERNET;
    import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
    import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;

    public class MainActivity extends AppCompatActivity implements Device.Delegate, Device.StreamDelegate, Device.PowerUpdateDelegate, FrameProcessor.Delegate {

    private static final int REQUEST_EXTERNAL_STORAGE = 123;

    private volatile Device flirDevice;
    ImageView thermalImageView;
    TextView tv1, tv2;
    Bitmap thermalBitmap;
    Button Capture_Image;
    boolean WRITE_IMG = false;
    static int img_cnt = 0;
    File dirFile;
    long tic = System.currentTimeMillis();
    long toc = System.currentTimeMillis();
    double fps;
    byte[] bitmapdata;
    private FrameProcessor frameProcessor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permission != PackageManager.PERMISSION_GRANTED) {
    ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, INTERNET}, REQUEST_EXTERNAL_STORAGE);
    }

    thermalImageView = findViewById(R.id.imageView);
    thermalImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    Capture_Image = findViewById(R.id.capture);

    tv1 = findViewById(R.id.textView1);
    tv1.setTextSize(50);
    tv1.setTextColor(Color.GREEN);

    tv2 = findViewById(R.id.textView2);
    tv2.setTextSize(50);
    tv2.setTextColor(Color.GREEN);

    frameProcessor = new FrameProcessor(this, this, EnumSet.of(RenderedImage.ImageType.ThermalRGBA8888Image, RenderedImage.ImageType.ThermalRadiometricKelvinImage));

    Capture_Image.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

    WRITE_IMG = !WRITE_IMG;

    if (WRITE_IMG) {
    SimpleDateFormat sDateFormat = new SimpleDateFormat(“hh:mm:ss”);
    String current_time = sDateFormat.format(new java.util.Date());
    String current_time_split[] = current_time.split(“:”);
    current_time = current_time_split[0] + “_” + current_time_split[1] + “_” + current_time_split[2];

    String create_folder_path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + File.separator + current_time;
    dirFile = new File(create_folder_path);
    dirFile.mkdirs();

    tv2.setText(current_time);
    } else {
    img_cnt = 0;
    }
    }
    });
    }

    @Override
    protected void onResume() {
    super.onResume();
    Device.startDiscovery(this, this);
    }

    @Override
    protected void onPause() {
    super.onPause();
    Device.stopDiscovery();
    }

    @Override
    public void onDeviceConnected(Device device) {
    flirDevice = device;
    flirDevice.startFrameStream(this);
    }

    @Override
    public void onDeviceDisconnected(Device device) {
    }

    @Override
    public void onAutomaticTuningChanged(boolean b) {
    }

    @Override
    public void onTuningStateChanged(Device.TuningState tuningState) {
    }

    @Override
    public void onFrameReceived(Frame frame) {
    frameProcessor.processFrame(frame);
    }

    @Override
    public void onFrameProcessed(final RenderedImage renderedImage) {

    if (renderedImage.imageType() == RenderedImage.ImageType.ThermalRadiometricKelvinImage) {
    int[] thermalPixels = renderedImage.thermalPixelValues();
    short[] thermalPixelData = renderedImage.thermalPixelData();

    // thermalBitmap = renderedImage.getBitmap();
    //
    // if (WRITE_IMG) {
    // if (dirFile.exists()) {
    // try {
    // img_cnt = img_cnt + 1;
    // File f = new File(dirFile + File.separator + String.valueOf(img_cnt) + “.png”);
    // ByteArrayOutputStream bos = new ByteArrayOutputStream();
    // thermalBitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
    // bitmapdata = bos.toByteArray();
    // FileOutputStream fos = new FileOutputStream(f);
    // fos.write(bitmapdata);
    // fos.flush();
    // fos.close();
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    // }
    // }
    //
    // runOnUiThread(new Runnable() {
    // @Override
    // public void run() {
    // thermalImageView.setImageBitmap(thermalBitmap);
    // tv1.setText(String.valueOf(img_cnt));
    // }
    // });

    // toc = System.currentTimeMillis();
    // fps = 1 / ((toc – tic) / 1000.);
    // tic = System.currentTimeMillis();
    }
    }

    @Override
    public void onBatteryChargingStateReceived(Device.BatteryChargingState batteryChargingState) {
    }

    @Override
    public void onBatteryPercentageReceived(byte b) {
    }
    }

    and here is my AndroidManifest.xml

    <?xml version=”1.0″ encoding=”utf-8″?>
    <manifest xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.example.ford.flir_test”>

    <uses-permission android:name=”android.permission.MOUNT_UNMOUNT_FILESYSTEMS”/>
    <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/>

    <application
    android:largeHeap=”true”
    android:hardwareAccelerated=”false”

    android:allowBackup=”true”
    android:icon=”@mipmap/ic_launcher”
    android:label=”@string/app_name”
    android:roundIcon=”@mipmap/ic_launcher_round”
    android:supportsRtl=”true”
    android:theme=”@style/AppTheme”>
    <activity android:name=”.MainActivity”>
    <intent-filter>
    <action android:name=”android.intent.action.MAIN” />

    <category android:name=”android.intent.category.LAUNCHER” />
    </intent-filter>
    </activity>
    </application>

    </manifest>

    #7662

    Profile photo of Allison
    Allison

    Moderator

    Hi Ford,

    Have you used your FLIR One with the FLIR One App and does it give you correct temperatures?

    Additionally, there is a small chance it could be an issue with calibration. Tuning allows the camera to perform a Flat Field Calibration which is needed for temperature accuracy. I would see if importing the tuning logic from the sample application changes the values you’re seeing at all.

    Please let me know if the camera works correctly with the app and if tuning has any effect so I can continue to assist you in troubleshooting this issue.

    Thank you,
    Allison Torchia

    #7686

    Profile photo of ford
    ford

    Participant

    Hi Allison,

    First of all, thank you for your reply.

    I think it may be because I am still getting started with develop android apps, so I’m don’t know very well about the ‘importing the tuning logic’ you said in your reply. Can you please explain more in detail? And I will try my best to explain the situation I have encountered more clearly. I hope this will help you understand my problem better.

    I used to download the officially released app from the Google Play store and it gives me correct temperatures. And I also tried to write my own app to show the thermal image just like above code by using ThermalRGBA8888Image and it also works well (it can give me the correct thermal bitmap by using renderedImage.getBitmap method), but when I change the image type to ThermalRadiometricKelvinImage and try using thermalPixelData method to get the pixel temperature value and it give me 21313 for every pixel in every frame received. I hope these information helps you understand my problem. And if there is any sample code about use ThermalRadiometricKelvinImage correctly, it must be very helpful to me.

    Thank you so much for your patience reply, have a nice day!
    Ford

    #7715

    Profile photo of Allison
    Allison

    Moderator

    Hi Ford,

    I apologize for my lack of clarity, I simply meant copy and pasting the methods involving tuning from the sample app.

    However, that is very abnormal behavior. Please let me know what device you’re using and it’s OS version as I continue to look into this.

    Thank you,
    Allison Torchia

    #8185

    Profile photo of Milos
    Milos

    Participant

    Hi,

    me and my team have exactly the same issue. We have performed camera calibration but we are getting bad values for pixels as ‘ford’ described. In our case we were using Samsung Galaxy S8+ device, but i am thinking now that this is not device related.

    Please see our forum post with all details:

    Issue with Flir One and Samsung Galaxy S8+ devices

    Any help regarding this would be more than welcome! 🙂
    Thank you!

    #8193

    Profile photo of Milos
    Milos

    Participant

    After intensive testing and verifying that we are performing tuning, i am sure that camera is tuned every time, however for every Radiometric Kelvin type’s pixel we are getting the same values again and again (that is: 22314). Sometimes, we get good data. It lasts for some time (hour for example), but it starts returning 22134 again.

    #8227

    Profile photo of Milos
    Milos

    Participant

    I got this issue with Samsung Galaxy S9+ with Android 9. Here are some details (if helpful):

    Flir info:
    Battery level: 56
    Flir SDK info:
    Version name: 1.2.8
    Version code: 128
    Detected repeating value: 22314
    Tuning state: ApproximatelyTuned

    After a half of hour, camera recovered and started returning good values again! No change in our application codebase was done!

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

    #12802

    Profile photo of yiyu
    yiyu

    Participant

    Hi

    I used 3.1.5 version of the SDK.
    I have the same situation.
    Can you provide some advice?

    Best regards,
    yiyu

    #13809

    Profile photo of Gavin
    Gavin

    Keymaster

    Hi yiyu,

    I would recommend upgrading to the FLIR Mobile SDK, which is our newest SDK. To get started go here

    Best,
    Gavin
    FLIR Community Support

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

You must be logged in to reply to this topic.