Skip to content

feat: 新增 C API 导出与 Python 封装#197

Merged
qianniancn merged 1 commit into
WallBreaker2:masterfrom
qianniancn:codex/c-api
Jun 17, 2026
Merged

feat: 新增 C API 导出与 Python 封装#197
qianniancn merged 1 commit into
WallBreaker2:masterfrom
qianniancn:codex/c-api

Conversation

@qianniancn

Copy link
Copy Markdown
Collaborator

说明

新增独立的 C API 动态库导出,方便非 COM 场景直接调用 libop。

这次同时补了 Python 封装层,Python 侧通过 ctypes 调用 C API,
不再依赖 COM,也只保留 snake_case 风格的方法名。

主要改动

  • 新增 op_c_api_x86 / op_c_api_x64 构建目标
  • 新增 include/op_c_api.h 和 C API 实现
  • 补齐内存读写相关接口,包括整数、浮点数和字符串
  • COM 接口同步增加新的内存方法
  • 新增 Python 包装层和中文 README

验证

  • 构建通过 libop
  • 构建通过 op_c_api_x64
  • 构建通过 op_x64
  • Python 封装可加载 op_c_api_x64.dll
  • Python 内存读写基础用例通过
  • python -m compileall -q python\op 通过

新增独立的 op_c_api 动态库目标,补齐公开头文件和导出实现。

C API 覆盖现有 libop 能力,并补上整数、浮点数和字符串
内存读写接口。COM 接口同步增加这些方法,避免不同调用入口
能力不一致。

调整 CMake 安装规则和构建脚本,让 x86/x64 都能产出
op_c_api_x86/op_c_api_x64。libop 作为静态实现被 C API 目标
复用,减少重复链接问题。

新增 Python 包装层,通过 ctypes 调用 C API。Python 侧只保留
snake_case 方法,并提供 constants 模块保存窗口、绑定、图色
和 OpenCV 等常用模式值。
@qianniancn qianniancn merged commit be5cf3e into WallBreaker2:master Jun 17, 2026
3 checks passed
WallBreaker2 added a commit that referenced this pull request Jun 18, 2026
This PR adds an optional YOLO HTTP detection integration that follows
the existing OCR HTTP-service pattern.

New COM/C++ APIs:
- SetYoloEngine(path_of_engine, dll_name, argv)
- YoloDetect(x1, y1, x2, y2, conf, iou)
- YoloDetectFromFile(file_name, conf, iou)

The DLL does not embed YOLO/ONNX/DirectML runtime dependencies. It only
captures or loads images and sends raw pixels to an external HTTP service,
similar to the current generic OCR service flow.

Refactored to extract shared HTTP infrastructure into HttpWrapper,
eliminating ~200+ lines of duplicated code between OcrWrapper and YoloWrapper.

Resolved merge conflicts with master (PR #197 C API changes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Add optional YOLO HTTP detection integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant