All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.lept4j.L_Recoga Maven / Gradle / Ivy

Go to download

# Lept4J ## Description: A Java JNA wrapper for Leptonica Image Processing library. Lept4J is released and distributed under the Apache License, v2.0.

There is a newer version: 1.20.0
Show newest version
package net.sourceforge.lept4j;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import java.util.Arrays;
import java.util.List;
/**
 * recog.h
* A simple utility for training and recognizing individual
* machine-printed text characters. In an application, one can
* envision using a number of these, one for each trained set.
* In training mode, a set of labelled bitmaps is presented, either
* one at a time, or in a directory, or in a pixa. If in a directory,
* or a pixa, the labelling text string must be embedded in the
* text field of the image file.
* Any number of recognizers (L_Recog) can be trained and then used
* together in an array (L_Recoga). All these trained structures
* can be serialized to file and read back. The serialized version
* holds all the bitmaps used for training, plus, for arbitrary
* character sets, the UTF8 representation and the lookup table
* mapping from the character representation to index.
* There are three levels of "sets" here:
* (1) Example set: the examples representing a character that
* were printed in the same way, so that they can be combined
* without scaling to form an "average" template for the character.
* In the recognition phase, we use either this aligned average,
* or the individual bitmaps. All examples in the set are given
* the same character label. Example: the letter 'a' in the
* predominant font in a book.
* (2) Character set (represented by L_Recog, a single recognizer):
* The set of different characters, each of which is described
* by (1). Each element of the set has a different character
* label. Example: the digits '0' through '9' that are used for
* page numbering in a book.
* (3) Recognizer set (represented by L_Recoga, an array of recogs):
* A set of recognizers, each of which is described by (2).
* In general, we do not want to combine the character sets
* with the same labels within different recognizer sets,
* because the bitmaps can differ in font type, style or size.
* Example 1: the letter 'a' can be printed in two very different
* ways (either with a large loop or with a smaller loop in
* the lower half); both share the same label but need to be
* distinguished so that they are not mixed when averaging.
* Example 2: a recognizer trained for a book may be missing
* some characters, so we need to supplement it with another
* "generic" or "bootstrap" recognizer that has the additional
* characters from a variety of sources. Bootstrap recognizers
* must be run in a mode where all characters are scaled.
* In the recognition process, for each component in an input image,
* each recognizer (L_Recog) records the best match (highest
* correlation score). If there is more than one recognizer, these
* results are aggregated to find the best match for each character
* for all the recognizers, and this is stored in L_Recoga.
* native declaration : recog.h:53
* This file was autogenerated by JNAerator,
* a tool written by Olivier Chafik that uses a few opensource projects..
* For help, please visit NativeLibs4Java or JNA. */ public class L_Recoga extends Structure { /** * number of recogs
* C type : l_int32 */ public int n; /** * number of recog ptrs allocated
* C type : l_int32 */ public int nalloc; /** * recog ptr array
* C type : L_Recog** */ public PointerByReference recog; /** * stores the array of best chars
* C type : L_Rcha* */ public net.sourceforge.lept4j.L_Rcha.ByReference rcha; public L_Recoga() { super(); } /** * Gets this Structure's field names in their proper order. * @return list of ordered field names */ @Override protected List getFieldOrder() { return Arrays.asList("n", "nalloc", "recog", "rcha"); } /** * @param n number of recogs
* C type : l_int32
* @param nalloc number of recog ptrs allocated
* C type : l_int32
* @param recog recog ptr array
* C type : L_Recog**
* @param rcha stores the array of best chars
* C type : L_Rcha* */ public L_Recoga(int n, int nalloc, PointerByReference recog, net.sourceforge.lept4j.L_Rcha.ByReference rcha) { super(); this.n = n; this.nalloc = nalloc; // if ((recog.length != this.recog.length)) // throw new IllegalArgumentException("Wrong array size !"); this.recog = recog; this.rcha = rcha; } public L_Recoga(Pointer peer) { super(peer); read(); } public static class ByReference extends L_Recoga implements Structure.ByReference { }; public static class ByValue extends L_Recoga implements Structure.ByValue { }; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy