dji-thermal-sdk


Namedji-thermal-sdk JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/lyuhaitao/dji_thermal_sdk
SummaryUse ctypes to capsulate DJI thermal SDK. Generate thermal images with different palettes and heatmaps.
upload_time2023-08-30 23:42:32
maintainer
docs_urlNone
authorhxl170008
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            DJI Thermal SDK
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
from dji_thermal_sdk.dji_sdk import *
from dji_thermal_sdk.utility import rjpeg_to_heatmap, rjpeg_to_thermal
import dji_thermal_sdk.dji_sdk as DJI
import ctypes as CT
from ctypes import *
import os
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
```

This version of DJI Thermal SDK is 1.3, which was published on
05/15/2022

## Install

`pip install dji_thermal_sdk`

## The package only can work on Windows System.

Normally, DJI SDK DLLs include
`libdirp.dll, libv_dirp.dll, libv_girp.dll, libv_iirp.dll, libv_list.ini`.

DJI does not provide the library for Linux. Therefore, if you run the
package on Linux, python complier will pop out ‘invalid ELF header’
error.

Firstly, you should invoke ‘dji_init’ to initialize DJI sdk environment.
This step is very important

## Initialize the DJI environment. This step is very important

``` python
nbdev.show_doc(dji_init)
```

------------------------------------------------------------------------

### dji_init

>      dji_init (dllpath:str=None)

if you don’t provide the file path of ‘libdirp.dll’, the default
‘libdirp.dll’ with version 1.3 will be automatically chosen.

``` python
dji_init()
DJI._libdirp
```

    <CDLL 'C:\Users\hxl170008\Documents\git_repo\dji_thermal_sdk\dji_thermal_sdk\libdirp.dll', handle 7ffcdb580000>

## Get the handle of a R-JPEG image

DIRP_HANDLE is a void pointer, and it has been definded.  
you can get it by `package.DIRP_HANDLE`

``` python
nbdev.show_doc(dirp_create_from_rjpeg)
```

------------------------------------------------------------------------

### dirp_create_from_rjpeg

>      dirp_create_from_rjpeg (data, size, ph)

Parameters: \[in\] data: R-JPEG binary data buffer pointer \[in\] size:
R-JPEG binary data buffer size in bytes \[out\]ph : DIRP API handle
pointer - reminder: use two-level pointer to assign value to one-level
pointer Return: int return code dirp_ret_code_e

``` python
rd = r"dataset\Deer_Goats_Unsure.jpg"
with open(rd, 'rb') as f:
    content = f.read()
    print(len(content))
# method1 to get the file size
print(f"File size: {os.path.getsize(rd)}")
# method 2 to get the file size
file_stat = os.stat(rd)
size = c_int32(file_stat.st_size)
print(f"File size: {size}")

# the method to create a string buffer, which is important.
rjpeg_data = CT.create_string_buffer(len(content))
rjpeg_data.value = content
print(f"rjpeg_data: {rjpeg_data}")

# test the function to create a handle of an image
ret = dirp_create_from_rjpeg(rjpeg_data,size, CT.byref(DIRP_HANDLE))
print(f'ret = {ret}')
if ret == 0:
    print("successfully get the r-jpeg handle.")
#
print(f"DIRP_HANDLE: {DIRP_HANDLE}  address: {hex(DIRP_HANDLE.value)} ")
```

    1367428
    File size: 1367428
    File size: c_long(1367428)
    rjpeg_data: <ctypes.c_char_Array_1367428 object>
    ret = 0
    successfully get the r-jpeg handle.
    DIRP_HANDLE: c_void_p(2201333297840)  address: 0x20089b072b0 

## Get the version of API

``` python
nbdev.show_doc(dirp_get_api_version)
```

<h4 id="dirp_get_api_version" class="doc_header">
<code>dirp_get_api_version</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L193" class="source_link" style="float:right">\[source\]</a>
</h4>

> <code>dirp_get_api_version</code>(**`version`**)

Parameters: \[out\] version DIRP API version information pointer Return:
int return code dirp_ret_code_e

``` python
nbdev.show_doc(dirp_api_version_t)
```

<h2 id="dirp_api_version_t" class="doc_header">
<code>class</code>
<code>dirp_api_version_t</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L68" class="source_link" style="float:right">\[source\]</a>
</h2>

> <code>dirp_api_version_t</code>() :: `Structure`

API version structure definition

``` python
jpeg_version = dirp_api_version_t() 
ret = dirp_get_api_version(CT.byref(jpeg_version))
if ret == DIRP_SUCCESS:
    print("Success")
