OpenCV和Tesseract之间是否存在任何冲突
Is there any conflict between opencv and tesseract?
我在项目中使用tesseract和opencv。
但是问题是当我使用openCV显示图像时,只出现图像窗口,但图像没有出现,并且完全是灰色的。
如果我评论与Tesseract相关的代码,则OpenCV可以正确拍摄图像。
太奇怪了。有身体可以帮助我吗?
预先感谢!
#include "stdafx.h"
#include <string>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
// [1]
const char* imagename = "phototest.tif";
Mat img = imread(imagename);
if(img.empty())
{
fprintf(stderr, "Can not load image %sn", imagename);
return -1;
}
imshow("image", img);
tesseract::TessBaseAPI *myOCR =
new tesseract::TessBaseAPI();
// [2]
printf("Tesseract-ocr version: %sn",
myOCR->Version());
printf("Leptonica version: %sn",
getLeptonicaVersion());
// [3]
if (myOCR->Init(NULL, "eng")) {
fprintf(stderr, "Could not initialize tesseract.n");
exit(1);
}
// [4]
Pix *pix = pixRead("phototest.tif");
myOCR->SetImage(pix);
// [5]
char* outText = myOCR->GetUTF8Text();
printf("OCR output:nn");
printf(outText);
// [6]
myOCR->Clear();
myOCR->End();
delete [] outText;
pixDestroy(&pix);
system("pause");
return 0;
}
您可以尝试在iMshow之后的某个地方添加CV :: Waitkey(10),这可能会解决您的问题。您可以通过CV :: Waitkey(-1)替换系统(暂停)。
相关文章:
- 使用聚合初始化模拟默认函数参数是否存在任何陷阱?
- 如何检查特定文件夹中是否存在任何文件?
- 除了字符串或宏调用之外,是否存在任何情况,其中"(<"是有效的字符流?
- std :: vector用作堆栈和std :: stack之间是否存在任何复杂性差异
- 在使用__file__,__line__时,是否存在任何兼容性问题
- 如果存在任何循环关系,我应该假设弱指针使用吗?
- 用“ strcpy”在2D数组中删除(字符)的一行(字符)时是否存在任何错误
- 结构数据D = {0}和结构数据D = {}之间是否存在任何区别
- 编译时,复制构造函数/复制分配和正常功能调用优化之间是否存在任何区别
- OpenCV和Tesseract之间是否存在任何冲突
- 使用成员对成员的引用是否存在任何陷阱
- 当使用不相等vs均等时,是否存在任何性能差异
- 如果在另一个库和链接到此库的应用程序中都使用了仅标头的库,是否存在任何问题
- 如何在不存在任何数据损坏风险的情况下序列化对象
- 两个线程之间是否存在任何内存泄漏(缓冲、清空)
- VBO 与即时模式 (glBegin/glEnd) 的行为是否存在任何行为差异
- 如何将数字拆分为其数字并将它们相加,如果存在任何字符,则应"invalid input"输出?
- 模板别名shared_ptr和unique_ptr时是否存在任何问题或限制
- 从抽象类继承的抽象方法是否存在任何性能问题
- 在 OMNeT++ 中使用多重继承时是否存在任何已知问题