首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

针对原始pyk4a进行了修改,适用于双AzureKinect相机同时采图,该库使用详情请见后续博客

后端 63.4KB 11 需要积分: 1
立即下载

资源介绍:

主要将AzureKinect相机的python-SDK进行了重写,添加了一个capture类,使得其调用后能够提取两台相机的视频流,根据此原理,只要主机算力足够,理论上可以实现三相机、四相机的图像采集
#include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif // to debug, use fprintf(stdout, "debug msg\n") or fprintf(stderr, "debug // msg\n");; #define NON_THREAD_SAFE 0 // Simple way to map k4a_color_resolution_t to dimensions const int RESOLUTION_TO_DIMS[][2] = {{0, 0}, {1280, 720}, {1920, 1080}, {2560, 1440}, {2048, 1536}, {3840, 2160}, {4096, 3072}}; const char *CAPSULE_PLAYBACK_NAME = "pyk4a playback handle"; const char *CAPSULE_DEVICE_NAME = "pyk4a device handle"; const char *CAPSULE_CALIBRATION_NAME = "pyk4a calibration handle"; const char *CAPSULE_TRANSFORMATION_NAME = "pyk4a transformation handle"; const char *CAPSULE_CAPTURE_NAME = "pyk4a capture handle"; const char *CAPSULE_RECORD_NAME = "pyk4a record handle"; static PyThreadState *_gil_release(int thread_safe) { PyThreadState *thread_state = NULL; if (thread_safe == NON_THREAD_SAFE) { thread_state = PyEval_SaveThread(); } return thread_state; } static void _gil_restore(PyThreadState *thread_state) { if (thread_state != NULL) { PyEval_RestoreThread(thread_state); } } static void capsule_cleanup_device(PyObject *capsule) { k4a_device_t *device_handle; device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); free(device_handle); } static void capsule_cleanup_image(PyObject *capsule) { k4a_image_t *image = (k4a_image_t *)PyCapsule_GetContext(capsule); k4a_image_release(*image); free(image); } static void capsule_cleanup_calibration(PyObject *capsule) { k4a_calibration_t *calibration = (k4a_calibration_t *)PyCapsule_GetPointer(capsule, CAPSULE_CALIBRATION_NAME); free(calibration); } static void capsule_cleanup_capture(PyObject *capsule) { k4a_capture_t *capture = (k4a_capture_t *)PyCapsule_GetPointer(capsule, CAPSULE_CAPTURE_NAME); k4a_capture_release(*capture); free(capture); } static void capsule_cleanup_playback(PyObject *capsule) { k4a_playback_t *playback_handle; playback_handle = (k4a_playback_t *)PyCapsule_GetPointer(capsule, CAPSULE_PLAYBACK_NAME); free(playback_handle); } static void capsule_cleanup_record(PyObject *capsule) { k4a_record_t *record_handle; record_handle = (k4a_record_t *)PyCapsule_GetPointer(capsule, CAPSULE_RECORD_NAME); free(record_handle); } static void capsule_cleanup_transformation(PyObject *capsule) { k4a_transformation_t *transformation = (k4a_transformation_t *)PyCapsule_GetPointer(capsule, CAPSULE_TRANSFORMATION_NAME); k4a_transformation_destroy(*transformation); free(transformation); } static PyObject *device_open(PyObject *self, PyObject *args) { uint32_t device_id; int thread_safe; PyThreadState *thread_state; PyArg_ParseTuple(args, "Ip", &device_id, &thread_safe); k4a_device_t *device_handle = (k4a_device_t *)malloc(sizeof(k4a_device_t)); if (device_handle == NULL) { fprintf(stderr, "Cannot allocate memory"); return Py_BuildValue("IN", K4A_RESULT_FAILED, Py_None); } thread_state = _gil_release(thread_safe); k4a_result_t result = k4a_device_open(device_id, device_handle); _gil_restore(thread_state); if (result == K4A_RESULT_FAILED) { free(device_handle); return Py_BuildValue("IN", result, Py_None); } PyObject *capsule = PyCapsule_New(device_handle, CAPSULE_DEVICE_NAME, capsule_cleanup_device); return Py_BuildValue("IN", result, capsule); } static PyObject *device_get_installed_count(PyObject *self, PyObject *args) { uint32_t count; count = k4a_device_get_installed_count(); return Py_BuildValue("I", count); } static PyObject *device_get_serialnum(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; k4a_buffer_result_t result; size_t data_size; PyArg_ParseTuple(args, "Op", &capsule, &thread_safe); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); result = k4a_device_get_serialnum(*device_handle, NULL, &data_size); if (result == K4A_BUFFER_RESULT_FAILED) { _gil_restore(thread_state); return Py_BuildValue("s", ""); } char *data = (char *)malloc(data_size); if (data == NULL) { _gil_restore(thread_state); fprintf(stderr, "Cannot allocate memory"); return Py_BuildValue("s", ""); } result = k4a_device_get_serialnum(*device_handle, data, &data_size); if (result != K4A_BUFFER_RESULT_SUCCEEDED) { free(data); return Py_BuildValue("s", ""); } _gil_restore(thread_state); PyObject *res = Py_BuildValue("s", data); free(data); return res; } static PyObject *device_close(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; PyArg_ParseTuple(args, "Op", &capsule, &thread_safe); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); k4a_device_close(*device_handle); _gil_restore(thread_state); return Py_BuildValue("I", K4A_RESULT_SUCCEEDED); } static PyObject *device_get_sync_jack(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; bool in_jack = 0; bool out_jack = 0; PyArg_ParseTuple(args, "Op", &capsule, &thread_safe); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); k4a_result_t result = k4a_device_get_sync_jack(*device_handle, &in_jack, &out_jack); _gil_restore(thread_state); return Py_BuildValue("III", result, in_jack, out_jack); } static PyObject *device_get_color_control(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; k4a_color_control_command_t command; k4a_color_control_mode_t mode; int32_t value = 0; PyArg_ParseTuple(args, "OpI", &capsule, &thread_safe, &command); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); k4a_result_t result = k4a_device_get_color_control(*device_handle, command, &mode, &value); _gil_restore(thread_state); if (result == K4A_RESULT_FAILED) { return Py_BuildValue("IIi", 0, 0, 0); } return Py_BuildValue("IIi", result, mode, value); } static PyObject *device_set_color_control(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; k4a_color_control_command_t command = K4A_COLOR_CONTROL_EXPOSURE_TIME_ABSOLUTE; k4a_color_control_mode_t mode = K4A_COLOR_CONTROL_MODE_MANUAL; int32_t value = 0; PyArg_ParseTuple(args, "OpIIi", &capsule, &thread_safe, &command, &mode, &value); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); k4a_result_t result = k4a_device_set_color_control(*device_handle, command, mode, value); _gil_restore(thread_state); if (result == K4A_RESULT_FAILED) { return Py_BuildValue("I", K4A_RESULT_FAILED); } return Py_BuildValue("I", result); } static PyObject *device_get_color_control_capabilities(PyObject *self, PyObject *args) { k4a_device_t *device_handle; PyObject *capsule; int thread_safe; PyThreadState *thread_state; k4a_color_control_command_t command; bool supports_auto; int min_value; int max_value; int step_value; int default_value; k4a_color_control_mode_t default_mode; PyArg_ParseTuple(args, "OpI", &capsule, &thread_safe, &command); device_handle = (k4a_device_t *)PyCapsule_GetPointer(capsule, CAPSULE_DEVICE_NAME); thread_state = _gil_release(thread_safe); k4a_result_t result = k4a_device_get_color_control_capabili

