2016-10-22 19 views
1

BoostでPythonでプログラムを最適化し、PythonコードをC++関数に置き換えようとしています。画像をPythonからC++にBoost経由で送信

Pythonコード:C++で

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 

とコード:

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);` 

だから、私は2つのことにする必要があります。

  1. をパイソンからの画像を送信しますC++はBoost.Pythonを使用しています。
  2. イメージの配列をC++に送信します(C++でマルチ処理を使用してパフォーマンスを向上させたい)。

答えて

0

あなたがたTesseractのC++のAPIをラップtesserocrを使用して試すことができます:

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を初期化し、複数の画像を処理するためにそれを使用します。

+0

答えていただきありがとうございます。私はpy-tesseractをtesserocrに置き換えようとします。結果について後ほど書きます。 – lucas63

+0

Ty、 – lucas63

関連する問題