你应该传递一个字符串.
例如:
self.tesseract.TessTextRendererCreate('/path/to/output/file/without/extension')
这是一个带有模拟API的通用示例.在lib.cc中:
#include
extern "C" {
const char * foo (const char * input) {
std::cout <<
"The function 'foo' was called with the following "
"input argument: '" << input << "'" << std::endl;
return input;
}
}
使用以下命令编译共享库:
clang++ -fPIC -shared lib.cc -o lib.so
然后,在Python中:
>>> from ctypes import cdll, c_char_p
>>> lib = cdll.LoadLibrary('./lib.so')
>>> lib.foo.restype = c_char_p
>>> result = lib.foo('Hello world!')
The function 'foo' was called with the following input argument: 'Hello world!'
>>> result
'Hello world!'