资源文件列表:

pyk4a_for_2camera.zip 大约有39个文件
  1. pyk4a/
  2. pyk4a/__init__.py 1.37KB
  3. pyk4a/__pycache__/
  4. pyk4a/__pycache__/__init__.cpython-36.pyc 1.43KB
  5. pyk4a/__pycache__/__init__.cpython-37.pyc 1.27KB
  6. pyk4a/__pycache__/calibration.cpython-36.pyc 6.74KB
  7. pyk4a/__pycache__/calibration.cpython-37.pyc 6.74KB
  8. pyk4a/__pycache__/capture.cpython-36.pyc 10.52KB
  9. pyk4a/__pycache__/capture.cpython-37.pyc 10.5KB
  10. pyk4a/__pycache__/config.cpython-36.pyc 3.02KB
  11. pyk4a/__pycache__/config.cpython-37.pyc 3KB
  12. pyk4a/__pycache__/errors.cpython-36.pyc 715B
  13. pyk4a/__pycache__/errors.cpython-37.pyc 715B
  14. pyk4a/__pycache__/module.cpython-36.pyc 792B
  15. pyk4a/__pycache__/module.cpython-37.pyc 792B
  16. pyk4a/__pycache__/playback.cpython-36.pyc 6.45KB
  17. pyk4a/__pycache__/playback.cpython-37.pyc 6.49KB
  18. pyk4a/__pycache__/pyk4a1.cpython-36.pyc 21.61KB
  19. pyk4a/__pycache__/pyk4a1.cpython-37.pyc 21.71KB
  20. pyk4a/__pycache__/record.cpython-36.pyc 6.25KB
  21. pyk4a/__pycache__/record.cpython-37.pyc 6.24KB
  22. pyk4a/__pycache__/results.cpython-36.pyc 739B
  23. pyk4a/__pycache__/results.cpython-37.pyc 739B
  24. pyk4a/__pycache__/transformation.cpython-36.pyc 1.83KB
  25. pyk4a/__pycache__/transformation.cpython-37.pyc 1.83KB
  26. pyk4a/__pycache__/win32_utils.cpython-36.pyc 1.47KB
  27. pyk4a/calibration.py 7.51KB
  28. pyk4a/capture.py 13.71KB
  29. pyk4a/config.py 2.71KB
  30. pyk4a/errors.py 348B
  31. pyk4a/module.py 1.01KB
  32. pyk4a/playback.py 6.49KB
  33. pyk4a/py.typed 8B
  34. pyk4a/pyk4a.cpp 57KB
  35. pyk4a/pyk4a1.py 21.57KB
  36. pyk4a/record.py 5.8KB
  37. pyk4a/results.py 314B
  38. pyk4a/transformation.py 1.94KB
  39. pyk4a/win32_utils.py 1.56KB
