通过Boost将图像从Python发送到c++
Send image from Python to C++ through Boost
我正在尝试用Boost优化Python上的程序,并将一些Python代码替换为c++函数。
Python代码: from PIL import Image
for i in xrange(len(lines)):
im = Image.fromarray(lines[i])
line = pytesseract.image_to_string(im, "ukr+ukrb") # working to slow
c++上的代码:
Pix *image = pixRead("/home/lucas63/Downloads/test.tif"); # here i need to get image directly from Python
api->SetImage(image);
outText = api->GetUTF8Text();
printf("OCR output:n%s", outText);`
所以,我需要做两件事:
- 使用
Boost.Python
从Python发送图像到c++。 - 发送图像数组到c++(我想在c++中使用多线程来提高性能)。
你可以尝试使用tesserocr来封装tesseract的c++ API:
import tesserocr
with tesserocr.PyTessBaseAPI(lang='ukr+ukrb') as api:
for l in lines:
im = Image.fromarray(l)
api.SetImage(im)
line = api.GetUTF8Text()
这将初始化API一次,并使用它来处理多个图像。
相关文章:
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- Pybind11:将元组列表从Python传递到C++
- 如何在c++中使用引用实现类似python的行为
- 是否可以通过C++扩展强制多个python进程共享同一内存
- 递归列出所有目录中的C++与Python与Ruby的性能
- IPC使用多个管道和分支进程来运行Python程序
- 从python中调用C++函数并获取返回值
- Python 3.7 和 excess_args 的 SWIG 问题
- Python中的for循环与C++有何不同
- 使用Pybind11向Python公开Eigen::张量
- Python str to C++ to Python str
- 如何使用Python从C++中读取谷物序列化数据
- 如何在C++中使用pybind11加载一个pickle python列表
- 如何在c++中使用system()来运行包含空格的python脚本
- python集合的C++等价物是什么.计数器
- 如果C++对象的类在另一个boost模块中声明,如何使用boost将指向该对象的指针返回到python
- 从python调用openMP共享库时,未定义opnMP函数
- 使用JsonCpp将数据返回到带有pybind11的python会在python调用中产生Symbol not foun
- 如何将真正的字符串从python c-api转换为python脚本
- Python ctype 'c_char_p' Memory Leak