I am trying to call this cpp function from python:
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename,
const char* retry_config, int timeout_millisec, TessResultRenderer* renderer)
{
if (handle->ProcessPages(filename, retry_config, timeout_millisec, renderer))
return TRUE;
else
return FALSE;
}
The last parameter to this function is TessResultRenderer. There is another cpp function to createTessResultRenderer
TESS_API TessResultRenderer* TESS_CALL TessTextRendererCreate(const char* outputbase)
{
return new TessTextRenderer(outputbase);
}
Now, calling this from my python, I did the following:
outputbase = "stdout"
renderer = tesseract.TessTextRendererCreate(outputbase)
text_out = tesseract.TessBaseAPIProcessPages(api,
ctypes.create_string_buffer(path),
None, 0, renderer) //Segmentation fault (core dumped) error on this line
but I keep getting the error Segmentation fault.
My question is: how can I call TessBaseAPIProcessPagesfrom Python?
A few more links are links to the codebase:
referer api
Implementation of processPages (...)
Edit
After reading the comments, I did the following, but I get an error: item 1 in _argtypes_ has no from_param method
PTessResultRenderer = ctypes.POINTER(TessResultRenderer)
self.tesseract.TessTextRendererCreate.restype = PTessResultRenderer
outputbase = "stdout"
self.tesseract.TessTextRendererCreate.argtypes = [outputbase]
self.tesseract.TessTextRendererCreate
ReturnVal = ctypes.c_bool
self.tesseract.TessBaseAPIProcessPages.argtypes = [self.api, path, None, 0, PTessResultRenderer]
self.tesseract.TessBaseAPIProcessPages.restype = ReturnVal
self.tesseracto.TessBaseAPIProcessPages
class TessResultRenderer(ctypes.Structure):
pass