Leptonica 1.54
|
Input: boxaa index (of boxa with boxaa) box (to be added) accessflag (L_INSERT, L_COPY or L_CLONE) Return: 0 if OK, 1 on error
Notes: (1) Adds to an existing boxa only.
Input: boxaa boxa (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error
Input: baas (input boxaa to be copied) copyflag (L_COPY, L_CLONE) Return: baad (new boxaa, composed of copies or clones of the boxa in baas), or null on error
Notes: (1) L_COPY makes a copy of each boxa in baas. L_CLONE makes a clone of each boxa in baas.
Input: size of boxa ptr array to be alloc'd (0 for default) Return: baa, or null on error
Input: boxa box (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error
void boxaaDestroy | ( | BOXAA ** | pbaa | ) |
Input: &boxaa (<will be="" set="" to="" null="" before="" returning>="">) Return: void
Input: boxaa Return: 0 if OK, 1 on error
Input: boxaa index (to the index-th boxa) accessflag (L_COPY or L_CLONE) Return: boxa, or null on error
Input: boxaa Return: count (number of boxes), or 0 if no boxes or on error
Input: boxaa Return: count (number of boxa), or 0 if no boxa or on error
Input: boxaa index (location in boxaa to insert new boxa) boxa (new boxa to be inserted) Return: 0 if OK, 1 on error
Notes: (1) This shifts boxa[i] --> boxa[i + 1] for all i >= index, and then inserts boxa as boxa[index]. (2) To insert at the beginning of the array, set index = 0. (3) To append to the array, it's easier to use boxaaAddBoxa(). (4) This should not be used repeatedly to insert into large arrays, because the function is O(n).
BOXAA* boxaaRead | ( | const char * | filename | ) |
Input: filename Return: boxaa, or null on error
BOXAA* boxaaReadStream | ( | FILE * | fp | ) |
Input: stream Return: boxaa, or null on error
Input: boxaa index (of the boxa to be removed) Return: 0 if OK, 1 on error
Notes: (1) This removes boxa[index] and then shifts boxa[i] --> boxa[i - 1] for all i > index. (2) The removed boxaa is destroyed. (2) This should not be used repeatedly on large arrays, because the function is O(n).
Input: boxaa index (to the index-th boxa) boxa (insert and replace any existing one) Return: 0 if OK, 1 on error
Notes: (1) Any existing boxa is destroyed, and the input one is inserted in its place. (2) If the index is invalid, return 1 (error)
Input: filename boxaa Return: 0 if OK, 1 on error
Input: stream boxaa Return: 0 if OK, 1 on error
Input: boxa Return: 0 if OK, 1 on error
Notes: (1) This destroys all boxes in the boxa, setting the ptrs to null. The number of allocated boxes, n, is set to 0.
Input: boxa copyflag (L_COPY, L_CLONE, L_COPY_CLONE) Return: new boxa, or null on error
Notes: (1) See pix.h for description of the copyflag. (2) The copy-clone makes a new boxa that holds clones of each box.
Input: n (initial number of ptrs) Return: boxa, or null on error
void boxaDestroy | ( | BOXA ** | pboxa | ) |
Input: &boxa (<will be="" set="" to="" null="" before="" returning>="">) Return: void
Note:
Input: boxa Return: 0 if OK; 1 on error
Notes: (1) Reallocs with doubled size of ptr array.
Input: boxa size (new size of boxa array) Return: 0 if OK; 1 on error
Notes: (1) If necessary, reallocs new boxa ptr array to .
Input: boxa index (to the index-th box) accessflag (L_COPY or L_CLONE) Return: box, or null on error
l_int32 boxaGetBoxGeometry | ( | BOXA * | boxa, |
l_int32 | index, | ||
l_int32 * | px, | ||
l_int32 * | py, | ||
l_int32 * | pw, | ||
l_int32 * | ph | ||
) |
Input: boxa index (to the index-th box) &x, &y, &w, &h (<optional return>="">; each can be null) Return: 0 if OK, 1 on error
Input: boxa Return: count (of all boxes); 0 if no boxes or on error
Input: boxa index (to the index-th box) accessflag (L_COPY or L_CLONE) Return: box, or null if box is not valid or on error
Notes: (1) This returns NULL for an invalid box in a boxa. For a box to be valid, both the width and height must be > 0. (2) We allow invalid boxes, with w = 0 or h = 0, as placeholders in boxa for which the index of the box in the boxa is important. This is an atypical situation; usually you want to put only valid boxes in a boxa.
Input: boxa Return: count (of valid boxes); 0 if no valid boxes or on error
Input: boxa (typically empty) box (to be replicated into the entire ptr array) Return: 0 if OK, 1 on error
Notes: (1) This initializes a boxa by filling up the entire box ptr array with copies of . Any existing boxes are destroyed. After this oepration, the number of boxes is equal to the number of allocated ptrs. (2) Note that we use boxaReplaceBox() instead of boxaInsertBox(). They both have the same effect when inserting into a NULL ptr in the boxa ptr array: (3) Example usage. This function is useful to prepare for a random insertion (or replacement) of boxes into a boxa. To randomly insert boxes into a boxa, up to some index "max": Boxa *boxa = boxaCreate(max); Box *box = boxCreate(...); boxaInitFull(boxa, box); If we have an existing boxa with a smaller ptr array, it can be reused: boxaExtendArrayToSize(boxa, max); Box *box = boxCreate(...); boxaInitFull(boxa, box); The initialization allows the boxa to always be properly filled, even if all the boxes are not later replaced. If you want to know which boxes have been replaced, you can initialize the array with invalid boxes that have w = 0 and/or h = 0. Then boxaGetValidBox() will return NULL for the invalid boxes.
Input: boxa index (location in boxa to insert new value) box (new box to be inserted) Return: 0 if OK, 1 on error
Notes: (1) This shifts box[i] --> box[i + 1] for all i >= index, and then inserts box as box[index]. (2) To insert at the beginning of the array, set index = 0. (3) To append to the array, it's easier to use boxaAddBox(). (4) This should not be used repeatedly to insert into large arrays, because the function is O(n).
BOXA* boxaRead | ( | const char * | filename | ) |
Input: filename Return: boxa, or null on error
BOXA* boxaReadStream | ( | FILE * | fp | ) |
Input: stream Return: boxa, or null on error
Input: boxa index (of box to be removed) Return: 0 if OK, 1 on error
Notes: (1) This removes box[index] and then shifts box[i] --> box[i - 1] for all i > index. (2) It should not be used repeatedly to remove boxes from large arrays, because the function is O(n).
Input: boxa index (to the index-th box) box (insert to replace existing one) Return: 0 if OK, 1 on error
Notes: (1) In-place replacement of one box. (2) The previous box at that location is destroyed.
Input: filename boxa Return: 0 if OK, 1 on error
Input: stream boxa Return: 0 if OK, 1 on error
Input: box Return: ptr to same box, or null on error
Input: x, y, w, h Return: box, or null on error
Notes: (1) This clips the box to the +quad. If no part of the box is in the +quad, this returns NULL. (2) We allow you to make a box with w = 0 and/or h = 0. This does not represent a valid region, but it is useful as a placeholder in a boxa for which the index of the box in the boxa is important. This is an atypical situation; usually you want to put only valid boxes with nonzero width and height in a boxa. If you have a boxa with invalid boxes, the accessor boxaGetValidBox() will return NULL on each invalid box. (3) If you want to create only valid boxes, use boxCreateValid(), which returns NULL if either w or h is 0.
Input: x, y, w, h Return: box, or null on error
Notes: (1) This returns NULL if either w = 0 or h = 0.
void boxDestroy | ( | BOX ** | pbox | ) |
Input: &box (<will be="" set="" to="" null="" before="" returning>="">) Return: void
Notes: (1) Decrements the ref count and, if 0, destroys the box. (2) Always nulls the input ptr.
Input: box &x, &y, &w, &h (<optional return>="">; each can be null) Return: 0 if OK, 1 on error
Input: stream box Return: 0 if OK, 1 on error
Notes: (1) This outputs information about the box, for debugging. (2) Use serialization functions to write to file if you want to read the data back.
Input: box x, y, w, h (use -1 to leave unchanged) Return: 0 if OK, 1 on error
const l_int32 INITIAL_PTR_ARRAYSIZE = 20 [static] |