0评论
提交 加载更多评论
其他资源 IBM版 JDK1.4-1.7,通用 Java限制密钥长度策略文件
替换至%java_home%/jre/lib/security 下,覆盖即可
RealEvo-Simulator 下的 AMD64 平台系统镜像
RealEvo-Simulator 并不自带 AMD64 平台虚拟机,需要手动新建,这里给大家提供了该虚拟机的系统镜像,直接导入即可使用。 注意:使用 SylixOS 系统需要注册授权,这里提供的系统镜像是未授权的,有 24 小时复位限制,不过对于学习和验证这个时间也足够了。
RealEvo-Simulator 下的 AMD64 平台磁盘镜像
RealEvo-Simulator 并不自带 AMD64 平台虚拟机,需要手动新建,这里给大家提供了该虚拟机的磁盘镜像,里面已部署了base,VSOA、配置文件,测试程序等内容,直接导入即可使用。
高亮11111111111
高亮11111111111
61850装置通讯检查软件 检查装置61850通讯是否正常,用电脑搭建简易客户端读取装置模型非常方便
可以检查装置61850通讯是否正常,用电脑搭建简易客户端读取装置模型非常方便。 61850客户端模拟工具的主要功能包括: 1. 数据模型测试:模拟工具能够创建和管理61850数据模型,测试设备是否能正确解析和响应数据对象。 2. 服务模拟:模拟各种61850服务,如订阅(Subscription)、报告(Report)、控制(Control)和保护跳闸(Protection Trip)服务,评估设备的服务处理能力。 3. 一致性测试:根据61850标准进行一致性测试,检查设备是否符合标准要求。 4. 故障模拟:模拟网络故障、数据错误等情况,测试设备的容错能力和恢复机制。 5. 性能测试:测量设备在不同负载下的性能,包括数据传输速率、延迟等。
CheckStyle-IDEA-5.92.0.zip
CheckStyle IDEA插件(帮助JAVA开发人员遵守某些编码规范的工具)
由于找不到 MSVCR120.dl.zip
由于找不到 MSVCR120.dl.zip
易语言环境下共享图书源码
利用易语言制作的一款小说共享软件源码