← Back to team overview

cuneiform team mailing list archive

API issues

 

Dear All,

I'm trying to use cuneiform as a library. This is the code snippet
(mostly adapted from cuneiform_cli):

Magick::Image bmp(Magick::Geometry(x2-x1+1,y2-y1+1),"white");
bmp.monochrome(); 
bmp.type(Magick::BilevelType);

... populate the image using bmp.pixelColor(x, y, "black")...

Magick::Blob blob;
bmp.write(&blob, "DIB");
size_t data_size = blob.length();
char *dib = new char[data_size];
memcpy(dib, blob.data(), data_size);
char str[2]="_";
int langcode = LANG_ENGLISH;
Bool dotmatrix = 0;
Bool fax = 0;
Bool onecolumn = 1;
int32_t outputformat = PUMA_TOTEXT;
PUMA_Init(0, 0);
PUMA_SetImportData(PUMA_Word32_Language, &langcode);
PUMA_SetImportData(PUMA_Bool32_DotMatrix, &dotmatrix);
PUMA_SetImportData(PUMA_Bool32_Fax100, &fax);
PUMA_SetImportData(PUMA_Bool32_OneColumn, &onecolumn);
PUMA_XOpen(dib, NULL);
PUMA_XFinalRecognition();
PUMA_SaveToMemory(NULL, outputformat, PUMA_CODE_UTF8, str, 2);
PUMA_XClose();
PUMA_Done();

As you can see all I want is to get one or two recognized characters in
str. However I'm getting a crash at PUMA_Done() - here is the backtrace:

#0  0x0000003dd06326c5 in raise () from /lib64/libc.so.6
#1  0x0000003dd0633ea5 in abort () from /lib64/libc.so.6
#2  0x0000003dd066f133 in __libc_message () from /lib64/libc.so.6
#3  0x0000003dd0674ac6 in malloc_printerr () from /lib64/libc.so.6
#4  0x00007ffff32ea09d in CTB_done ()
   from /home/igor/cuneiform-linux-1.0.0/install/lib64/libctb32.so.1.0.0
#5  0x00007ffff39ca9fb in LEODone ()
   from /home/igor/cuneiform-linux-1.0.0/install/lib64/libleo32.so.1.0.0
#6  0x00007ffff4723ae7 in RSTRDone ()
   from /home/igor/cuneiform-linux-1.0.0/install/lib64/librstr.so.1.0.0
#7  0x00007ffff4723af9 in RSTR_Done ()
   from /home/igor/cuneiform-linux-1.0.0/install/lib64/librstr.so.1.0.0
#8  0x00007ffff7ddfafa in ModulesDone(void*) ()
from /home/igor/cuneiform-linux-1.0.0/install/lib64/libcuneiform.so.1.0.0
#9  0x00007ffff7de43b8 in PUMA_Done ()
from /home/igor/cuneiform-linux-1.0.0/install/lib64/libcuneiform.so.1.0.0

If I comment out PUMA_Done, the program is crashing at PUMA_XClose, and
so on until PUMA_XOpen - though the latter crashes might not be on the
first pass of the subroutine calling cuneiform functions.
Any recommendations?

Igor