Next: Setting attributes
Up: charFinder
Previous: Getting block information
  Contents
  Index
Delimiting characters
To delimit a character, GOCR API provides a set of functions that
let you select only the pixels that are part of the character.
First thing to do is to declare that you are starting a new character:
-
- int gocr_charBegin ( void );
This function returns -1 in case something is wrong; starting a character
without ending the last one is considered an error. To end a character:
-
- int gocr_charEnd ( void );
This function creates an image that is initially filled with the background
color, with all bits unset. This image is big enough to contain all
the pixels selected; these pixels are copied to the new image (only
the data, the info bits are still unset), and will be passed to the
charRecognizer module. gocr_charEnd automatically
calls the charRecognizer module? Explain FIND_ALL
Between these two functions, you can set the pixels of the character,
using the functions explained below. The action field is
common to all of them; if GOCR_SET, then the function will select;
if GOCR_UNSET, the function will unselect.
-
- int gocr_charSetPixel ( int action, int x, int y );
Selects the pixel at (x, y).
-
- int gocr_charSetAllNearPixels ( int action, int x, int y,
-
- int connect );
If connect is 4, selects all the pixels of the same color
that are 4-connected with the pixel at (x, y); if connect is 8, selects
all the pixels of the same color that are 8-connected with the pixel
at (x, y). If connect is neither 4 nor 8, the function assumes
4-connection.
-
- int gocr_charSetRect ( int action, int x0, int y0, int x1,
-
- int y1 );
Selects all pixels contained at the rectangle defined by (x0, y0)
and (x1, y1). These points don't need to be top left and right bottom;
they can be any diagonally opposite vertices. Internally, however,
GOCR always convert (x0, y0) to be top left and (x1, y1) to be bottom
right. This is valid for any function that takes two points defining
a rectangle as arguments.
If you change your mind after a call to gocr_charBegin,
you can still save the nation:
-
- void gocr_charAbort ( void );
This function aborts a character begun using gocr_charBegin. All
changes done by the gocr_charSet* functions since the last call
to gocr_charBegin are undone.
When you can gocr_charEnd, the character can be saved as
a simple rectangle that covers all the pixels you selected, or saving
each individual pixel. While the later gives a lot more freedom, letting
you select awkward regions, it consumes about 12.5% more memory,
and is slower. This is controlled by the CHAR_RECTANGLES
flag. Done as argument to gocr_charEnd?
Next: Setting attributes
Up: charFinder
Previous: Getting block information
  Contents
  Index
root
2002-02-17