【发布时间】:2011-12-13 13:45:15
【问题描述】:
我需要处理从 OpenCV 获取的图像。
到目前为止我写的:
IplImage* img=0;
img=cvLoadImage("paket2.tif");
api.SetRectangle(0,0,img->width, img->height);
api.SetImage((uchar*)img->imageData,img->width,img->height,img->depth/8,img->width*(img->depth/8));
//i tried also below line
//api.SetImage((uchar*)img->imageData,img->width,img->height,img->depth/8,img->widthStep);
int left,top,right,bottom;
left=0;top=0;right=0;bottom=0;
api.Recognize(NULL);
tesseract::ResultIterator *ri=api.GetIterator();
char * sonuc=(*ri).GetUTF8Text(tesseract::RIL_SYMBOL);
if((*ri).BoundingBox(tesseract::RIL_SYMBOL,&left,&top,&right,&bottom))
{printf("bb dogru\n");printf("%d,%d,%d,%d",left,top,right,bottom);}
printf("sonuc:%s",sonuc);
如果我将 IplImage->widthStep 传递给每行字节数,我在左右值中有“错误”边界框,并且无法读取图像中的所有文本。
如果我通过 IplImage->width*(IplImage->depth/8),boundingBox 函数返回 false。
我希望你有一些想法。 提前致谢。
【问题讨论】:
-
IplImage* img=0; img=cvLoadImage("paket2copy.png"); printf("width:%d",img->width); printf("byte depth:%d",img->depth/8); printf("widthStep:%d",img->widthStep);结果:width:642 byte depth:1 widthStep:1928;这是正常的吗,每像素字节为 1 但宽度步长是宽度的 3 倍? -
如果您在此期间找到了可行的解决方案,能否请您发布您的代码?
-
不幸的是不是一个精确的解决方案。但我认为用opencv获取字母(作为结合的黑色形状)并逐字母发送到tesseract以识别它们。但在我的情况下,这已经足够了,因为我不需要左右边界,我只需要上下边界。