Python version of dji_thermal_sdk
Project description
大疆红外测温SDK调用封装
为提供给python调用, 尝试将大疆红外测温sdk, 通过pybind11封装为python模块。 而在实际封装过程中存在内存泄漏, 于是放弃。 直接利用python的ctypes调用dll, 反而不存在内存泄漏。
大疆红外测温sdk下载地址为https://www.dji.com/cn/downloads/softwares/dji-thermal-sdk
如何切换
在thermal/CMakeLists.txt中存在COMPILE_TO_DLL选项用于切换pybind11方式还是dll方式。
测试与检测内存泄漏
Windows检测内存泄漏参考使用 CRT 库查找内存泄漏。 具体在代码中使用:
在合适的地方包含如下代码:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
建议在程序开始处编写如下代码:
_CrtDumpMemoryLeaks();
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
运行后即可在命令行窗口观察到内存泄漏报告
如何测试内存泄漏?通过python的psutil很方便对程序的内存情况进行监控, 案例如下:
import psutil
import os
process = psutil.Process(os.getpid())
print(f"RSS memory: {process.memory_info().rss / (1024 * 1024):.2f} MB")
# 此处为检测核心代码, 内存消耗的代码
print(f"RSS memory: {process.memory_info().rss / (1024 * 1024):.2f} MB")
RSS是指Resident Set Size 实际使用物理内存
示例
thermal = ThermalInfo(True)
thermal.open(r"0B2D25BC332B40D09D8E6DD60050B00A.jpg")
temperature = thermal.get_temperature()
raw_image = thermal.get_raw_image()
thermal.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytsdk-0.0.8.tar.gz.
File metadata
- Download URL: pytsdk-0.0.8.tar.gz
- Upload date:
- Size: 2.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f917aca9667100fe7ef6a251c9bcc54f0f0b7b300527047501efcbe3e2cc45
|
|
| MD5 |
0fda4214e534be0e0b9b495efcd2b9b3
|
|
| BLAKE2b-256 |
98b63350a8c7cf9139b00b577b93fdb5718686b11ca2820ff47e001f5420a7a7
|
File details
Details for the file pytsdk-0.0.8-py3-none-any.whl.
File metadata
- Download URL: pytsdk-0.0.8-py3-none-any.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a92f235630f0b659fd141ac3d18386b94af4a4d6f08354a12863d693d9eb79c6
|
|
| MD5 |
134fb787eff016ed4782fd4f1aa7840b
|
|
| BLAKE2b-256 |
b791c20a47829485e913f079620aed28912ff96773c07730e3db98269cac4547
|