[英]Using Magick++ with Tesseract
I wish to combine Magick++ with Tesseract OCR. 我希望将Magick ++与Tesseract OCR相结合。 I couldn't send Magick++
我无法发送Magick ++
Image
图片
object to Tesseract 反对Tesseract
setImage(const uchar*,int width,int height,int byte_per_pixel,int byte_per_line);
setImage(const uchar *,int width,int height,int byte_per_pixel,int byte_per_line);
method. 方法。 It doesnt have byte_per_line information.
它没有byte_per_line信息。
Thanks for any help. 谢谢你的帮助。
Edit: with the help of emcconville i organized my code and it seems working. 编辑:在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;
Magick++ has a data-export method of... Magick ++的数据导出方法为...
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_)
Before exporting data, you need to determine which color channels in the &map_
argument (eg "RGBA"), and the size of the each color channel type_
(eg CharPixel
). 导出数据之前,需要以确定哪些颜色通道
&map_
参数(例如,“RGBA”),并且每个颜色通道的大小type_
(例如CharPixel
)。 You'll then be responsible for allocating a buffer pixels_
large enough to hold all the data (number of channels * sizeof storage type * area of image). 然后你会负责分配的缓冲区
pixels_
大到足以容纳所有数据(通道数*的sizeof存储类型*图像的区域)。
After exporting, you should be able to pass the buffer to TessBaseAPI::SetImage
with byte_per_pixel
being the number of channels * storage type size, and byte_per_line
usually byte_per_pixel
* width of area. 导出后,您应该能够将缓冲区传递给
TessBaseAPI::SetImage
其中byte_per_pixel
是通道数*存储类型大小,而byte_per_line
通常是byte_per_pixel
*区域宽度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.