npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dji-thermal-sdk

v1.0.8

Published

## Notes

Downloads

79

Readme

DJI Thermal SDK

Notes

  • The version of the SDK is 1.4 released on 2022-09-29.
  • Currently, the package only supports Linux platforms.
  • It uses node-gyp to build the native module.

Installation

npm install dji-thermal-sdk

Usage

const { version, getTemperatureData } = require("dji-thermal-sdk");

console.log("version:", version()); //print the version of the SDK (magic number)

const fs = require("fs");

const imageBuffer = fs.readFileSync("test.jpg"); //read the R-JPEG image from DJI infrared camera products

const { width, height, parameters, data } = getTemperatureData(imageBuffer);

/*
width: the width of the image
height: the height of the image

parameters: the parameters of the image eg: { distance: 5, humidity: 70, emissivity: 1, reflection: 23 }

data: the temperature data of the image as Uint16Array, each array element represents the temperature in 0.1℃
so the real temperature is the array element divided by 10. eg: 1234 means 123.4℃

*/

Example

Extract the temperature data from the R-JPEG image, use sharp package to generate a UInt16 TIFF image, and then decode the TIFF image using tiff package.

const { getTemperatureData } = require("dji-thermal-sdk");
const sharp = require("sharp");
const { decode } = require("tiff");
const fs = require("fs");

const imageBuffer = fs.readFileSync("DJI_0001_R.jpg");

const { width, height, parameters, data } = getTemperatureData(imageBuffer);

console.log(parameters);

console.log(data);

//create a sharp image from the temperature data
// /sharp accepts raw image data (Uint16Array), so we need to specify the width, height and channels of the image.
const sharpImage = sharp(data, { raw: { width, height, channels: 1 } }); 

sharpImage
  .toColorspace("grey16") //convert the image to 16-bit grayscale (1 channel)
  .tiff({
    compression: "none", //no compression
  })
  .toBuffer() //get the buffer of the TIFF image
  .then((buffer) => {
    fs.writeFileSync("test.tiff", buffer); //write the buffer to a file
 
    const tiffBuffer = fs.readFileSync("test.tiff"); //read the TIFF image from the file

    const [image] = decode(tiffBuffer); //decode the TIFF image

    console.log(image.data); //print the temperature data of the TIFF image
  });

TODO

  • Support Windows platforms.
  • Export typescript definition files.
  • Add methods to get the temperature data as float array.
  • Set thermal parameters to override the parameters in the image, before getting the temperature data.

References

  • DJI Thermal SDK The DJI Thermal SDK enables you to process R-JPEG (Radiometric JPEG) images which were captured by DJI infrared camera products.