我已经创建了一个C++项目,我使用C和C++代码并且标题有一些问题......好吧,我有3个代码:
basicOCR.cpp
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "preprocessing.h"
#include "basicOCR.h"
Run Code Online (Sandbox Code Playgroud)
preprocessing.c
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include "preprocessing.h"
Run Code Online (Sandbox Code Playgroud)
main.c中
#include <stdio.h>
#include <ctype.h>
#include "basicOCR.h"
Run Code Online (Sandbox Code Playgroud)
和我自己的头文件:
basicOCR.h
#include <stdio.h>
#include <ctype.h>
Run Code Online (Sandbox Code Playgroud)
preprocessing.h
#include <stdio.h>
#include <ctype.h>
Run Code Online (Sandbox Code Playgroud)
每当我尝试编译项目时,它编译basicOCR.cpp没有任何问题,但preprocessing.c和main.c在cstdlib和xstddef中给出了语法错误.我知道它们是C++库.我读了这篇如何混合C和C++
并尝试了几乎所有的东西,但它没有奏效.
1> preprocessing.c
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cstdlib(19): error C2054: expected '(' to follow 'using'
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cstdlib(19): error C2061: syntax error : identifier 'using' …Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2010中有一个C++项目,并希望使用OCR.我偶然发现了Tesseract的许多"教程",但遗憾的是,我得到的只是头疼和浪费时间.
在我的项目中,我将图像存储为Mat.我的问题的一个解决方案是将此Mat保存为图像(例如image.jpg),然后像这样调用Tesseract可执行文件:
system("tesseract.exe image.jpg out");
Run Code Online (Sandbox Code Playgroud)
哪我得到输出out.txt然后我打电话
infile.open ("out.txt");
Run Code Online (Sandbox Code Playgroud)
从Tesseract读取输出.
这一切都很好,就像椅子一样,但它不是最佳解决方案.在我的项目中,我正在处理一个视频,因此以10+ FPS 保存/调用.exe/write/read并不是我真正想要的.我想将Tesseract实现为现有代码,以便能够将Mat作为参数传递并立即将结果作为String获取.
您是否知道使用Visual Studio 2010实现Tesseract OCR的任何好教程(首先是一步一步)?或者您自己的解决方案