> The fact I have to supply those coordinates to the function is because
> I'm working with a raster image and the coordinates system on it is
> different than the one OCRopus uses...

I know this is confusing; keep in mind, however, that the difference
is only in reading/writing the images.  Arrays in OCRopus are all
represented as in C.  Furthermore, if your raster coordinates are row
and column, you access arrays as image(column,height-row-1).

> The problem I have is with returning anything... The
> printf() shows me correct results on stdout, but then, if I do return
> (char*)output.c_str(); in the caller the initialised char* loses the
> first 4 letters of the returned value... (it works fine when I use
> valgrind ;-)).

The value gets deallocated when "output" goes out of scope.

> I know it's a fairly simple question, but what would be the best way
> of solving this problem? All the variables and components from OCRopus
> are initialised correctly.

The recommended way of dealing with this is to pass the string holding
the result by reference (same for arrays and everything else):

void myfunction(strg &result,...) {
    ...
    result = ...;
}

If you really must return a char *, then do something like:

char *myfunction(...) {
    ...
    return strdup(output.c_str());
}

However, then you have to remember to deallocate.

Within OCRopus, we have a "no pointers" policy; I recommend following it.

Tom

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ocropus" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ocropus?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to