-
October 4th, 2018, 05:39 AM
#31
Re: Using Tesseract in MFC
Originally Posted by 2kaud
You are redefining the symbol DLLSYM.
Try just
Code:
debug_file = "C:\\Flaviu\\test.txt";
I have tried that, the test.txt file is still empty ... I am not get it ... I have compiled leptonica, and tesseract library successfully, included inside my project, no error, still, the following simple code is not working:
Code:
if (0 != api.Init(NULL, NULL))
{
m_sState.Format(_T("tesseract initialize error. last error: %d"), GetLastError());
::SendMessage(theApp.m_pMainWnd->GetSafeHwnd(), WM_SETMESSAGESTRING, 0, (LPARAM)(LPCTSTR)m_sState);
}
// tesseract initialize error. last error: 3
strange ... I guess is about configuring tesseract ? However, they were compiled successfully ... with no error, the same platform, the same settings ...
-
October 4th, 2018, 06:46 AM
#32
Re: Using Tesseract in MFC
I would suggest that first you try creating a new non-mfc standard console c++ solution that only tries to initialise tesseract. If this still fails then you're going to have to get your hands dirty and debug tesseract.
If this simple test program does initialise ok, then it's something you doing in your code that tesseract doesn't like. Then try the simplest mfc program with tesseract and see if that works. If not, then there's something about mfc and tesseract which will have to be debugged to determine. If this simple mfc test program does initialise tesseract then add code and test after each code addition until you know what code was added to cause tesseract to not initialise.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
October 5th, 2018, 04:58 AM
#33
Re: Using Tesseract in MFC
Originally Posted by 2kaud
I would suggest that first you try creating a new non-mfc standard console c++ solution that only tries to initialise tesseract. If this still fails then you're going to have to get your hands dirty and debug tesseract.
If this simple test program does initialise ok, then it's something you doing in your code that tesseract doesn't like. Then try the simplest mfc program with tesseract and see if that works. If not, then there's something about mfc and tesseract which will have to be debugged to determine. If this simple mfc test program does initialise tesseract then add code and test after each code addition until you know what code was added to cause tesseract to not initialise.
Very good suggestion: soon as I run this code inside a console app, I get valuable error messages. Here is the code:
Code:
#include <leptonica/allheaders.h>
#include <tesseract/baseapi.h>
int main()
{
std::cout << "Hello World!\n";
tesseract::TessBaseAPI api;
if (0 != api.Init(NULL, NULL))
{
std::cout << "tesseract initialize error\n";
std::cout << "Last error:" << GetLastError() << std::endl;
}
}
and here is the messages:
Code:
Hello World!
Error in pixReadMemTiff: function not present
Error in pixReadMem: tiff: no pix returned
Error in pixaGenerateFontFromString: pix not made
Error in bmfCreate: font pixa not made
Error opening data file C:\Program Files (x86)\Tesseract-OCR\eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
tesseract initialize error
Last error:3
but I have not any "Tesseract-OCR" folder in "Program Files (x86)" ...
-
October 5th, 2018, 06:20 AM
#34
Re: Using Tesseract in MFC
Originally Posted by mesajflaviu
Very good suggestion: soon as I run this code inside a console app, I get valuable error messages. Here is the code:
Code:
#include <leptonica/allheaders.h>
#include <tesseract/baseapi.h>
int main()
{
std::cout << "Hello World!\n";
tesseract::TessBaseAPI api;
if (0 != api.Init(NULL, NULL))
{
std::cout << "tesseract initialize error\n";
std::cout << "Last error:" << GetLastError() << std::endl;
}
}
and here is the messages:
Code:
Hello World!
Error in pixReadMemTiff: function not present
Error in pixReadMem: tiff: no pix returned
Error in pixaGenerateFontFromString: pix not made
Error in bmfCreate: font pixa not made
Error opening data file C:\Program Files (x86)\Tesseract-OCR\eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
tesseract initialize error
Last error:3
but I have not any "Tesseract-OCR" folder in "Program Files (x86)" ...
Well there's your error 3 from GetLastError(). It was being set by .Init() trying to open a non-existent file.
The 'fix' is also stated in the messages. You need to find the file 'eng.traineddata' on your system and set the TESSDATA_PREFIX environment variable to point to the directory on your system in which this file resides. If this file doesn't exist anywhere then you haven't downloaded and installed the required data files. See https://github.com/tesseract-ocr/tessdata for eng.traineddata file.
PS See also https://github.com/tesseract-ocr for further data/info.
Last edited by 2kaud; October 5th, 2018 at 06:23 AM.
Reason: PS
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
October 11th, 2018, 05:23 AM
#35
Re: Using Tesseract in MFC
That is why I coming here, I always solve the problems
Soon as I set up the correct TESSDATA_PREFIX system variable, the .Init method has worked well.
Now I have met another error, while was trying to use:
Code:
Pix* pImage = pixRead("C:\\Flaviu\\imagine.png");
from official API example: https://github.com/tesseract-ocr/tes...iki/APIExample
Code:
int main()
{
tesseract::TessBaseAPI api;
if (0 != api.Init(NULL, NULL))
{
std::cout << "====tesseract initialize error\n";
std::cout << "====Last error:" << GetLastError() << std::endl;
}
Pix* pImage = pixRead("C:\\Flaviu\\imagine.png"); // <--- pImage has 0
printf("pImage pointer value: %p\n", pImage);
}
the result is:
Code:
Error in pixReadMemTiff: function not present
Error in pixReadMem: tiff: no pix returned
Error in pixaGenerateFontFromString: pix not made
Error in bmfCreate: font pixa not made
Error in pixReadStreamPng: function not present
Error in pixReadStream: png: no pix returned
Error in pixRead: pix not read
pImage pointer value: 00000000
obviously, I have searched on internet these errors messages, and they tell me to compile libtiff before to install leptonica: https://stackoverflow.com/questions/...nclude-libtiff
Code:
Try to install
apt-get install -y libtiff5-dev
Then install leptonica from source
git clone https://github.com/DanBloomberg/leptonica.git leptonica
cd leptonica
./autobuild
./configure --with-libtiff
make -j
make install
And reinstall tesseract after that
what is these commands ? git clone ... etc. ? I don't have any git app, and I have no need of such thing ...
-
October 11th, 2018, 05:44 AM
#36
Re: Using Tesseract in MFC
These are linux commands! Have you installed/compiled libtiff/leptonica on your system?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
October 11th, 2018, 06:56 AM
#37
Re: Using Tesseract in MFC
Originally Posted by 2kaud
These are linux commands! Have you installed/compiled libtiff/leptonica on your system?
No, I guess not ... myself I installed nothing about this ... I only compiled leptonica from github ... that is all.
-
October 12th, 2018, 02:55 AM
#38
Re: Using Tesseract in MFC
I have installed leptonica and tesseract library on my PC. I haven't seen any libtiff option during installation/compilation process ..
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|