2016-10-25 3 views
0

Magick ++とTesseract OCRを組み合わせたいと思っています。私は++Magick ++をTesseractで使用する

画像

オブジェクト

たTesseract

にsetImage(のconst UCHARの*、int型の幅、int型の高さ、int型byte_per_pixel、int型byte_per_line)魔術を送信できませんでした。

メソッド。それはbyte_per_line情報を持っていません。

ありがとうございました。

編集:emcconvilleの助けを借りて私のコードを整理したところ、うまくいくようです。

Magick::Image* imgptr = mat2Image(frame); // cv::Mat 
Geometry size = imgptr->size(); 
imgptr->density(Geometry(300,300)); 

size_t area = frame.rows * frame.cols; 
uchar* data = new uchar[3 * CharPixel * area]; 

imgptr->write(0,0,frame.cols,frame.rows, "BGR",CharPixel,data); 
api- >SetImage(data,size.width(),size.height(),3*CharPixel,3*CharPixel*size.width()); 

delete [] data; 
delete imgptr; 
+0

[mcve]は、あなたに役立つ情報が不足しているときに入力してください。 – Nikita

+1

クイックノート: 'CharPixel'はデータ型です。サイズを計算するには 'sizeof(unsigned char)'があります。だから '3 * sizeof(unsigned char)' – emcconville

答えて

2

魔術++でデータをエクスポートする前に

Magick::Image.write(const ssize_t x_, 
        const ssize_t y_, 
        const size_t columns_, 
        const size_t rows_, 
        const std::string &map_, 
        const StorageType type_, void *pixels_) 

...のデータのエクスポート方法を持っている、あなたは&map_引数(例えば「RGBA」)、およびサイズはどのカラーチャンネルを決定する必要があります各色チャネルのtype_(例:CharPixel)。次に、すべてのデータ(チャネルの数*ストレージタイプのサイズ*イメージの領域)を保持するのに十分な大きさのバッファーを割り当てます(pixels_)。

エクスポートしたら、*蓄積型サイズチャネルの数であるbyte_per_pixelTessBaseAPI::SetImageにバッファを通過することができる必要があり、面積のbyte_per_line通常byte_per_pixel *幅。

関連する問題