#
print(f"jpeg_version.api: \t {jpeg_version.api}")
print(f"jpeg_version.magic: \t {jpeg_version.magic}")
```

    Success
    jpeg_version.api:    19
    jpeg_version.magic:      b'b85e4d3'

## Get the version of DJI JPG

``` python
nbdev.show_doc(dirp_get_rjpeg_version)
```

------------------------------------------------------------------------

### dirp_get_rjpeg_version

>      dirp_get_rjpeg_version (h, version)

Get R-JPEG version. Parameters \[in\]h:DIRP API handle \[out\]version:
R-JPEG version information pointer Returns int return code
dirp_ret_code_e

``` python
nbdev.show_doc(dirp_rjpeg_version_t)
```

------------------------------------------------------------------------

### dirp_rjpeg_version_t

R-JPEG version structure definition

``` python
jpeg_version = dirp_rjpeg_version_t()
ret = dirp_get_api_version(CT.byref(jpeg_version))
if ret == DIRP_SUCCESS:
    print("Success")
#
print(f"rjpeg:{jpeg_version.rjpeg}")
print(f"header:{jpeg_version.header}")
print(f"curve:{jpeg_version.curve}")
```

    Success
    rjpeg:19
    header:1697986658
    curve:3367988

## Get Color Bar

``` python
nbdev.show_doc(dirp_get_color_bar)
```

<h4 id="dirp_get_color_bar" class="doc_header">
<code>dirp_get_color_bar</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L205" class="source_link" style="float:right">\[source\]</a>
</h4>

> <code>dirp_get_color_bar</code>(**`h`**, **`color_bar`**)

Parameters: \[in\] h: DIRP API handle \[out\] color_bar: ISP color bar
parameters pointer Return: int return code dirp_ret_code_e

``` python
nbdev.show_doc(dirp_color_bar_t)
```

<h2 id="dirp_color_bar_t" class="doc_header">
<code>class</code>
<code>dirp_color_bar_t</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L74" class="source_link" style="float:right">\[source\]</a>
</h2>

> <code>dirp_color_bar_t</code>() :: `Structure`

Color bar parameters structure definition

``` python
jpeg_color_bar = dirp_color_bar_t()
ret = dirp_get_color_bar(DIRP_HANDLE, CT.byref(jpeg_color_bar))
if ret == DIRP_SUCCESS:
    print("Success")
print(f"jpeg_color_bar.high: \t {jpeg_color_bar.high}")
print(f"jpeg_color_bar.low: \t {jpeg_color_bar.low}")
print(f"jpeg_color_bar.manual_enable: \t {jpeg_color_bar.manual_enable}")
```

    Success
    jpeg_color_bar.high:     -131073.015625
    jpeg_color_bar.low:      9.10844001811131e-44
    jpeg_color_bar.manual_enable:    False

## Get the resolution of a R-JPEG image

nbdev.show_doc(dirp_create_from_rjpeg)

``` python
nbdev.show_doc(dirp_get_rjpeg_resolution)
```

<h4 id="dirp_get_rjpeg_resolution" class="doc_header">
<code>dirp_get_rjpeg_resolution</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L336" class="source_link" style="float:right">\[source\]</a>
</h4>

> <code>dirp_get_rjpeg_resolution</code>(**`h`**, **`rjpeg_info`**)

Get R-JPEG image resolution information. Parameters \[in\]h: DIRP API
handle \[out\]rjpeg_info: R-JPEG basic information pointer Returns int
return code dirp_ret_code_e

``` python
nbdev.show_doc(dirp_resolution_t)
```

<h2 id="dirp_resolution_t" class="doc_header">
<code>class</code>
<code>dirp_resolution_t</code><a href="https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L133" class="source_link" style="float:right">\[source\]</a>
</h2>

> <code>dirp_resolution_t</code>() :: `Structure`

The image size structure definition

``` python
rjpeg_resolution = dirp_resolution_t()
ret = dirp_get_rjpeg_resolution(DIRP_HANDLE, CT.byref(rjpeg_resolution))
print(f'ret = {ret}')
if ret == 0:
    print("successfully get the resolution.")

