RecData
typedef struct RecData_tag {
ReInit init;
ReParm parm;
ReImage image;
long image_top;
long image_bottom;
long busy;
INT_PTR hWND_rec_finished;
long left, top;
long width, height;
long result_flags;
void *result_image;
long result_width;
long result_height;
long projection[2];
short italic, bold;
short strokelen, black;
short rec_wchar[REC_ALT][REC_WCHAR_COUNT];
unsigned char rec_value[REC_ALT];
long rec_top[REC_ALT];
long rec_bottom[REC_ALT];
} RecData;
Elements:
init
- Data for classifier initialisation. It must be set before
rec_init()
.
parm
- REC can be performed with many parameters. These parameters are included in the structure
ReParm
.
image
- In this structure
ReImage
the image for processing and/or recognition will be expected or provided.
image_top, image_bottom
- As
image_top
and image_bottom
the upper and lower border of the character(s)
can be specified, based on the scale given by base_line. For base_line=64
typical values for single
characters are:
- A image_top=0, image_bottom=64,
- Ü image_top=-16, image_bottom=64
- a image_top=14, image_bottom=64,
- g image_top=14, image_bottom=82
-
If no values are specified here, the
REC
module keeps all alternative results. The module REL
tries to find the top and bottom line by evaluating the position of accurate recognition results. This information is
used to exclude alternatives that don't fit into the detected line structure. For finer control of this evaluation and
the related exclusion of alternatives, the macros POS_NOliNECONTEXT
, POS_SOFTliNECONTEXT
,
and POS_HARdlINECONTEXT
in the parameter pos can be used.
busy
- This value indicates whether recognition is in process (1) or completed (0). This is particularly
important for parallel processing.
hWND_rec_finished
- This parameter is relevant for Windows only. If provided, the module
rec_do()
will
send messages to that window, which is described as handle by this value. As soon as the preprocessing of the image
has been finished, rec_do()
will perform the following call:
SendMessage((HWND) rec->hWND_rec_finished, WM_USER,
(WPARAM)(REC_MESSAGE | REX_IMGREADY), (LPARAM) rec);
This gives the possibility to retrieve the result of the preprocessing (rec->image
) before recognition.
The pointer image will be set to the internal preprocessed image for this call. As soon as the recognition of a
character is finished, rec_do()
will perform the following call:
SendMessage((HWND) rec->hWND_rec_finished, WM_USER,
(WPARAM)(REC_MESSAGE | REX_FINISHED), (LPARAM) rec);
In case of an error wParm contains also the bit REX_ERROR
.
left, top
- Position of the character after noise reduction.
width, height
- Height and width of the character after noise reduction.
result_flags
- The data element result_flags is set with
RESULT_FLAG_RESPELL
whenever the related result
is approved by a dictionary lookup (RESPELL
).
RESULT_FLAG_RESPELL_CONFIRMED
- wird gesetzt wenn durch
RESPELL
bestätigt wurde.
RESULT_FLAG_RESPELL_GENERATED
- wird gesetzt wenn durch
RESPELL
generiert wurde.
RESULT_FLAG_RESPELL
- zur Abfrage ob
RESULT_FLAG_RESPELL_CONFIRMED
oder
RESULT_FLAG_RESPELL_GENERATED
gesetzt wurden.
result_image
- If
TYPO_KEEPIMG
is set at the parameter parm.typograph
, the segmented characters
are provided as images. The required memory is allocated and controlled from the REL
module but can be freed
directly with the function rel_freeimages()
. Images are stored line by line, starting with the top line first.
The lines are stored pixel by pixel, the most left pixel is stored first, and each pixel is represented as one byte.
result_height
contains the number of lines, result_width
the number of columns of the image.
Prior to result_image
the related surrounding rectangle is found in the data structures RecData and
RelResult
. This describes the position of the images within the supplied original image. Please consider that
the dimensions of the surrounding rectangle and the image dimensions are not always the same. Large images are compressed
by the REL
module and extraction is made from this compressed data.
result_width, result_height
- Height and width of result_image (can be compressed).
projection[2]
- Projection according to the mean slant of the characters of the line from the start and the end of the character onto the baseline.
italic, bold
Slant of characters (italic).
These items are set the detected slant and stroke width of the given character. It is not easy to define the slant of a
character. We take two horizontal tangents of the character, one at the top and one at the bottom, connect the upper and
the lower mean touching points. The slant of this line defines the slant of the character. One should take into consideration
that several characters like L or k have a negative slant, i.e. to the left. For characters with a large horizontal
extension like '-', determining the slant does not make sense. Let us describe the value italic of a character by construction:
- normierte Zeilenhöhe mit 64 Pixel
Take a vertical line and rotate it around its middle point in the given slant. Assume a normalized line height of 64 pixels.
Now measure the distance between the intersections of the vertical and the rotated line at the upper line boundary. This
value, measured in units of pixel width, is delivered under italic. This definition has an advantage against measurement
in degrees: the value can directly be used for slant correction by horizontal shifts. Under bold the mean stroke width of
the character is delivered. It is measured in units of half pixel width. A value of 3 describes a stroke width of 1.5 pixel.
strokelen, black
- strokelen returns the sum of the length of all strokes in the character image. Multiplication with the mean
stroke width bold provides a rough approximation for the (double) number of black pixels in the image. A more precise value
is given under black - the percentage of black pixels in the image (100*black_points/image_points).
rec_wchar
- Depending on the set code page, under
rec_wchar
, the 2-byte identifier for the associated
character is returned, the result of te recognition. The first character is generally the associated UTF_16 code and
the second characterizes form classes. For example, for a normal handwriting zero the label 0_
will be
delivered and for handwriting zero with a slash the label 0W
.
If the result of the detection is not unique, then up to 8 alternatives are returned in order of decreasing security.
An empty or blanked string means "no result" or "no other alternatives".
An overview of the labels and form classes available in KADMOS with their 2-byte labels is be found on our
website.
rec_value
- For each recognized character (and for all alternatives in ambiguous cases) the confidence of
recognition is returned here. One means highest confidence, values above 128 mean least confidence.
rec_top, rec_bottom
-
All recognized alternatives are returned with information where their correct position should be in the current line.
The values are scaled analogous to
image_top
and image_bottom
, based on the specified
base_line
. For a non-specified base_line
, a base_line = 64
is assumed.
Reference: