I'm building tesseract 3.01 and magick++ into a program because the command line versions were too slow. getting everything compiled correctly took forever but finally I get no errors in my compiler, but as soon as I go to run my console app I get
PS C:\Users\sirus\Documents\Visual Studio 2013\Projects\ConsoleApplication4\Release> .\ConsoleApplication4.exe
first command
actual_tessdata_num_entries_ <= TESSDATA_NUM_ENTRIES:Error:Assert failed:in file ..\ccutil\tessdatamanager.cpp, line 48
PS C:\Users\sirus\Documents\Visual Studio 2013\Projects\ConsoleApplication4\Release> l
searching for this online shows that this is what happens when you have to incorrect language data, but I have tesseract 3.01 and the tesseract 3.01 language data downloaded directly from their google code site.
I'm using visual studio 2013 on windows 8.1 building 32 bit /MD
here is a sample of my source
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <locale>
#include <sstream>
#include <string>
#include <Magick++.h>
#include "baseapi.h"
#include "allheaders.h"
using namespace Magick;
using namespace std;
using namespace tesseract;
#define MaxRGB ((Magick::Quantum)65545)
tesseract::TessBaseAPI tess;
string cmd = "";
string cmd2 = "";
void img_split(){
string tesseract = "\"C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe\" text/";
int rect_y = 141;
string del = "del /s /q text\\*";
system(del.c_str());
for (int x = 1; x < 40; x++){
rect_y += 19;
Image image;
image.read("source.jpg");
Magick::Image* mImage;
Image sub_image(image);
mImage = &sub_image;
//mImage->write("test.jpg");
sub_image.chop(Geometry(1481, rect_y));
sub_image.crop(Geometry(220, 17));
sub_image.quantizeColorSpace(GRAYColorspace);
sub_image.quantizeColors(2);
sub_image.quantizeDither(false);
sub_image.quantize();
sub_image.scale(Geometry(2200,170));
sub_image.antiAlias();
sub_image.compressType(Magick::NoCompression);
//const unsigned char* imagedata = (unsigned char*)mImage;
//tess.SetImage(imagedata, 2200, 170, 1, 17300);
//tess.Recognize(0);
//const char* out = tess.GetUTF8Text();
//cout << "\n\nno idea if this will work: " << out << endl;
sub_image.write("text/" + static_cast<ostringstream*>(&(ostringstream() << x))->str() + ".gif");
//cmd2 = tesseract + static_cast<ostringstream*>(&(ostringstream() << x))->str() + ".png text/" + static_cast<ostringstream*>(&(ostringstream() << x))->str();
//tesseract_ocr(x);
}
}
int main(int argc, char **argv)
{
cout << "first command\n";
//tess.Init(argv[0], "eng", tesseract::OEM_DEFAULT);
tess.Init(*argv, "eng");
tess.SetPageSegMode(tesseract::PSM_AUTO);
cout << "\ntest" << endl;
InitializeMagick(*argv);
//img_split();
return 0;
}
bonus points if you can tell me how to correctly pass the image in sub_image to tesseract's setimage function (because i'm pretty sure what I have wont be right either)