out = f'Height: {rjpeg_resolution.height}, width: {rjpeg_resolution.width}'
out
```

    ret = 0
    successfully get the resolution.

    'Height: 512, width: 640'

## Set Pseudo Color

``` python
nbdev.show_doc(dirp_set_pseudo_color)
```

------------------------------------------------------------------------

<a
href="https://github.com/lyuhaitao/dji_thermal_sdk/blob/master/dji_thermal_sdk/dji_sdk.py#LNone"
target="_blank" style="float:right; font-size:smaller">source</a>

### dirp_set_pseudo_color

>      dirp_set_pseudo_color (h, pseudo_color)

Set custom ISP pseudo color type. Parameters \[in\]h:DIRP API handle
\[in\]pseudo_color:ISP pseudo color type dirp_pseudo_color_e Returns int
return code dirp_ret_code_e

- DIRP_PSEUDO_COLOR_WHITEHOT = 0
- DIRP_PSEUDO_COLOR_FULGURITE = 1
- DIRP_PSEUDO_COLOR_IRONRED = 2
- DIRP_PSEUDO_COLOR_HOTIRON = 3
- DIRP_PSEUDO_COLOR_MEDICAL = 4
- DIRP_PSEUDO_COLOR_ARCTIC = 5
- DIRP_PSEUDO_COLOR_RAINBOW1 = 6
- DIRP_PSEUDO_COLOR_RAINBOW2 = 7
- DIRP_PSEUDO_COLOR_TINT = 8
- DIRP_PSEUDO_COLOR_BLACKHOT = 9

``` python
ret = dirp_set_pseudo_color(DIRP_HANDLE, c_int(0))
if ret == DIRP_SUCCESS:
    print("Success")
else:
    print(f"Error: ret={ret}")
```

    Success

## Transform a thermal image by a specific palette

``` python
nbdev.show_doc(dirp_process)
```

------------------------------------------------------------------------

### dirp_process

>      dirp_process (h, color_image, size)

Run ISP algorithm with RAW data in R-JPEG and output RGB pseudo color
image. The ISP configurable parameters can be modifed by these APIs:
dirp_set_enhancement_params dirp_set_isotherm dirp_set_color_bar
dirp_set_pseudo_color Parameters \[in\]h:DIRP API handle
\[out\]color_image:Color image data buffer pointer \[in\]size:Color
image data buffer size in bytes. Returns int return code dirp_ret_code_e

``` python
size = rjpeg_resolution.height * rjpeg_resolution.width * 3 * CT.sizeof(c_uint8)
raw_image_buffer = CT.create_string_buffer(size)
print(raw_image_buffer.raw[100])
ret = dirp_process(DIRP_HANDLE,byref(raw_image_buffer), size)
if ret == DIRP_SUCCESS:
    print("Success")
else:
    print(f"Error: ret={ret}")
#
raw_file_path = os.path.splitext(rd)[0] + ".raw"
print(raw_file_path)
with open(raw_file_path, 'wb') as f:
    f.write(raw_image_buffer.raw)
#
if os.path.exists(raw_file_path):
    print(f"Success! file size: {os.path.getsize(raw_file_path)}")
else:
    print("Error")
#
with open(raw_file_path, encoding='cp1252') as fin:
    img = np.fromfile(fin, dtype = np.uint8)
    print(img.shape)
    img.shape = (512,640,3)
    #original = Image.fromarray(img)
#

fig = plt.figure(figsize=(10,8))
plt.imshow(img, cmap='gray')
```

## rjpge_to_thermal

``` python
nbdev.show_doc(rjpeg_to_thermal)
```

------------------------------------------------------------------------

### rjpeg_to_thermal

>      rjpeg_to_thermal (src:str, palette:int)

parameters: \[str\] src: file path of original jpg. For example, c:.jpg
\[int\] palette: the number of palette - DIRP_PSEUDO_COLOR_WHITEHOT =
0 - DIRP_PSEUDO_COLOR_FULGURITE = 1 - DIRP_PSEUDO_COLOR_IRONRED = 2 -
DIRP_PSEUDO_COLOR_HOTIRON = 3 - DIRP_PSEUDO_COLOR_MEDICAL = 4 -
DIRP_PSEUDO_COLOR_ARCTIC = 5 - DIRP_PSEUDO_COLOR_RAINBOW1 = 6 -
DIRP_PSEUDO_COLOR_RAINBOW2 = 7 - DIRP_PSEUDO_COLOR_TINT = 8 -
DIRP_PSEUDO_COLOR_BLACKHOT = 9 return: return numpy.ndarray -\> img

``` python
if DJI._libdirp == "":
    print("run dji_init() to initialize the DJI sdk.")
