### Example: Get Image Dimensions Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Demonstrates loading an image, initializing TessApi, setting the image, and asserting its dimensions. Ensure the 'tests/di.png' file exists and 'tests/tessdata' contains language data. ```rust let path = std::path::Path::new("tests/di.png"); let img = leptess::leptonica::pix_read(&path).unwrap(); let mut tes = leptess::tesseract::TessApi::new(Some("tests/tessdata"), "eng").unwrap(); tes.set_image(&img); assert_eq!(tes.get_image_dimensions(), Some((442, 852))); ``` -------------------------------- ### Install Tesseract Language Data on Ubuntu Source: https://docs.rs/leptess/0.14.0/leptess/index.html Install Tesseract OCR language data for specific languages on Ubuntu using apt-get. This is required for OCR functionality. ```bash sudo apt-get install tesseract-ocr-eng ``` -------------------------------- ### startWallTimer Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.startWallTimer.html Initializes and starts a wall timer, returning a pointer to the timer instance. ```APIDOC ## C Function: startWallTimer ### Description Initializes and starts a new wall timer instance. ### Method FFI / C Export ### Endpoint leptess::capi::startWallTimer ### Response - **Return Value** (*mut L_WallTimer) - A pointer to the initialized wall timer instance. ``` -------------------------------- ### High-level LepTess Wrapper Example Source: https://docs.rs/leptess/0.14.0/leptess/index.html Use the high-level LepTess wrapper for productivity and memory safety. Ensure you have the tessdata directory and the specified language data installed. ```rust let mut lt = leptess::LepTess::new(Some("./tests/tessdata"), "eng").unwrap(); lt.set_image("./tests/di.png"); println!("{}", lt.get_utf8_text().unwrap()); ``` -------------------------------- ### Get Word Bounding Boxes Source: https://docs.rs/leptess/0.14.0/leptess/struct.LepTess.html Retrieves bounding boxes for all recognized words in an image. This example initializes LepTess, sets an image, and then iterates through the word bounding boxes. ```rust let mut lt = leptess::LepTess::new(None, "eng").unwrap(); lt.set_image("./tests/di.png"); let boxes = lt.get_component_boxes( leptess::capi::TessPageIteratorLevel_RIL_WORD, true, ).unwrap(); for b in &boxes { println!("{:?}", b); } ``` -------------------------------- ### Install Leptonica and Tesseract on Ubuntu Source: https://docs.rs/leptess/0.14.0/leptess/index.html Install Leptonica and Tesseract development libraries on Ubuntu using apt-get. This is a build dependency for the leptess crate. ```bash sudo apt-get install libleptonica-dev libtesseract-dev clang ``` -------------------------------- ### Start Wall Timer Function Signature Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.startWallTimer.html This function is an unsafe C-compatible interface for initializing a wall timer. ```rust pub unsafe extern "C" fn startWallTimer() -> *mut L_WallTimer ``` -------------------------------- ### Rust Option `and` Method Examples Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.TessProgressFunc.html Demonstrates the `and` method, which returns `None` if either option is `None`, otherwise returns the second option. ```rust let x = Some(2); let y: Option<&str> = None; assert_eq!(x.and(y), None); ``` ```rust let x: Option = None; let y = Some("foo"); assert_eq!(x.and(y), None); ``` ```rust let x = Some(2); let y = Some("foo"); assert_eq!(x.and(y), Some("foo")); ``` ```rust let x: Option = None; let y: Option<&str> = None; assert_eq!(x.and(y), None); ``` -------------------------------- ### Rust Option `xor` Method Examples Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.TessProgressFunc.html Illustrates `xor`, which returns `Some` if exactly one of the options is `Some`, otherwise returns `None`. ```rust let x = Some(2); let y: Option = None; assert_eq!(x.xor(y), Some(2)); ``` ```rust let x: Option = None; let y = Some(2); assert_eq!(x.xor(y), Some(2)); ``` ```rust let x = Some(2); let y = Some(2); assert_eq!(x.xor(y), None); ``` ```rust let x: Option = None; let y: Option = None; assert_eq!(x.xor(y), None); ``` -------------------------------- ### Rust Option `or` Method Examples Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.TessProgressFunc.html Demonstrates the `or` method, which returns the option if it contains a value, otherwise returns the other option. Arguments are eagerly evaluated. ```rust let x = Some(2); let y = None; assert_eq!(x.or(y), Some(2)); ``` ```rust let x = None; let y = Some(100); assert_eq!(x.or(y), Some(100)); ``` ```rust let x = Some(2); let y = Some(100); assert_eq!(x.or(y), Some(2)); ``` ```rust let x: Option = None; let y = None; assert_eq!(x.or(y), None); ``` -------------------------------- ### regTestSetup Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.regTestSetup.html Initializes the testing environment for leptess. This function is unsafe and should be used with caution. ```APIDOC ## regTestSetup ### Description Initializes the testing environment for leptess. This function is unsafe and should be used with caution. ### Method `extern "C" fn` (C ABI) ### Endpoint `leptess::capi::regTestSetup` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **argc** (`i32`) - The number of arguments passed to the program. - **argv** (`*mut *mut i8`) - A pointer to an array of C-style strings representing the arguments. - **prp** (`*mut *mut L_RegParams`) - A pointer to a pointer that will be populated with registration parameters. ### Request Example ```c // Example usage (conceptual, requires L_RegParams definition and proper C string handling) int main(int argc, char* argv[]) { L_RegParams* params; int result = regTestSetup(argc, argv, ¶ms); // ... use params ... // Remember to free params if necessary return result; } ``` ### Response #### Success Response (0) Returns `0` on successful setup. #### Error Response (Non-zero) Returns a non-zero value indicating an error during setup. #### Response Example ```c // Assuming regTestSetup returns 0 on success int setup_result = regTestSetup(argc, argv, ¶ms); if (setup_result == 0) { // Setup successful } else { // Setup failed } ``` ``` -------------------------------- ### impl Product> for Option Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.TessCancelFunc.html Provides the Product implementation for Option when T implements Product. ```APIDOC ## impl Product> for Option ### Description Provides the `Product` implementation for `Option` where `T` implements `Product`. ``` -------------------------------- ### Get NUMA Node Edge Values Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.numaGetEdgeValues.html This function retrieves the start, end, and sign values for a specified NUMA edge. It requires a mutable pointer to a Numa structure and integer pointers for output parameters. Use with caution as it is an unsafe extern function. ```rust pub unsafe extern "C" fn numaGetEdgeValues( na: *mut Numa, edge: i32, pstart: *mut i32, pend: *mut i32, psign: *mut i32, ) -> i32 ``` -------------------------------- ### pixacompCreateWithInit Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixacompCreateWithInit.html Documentation for the C API function `pixacompCreateWithInit` from the leptess library. ```APIDOC ## pixacompCreateWithInit ### Description Creates a PixaComp structure with initialization. ### Method `pub unsafe extern "C" fn` ### Endpoint `leptess::capi` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - ***mut PixaComp** - A pointer to the created PixaComp structure. #### Response Example None ``` -------------------------------- ### Low-level Tesseract API Example Source: https://docs.rs/leptess/0.14.0/leptess/index.html Utilize the low-level Tesseract API for flexibility, closely mirroring upstream C APIs. This requires importing necessary modules and functions from the leptess crate. ```rust use std::path::Path; let mut api = leptess::tesseract::TessApi::new(Some("./tests/tessdata"), "eng").unwrap(); let mut pix = leptess::leptonica::pix_read(Path::new("./tests/di.png")).unwrap(); api.set_image(&pix); let text = api.get_utf8_text(); println!("{}", text.unwrap()); ``` -------------------------------- ### Get Range Information with ptaGetRange Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.ptaGetRange.html Use this function to get the minimum and maximum x and y coordinates from a Pta structure. It returns an i32 status code. ```rust pub unsafe extern "C" fn ptaGetRange( pta: *mut Pta, pminx: *mut f32, pmaxx: *mut f32, pminy: *mut f32, pmaxy: *mut f32, ) -> i32 ``` -------------------------------- ### kernelCreateFromFile Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.kernelCreateFromFile.html Initializes a new kernel from a specified file path. ```APIDOC ## kernelCreateFromFile ### Description Creates a new kernel instance by loading it from a file specified by the filename. ### Method FFI (C-style function) ### Parameters #### Parameters - **filename** (*const i8) - Required - A pointer to a null-terminated string representing the path to the file. ### Response - **Returns** (*mut L_Kernel) - A pointer to the created L_Kernel structure. ``` -------------------------------- ### Get Pixels X Resolution Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixGetXRes.html Use this function to get the X resolution of a Pix object. It requires an unsafe block due to raw pointer manipulation. ```rust pub unsafe extern "C" fn pixGetXRes(pix: *const Pix) -> i32 ``` -------------------------------- ### makeFlatKernel Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.makeFlatKernel.html Creates a flat kernel for image processing operations. ```APIDOC ## C Function: makeFlatKernel ### Description Creates a flat kernel with specified dimensions and center coordinates. ### Method FFI (Foreign Function Interface) ### Parameters - **height** (i32) - Required - The height of the kernel. - **width** (i32) - Required - The width of the kernel. - **cy** (i32) - Required - The y-coordinate of the kernel center. - **cx** (i32) - Required - The x-coordinate of the kernel center. ### Response - **Return Value** (*mut L_Kernel) - A pointer to the newly created L_Kernel structure. ``` -------------------------------- ### Get Source Y Resolution Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the source Y resolution of the image. ```APIDOC ## GET /api/tessapi/get_source_y_resolution ### Description Get the source Y resolution of the currently loaded image. ### Method GET ### Endpoint /api/tessapi/get_source_y_resolution ### Parameters None ### Response #### Success Response (200) - **resolution** (i32) - The source Y resolution of the image. #### Response Example ```json { "resolution": 300 } ``` ``` -------------------------------- ### Initialize L_Bytea from file Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.l_byteaInitFromFile.html This function is unsafe and requires a pointer to a C-style string representing the file path. ```rust pub unsafe extern "C" fn l_byteaInitFromFile( fname: *const i8, ) -> *mut L_Bytea ``` -------------------------------- ### Get Source Y Resolution Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the source Y resolution of the image. ```rust pub fn get_source_y_resolution(&self) -> i32 ``` -------------------------------- ### GET /leptess/capi/getdelim Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.getdelim.html Documentation for the unsafe C-API function getdelim. ```APIDOC ## getdelim ### Description Reads a delimited string from a stream. ### Method unsafe extern "C" ### Parameters #### Path Parameters - **__lineptr** (*mut *mut i8) - Required - Pointer to the buffer to store the line. - **__n** (*mut usize) - Required - Pointer to the size of the buffer. - **__delimiter** (i32) - Required - The delimiter character. - **__stream** (*mut _IO_FILE) - Required - The input stream to read from. ### Response - **Return Value** (i64) - Returns the number of characters read, or -1 on failure. ``` -------------------------------- ### Landscape/Portrait and Baseline Algorithm Settings Source: https://docs.rs/leptess/0.14.0/leptess/enum.Variable.html Configuration options for testing landscape/portrait modes and selecting baseline algorithms. ```APIDOC ## TextordTestLandscape ### Description Tests refer to land/port ### Example Value `"0"` ## TextordParallelBaselines ### Description Force parallel baselines ### Example Value `"1"` ## TextordStraightBaselines ### Description Force straight baselines ### Example Value `"0"` ## TextordOldBaselines ### Description Use old baseline algorithm ### Example Value `"1"` ## TextordOldXheight ### Description Use old xheight algorithm ### Example Value `"0"` ## TextordFixXheightBug ### Description Use spline baseline ### Example Value `"1"` ``` -------------------------------- ### Get Leptonica Version Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.getLeptonicaVersion.html Retrieves the version of the Leptonica library. ```APIDOC ## getLeptonicaVersion ### Description Retrieves the version of the Leptonica library. ### Method GET ### Endpoint /leptonica/version ### Response #### Success Response (200) - **version** (string) - The version string of the Leptonica library. #### Response Example { "version": "1.82.0" } ``` -------------------------------- ### Get UTF8 Text Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the recognized text in UTF-8 format. ```APIDOC ## GET /api/tessapi/get_utf8_text ### Description Get the recognized text in UTF-8 format. ### Method GET ### Endpoint /api/tessapi/get_utf8_text ### Parameters None ### Response #### Success Response (200) - **text** (string) - The recognized text in UTF-8 encoding. #### Response Example ```json { "text": "This is the recognized text." } ``` ``` -------------------------------- ### fopenWriteWinTempfile Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.fopenWriteWinTempfile.html Creates and opens a temporary file on Windows for writing. ```APIDOC ## fopenWriteWinTempfile ### Description Creates and opens a temporary file on Windows for writing. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters None ### Request Example N/A ### Response #### Success Response - `*mut _IO_FILE` - A pointer to the opened temporary file stream. #### Response Example N/A ``` -------------------------------- ### TessApi Initialization Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Initializes a new TessApi instance with the specified data path and language. ```APIDOC ## POST /api/tessapi/new ### Description Initializes a new TessApi instance. ### Method POST ### Endpoint /api/tessapi/new ### Parameters #### Query Parameters - **data_path** (Option<&str>) - Optional - The path to the Tesseract data directory. - **lang** (str) - Required - The language code for Tesseract (e.g., "eng"). ### Request Body None ### Response #### Success Response (200) - **TessApi** (object) - An initialized TessApi instance. #### Response Example ```json { "raw": { "data_path": "/usr/share/tessdata", "lang": "eng" } } ``` ``` -------------------------------- ### Get size of L_Ptraa Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.ptraaGetSize.html Retrieves the size of the provided L_Ptraa structure. ```rust pub unsafe extern "C" fn ptraaGetSize( paa: *mut L_Ptraa, psize: *mut i32, ) -> i32 ``` -------------------------------- ### numaGetParameters Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.numaGetParameters.html Retrieves the start x-value and delta x-value from a Numa structure. ```APIDOC ## C numaGetParameters ### Description Retrieves the start x-value and delta x-value from a Numa structure. ### Method C Function Call ### Parameters - **na** (*mut Numa) - Required - Pointer to the Numa structure. - **pstartx** (*mut f32) - Required - Pointer to store the start x-value. - **pdelx** (*mut f32) - Required - Pointer to store the delta x-value. ### Response - **Return Value** (i32) - Returns 0 on success, non-zero on error. ``` -------------------------------- ### getsubopt Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.getsubopt.html Documentation for the C-compatible getsubopt function used in leptess. ```APIDOC ## getsubopt ### Description Parses suboptions from a string, typically used for command-line argument parsing. ### Method Function Call (C FFI) ### Parameters - **__optionp** (*mut *mut i8) - Pointer to the pointer of the option string. - **__tokens** (*const *mut i8) - Pointer to the array of allowed tokens. - **__valuep** (*mut *mut i8) - Pointer to the pointer where the value will be stored. ### Response - **Return Value** (i32) - Returns the index of the matched token or -1 if no match is found. ``` -------------------------------- ### Variable::as_cstr Method Source: https://docs.rs/leptess/0.14.0/leptess/enum.Variable.html Gets the variable's name as used by Tesseract. ```rust pub fn as_cstr(&self) -> &'static CStr ``` -------------------------------- ### Get Regions Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the detected regions (e.g., paragraphs, lines) from the image. ```APIDOC ## GET /api/tessapi/get_regions ### Description Get the detected regions (e.g., paragraphs, lines) from the image. ### Method GET ### Endpoint /api/tessapi/get_regions ### Parameters None ### Response #### Success Response (200) - **regions** (Boxa | null) - A Boxa object containing the bounding boxes of the detected regions, or null if none are found. #### Response Example ```json { "regions": [ {"x1": 10, "y1": 10, "x2": 200, "y2": 50}, {"x1": 10, "y1": 60, "x2": 200, "y2": 100} ] } ``` ``` -------------------------------- ### Using Option::and Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.__compar_fn_t.html Returns None if the option is None, otherwise returns optb. ```rust let x = Some(2); let y: Option<&str> = None; assert_eq!(x.and(y), None); let x: Option = None; let y = Some("foo"); assert_eq!(x.and(y), None); let x = Some(2); let y = Some("foo"); assert_eq!(x.and(y), Some("foo")); let x: Option = None; let y: Option<&str> = None; assert_eq!(x.and(y), None); ``` -------------------------------- ### l_byteaInitFromFile Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.l_byteaInitFromFile.html Initializes an L_Bytea structure from a file path. ```APIDOC ## l_byteaInitFromFile ### Description Initializes an L_Bytea structure by reading data from a specified file path. ### Method C Function ### Parameters #### Path Parameters - **fname** (*const i8) - Required - A pointer to a null-terminated string representing the file path. ### Response - **Return Value** (*mut L_Bytea) - Returns a pointer to the initialized L_Bytea structure. ``` -------------------------------- ### Get Regions Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the detected regions within the image as a Boxa object. ```rust pub fn get_regions(&self) -> Option ``` -------------------------------- ### l_asetCreate Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.l_asetCreate.html Documentation for the `l_asetCreate` function, which is part of the leptess C API. ```APIDOC ## l_asetCreate ### Description Creates a new set with the specified key type. ### Method `pub unsafe extern "C" fn` ### Endpoint `leptess::capi::l_asetCreate` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - ***mut L_Rbtree** - A pointer to the newly created L_Rbtree. #### Response Example None ### Parameters - **keytype** (i32) - Required - The type of the key for the set. ``` -------------------------------- ### __GLIBC_USE_LIB_EXT2 Constant Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__GLIBC_USE_LIB_EXT2.html Documentation for the __GLIBC_USE_LIB_EXT2 constant used in the leptess::capi module. ```APIDOC ## Constant: __GLIBC_USE_LIB_EXT2 ### Description A constant representing a GLIBC feature flag used within the leptess C API bindings. ### Definition `pub const __GLIBC_USE_LIB_EXT2: u32 = 0;` ### Value 0 ``` -------------------------------- ### findNextLargerPrime Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.findNextLargerPrime.html Finds the next prime number greater than the provided starting integer. ```APIDOC ## C Function: findNextLargerPrime ### Description Finds the next prime number greater than the specified starting value and stores it in the provided pointer. ### Method FFI / C-Export ### Parameters #### Arguments - **start** (i32) - The integer to start searching from. - **pprime** (*mut u32) - A pointer to a memory location where the resulting prime number will be stored. ### Returns - **i32** - Returns an integer status code (implementation specific). ``` -------------------------------- ### Get ALTO Text Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the recognized text in ALTO format for a specific page. ```APIDOC ## GET /api/tessapi/get_alto_text ### Description Get the recognized text in ALTO format for a specific page. ### Method GET ### Endpoint /api/tessapi/get_alto_text ### Parameters #### Query Parameters - **page** (c_int) - Required - The page number to retrieve ALTO text from. ### Response #### Success Response (200) - **text** (string) - The recognized text in ALTO format. #### Response Example ```json { "text": "..." } ``` ``` -------------------------------- ### Get HOCR Text Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the recognized text in HOCR format for a specific page. ```APIDOC ## GET /api/tessapi/get_hocr_text ### Description Get the recognized text in HOCR format for a specific page. ### Method GET ### Endpoint /api/tessapi/get_hocr_text ### Parameters #### Query Parameters - **page** (c_int) - Required - The page number to retrieve HOCR text from. ### Response #### Success Response (200) - **text** (string) - The recognized text in HOCR format. #### Response Example ```json { "text": "
...
" } ``` ``` -------------------------------- ### Get Image Dimensions Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the dimensions (width and height) of the currently loaded image. ```APIDOC ## GET /api/tessapi/get_image_dimensions ### Description Get the dimensions of the currently loaded image, or None if no image is loaded. ### Method GET ### Endpoint /api/tessapi/get_image_dimensions ### Parameters None ### Response #### Success Response (200) - **dimensions** (object | null) - An object containing width and height, or null if no image is loaded. - **width** (u32) - **height** (u32) #### Response Example ```json { "dimensions": { "width": 442, "height": 852 } } ``` ``` -------------------------------- ### Initialize TessBaseAPI with Data Path and Language Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.TessBaseAPIInit3.html Use this C function to initialize the Tesseract OCR engine. It requires a handle to the TessBaseAPI structure, the path to the Tesseract data files, and the language(s) to use. Returns 0 on success, or a negative error code on failure. ```c pub unsafe extern "C" fn TessBaseAPIInit3( handle: *mut TessBaseAPI, datapath: *const i8, language: *const i8, ) -> i32 ``` -------------------------------- ### Type ID Retrieval Source: https://docs.rs/leptess/0.14.0/leptess/capi/struct.FPix.html Gets the `TypeId` of a type, useful for runtime type identification. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### SELA Get Selection Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.selaGetSel.html Retrieves a selection from a Sela object. This is an unsafe C function. ```APIDOC ## selaGetSel ### Description Retrieves a specific selection from a Sela object based on an index. ### Method C Function (unsafe extern "C") ### Endpoint leptess::capi ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage (requires Sela and Sel types to be defined and managed) // Sela* mySela = ...; // int index = 0; // Sel* selection = selaGetSel(mySela, index); ``` ### Response #### Success Response (Pointer to Sel) - **sel** (*mut Sel) - A pointer to the requested Sel object, or null if the index is out of bounds or an error occurs. #### Response Example ```c // Assuming 'selection' is the pointer returned by selaGetSel // if (selection != NULL) { // // Use the selection object // } ``` ``` -------------------------------- ### Get Size of PTHREAD_MUTEXATTR_T Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__SIZEOF_PTHREAD_MUTEXATTR_T.html This constant represents the size of the pthread_mutexattr_t type, which is 4 bytes. ```rust pub const __SIZEOF_PTHREAD_MUTEXATTR_T: u32 = 4; // 4u32 ``` -------------------------------- ### pixConnCompIncrInit Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixConnCompIncrInit.html Initializes a pix for incremental connected components analysis. ```APIDOC ## pixConnCompIncrInit ### Description Initializes a pix for incremental connected components analysis. This function is part of the C API for Leptess. ### Method `pub unsafe extern "C" fn` ### Endpoint `leptess::capi::pixConnCompIncrInit` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (0) Returns 0 on success. #### Response Example `0` ``` -------------------------------- ### kernelCreate Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.kernelCreate.html Initializes a new kernel with the specified dimensions. ```APIDOC ## kernelCreate ### Description Creates a new kernel structure with the specified height and width. ### Method FFI / C Function Call ### Parameters #### Arguments - **height** (i32) - Required - The height of the kernel. - **width** (i32) - Required - The width of the kernel. ### Response - **Return Value** (*mut L_Kernel) - A pointer to the newly created L_Kernel structure. ``` -------------------------------- ### Get Size of PTHREAD_MUTEX_T Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__SIZEOF_PTHREAD_MUTEX_T.html This constant represents the size of a pthread_mutex_t in bytes. It is defined as 40. ```rust pub const __SIZEOF_PTHREAD_MUTEX_T: u32 = 40; // 40u32 ``` -------------------------------- ### recogTrainFromBoot Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.recogTrainFromBoot.html Trains a recognizer from a boot set of images. ```APIDOC ## recogTrainFromBoot ### Description Trains a recognizer from a boot set of images. ### Method FFI (C API) ### Parameters - **recogboot** (*mut L_Recog) - Required - Pointer to the boot recognizer. - **pixas** (*mut Pixa) - Required - Pointer to the Pixa structure containing images. - **minscore** (f32) - Required - Minimum score threshold. - **threshold** (i32) - Required - Threshold value. - **debug** (i32) - Required - Debug flag. ### Response - **Returns** (*mut Pixa) - Returns a pointer to a Pixa structure. ``` -------------------------------- ### L_WallTimer Struct Source: https://docs.rs/leptess/0.14.0/leptess/capi/struct.L_WallTimer.html The L_WallTimer struct represents a wall timer with start and stop times. ```APIDOC ## Struct L_WallTimer ### Description The `L_WallTimer` struct is used to store the start and stop times of a wall timer. ### Fields - **start_sec** (i32) - The starting second. - **start_usec** (i32) - The starting microsecond. - **stop_sec** (i32) - The stopping second. - **stop_usec** (i32) - The stopping microsecond. ### Implementations - **Clone**: Allows creating a duplicate of the `L_WallTimer`. - **Debug**: Enables formatting the struct for debugging. - **Copy**: Indicates that the struct can be copied by bits. - **Freeze, RefUnwindSafe, Send, Sync, Unpin, UnwindSafe**: Auto-implemented traits. - **Blanket Implementations**: Includes implementations for generic traits like `Any`, `Borrow`, `BorrowMut`, `CloneToUninit`, `From`, `Into`, `ToOwned`, `TryFrom`, `TryInto`. ``` -------------------------------- ### __GLIBC_USE_IEC_60559_EXT Constant Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__GLIBC_USE_IEC_60559_EXT.html Documentation for the __GLIBC_USE_IEC_60559_EXT constant used in leptess::capi. ```APIDOC ## Constant: __GLIBC_USE_IEC_60559_EXT ### Description A constant defined in `leptess::capi` representing a GLIBC feature flag. ### Value `0` (u32) ``` -------------------------------- ### l_dnaMakeSequence Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.l_dnaMakeSequence.html Creates a new L_Dna sequence with a specified start value, increment, and size. ```APIDOC ## C Function: l_dnaMakeSequence ### Description Creates a new L_Dna sequence with a specified start value, increment, and size. ### Method FFI / C Function ### Parameters - **startval** (f64) - Required - The starting value of the sequence. - **increment** (f64) - Required - The increment value for each step in the sequence. - **size** (i32) - Required - The number of elements in the sequence. ### Response - **Returns** (*mut L_Dna) - A pointer to the newly created L_Dna structure. ``` -------------------------------- ### Constant: __USE_FORTIFY_LEVEL Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__USE_FORTIFY_LEVEL.html Documentation for the __USE_FORTIFY_LEVEL constant found in the leptess::capi module. ```APIDOC ## Constant: __USE_FORTIFY_LEVEL ### Description A constant representing the fortify level used in the leptess C API bindings. ### Value 0 (u32) ### Module leptess::capi ``` -------------------------------- ### l_binaryReadSelectStream Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.l_binaryReadSelectStream.html Reads a specified number of bytes from a file stream starting at a given offset. ```APIDOC ## C Function: l_binaryReadSelectStream ### Description Reads a specific range of bytes from a file stream into a newly allocated buffer. ### Method FFI / C Function Call ### Parameters - **fp** (*mut _IO_FILE) - Required - Pointer to the file stream. - **start** (usize) - Required - The starting byte offset. - **nbytes** (usize) - Required - The number of bytes to read. - **pnread** (*mut usize) - Required - Pointer to store the actual number of bytes read. ### Response - **Return Value** (*mut u8) - A pointer to the allocated buffer containing the read data, or null if the operation fails. ``` -------------------------------- ### Get Mean Text Confidence Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Calculates and returns the mean confidence level of the recognized text. ```rust pub fn mean_text_conf(&self) -> i32 ``` -------------------------------- ### mkstemp Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.mkstemp.html Documentation for the mkstemp C-compatible function used for creating temporary files. ```APIDOC ## mkstemp ### Description Creates a temporary file based on the provided template. ### Method C Function ### Parameters #### Arguments - **__template** (*mut i8) - Required - A pointer to a character array representing the template for the temporary file name. ### Response - **Return Value** (i32) - Returns a file descriptor for the created temporary file, or -1 on failure. ``` -------------------------------- ### Get Imagelib Versions Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.getImagelibVersions.html Retrieves the versions of the underlying image processing libraries used by Leptess. ```APIDOC ## getImagelibVersions ### Description Retrieves the versions of the underlying image processing libraries used by Leptess. ### Method C API (unsafe extern "C") ### Endpoint N/A (This is a C function call) ### Parameters None ### Request Example N/A (This is a C function call) ### Response #### Success Response - ***mut i8** - A pointer to a null-terminated C string containing the image library versions. #### Response Example N/A (This is a C function call, the return value is a pointer to a C string.) ``` -------------------------------- ### recogReadMem Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.recogReadMem.html Initializes a recognition object from a memory buffer. ```APIDOC ## recogReadMem ### Description Initializes a new L_Recog object by reading data from a provided memory buffer. ### Method C Function ### Parameters - **data** (*const u8) - Required - Pointer to the memory buffer containing the data. - **size** (usize) - Required - The size of the memory buffer. ### Response - **Returns** (*mut L_Recog) - A pointer to the initialized L_Recog structure. ``` -------------------------------- ### Get Size of Pthread Barrier Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__SIZEOF_PTHREAD_BARRIER_T.html This constant represents the size of the pthread_barrier_t type, which is 32 bytes. ```rust pub const __SIZEOF_PTHREAD_BARRIER_T: u32 = 32; // 32u32 ``` -------------------------------- ### Initialize TessApi Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Initializes a new TessApi instance. Requires the path to Tesseract data files and the language to use. Returns a Result with TessApi on success or TessInitError on failure. ```rust pub fn new<'a>( data_path: Option<&'a str>, lang: &'a str, ) -> Result ``` -------------------------------- ### Option::and Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.TessProgressFunc.html Returns `None` if the option is `None`, otherwise returns `optb`. ```APIDOC ## Option::and ### Description Returns `None` if the option is `None`, otherwise returns `optb`. ### Method `and` ### Endpoint N/A (Method on Option type) ### Parameters #### Query Parameters - **optb** (Option) - Required - The other option to return if `self` is `Some`. ### Request Example ```rust let x = Some(2); let y: Option<&str> = None; assert_eq!(x.and(y), None); ``` ### Response #### Success Response (Option) - The other option (`optb`) if `self` is `Some`, otherwise `None`. #### Response Example ```rust // Example 1: self is Some, optb is None // Returns None // Example 2: self is None, optb is Some // Returns Some(value_from_optb) // Example 3: self is Some, optb is Some // Returns Some(value_from_optb) // Example 4: self is None, optb is None // Returns None ``` ``` -------------------------------- ### pixaCreateFromBoxa Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixaCreateFromBoxa.html Creates a Pixa object from a Boxa structure using specified start and number parameters. ```APIDOC ## pixaCreateFromBoxa ### Description Creates a Pixa object from a Boxa structure, optionally cropping based on the provided start index and number of elements. ### Method C Function ### Parameters - **pixs** (*mut Pix) - Required - Pointer to the source Pix object. - **boxa** (*mut Boxa) - Required - Pointer to the source Boxa object. - **start** (i32) - Required - The starting index in the Boxa. - **num** (i32) - Required - The number of boxes to process. - **pcropwarn** (*mut i32) - Required - Pointer to an integer for crop warning status. ### Response - **Returns** (*mut Pixa) - A pointer to the newly created Pixa object. ``` -------------------------------- ### Get LSTM Box Text Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves text with LSTM bounding box information for a specific page. ```APIDOC ## GET /api/tessapi/get_lstm_box_text ### Description Get text with LSTM bounding box information for a specific page. ### Method GET ### Endpoint /api/tessapi/get_lstm_box_text ### Parameters #### Query Parameters - **page** (c_int) - Required - The page number to retrieve LSTM box text from. ### Response #### Success Response (200) - **text** (string) - The recognized text with LSTM bounding box information. #### Response Example ```json { "text": "( 10 10 100 50 0 ) hello" } ``` ``` -------------------------------- ### LepTess Initialization and Image Processing Source: https://docs.rs/leptess/0.14.0/leptess/struct.LepTess.html Methods for initializing the OCR engine and setting the source image for processing. ```APIDOC ## new(data_path: Option<&str>, lang: &str) ### Description Initializes a new LepTess instance with the specified Tesseract data path and language. ### Method Constructor ## set_image(img_uri: impl AsRef) ### Description Sets the source image for OCR from a file path. ## set_image_from_mem(img: &[u8]) ### Description Sets the source image for OCR from an in-memory buffer. ``` -------------------------------- ### Get TSV Text Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves the recognized text in TSV (Tab-Separated Values) format for a specific page. ```APIDOC ## GET /api/tessapi/get_tsv_text ### Description Get the recognized text in TSV (Tab-Separated Values) format for a specific page. ### Method GET ### Endpoint /api/tessapi/get_tsv_text ### Parameters #### Query Parameters - **page** (c_int) - Required - The page number to retrieve TSV text from. ### Response #### Success Response (200) - **text** (string) - The recognized text in TSV format. #### Response Example ```json { "text": "word\tconfidence\nhello\t95\nworld\t90" } ``` ``` -------------------------------- ### Option Product Implementation Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.dealloc_fn.html Provides product calculation for Option where T is Product. ```APIDOC ### impl Product> for Option where T: Product, ``` -------------------------------- ### pixCreateTemplateNoInit Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixCreateTemplateNoInit.html Documentation for the pixCreateTemplateNoInit function used to create a template Pix object without initialization. ```APIDOC ## pixCreateTemplateNoInit ### Description Creates a new Pix object as a template without initializing its data buffer. ### Method FFI / C Function ### Parameters #### Arguments - **pixs** (*const Pix) - Required - Pointer to the source Pix object. ### Response - **Returns** (*mut Pix) - A pointer to the newly created Pix object. ``` -------------------------------- ### Retrieve Y Resolution from Pix Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixGetYRes.html Use this function to get the Y resolution of a Pix structure. It is an unsafe C-style function. ```rust pub unsafe extern "C" fn pixGetYRes(pix: *const Pix) -> i32 ``` -------------------------------- ### Define __GLIBC_USE_DEPRECATED_GETS Constant Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__GLIBC_USE_DEPRECATED_GETS.html This constant is defined as 0. It is related to the use of deprecated gets functions in glibc. ```rust pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; // 0u32 ``` -------------------------------- ### numaCreate Function Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.numaCreate.html Documentation for the C-style `numaCreate` function within the leptess library. ```APIDOC ## numaCreate ### Description Creates a new Numa object. This is an unsafe C-style function. ### Method extern "C" ### Endpoint leptess::capi ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - ***mut Numa** - A pointer to the newly created Numa object. #### Response Example None ``` -------------------------------- ### Tesseract Base API Variable and Configuration Source: https://docs.rs/leptess/0.14.0/leptess/all.html Functions for getting, setting, and printing Tesseract variables and configuration. ```APIDOC ## Tesseract Base API Variable and Configuration ### Description Functions for managing Tesseract's internal variables, including getting, setting, and printing them. ### Functions - `capi::TessBaseAPIGetBoolVariable` - `capi::TessBaseAPIGetIntVariable` - `capi::TessBaseAPIGetDoubleVariable` - `capi::TessBaseAPIGetStringVariable` - `capi::TessBaseAPISetVariable` - `capi::TessBaseAPISetDebugVariable` - `capi::TessBaseAPIPrintVariables` - `capi::TessBaseAPIPrintVariablesToFile` - `capi::TessBaseAPIReadConfigFile` - `capi::TessBaseAPIReadDebugConfigFile` ``` -------------------------------- ### makeRangeKernel Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.makeRangeKernel.html Creates a range kernel using the specified standard deviation. ```APIDOC ## makeRangeKernel ### Description Creates a range kernel with the provided standard deviation. This function is part of the leptess C API. ### Method FFI / C Function Call ### Parameters #### Arguments - **range_stdev** (f32) - Required - The standard deviation value for the range kernel. ### Response - **Returns** (*mut L_Kernel) - A pointer to the created L_Kernel structure. ``` -------------------------------- ### Define L_WALLTIMER Struct Source: https://docs.rs/leptess/0.14.0/leptess/capi/type.L_WALLTIMER.html The C-compatible structure definition for L_WALLTIMER containing start and stop time components. ```rust #[repr(C)] pub struct L_WALLTIMER { pub start_sec: i32, pub start_usec: i32, pub stop_sec: i32, pub stop_usec: i32, } ``` -------------------------------- ### Constant __GLIBC_USE_ISOC2X Source: https://docs.rs/leptess/0.14.0/leptess/capi/constant.__GLIBC_USE_ISOC2X.html Documentation for the __GLIBC_USE_ISOC2X constant defined in the leptess::capi module. ```APIDOC ## Constant __GLIBC_USE_ISOC2X ### Description Represents a constant value used within the leptess C API bindings. ### Definition `pub const __GLIBC_USE_ISOC2X: u32 = 0;` ``` -------------------------------- ### pixRenderContours Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.pixRenderContours.html Renders contours on a Pix image based on specified start value, increment, and output depth. ```APIDOC ## pixRenderContours ### Description Renders contours on a Pix image object. ### Method FFI Function Call ### Parameters - **pixs** (*mut Pix) - Required - Pointer to the source Pix image. - **startval** (i32) - Required - The starting value for contour rendering. - **incr** (i32) - Required - The increment value for contour rendering. - **outdepth** (i32) - Required - The output depth of the resulting Pix image. ### Response - **Returns** (*mut Pix) - A pointer to the resulting Pix image. ``` -------------------------------- ### selCreate Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.selCreate.html Initializes a new selection object with specified dimensions and a name. ```APIDOC ## C Function: selCreate ### Description Creates a new selection object (Sel) with the specified height, width, and name. ### Method FFI / C Function ### Parameters - **height** (i32) - Required - The height of the selection. - **width** (i32) - Required - The width of the selection. - **name** (*const i8) - Required - A pointer to a null-terminated string representing the name. ### Response - **Returns** (*mut Sel) - A pointer to the newly created Sel object. ``` -------------------------------- ### Get Component Images Source: https://docs.rs/leptess/0.14.0/leptess/tesseract/struct.TessApi.html Retrieves component images (e.g., blocks, text lines, words) at a specified level. ```APIDOC ## GET /api/tessapi/get_component_images ### Description Get the given level kind of components (block, textline, word etc.) as a leptonica-style Boxa, in reading order. If text_only is true, then only text components are returned. ### Method GET ### Endpoint /api/tessapi/get_component_images ### Parameters #### Query Parameters - **level** (TessPageIteratorLevel) - Required - The level of components to retrieve (e.g., block, textline, word). - **text_only** (bool) - Optional - If true, only text components are returned. ### Response #### Success Response (200) - **components** (Boxa | null) - A Boxa object containing the bounding boxes of the component images, or null if none are found. #### Response Example ```json { "components": [ {"x1": 10, "y1": 10, "x2": 200, "y2": 50}, {"x1": 10, "y1": 60, "x2": 200, "y2": 100} ] } ``` ``` -------------------------------- ### sarrayCreateInitialized Source: https://docs.rs/leptess/0.14.0/leptess/capi/fn.sarrayCreateInitialized.html Initializes and creates a new Sarray with a specified size and initial string. ```APIDOC ## sarrayCreateInitialized ### Description Initializes and creates a new Sarray with a specified size and initial string. ### Method `pub unsafe extern "C" fn` ### Endpoint `leptess::capi` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **n** (i32) - Required - The size of the Sarray to create. - **initstr** (*const i8) - Required - The initial string to populate the Sarray with. ### Request Example ```json { "n": 10, "initstr": "initial string" } ``` ### Response #### Success Response (200) - ***mut Sarray** - A pointer to the newly created and initialized Sarray. #### Response Example ```json { "sarray_pointer": "0x..." } ``` ```