pytsdk


Namepytsdk JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/Quenwaz/tsdk-wrap
SummaryPython version of dji_thermal_sdk
upload_time2024-08-06 12:03:06
maintainerNone
docs_urlNone
authorquenwa zhang
requires_pythonNone
licenseMIT License
keywords thermal dji tsdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 大疆红外测温SDK调用封装

为提供给python调用, 尝试将大疆红外测温sdk, 通过`pybind11`封装为python模块。 而在实际封装过程中存在`内存泄漏`, 于是放弃。 直接利用python的`ctypes`调用dll, 反而不存在内存泄漏。


> 大疆红外测温sdk下载地址为[https://www.dji.com/cn/downloads/softwares/dji-thermal-sdk](https://www.dji.com/cn/downloads/softwares/dji-thermal-sdk)


## 如何切换
在thermal/CMakeLists.txt中存在COMPILE_TO_DLL选项用于切换pybind11方式还是dll方式。


## 测试与检测内存泄漏

Windows检测内存泄漏参考[使用 CRT 库查找内存泄漏](https://learn.microsoft.com/zh-cn/cpp/c-runtime-library/find-memory-leaks-using-the-crt-library?view=msvc-170)。 具体在代码中使用:

在合适的地方包含如下代码:
```c++
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
```

建议在程序开始处编写如下代码:
```c++
_CrtDumpMemoryLeaks();
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
```

运行后即可在命令行窗口观察到内存泄漏报告


如何测试内存泄漏?通过python的`psutil`很方便对程序的内存情况进行监控, 案例如下:
```python
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 实际使用物理内存


## 示例
```python

thermal = ThermalInfo(True)
thermal.open(r"0B2D25BC332B40D09D8E6DD60050B00A.jpg")
temperature = thermal.get_temperature()
raw_image = thermal.get_raw_image()
thermal.close()

```












            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Quenwaz/tsdk-wrap",
    "name": "pytsdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "thermal, dji, tsdk",
    "author": "quenwa zhang",
    "author_email": "404937333@qq.com",
    "download_url": null,
    "platform": "Windows",
    "description": "# \u5927\u7586\u7ea2\u5916\u6d4b\u6e29SDK\u8c03\u7528\u5c01\u88c5\r\n\r\n\u4e3a\u63d0\u4f9b\u7ed9python\u8c03\u7528\uff0c \u5c1d\u8bd5\u5c06\u5927\u7586\u7ea2\u5916\u6d4b\u6e29sdk\uff0c \u901a\u8fc7`pybind11`\u5c01\u88c5\u4e3apython\u6a21\u5757\u3002 \u800c\u5728\u5b9e\u9645\u5c01\u88c5\u8fc7\u7a0b\u4e2d\u5b58\u5728`\u5185\u5b58\u6cc4\u6f0f`\uff0c \u4e8e\u662f\u653e\u5f03\u3002 \u76f4\u63a5\u5229\u7528python\u7684`ctypes`\u8c03\u7528dll, \u53cd\u800c\u4e0d\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f\u3002\r\n\r\n\r\n> \u5927\u7586\u7ea2\u5916\u6d4b\u6e29sdk\u4e0b\u8f7d\u5730\u5740\u4e3a[https://www.dji.com/cn/downloads/softwares/dji-thermal-sdk](https://www.dji.com/cn/downloads/softwares/dji-thermal-sdk)\r\n\r\n\r\n## \u5982\u4f55\u5207\u6362\r\n\u5728thermal/CMakeLists.txt\u4e2d\u5b58\u5728COMPILE_TO_DLL\u9009\u9879\u7528\u4e8e\u5207\u6362pybind11\u65b9\u5f0f\u8fd8\u662fdll\u65b9\u5f0f\u3002\r\n\r\n\r\n## \u6d4b\u8bd5\u4e0e\u68c0\u6d4b\u5185\u5b58\u6cc4\u6f0f\r\n\r\nWindows\u68c0\u6d4b\u5185\u5b58\u6cc4\u6f0f\u53c2\u8003[\u4f7f\u7528 CRT \u5e93\u67e5\u627e\u5185\u5b58\u6cc4\u6f0f](https://learn.microsoft.com/zh-cn/cpp/c-runtime-library/find-memory-leaks-using-the-crt-library?view=msvc-170)\u3002 \u5177\u4f53\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\uff1a\r\n\r\n\u5728\u5408\u9002\u7684\u5730\u65b9\u5305\u542b\u5982\u4e0b\u4ee3\u7801\uff1a\r\n```c++\r\n#define _CRTDBG_MAP_ALLOC\r\n#include <stdlib.h>\r\n#include <crtdbg.h>\r\n```\r\n\r\n\u5efa\u8bae\u5728\u7a0b\u5e8f\u5f00\u59cb\u5904\u7f16\u5199\u5982\u4e0b\u4ee3\u7801:\r\n```c++\r\n_CrtDumpMemoryLeaks();\r\n_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\r\n_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);\r\n```\r\n\r\n\u8fd0\u884c\u540e\u5373\u53ef\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u89c2\u5bdf\u5230\u5185\u5b58\u6cc4\u6f0f\u62a5\u544a\r\n\r\n\r\n\u5982\u4f55\u6d4b\u8bd5\u5185\u5b58\u6cc4\u6f0f\uff1f\u901a\u8fc7python\u7684`psutil`\u5f88\u65b9\u4fbf\u5bf9\u7a0b\u5e8f\u7684\u5185\u5b58\u60c5\u51b5\u8fdb\u884c\u76d1\u63a7\uff0c \u6848\u4f8b\u5982\u4e0b:\r\n```python\r\nimport psutil\r\nimport os\r\n\r\nprocess = psutil.Process(os.getpid())\r\n\r\nprint(f\"RSS memory: {process.memory_info().rss / (1024 * 1024):.2f} MB\")\r\n\r\n# \u6b64\u5904\u4e3a\u68c0\u6d4b\u6838\u5fc3\u4ee3\u7801\uff0c \u5185\u5b58\u6d88\u8017\u7684\u4ee3\u7801\r\n\r\nprint(f\"RSS memory: {process.memory_info().rss / (1024 * 1024):.2f} MB\")\r\n```\r\n\r\n> RSS\u662f\u6307Resident Set Size \u5b9e\u9645\u4f7f\u7528\u7269\u7406\u5185\u5b58\r\n\r\n\r\n## \u793a\u4f8b\r\n```python\r\n\r\nthermal = ThermalInfo(True)\r\nthermal.open(r\"0B2D25BC332B40D09D8E6DD60050B00A.jpg\")\r\ntemperature = thermal.get_temperature()\r\nraw_image = thermal.get_raw_image()\r\nthermal.close()\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python version of dji_thermal_sdk",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://github.com/Quenwaz/tsdk-wrap"
    },
    "split_keywords": [
        "thermal",
        " dji",
        " tsdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "12c1aad1a1364ec22c6d0f3b114c92413a99222da2595ae77616b91ab6548995",
                "md5": "0c15238f155ef0cd927e2c343018b9a4",
                "sha256": "a7a775277465515e7a23eee284c734fa246ac8976e73c63840ed6e4684b5b14f"
            },
            "downloads": -1,
            "filename": "pytsdk-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0c15238f155ef0cd927e2c343018b9a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5478490,
            "upload_time": "2024-08-06T12:03:06",
            "upload_time_iso_8601": "2024-08-06T12:03:06.290076Z",
            "url": "https://files.pythonhosted.org/packages/12/c1/aad1a1364ec22c6d0f3b114c92413a99222da2595ae77616b91ab6548995/pytsdk-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-06 12:03:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Quenwaz",
    "github_project": "tsdk-wrap",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytsdk"
}
        
Elapsed time: 0.56698s