src = r"dataset\Deer_Goats_Unsure.jpg"
img = rjpeg_to_thermal(src,0)
fig = plt.figure(figsize=(10,8))
plt.imshow(img)
plt.show()
```

![](index_files/figure-commonmark/cell-24-output-1.png)

## rjpge_to_heatmap

``` python
nbdev.show_doc(rjpeg_to_heatmap)
```

------------------------------------------------------------------------

### rjpeg_to_heatmap

>      rjpeg_to_heatmap (src:str, dtype='float32')

parameters: \[str\] src: file path of original jpg. For example, c:.jpg
\[str\] dtype: ‘float32’ or ‘int16’ return: return numpy.ndarray -\> img

``` python
if DJI._libdirp == "":
    print("run dji_init() to initialize the DJI sdk.")
src = r"dataset\Deer_Goats_Unsure.jpg"
img = rjpeg_to_heatmap(src,dtype='float32')
fig = plt.figure(figsize=(10,8))
ax = sns.heatmap(img, cmap='gray')
ax.set_xticks([])
ax.set_yticks([])
plt.show()
```

![](index_files/figure-commonmark/cell-26-output-1.png)

``` python
if DJI._libdirp == "":
    print("run dji_init() to initialize the DJI sdk.")
src = r"dataset\Deer_Goats_Unsure.jpg"
img = rjpeg_to_heatmap(src,dtype='int16')
fig = plt.figure(figsize=(10,8))
ax = sns.heatmap(img, cmap='gray')
ax.set_xticks([])
ax.set_yticks([])
plt.show()
```

![](index_files/figure-commonmark/cell-27-output-1.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lyuhaitao/dji_thermal_sdk",
    "name": "dji-thermal-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nbdev jupyter notebook python",
    "author": "hxl170008",
    "author_email": "hxl170008@utdallas.edu",
    "download_url": "https://files.pythonhosted.org/packages/60/26/19b7eba506973e7f3152dfb1527c6571eb94cdfc40e6b01defede5f9da10/dji_thermal_sdk-0.0.2.tar.gz",
    "platform": null,
    "description": "DJI Thermal SDK\n================\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n``` python\nfrom dji_thermal_sdk.dji_sdk import *\nfrom dji_thermal_sdk.utility import rjpeg_to_heatmap, rjpeg_to_thermal\nimport dji_thermal_sdk.dji_sdk as DJI\nimport ctypes as CT\nfrom ctypes import *\nimport os\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n```\n\nThis version of DJI Thermal SDK is 1.3, which was published on\n05/15/2022\n\n## Install\n\n`pip install dji_thermal_sdk`\n\n## The package only can work on Windows System.\n\nNormally, DJI SDK DLLs include\n`libdirp.dll, libv_dirp.dll, libv_girp.dll, libv_iirp.dll, libv_list.ini`.\n\nDJI does not provide the library for Linux. Therefore, if you run the\npackage on Linux, python complier will pop out \u2018invalid ELF header\u2019\nerror.\n\nFirstly, you should invoke \u2018dji_init\u2019 to initialize DJI sdk environment.\nThis step is very important\n\n## Initialize the DJI environment. This step is very important\n\n``` python\nnbdev.show_doc(dji_init)\n```\n\n------------------------------------------------------------------------\n\n### dji_init\n\n>      dji_init (dllpath:str=None)\n\nif you don\u2019t provide the file path of \u2018libdirp.dll\u2019, the default\n\u2018libdirp.dll\u2019 with version 1.3 will be automatically chosen.\n\n``` python\ndji_init()\nDJI._libdirp\n```\n\n    <CDLL 'C:\\Users\\hxl170008\\Documents\\git_repo\\dji_thermal_sdk\\dji_thermal_sdk\\libdirp.dll', handle 7ffcdb580000>\n\n## Get the handle of a R-JPEG image\n\nDIRP_HANDLE is a void pointer, and it has been definded.  \nyou can get it by `package.DIRP_HANDLE`\n\n``` python\nnbdev.show_doc(dirp_create_from_rjpeg)\n```\n\n------------------------------------------------------------------------\n\n### dirp_create_from_rjpeg\n\n>      dirp_create_from_rjpeg (data, size, ph)\n\nParameters: \\[in\\] data: R-JPEG binary data buffer pointer \\[in\\] size:\nR-JPEG binary data buffer size in bytes \\[out\\]ph : DIRP API handle\npointer - reminder: use two-level pointer to assign value to one-level\npointer Return: int return code dirp_ret_code_e\n\n``` python\nrd = r\"dataset\\Deer_Goats_Unsure.jpg\"\nwith open(rd, 'rb') as f:\n    content = f.read()\n    print(len(content))\n# method1 to get the file size\nprint(f\"File size: {os.path.getsize(rd)}\")\n# method 2 to get the file size\nfile_stat = os.stat(rd)\nsize = c_int32(file_stat.st_size)\nprint(f\"File size: {size}\")\n\n# the method to create a string buffer, which is important.\nrjpeg_data = CT.create_string_buffer(len(content))\nrjpeg_data.value = content\nprint(f\"rjpeg_data: {rjpeg_data}\")\n\n# test the function to create a handle of an image\nret = dirp_create_from_rjpeg(rjpeg_data,size, CT.byref(DIRP_HANDLE))\nprint(f'ret = {ret}')\nif ret == 0:\n    print(\"successfully get the r-jpeg handle.\")\n#\nprint(f\"DIRP_HANDLE: {DIRP_HANDLE}  address: {hex(DIRP_HANDLE.value)} \")\n```\n\n    1367428\n    File size: 1367428\n    File size: c_long(1367428)\n    rjpeg_data: <ctypes.c_char_Array_1367428 object>\n    ret = 0\n    successfully get the r-jpeg handle.\n    DIRP_HANDLE: c_void_p(2201333297840)  address: 0x20089b072b0 \n\n## Get the version of API\n\n``` python\nnbdev.show_doc(dirp_get_api_version)\n```\n\n<h4 id=\"dirp_get_api_version\" class=\"doc_header\">\n<code>dirp_get_api_version</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L193\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h4>\n\n> <code>dirp_get_api_version</code>(**`version`**)\n\nParameters: \\[out\\] version DIRP API version information pointer Return:\nint return code dirp_ret_code_e\n\n``` python\nnbdev.show_doc(dirp_api_version_t)\n```\n\n<h2 id=\"dirp_api_version_t\" class=\"doc_header\">\n<code>class</code>\n<code>dirp_api_version_t</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L68\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h2>\n\n> <code>dirp_api_version_t</code>() :: `Structure`\n\nAPI version structure definition\n\n``` python\njpeg_version = dirp_api_version_t() \nret = dirp_get_api_version(CT.byref(jpeg_version))\nif ret == DIRP_SUCCESS:\n    print(\"Success\")\n#\nprint(f\"jpeg_version.api: \\t {jpeg_version.api}\")\nprint(f\"jpeg_version.magic: \\t {jpeg_version.magic}\")\n```\n\n    Success\n    jpeg_version.api:    19\n    jpeg_version.magic:      b'b85e4d3'\n\n## Get the version of DJI JPG\n\n``` python\nnbdev.show_doc(dirp_get_rjpeg_version)\n```\n\n------------------------------------------------------------------------\n\n### dirp_get_rjpeg_version\n\n>      dirp_get_rjpeg_version (h, version)\n\nGet R-JPEG version. Parameters \\[in\\]h:DIRP API handle \\[out\\]version:\nR-JPEG version information pointer Returns int return code\ndirp_ret_code_e\n\n``` python\nnbdev.show_doc(dirp_rjpeg_version_t)\n```\n\n------------------------------------------------------------------------\n\n### dirp_rjpeg_version_t\n\nR-JPEG version structure definition\n\n``` python\njpeg_version = dirp_rjpeg_version_t()\nret = dirp_get_api_version(CT.byref(jpeg_version))\nif ret == DIRP_SUCCESS:\n    print(\"Success\")\n#\nprint(f\"rjpeg:{jpeg_version.rjpeg}\")\nprint(f\"header:{jpeg_version.header}\")\nprint(f\"curve:{jpeg_version.curve}\")\n```\n\n    Success\n    rjpeg:19\n    header:1697986658\n    curve:3367988\n\n## Get Color Bar\n\n``` python\nnbdev.show_doc(dirp_get_color_bar)\n```\n\n<h4 id=\"dirp_get_color_bar\" class=\"doc_header\">\n<code>dirp_get_color_bar</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L205\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h4>\n\n> <code>dirp_get_color_bar</code>(**`h`**, **`color_bar`**)\n\nParameters: \\[in\\] h: DIRP API handle \\[out\\] color_bar: ISP color bar\nparameters pointer Return: int return code dirp_ret_code_e\n\n``` python\nnbdev.show_doc(dirp_color_bar_t)\n```\n\n<h2 id=\"dirp_color_bar_t\" class=\"doc_header\">\n<code>class</code>\n<code>dirp_color_bar_t</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L74\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h2>\n\n> <code>dirp_color_bar_t</code>() :: `Structure`\n\nColor bar parameters structure definition\n\n``` python\njpeg_color_bar = dirp_color_bar_t()\nret = dirp_get_color_bar(DIRP_HANDLE, CT.byref(jpeg_color_bar))\nif ret == DIRP_SUCCESS:\n    print(\"Success\")\nprint(f\"jpeg_color_bar.high: \\t {jpeg_color_bar.high}\")\nprint(f\"jpeg_color_bar.low: \\t {jpeg_color_bar.low}\")\nprint(f\"jpeg_color_bar.manual_enable: \\t {jpeg_color_bar.manual_enable}\")\n```\n\n    Success\n    jpeg_color_bar.high:     -131073.015625\n    jpeg_color_bar.low:      9.10844001811131e-44\n    jpeg_color_bar.manual_enable:    False\n\n## Get the resolution of a R-JPEG image\n\nnbdev.show_doc(dirp_create_from_rjpeg)\n\n``` python\nnbdev.show_doc(dirp_get_rjpeg_resolution)\n```\n\n<h4 id=\"dirp_get_rjpeg_resolution\" class=\"doc_header\">\n<code>dirp_get_rjpeg_resolution</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L336\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h4>\n\n> <code>dirp_get_rjpeg_resolution</code>(**`h`**, **`rjpeg_info`**)\n\nGet R-JPEG image resolution information. Parameters \\[in\\]h: DIRP API\nhandle \\[out\\]rjpeg_info: R-JPEG basic information pointer Returns int\nreturn code dirp_ret_code_e\n\n``` python\nnbdev.show_doc(dirp_resolution_t)\n```\n\n<h2 id=\"dirp_resolution_t\" class=\"doc_header\">\n<code>class</code>\n<code>dirp_resolution_t</code><a href=\"https://github.com/lyuhaitao/dji_thermal_sdk/tree/master/dji_thermal_sdk/dji_sdk.py#L133\" class=\"source_link\" style=\"float:right\">\\[source\\]</a>\n</h2>\n\n> <code>dirp_resolution_t</code>() :: `Structure`\n\nThe image size structure definition\n\n``` python\nrjpeg_resolution = dirp_resolution_t()\nret = dirp_get_rjpeg_resolution(DIRP_HANDLE, CT.byref(rjpeg_resolution))\nprint(f'ret = {ret}')\nif ret == 0:\n    print(\"successfully get the resolution.\")\n\nout = f'Height: {rjpeg_resolution.height}, width: {rjpeg_resolution.width}'\nout\n```\n\n    ret = 0\n    successfully get the resolution.\n\n    'Height: 512, width: 640'\n\n## Set Pseudo Color\n\n``` python\nnbdev.show_doc(dirp_set_pseudo_color)\n```\n\n------------------------------------------------------------------------\n\n<a\nhref=\"https://github.com/lyuhaitao/dji_thermal_sdk/blob/master/dji_thermal_sdk/dji_sdk.py#LNone\"\ntarget=\"_blank\" style=\"float:right; font-size:smaller\">source</a>\n\n### dirp_set_pseudo_color\n\n>      dirp_set_pseudo_color (h, pseudo_color)\n\nSet custom ISP pseudo color type. Parameters \\[in\\]h:DIRP API handle\n\\[in\\]pseudo_color:ISP pseudo color type dirp_pseudo_color_e Returns int\nreturn code dirp_ret_code_e\n\n- DIRP_PSEUDO_COLOR_WHITEHOT = 0\n- DIRP_PSEUDO_COLOR_FULGURITE = 1\n- DIRP_PSEUDO_COLOR_IRONRED = 2\n- DIRP_PSEUDO_COLOR_HOTIRON = 3\n- DIRP_PSEUDO_COLOR_MEDICAL = 4\n- DIRP_PSEUDO_COLOR_ARCTIC = 5\n- DIRP_PSEUDO_COLOR_RAINBOW1 = 6\n- DIRP_PSEUDO_COLOR_RAINBOW2 = 7\n- DIRP_PSEUDO_COLOR_TINT = 8\n- DIRP_PSEUDO_COLOR_BLACKHOT = 9\n\n``` python\nret = dirp_set_pseudo_color(DIRP_HANDLE, c_int(0))\nif ret == DIRP_SUCCESS:\n    print(\"Success\")\nelse:\n    print(f\"Error: ret={ret}\")\n```\n\n    Success\n\n## Transform a thermal image by a specific palette\n\n``` python\nnbdev.show_doc(dirp_process)\n```\n\n------------------------------------------------------------------------\n\n### dirp_process\n\n>      dirp_process (h, color_image, size)\n\nRun ISP algorithm with RAW data in R-JPEG and output RGB pseudo color\nimage. The ISP configurable parameters can be modifed by these APIs:\ndirp_set_enhancement_params dirp_set_isotherm dirp_set_color_bar\ndirp_set_pseudo_color Parameters \\[in\\]h:DIRP API handle\n\\[out\\]color_image:Color image data buffer pointer \\[in\\]size:Color\nimage data buffer size in bytes. Returns int return code dirp_ret_code_e\n\n``` python\nsize = rjpeg_resolution.height * rjpeg_resolution.width * 3 * CT.sizeof(c_uint8)\nraw_image_buffer = CT.create_string_buffer(size)\nprint(raw_image_buffer.raw[100])\nret = dirp_process(DIRP_HANDLE,byref(raw_image_buffer), size)\nif ret == DIRP_SUCCESS:\n    print(\"Success\")\nelse:\n    print(f\"Error: ret={ret}\")\n#\nraw_file_path = os.path.splitext(rd)[0] + \".raw\"\nprint(raw_file_path)\nwith open(raw_file_path, 'wb') as f:\n    f.write(raw_image_buffer.raw)\n#\nif os.path.exists(raw_file_path):\n    print(f\"Success! file size: {os.path.getsize(raw_file_path)}\")\nelse:\n    print(\"Error\")\n#\nwith open(raw_file_path, encoding='cp1252') as fin:\n    img = np.fromfile(fin, dtype = np.uint8)\n    print(img.shape)\n    img.shape = (512,640,3)\n    #original = Image.fromarray(img)\n#\n\nfig = plt.figure(figsize=(10,8))\nplt.imshow(img, cmap='gray')\n```\n\n## rjpge_to_thermal\n\n``` python\nnbdev.show_doc(rjpeg_to_thermal)\n```\n\n------------------------------------------------------------------------\n\n### rjpeg_to_thermal\n\n>      rjpeg_to_thermal (src:str, palette:int)\n\nparameters: \\[str\\] src: file path of original jpg. For example, c:.jpg\n\\[int\\] palette: the number of palette - DIRP_PSEUDO_COLOR_WHITEHOT =\n0 - DIRP_PSEUDO_COLOR_FULGURITE = 1 - DIRP_PSEUDO_COLOR_IRONRED = 2 -\nDIRP_PSEUDO_COLOR_HOTIRON = 3 - DIRP_PSEUDO_COLOR_MEDICAL = 4 -\nDIRP_PSEUDO_COLOR_ARCTIC = 5 - DIRP_PSEUDO_COLOR_RAINBOW1 = 6 -\nDIRP_PSEUDO_COLOR_RAINBOW2 = 7 - DIRP_PSEUDO_COLOR_TINT = 8 -\nDIRP_PSEUDO_COLOR_BLACKHOT = 9 return: return numpy.ndarray -\\> img\n\n``` python\nif DJI._libdirp == \"\":\n    print(\"run dji_init() to initialize the DJI sdk.\")\nsrc = r\"dataset\\Deer_Goats_Unsure.jpg\"\nimg = rjpeg_to_thermal(src,0)\nfig = plt.figure(figsize=(10,8))\nplt.imshow(img)\nplt.show()\n```\n\n![](index_files/figure-commonmark/cell-24-output-1.png)\n\n## rjpge_to_heatmap\n\n``` python\nnbdev.show_doc(rjpeg_to_heatmap)\n```\n\n------------------------------------------------------------------------\n\n### rjpeg_to_heatmap\n\n>      rjpeg_to_heatmap (src:str, dtype='float32')\n\nparameters: \\[str\\] src: file path of original jpg. For example, c:.jpg\n\\[str\\] dtype: \u2018float32\u2019 or \u2018int16\u2019 return: return numpy.ndarray -\\> img\n\n``` python\nif DJI._libdirp == \"\":\n    print(\"run dji_init() to initialize the DJI sdk.\")\nsrc = r\"dataset\\Deer_Goats_Unsure.jpg\"\nimg = rjpeg_to_heatmap(src,dtype='float32')\nfig = plt.figure(figsize=(10,8))\nax = sns.heatmap(img, cmap='gray')\nax.set_xticks([])\nax.set_yticks([])\nplt.show()\n```\n\n![](index_files/figure-commonmark/cell-26-output-1.png)\n\n``` python\nif DJI._libdirp == \"\":\n    print(\"run dji_init() to initialize the DJI sdk.\")\nsrc = r\"dataset\\Deer_Goats_Unsure.jpg\"\nimg = rjpeg_to_heatmap(src,dtype='int16')\nfig = plt.figure(figsize=(10,8))\nax = sns.heatmap(img, cmap='gray')\nax.set_xticks([])\nax.set_yticks([])\nplt.show()\n```\n\n![](index_files/figure-commonmark/cell-27-output-1.png)\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Use ctypes to capsulate DJI thermal SDK. Generate thermal images with different palettes and heatmaps.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/lyuhaitao/dji_thermal_sdk"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "668bba3179724718c6d71eee242c0ecc95b06de1d4c42801f8d5b75b17744bfc",
                "md5": "f7a888dcdab171dc82cbb4737b136615",
                "sha256": "0b343b27c69dfb415c44dd1aaea1dd28def9ebcb8ab5aede7ff3bd3c9f615be0"
            },
            "downloads": -1,
            "filename": "dji_thermal_sdk-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7a888dcdab171dc82cbb4737b136615",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16068,
            "upload_time": "2023-08-30T23:42:30",
            "upload_time_iso_8601": "2023-08-30T23:42:30.844435Z",
            "url": "https://files.pythonhosted.org/packages/66/8b/ba3179724718c6d71eee242c0ecc95b06de1d4c42801f8d5b75b17744bfc/dji_thermal_sdk-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "602619b7eba506973e7f3152dfb1527c6571eb94cdfc40e6b01defede5f9da10",
                "md5": "cb89e1a912043598d007dd04e1dc0701",
                "sha256": "9cdfa7448b43a7b360e14b7c06220c22a7e6ac1aa8bfae2b9b21390a1273bb5c"
            },
            "downloads": -1,
            "filename": "dji_thermal_sdk-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cb89e1a912043598d007dd04e1dc0701",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 18743,
            "upload_time": "2023-08-30T23:42:32",
            "upload_time_iso_8601": "2023-08-30T23:42:32.443599Z",
            "url": "https://files.pythonhosted.org/packages/60/26/19b7eba506973e7f3152dfb1527c6571eb94cdfc40e6b01defede5f9da10/dji_thermal_sdk-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-30 23:42:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lyuhaitao",
    "github_project": "dji_thermal_sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dji-thermal-sdk"
}
        
Elapsed time: 0.53186s