sm_64第三方库编译
This commit is contained in:
parent
af350f0949
commit
e7456e0d6f
|
@ -132,6 +132,10 @@ unix {
|
|||
LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a
|
||||
LIBS += $$PWD/../../../third_party/tinyxml2/$${MY_OS}/$${MY_ARCH}/lib/libtinyxml2.a
|
||||
LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a
|
||||
contains(QT_ARCH, sw_64) {
|
||||
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libcrypto.a
|
||||
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libssl.a
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../utility
|
||||
|
|
|
@ -92,6 +92,7 @@ unix {
|
|||
|
||||
CONFIG += unversioned_libname unversioned_soname
|
||||
QMAKE_CXXFLAGS += -fvisibility=hidden
|
||||
QMAKE_CFLAGS += -fvisibility=hidden
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
|
||||
QMAKE_LFLAGS += -z defs -B direct
|
||||
|
|
|
@ -111,6 +111,10 @@ unix {
|
|||
LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a
|
||||
LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a
|
||||
LIBS += $$PWD/../../../third_party/libcurl/$${MY_OS}/$${MY_ARCH}/lib/libcurl.a
|
||||
contains(QT_ARCH, sw_64) {
|
||||
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libcrypto.a
|
||||
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libssl.a
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../modules
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,66 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_ALLTYPES_H
|
||||
#define LEPTONICA_ALLTYPES_H
|
||||
|
||||
/* Standard */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* General and configuration defs */
|
||||
#include "endianness.h"
|
||||
#include "environ.h"
|
||||
|
||||
/* Generic and non-image-specific containers */
|
||||
#include "array.h"
|
||||
#include "bbuffer.h"
|
||||
#include "heap.h"
|
||||
#include "list.h"
|
||||
#include "ptra.h"
|
||||
#include "queue.h"
|
||||
#include "rbtree.h"
|
||||
#include "stack.h"
|
||||
|
||||
/* Imaging */
|
||||
#include "arrayaccess.h"
|
||||
#include "bmf.h"
|
||||
#include "ccbord.h"
|
||||
#include "dewarp.h"
|
||||
#include "gplot.h"
|
||||
#include "imageio.h"
|
||||
#include "jbclass.h"
|
||||
#include "morph.h"
|
||||
#include "pix.h"
|
||||
#include "recog.h"
|
||||
#include "regutils.h"
|
||||
#include "stringcode.h"
|
||||
#include "sudoku.h"
|
||||
#include "watershed.h"
|
||||
|
||||
|
||||
#endif /* LEPTONICA_ALLTYPES_H */
|
|
@ -0,0 +1,159 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_ARRAY_H
|
||||
#define LEPTONICA_ARRAY_H
|
||||
|
||||
/*!
|
||||
* \file array.h
|
||||
*
|
||||
* <pre>
|
||||
* Contains the following structs:
|
||||
* struct Numa
|
||||
* struct Numaa
|
||||
* struct L_Dna
|
||||
* struct L_Dnaa
|
||||
* struct L_DnaHash
|
||||
* struct Sarray
|
||||
* struct L_Bytea
|
||||
*
|
||||
* Contains definitions for:
|
||||
* Numa interpolation flags
|
||||
* Numa and FPix border flags
|
||||
* Numa data type conversion to string
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Array Structs *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Numa version for serialization */
|
||||
#define NUMA_VERSION_NUMBER 1
|
||||
|
||||
/*! Number array: an array of floats */
|
||||
struct Numa
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated number array */
|
||||
l_int32 n; /*!< number of numbers saved */
|
||||
l_int32 refcount; /*!< reference count (1 if no clones) */
|
||||
l_float32 startx; /*!< x value assigned to array[0] */
|
||||
l_float32 delx; /*!< change in x value as i --> i + 1 */
|
||||
l_float32 *array; /*!< number array */
|
||||
};
|
||||
typedef struct Numa NUMA;
|
||||
|
||||
/*! Array of number arrays */
|
||||
struct Numaa
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 n; /*!< number of Numa saved */
|
||||
struct Numa **numa; /*!< array of Numa */
|
||||
};
|
||||
typedef struct Numaa NUMAA;
|
||||
|
||||
/*! Dna version for serialization */
|
||||
#define DNA_VERSION_NUMBER 1
|
||||
|
||||
/*! Double number array: an array of doubles */
|
||||
struct L_Dna
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated number array */
|
||||
l_int32 n; /*!< number of numbers saved */
|
||||
l_int32 refcount; /*!< reference count (1 if no clones) */
|
||||
l_float64 startx; /*!< x value assigned to array[0] */
|
||||
l_float64 delx; /*!< change in x value as i --> i + 1 */
|
||||
l_float64 *array; /*!< number array */
|
||||
};
|
||||
typedef struct L_Dna L_DNA;
|
||||
|
||||
/*! Array of double number arrays */
|
||||
struct L_Dnaa
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 n; /*!< number of L_Dna saved */
|
||||
struct L_Dna **dna; /*!< array of L_Dna */
|
||||
};
|
||||
typedef struct L_Dnaa L_DNAA;
|
||||
|
||||
/*! A hash table of Dnas */
|
||||
struct L_DnaHash
|
||||
{
|
||||
l_int32 nbuckets;
|
||||
l_int32 initsize; /*!< initial size of each dna that is made */
|
||||
struct L_Dna **dna; /*!< array of L_Dna */
|
||||
};
|
||||
typedef struct L_DnaHash L_DNAHASH;
|
||||
|
||||
/*! Sarray version for serialization */
|
||||
#define SARRAY_VERSION_NUMBER 1
|
||||
|
||||
/*! String array: an array of C strings */
|
||||
struct Sarray
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 n; /*!< number of strings allocated */
|
||||
l_int32 refcount; /*!< reference count (1 if no clones) */
|
||||
char **array; /*!< string array */
|
||||
};
|
||||
typedef struct Sarray SARRAY;
|
||||
|
||||
/*! Byte array (analogous to C++ "string") */
|
||||
struct L_Bytea
|
||||
{
|
||||
size_t nalloc; /*!< number of bytes allocated in data array */
|
||||
size_t size; /*!< number of bytes presently used */
|
||||
l_int32 refcount; /*!< reference count (1 if no clones) */
|
||||
l_uint8 *data; /*!< data array */
|
||||
};
|
||||
typedef struct L_Bytea L_BYTEA;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Array flags *
|
||||
*------------------------------------------------------------------------*/
|
||||
/*! Flags for interpolation in Numa */
|
||||
enum {
|
||||
L_LINEAR_INTERP = 1, /*!< linear */
|
||||
L_QUADRATIC_INTERP = 2 /*!< quadratic */
|
||||
};
|
||||
|
||||
/*! Flags for added borders in Numa and Fpix */
|
||||
enum {
|
||||
L_CONTINUED_BORDER = 1, /*!< extended with same value */
|
||||
L_SLOPE_BORDER = 2, /*!< extended with constant normal derivative */
|
||||
L_MIRRORED_BORDER = 3 /*!< mirrored */
|
||||
};
|
||||
|
||||
/*! Flags for data type converted from Numa */
|
||||
enum {
|
||||
L_INTEGER_VALUE = 1, /*!< convert to integer */
|
||||
L_FLOAT_VALUE = 2 /*!< convert to float */
|
||||
};
|
||||
|
||||
|
||||
#endif /* LEPTONICA_ARRAY_H */
|
|
@ -0,0 +1,264 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_ARRAY_ACCESS_H
|
||||
#define LEPTONICA_ARRAY_ACCESS_H
|
||||
|
||||
/*!
|
||||
* \file arrayaccess.h
|
||||
*
|
||||
* <pre>
|
||||
* 1, 2, 4, 8, 16 and 32 bit data access within an array of 32-bit words
|
||||
*
|
||||
* This is used primarily to access 1, 2, 4, 8, 16 and 32 bit pixels
|
||||
* in a line of image data, represented as an array of 32-bit words.
|
||||
*
|
||||
* pdata: pointer to first 32-bit word in the array
|
||||
* n: index of the pixel in the array
|
||||
*
|
||||
* Function calls for these accessors are defined in arrayaccess.c.
|
||||
*
|
||||
* However, for efficiency we use the inline macros for all accesses.
|
||||
* Even though the 2 and 4 bit set* accessors are more complicated,
|
||||
* they are about 10% faster than the function calls.
|
||||
*
|
||||
* The 32 bit access is just a cast and ptr arithmetic. We include
|
||||
* it so that the input ptr can be void*.
|
||||
*
|
||||
* At the end of this file is code for invoking the function calls
|
||||
* instead of inlining.
|
||||
*
|
||||
* The macro SET_DATA_BIT_VAL(pdata, n, val) is a bit slower than
|
||||
* if (val == 0)
|
||||
* CLEAR_DATA_BIT(pdata, n);
|
||||
* else
|
||||
* SET_DATA_BIT(pdata, n);
|
||||
*
|
||||
* Some compilers complain when the SET macros are surrounded by
|
||||
* parentheses, because parens require an evaluation and it is not
|
||||
* defined for SET macros. If SET_DATA_QBIT were defined as a
|
||||
* compound macro, in analogy to l_setDataQbit(), it requires
|
||||
* surrounding bracces:
|
||||
* #define SET_DATA_QBIT(pdata, n, val) \
|
||||
* {l_uint32 *_TEMP_WORD_PTR_; \
|
||||
* _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 3); \
|
||||
* *_TEMP_WORD_PTR_ &= ~(0xf0000000 >> (4 * ((n) & 7))); \
|
||||
* *_TEMP_WORD_PTR_ |= (((val) & 15) << (28 - 4 * ((n) & 7)));}
|
||||
* but if used in an if/else
|
||||
* if (x)
|
||||
* SET_DATA_QBIT(...);
|
||||
* else
|
||||
* ...
|
||||
* the compiler sees
|
||||
* if (x)
|
||||
* {......};
|
||||
* else
|
||||
* ...
|
||||
* The semicolon comes after the brace and will not compile.
|
||||
* This can be fixed in the call by either omitting the semicolon
|
||||
* or requiring another set of braces around SET_DATA_QBIT(), but
|
||||
* both these options break compatibility with current code, and
|
||||
* require special attention by anyone using the macros.
|
||||
*
|
||||
* There are (at least) two ways to fix this in the macro definitions,
|
||||
* suggested by Dave Bryan.
|
||||
* (1) Surround the braces in the macro above with
|
||||
* do {....} while(0)
|
||||
* Then the semicolon just terminates the expression.
|
||||
* (2) Reduce the blocks to a single expression; e.g,
|
||||
* *((l_uint32 *)(pdata) + ((n) >> 3)) = \
|
||||
* *((l_uint32 *)(pdata) + ((n) >> 3)) \
|
||||
* & ~(0xf0000000 >> (4 * ((n) & 7))) \
|
||||
* | (((val) & 15) << (28 - 4 * ((n) & 7)))
|
||||
* This appears to cause redundant computation, but the compiler
|
||||
* should evaluate the common subexpression only once.
|
||||
* All these methods have the same performance, giving about 300M
|
||||
* SET_DATA_QBIT operations per second on a fast 64 bit system.
|
||||
* Using the function calls instead of the macros results in about 250M
|
||||
* SET_DATA_QBIT operations per second, a performance hit of nearly 20%.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#define USE_INLINE_ACCESSORS 1
|
||||
|
||||
#if USE_INLINE_ACCESSORS
|
||||
|
||||
/*=============================================================*/
|
||||
/* Faster: use in line accessors */
|
||||
/*=============================================================*/
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 1 bit access *
|
||||
*--------------------------------------------------*/
|
||||
/*! 1 bit access - get */
|
||||
#define GET_DATA_BIT(pdata, n) \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
|
||||
|
||||
/*! 1 bit access - set */
|
||||
#define SET_DATA_BIT(pdata, n) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 5)) |= (0x80000000 >> ((n) & 31))
|
||||
|
||||
/*! 1 bit access - clear */
|
||||
#define CLEAR_DATA_BIT(pdata, n) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 5)) &= ~(0x80000000 >> ((n) & 31))
|
||||
|
||||
/*! 1 bit access - set value (0 or 1) */
|
||||
#define SET_DATA_BIT_VAL(pdata, n, val) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 5)) = \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 5)) \
|
||||
& (~(0x80000000 >> ((n) & 31)))) \
|
||||
| ((val) << (31 - ((n) & 31))))
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 2 bit access *
|
||||
*--------------------------------------------------*/
|
||||
/*! 2 bit access - get */
|
||||
#define GET_DATA_DIBIT(pdata, n) \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
|
||||
|
||||
/*! 2 bit access - set value (0 ... 3) */
|
||||
#define SET_DATA_DIBIT(pdata, n, val) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 4)) = \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 4)) \
|
||||
& (~(0xc0000000 >> (2 * ((n) & 15))))) \
|
||||
| (((val) & 3) << (30 - 2 * ((n) & 15))))
|
||||
|
||||
/*! 2 bit access - clear */
|
||||
#define CLEAR_DATA_DIBIT(pdata, n) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 4)) &= ~(0xc0000000 >> (2 * ((n) & 15)))
|
||||
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 4 bit access *
|
||||
*--------------------------------------------------*/
|
||||
/*! 4 bit access - get */
|
||||
#define GET_DATA_QBIT(pdata, n) \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
|
||||
|
||||
/*! 4 bit access - set value (0 ... 15) */
|
||||
#define SET_DATA_QBIT(pdata, n, val) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 3)) = \
|
||||
((*((l_uint32 *)(pdata) + ((n) >> 3)) \
|
||||
& (~(0xf0000000 >> (4 * ((n) & 7))))) \
|
||||
| (((val) & 15) << (28 - 4 * ((n) & 7))))
|
||||
|
||||
/*! 4 bit access - clear */
|
||||
#define CLEAR_DATA_QBIT(pdata, n) \
|
||||
*((l_uint32 *)(pdata) + ((n) >> 3)) &= ~(0xf0000000 >> (4 * ((n) & 7)))
|
||||
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 8 bit access *
|
||||
*--------------------------------------------------*/
|
||||
#ifdef L_BIG_ENDIAN
|
||||
/*! 8 bit access - get */
|
||||
#define GET_DATA_BYTE(pdata, n) \
|
||||
(*((l_uint8 *)(pdata) + (n)))
|
||||
#else /* L_LITTLE_ENDIAN */
|
||||
/*! 8 bit access - get */
|
||||
#define GET_DATA_BYTE(pdata, n) \
|
||||
(*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))
|
||||
#endif /* L_BIG_ENDIAN */
|
||||
|
||||
#ifdef L_BIG_ENDIAN
|
||||
/*! 8 bit access - set value (0 ... 255) */
|
||||
#define SET_DATA_BYTE(pdata, n, val) \
|
||||
*((l_uint8 *)(pdata) + (n)) = (val)
|
||||
#else /* L_LITTLE_ENDIAN */
|
||||
/*! 8 bit access - set value (0 ... 255) */
|
||||
#define SET_DATA_BYTE(pdata, n, val) \
|
||||
*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3) = (val)
|
||||
#endif /* L_BIG_ENDIAN */
|
||||
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 16 bit access *
|
||||
*--------------------------------------------------*/
|
||||
#ifdef L_BIG_ENDIAN
|
||||
/*! 16 bit access - get */
|
||||
#define GET_DATA_TWO_BYTES(pdata, n) \
|
||||
(*((l_uint16 *)(pdata) + (n)))
|
||||
#else /* L_LITTLE_ENDIAN */
|
||||
/*! 16 bit access - get */
|
||||
#define GET_DATA_TWO_BYTES(pdata, n) \
|
||||
(*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2))
|
||||
#endif /* L_BIG_ENDIAN */
|
||||
|
||||
#ifdef L_BIG_ENDIAN
|
||||
/*! 16 bit access - set value (0 ... 65535) */
|
||||
#define SET_DATA_TWO_BYTES(pdata, n, val) \
|
||||
*((l_uint16 *)(pdata) + (n)) = (val)
|
||||
#else /* L_LITTLE_ENDIAN */
|
||||
/*! 16 bit access - set value (0 ... 65535) */
|
||||
#define SET_DATA_TWO_BYTES(pdata, n, val) \
|
||||
*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2) = (val)
|
||||
#endif /* L_BIG_ENDIAN */
|
||||
|
||||
|
||||
/*--------------------------------------------------*
|
||||
* 32 bit access *
|
||||
*--------------------------------------------------*/
|
||||
/*! 32 bit access - get */
|
||||
#define GET_DATA_FOUR_BYTES(pdata, n) \
|
||||
(*((l_uint32 *)(pdata) + (n)))
|
||||
|
||||
/*! 32 bit access - set (0 ... 4294967295) */
|
||||
#define SET_DATA_FOUR_BYTES(pdata, n, val) \
|
||||
*((l_uint32 *)(pdata) + (n)) = (val)
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/*=============================================================*/
|
||||
/* Slower: use function calls for all accessors */
|
||||
/*=============================================================*/
|
||||
|
||||
#define GET_DATA_BIT(pdata, n) l_getDataBit(pdata, n)
|
||||
#define SET_DATA_BIT(pdata, n) l_setDataBit(pdata, n)
|
||||
#define CLEAR_DATA_BIT(pdata, n) l_clearDataBit(pdata, n)
|
||||
#define SET_DATA_BIT_VAL(pdata, n, val) l_setDataBitVal(pdata, n, val)
|
||||
|
||||
#define GET_DATA_DIBIT(pdata, n) l_getDataDibit(pdata, n)
|
||||
#define SET_DATA_DIBIT(pdata, n, val) l_setDataDibit(pdata, n, val)
|
||||
#define CLEAR_DATA_DIBIT(pdata, n) l_clearDataDibit(pdata, n)
|
||||
|
||||
#define GET_DATA_QBIT(pdata, n) l_getDataQbit(pdata, n)
|
||||
#define SET_DATA_QBIT(pdata, n, val) l_setDataQbit(pdata, n, val)
|
||||
#define CLEAR_DATA_QBIT(pdata, n) l_clearDataQbit(pdata, n)
|
||||
|
||||
#define GET_DATA_BYTE(pdata, n) l_getDataByte(pdata, n)
|
||||
#define SET_DATA_BYTE(pdata, n, val) l_setDataByte(pdata, n, val)
|
||||
|
||||
#define GET_DATA_TWO_BYTES(pdata, n) l_getDataTwoBytes(pdata, n)
|
||||
#define SET_DATA_TWO_BYTES(pdata, n, val) l_setDataTwoBytes(pdata, n, val)
|
||||
|
||||
#define GET_DATA_FOUR_BYTES(pdata, n) l_getDataFourBytes(pdata, n)
|
||||
#define SET_DATA_FOUR_BYTES(pdata, n, val) l_setDataFourBytes(pdata, n, val)
|
||||
|
||||
#endif /* USE_INLINE_ACCESSORS */
|
||||
|
||||
|
||||
#endif /* LEPTONICA_ARRAY_ACCESS_H */
|
|
@ -0,0 +1,60 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_BBUFFER_H
|
||||
#define LEPTONICA_BBUFFER_H
|
||||
|
||||
/*!
|
||||
* \file bbuffer.h
|
||||
*
|
||||
* <pre>
|
||||
* Expandable byte buffer for reading data in from memory and
|
||||
* writing data out to other memory.
|
||||
*
|
||||
* This implements a queue of bytes, so data read in is put
|
||||
* on the "back" of the queue (i.e., the end of the byte array)
|
||||
* and data written out is taken from the "front" of the queue
|
||||
* (i.e., from an index marker "nwritten" that is initially set at
|
||||
* the beginning of the array.) As usual with expandable
|
||||
* arrays, we keep the size of the allocated array and the
|
||||
* number of bytes that have been read into the array.
|
||||
*
|
||||
* For implementation details, see bbuffer.c.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*! Expandable byte buffer for memory read/write operations */
|
||||
struct L_ByteBuffer
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated byte array */
|
||||
l_int32 n; /*!< number of bytes read into to the array */
|
||||
l_int32 nwritten; /*!< number of bytes written from the array */
|
||||
l_uint8 *array; /*!< byte array */
|
||||
};
|
||||
typedef struct L_ByteBuffer L_BBUFFER;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_BBUFFER_H */
|
|
@ -0,0 +1,136 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_BILATERAL_H
|
||||
#define LEPTONICA_BILATERAL_H
|
||||
|
||||
/*!
|
||||
* \file bilateral.h
|
||||
*
|
||||
* <pre>
|
||||
* Contains the following struct
|
||||
* struct L_Bilateral
|
||||
*
|
||||
*
|
||||
* For a tutorial introduction to bilateral filters, which apply a
|
||||
* gaussian blur to smooth parts of the image while preserving edges, see
|
||||
* http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.pdf
|
||||
*
|
||||
* We give an implementation of a bilateral filtering algorithm given in:
|
||||
* "Real-Time O(1) Bilateral Filtering," by Yang, Tan and Ahuja, CVPR 2009
|
||||
* which is at:
|
||||
* http://vision.ai.uiuc.edu/~qyang6/publications/cvpr-09-qingxiong-yang.pdf
|
||||
* This is based on an earlier algorithm by Sylvain Paris and Frédo Durand:
|
||||
* http://people.csail.mit.edu/sparis/publi/2006/eccv/
|
||||
* Paris_06_Fast_Approximation.pdf
|
||||
*
|
||||
* The kernel of the filter is a product of a spatial gaussian and a
|
||||
* monotonically decreasing function of the difference in intensity
|
||||
* between the source pixel and the neighboring pixel. The intensity
|
||||
* part of the filter gives higher influence for pixels with intensities
|
||||
* that are near to the source pixel, and the spatial part of the
|
||||
* filter gives higher weight to pixels that are near the source pixel.
|
||||
* This combination smooths in relatively uniform regions, while
|
||||
* maintaining edges.
|
||||
*
|
||||
* The advantage of the appoach of Yang et al is that it is separable,
|
||||
* so the computation time is linear in the gaussian filter size.
|
||||
* Furthermore, it is possible to do much of the computation as a reduced
|
||||
* scale, which gives a good approximation to the full resolution version
|
||||
* but greatly speeds it up.
|
||||
*
|
||||
* The bilateral filtered value at x is:
|
||||
*
|
||||
* sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|) * I(y)
|
||||
* I'(x) = --------------------------------------------------------------
|
||||
* sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|)
|
||||
*
|
||||
* where I() is the input image, I'() is the filtered image, N(x) is the
|
||||
* set of pixels around x in the filter support, and spatial() and range()
|
||||
* are gaussian functions:
|
||||
* spatial(x) = exp(-x^2 / (2 * s_s^2))
|
||||
* range(x) = exp(-x^2 / (2 * s_r^2))
|
||||
* and s_s and s_r and the standard deviations of the two gaussians.
|
||||
*
|
||||
* Yang et al use a separable approximation to this, by defining a set
|
||||
* of related but separable functions J(k,x), that we call Principal
|
||||
* Bilateral Components (PBC):
|
||||
*
|
||||
* sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|) * I(y)
|
||||
* J(k,x) = -----------------------------------------------------------
|
||||
* sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|)
|
||||
*
|
||||
* which are computed quickly for a set of n values k[p], p = 0 ... n-1.
|
||||
* Then each output pixel is found using a linear interpolation:
|
||||
*
|
||||
* I'(x) = (1 - q) * J(k[p],x) + q * J(k[p+1],x)
|
||||
*
|
||||
* where J(k[p],x) and J(k[p+1],x) are PBC for which
|
||||
* k[p] <= I(x) and k[p+1] >= I(x), and
|
||||
* q = (I(x) - k[p]) / (k[p+1] - k[p]).
|
||||
*
|
||||
* We can also subsample I(x), create subsampled versions of J(k,x),
|
||||
* which are then interpolated between for I'(x).
|
||||
*
|
||||
* We generate 'pixsc', by optionally downscaling the input image
|
||||
* (using area mapping by the factor 'reduction'), and then adding
|
||||
* a mirrored border to avoid boundary cases. This is then used
|
||||
* to compute 'ncomps' PBCs.
|
||||
*
|
||||
* The 'spatial_stdev' is also downscaled by 'reduction'. The size
|
||||
* of the 'spatial' array is 4 * (reduced 'spatial_stdev') + 1.
|
||||
* The size of the 'range' array is 256.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Bilateral filter *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Bilateral filter */
|
||||
struct L_Bilateral
|
||||
{
|
||||
struct Pix *pixs; /*!< clone of source pix */
|
||||
struct Pix *pixsc; /*!< downscaled pix with mirrored border */
|
||||
l_int32 reduction; /*!< 1, 2 or 4x for intermediates */
|
||||
l_float32 spatial_stdev; /*!< stdev of spatial gaussian */
|
||||
l_float32 range_stdev; /*!< stdev of range gaussian */
|
||||
l_float32 *spatial; /*!< 1D gaussian spatial kernel */
|
||||
l_float32 *range; /*!< one-sided gaussian range kernel */
|
||||
l_int32 minval; /*!< min value in 8 bpp pix */
|
||||
l_int32 maxval; /*!< max value in 8 bpp pix */
|
||||
l_int32 ncomps; /*!< number of intermediate results */
|
||||
l_int32 *nc; /*!< set of k values (size ncomps) */
|
||||
l_int32 *kindex; /*!< mapping from intensity to lower k */
|
||||
l_float32 *kfract; /*!< mapping from intensity to fract k */
|
||||
struct Pixa *pixac; /*!< intermediate result images (PBC) */
|
||||
l_uint32 ***lineset; /*!< lineptrs for pixac */
|
||||
};
|
||||
typedef struct L_Bilateral L_BILATERAL;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_BILATERAL_H */
|
|
@ -0,0 +1,63 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_BMF_H
|
||||
#define LEPTONICA_BMF_H
|
||||
|
||||
/*!
|
||||
* \file bmf.h
|
||||
*
|
||||
* Simple data structure to hold bitmap fonts and related data
|
||||
*/
|
||||
|
||||
/*! Constants for deciding when text block is divided into paragraphs */
|
||||
enum {
|
||||
SPLIT_ON_LEADING_WHITE = 1, /*!< tab or space at beginning of line */
|
||||
SPLIT_ON_BLANK_LINE = 2, /*!< newline with optional white space */
|
||||
SPLIT_ON_BOTH = 3 /*!< leading white space or newline */
|
||||
};
|
||||
|
||||
|
||||
/*! Data structure to hold bitmap fonts and related data */
|
||||
struct L_Bmf
|
||||
{
|
||||
struct Pixa *pixa; /*!< pixa of bitmaps for 93 characters */
|
||||
l_int32 size; /*!< font size (in points at 300 ppi) */
|
||||
char *directory; /*!< directory containing font bitmaps */
|
||||
l_int32 baseline1; /*!< baseline offset for ascii 33 - 57 */
|
||||
l_int32 baseline2; /*!< baseline offset for ascii 58 - 91 */
|
||||
l_int32 baseline3; /*!< baseline offset for ascii 93 - 126 */
|
||||
l_int32 lineheight; /*!< max height of line of chars */
|
||||
l_int32 kernwidth; /*!< pixel dist between char bitmaps */
|
||||
l_int32 spacewidth; /*!< pixel dist between word bitmaps */
|
||||
l_int32 vertlinesep; /*!< extra vertical space between text lines */
|
||||
l_int32 *fonttab; /*!< table mapping ascii --> font index */
|
||||
l_int32 *baselinetab; /*!< table mapping ascii --> baseline offset */
|
||||
l_int32 *widthtab; /*!< table mapping ascii --> char width */
|
||||
};
|
||||
typedef struct L_Bmf L_BMF;
|
||||
|
||||
#endif /* LEPTONICA_BMF_H */
|
|
@ -0,0 +1,636 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
/*!
|
||||
* \file bmfdata.h
|
||||
*
|
||||
* <pre>
|
||||
* This file contains data for constructing the bitmap fonts.
|
||||
*
|
||||
* The fontdata string holds all 9 sets of bitmap fonts in a base64
|
||||
* encoding of a pixacomp representation of the tiff compressed images.
|
||||
* It was generated by prog/genfonts and pasted in. This allows
|
||||
* the use of the bitmap fonts for image labelling without accessing
|
||||
* stored versions of either the tiff images for each set, or the pixa
|
||||
* of the 95 printable character images that was derived from the tiff image.
|
||||
*
|
||||
* In use, to get the bmf for a specific font size, from the encoded
|
||||
* string in this file, call
|
||||
* bmfCreate(NULL, fontsize);
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#ifndef LEPTONICA_BMFDATA_H
|
||||
#define LEPTONICA_BMFDATA_H
|
||||
|
||||
#define NUM_FONTS 9
|
||||
static const char *inputfonts[] = {"chars-4.tif", "chars-6.tif",
|
||||
"chars-8.tif", "chars-10.tif",
|
||||
"chars-12.tif", "chars-14.tif",
|
||||
"chars-16.tif", "chars-18.tif",
|
||||
"chars-20.tif"};
|
||||
static const char *outputfonts[] = {"chars-4.pa", "chars-6.pa",
|
||||
"chars-8.pa", "chars-10.pa",
|
||||
"chars-12.pa", "chars-14.pa",
|
||||
"chars-16.pa", "chars-18.pa",
|
||||
"chars-20.pa"};
|
||||
static const l_int32 baselines[NUM_FONTS][3] = {{11, 12, 12}, {18, 18, 18},
|
||||
{24, 24, 24}, {30, 30, 30},
|
||||
{36, 36, 36}, {42, 42, 42},
|
||||
{48, 48, 48}, {54, 54, 54},
|
||||
{60, 60, 60}};
|
||||
|
||||
static const char fontdata_4[] =
|
||||
"SUkqACYFAAAmoHICP///////////////////////kFcchgc45Bgc45AgcgxBY5DY5DY5Agcg"
|
||||
"jkM45A8GocgxBA8M45BfCGgchhzOQxZBiNe/CDQRT6RQ+k4QV6BHcgvBBjCC+KoSjQI7wjj/"
|
||||
"16I+EUPTpV0rI4LilVtAjjyPuR58jg3CRd6dJkcDMCj+v//qlVsMgQPVY6vugih9Lr/8RCF+"
|
||||
"OqUUK6C/fHFV9RStf8MulG10fKcN6X+lXOBg+GexX71wxSPCf4/+kE0uR5zE0rtfCFg3oIp0"
|
||||
"R+GF5DSmQaMS/oG1xen0X2wyh8WXwoI46VPt/kNYcf9J4h/pUHB///2H+t+lkCByDj/r9ZBX"
|
||||
"H1BAtUr7u/IEOQanrS0eByO16tpVaSWtaEVsNiG66WrBgg05wM4bCYNWDCWIiDCER6HGhERE"
|
||||
"RER3ZHBfXjaSQ7iOP/////////////////////////////////////////////////////+Q"
|
||||
"JgK95DIDRZAjCDccgRMhn4g5yC9CD0IL+QxhuIfCCYQTC4IJhBiyLBB7J4QX4gvQgxxBehBi"
|
||||
"yGDkPhdkEw1kPZY5cEHck5BIJOQc9aI+wjE7DL7RdsMu2GXoZehGDYaDCDQaDSCDQdIOGEEX"
|
||||
"bDLzCLthl5ojzkeL0NMJhNNbVoJ6kclXuggyOGfugnw3vugv/0u+9IN7pBvdJ//brT3VtdLy"
|
||||
"B4NxyGsOPRnv9R7xx3/9L+EU/3/f4jj/t+3TdDvkFZyC7hYdKkCCKHQI76SW/pD/6XCKdAin"
|
||||
"29L9L6/9eEUOrD0kv8IIMNKkq/j/zD5h+P4r//99LfBKcDR9utK62NLxEIIhnmGGlpek3Lz/"
|
||||
"jj5cv/ul7f+EvimH///0l6CENpfrHt/y9l7kr/4RT/f7f+PwRTkG7/tpav26XtrxoVI5/vSx"
|
||||
"xsP/7ful7fdd1tv/7FRoj//DLgQZgQCFhlYlfv1kx9//28mPx/7ruu3/t9K3pEh/IKzkF3DL"
|
||||
"g2BENDtBr9Jh4S12H/+3+17GwwltpbZBx0u0unr0v9IMjhrBYYpO0KZmDikMJsYTCDCeE2Gh"
|
||||
"p6DTdiEE2KCdo8GcNj3pJsJofjiIiIiIiIiI4iIiIiIhhCIiIiIiIr1SMwyQbOkEiGQCvd4i"
|
||||
"I//////////////////////////////////////////////////////+QVo7IEDkGwchpOQV"
|
||||
"nIa0ENKCGhyC7kHchocgZschnHIMPtKk7oIP7ulv6f9Yj5DIDaH/3gjjr///+rI4aiIEXngg"
|
||||
"RZBfCBEWQXsofKggu5DD5Y+Qw5UHghiCoIEYQw5VkCMIO5TkF7shhzOQxZ4IJZxy3IO5nIJZ"
|
||||
"4IP//1iiPOGd0R+iPQgR3TQIIXZ3/S7BBnezui87MOiPbKHRHqftNNXvTTUjy/9JkcFjTpOk"
|
||||
"9NsKmFTu+Etppw06VtMjhhO0OLCd3S+rSdIUvyDD+Iha8fQ//+K//3/+D/vbQRT7d9LsjhgI"
|
||||
"7nH8Ivf/lw0bS/4RT////7f//pfq+lhr6/v/Yf/t//3/+D/sO2NNhpfiP66Xat8L/2//3S0r"
|
||||
"XIMD/rvUEd9Isf/4Mp5wCDgYBlOzgO0fB3aem2mmnYTtipwCAZQ6DnAXDgynapwk20h/+IiI"
|
||||
"iIy9ERxEREREZHDLiIiIiIjjj6kNWdP//qP/pMjhq8bSXwojsGkEwmliIiP/////////////"
|
||||
"/////////////////////////wAQAQ4AAAEDAAEAAACSAwAAAQEDAAEAAAA2AgAAAgEDAAEA"
|
||||
"AAABAAAAAwEDAAEAAAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAA"
|
||||
"FQEDAAEAAAABAAAAFgEDAAEAAAA2AgAAFwEEAAEAAAAeBQAAGgEFAAEAAADUBQAAGwEFAAEA"
|
||||
"AADcBQAAHAEDAAEAAAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
|
||||
|
||||
static const char fontdata_6[] =
|
||||
"SUkqAMoGAAAmoHVf///////////////////////////////IZAUfsgeBdyGdyDjkMgI+QPKC"
|
||||
"GIO5AhzOgyGiCMcgYtUrIKHohowhschs4hnwgXcgRQhsgguQQXwhov6/QYQI7qgRUUk2QIfV"
|
||||
"F5hQmmugqCMTCBHj/9F8j9JuknWm7rSbCBFPLtou2sjhlBSOKkE3Qf3+kv9fpcMQaXY9PTwR"
|
||||
"T6WvpX/0v19aVbeQ0D6X7+v/X//QIQfj6xSS4QLS3xx69IVtL/EQy8CvbSqhq4I7//pJeVnT"
|
||||
"Dr/+Niloufj9fpJLxalYrDtdr2DGk/etf6CDrkduzQkw21/w2prRfYZcNbj1+kQMQuL03hF5"
|
||||
"sQRT+CEMMj7pAjuk/5DVDINfr+k9b06Stj+GXgW6pN9/kNsdL/XQg/+nSx/0v20vxSv0v/S3"
|
||||
"/yDA/19sV/6WkQ0D5DY/6+lkDyf/SX9h65BRBDTdJ/StLILuk2lWkl399U2kw0Thpa0r7S0U"
|
||||
"A7S20rSVtJL/iGrFMSPJv+qYoEaA+KBA4pikmKCWIiDVCINaQ0KiIiIiIoFhoRfSodbS1xbp"
|
||||
"Id0hx8f///////////////////////////////////////////////////IHMFnMgTA0hyGQ"
|
||||
"G45DLcg0jkQfyGQDNxBv5DLcg3QQ2EEHDIEaEHDIaDkMTJzIeZBJkEmTwh5kNmEPhB7ITCGi"
|
||||
"ZDOghsmQ0IIbJhHUEMzPAh8jYOeIuRsEZFHCZEHBDhdoww1DLm0bOGXGwZccGXHCMDgwQMED"
|
||||
"BAwQMEi4ZwQdAg2GEEbYYZc2EbYYZcwwjB5dmDgwQMIMJoNbQNqHuRxF6I7YQIN+6BBrDf+E"
|
||||
"E//pf3oEG9tAg3vC9//126bQWlXh0gyODd+l7fXwv/0u1gio0m90m916x9uu60nXXyB4G7kN"
|
||||
"tx6JwU9oEU/4944qP/pcEU8EU+37f7f4j/q6q2tpDXhYaShBBDer1XfJD5IdL/0vtf9L9L//"
|
||||
"ergin9JukvIHk5BiAggw+kn1fSr///9L3r2/fS30of9r1exWqXp4QQYaWl9XH/a2vH+l9/t/"
|
||||
"6X58mgN//r07dJe04QRDYGGGgvpVeXb/jj5gT8X7r7f+CX6CDD/bp6bXY/xEIIQw16Xq8N/y"
|
||||
"5ZcvT/Lp/de3/j+2QMd/r/p0l6CDdf0h73//ZF7/w37r99/fuD/vVq9SP3S9hpd+lLj/6444"
|
||||
"a/9v7r39L0tt/7Xq9b0vDDIbAwQQu2ElKHq/fr3f/2/dfb39/b/V6jjSb1Io/hhiEFbEECFK"
|
||||
"r/euRR+//28ivxXt913XZBcf/jaevr8geTkCHDDCCIF3bEk9XpN6X7f/7f7+xtpbaW+l2l9K"
|
||||
"3pfpqGGEErBhJfCTBk4wl+wf/7f9fsMJba7cMJbDSa9JvSX2sPCwxCQYQaFBikIQQwQMMYIG"
|
||||
"CBggeCBsNCgg3CBhBuGKBA2KBA24hAgbFdOlYIGh+NCIiIiIiIiI4iIiIhxEGCERERERER9L"
|
||||
"GHfVBF0Tgtg0dSBoDTYk+h40PiP/////////////////////////////////////////////"
|
||||
"//////5A887IHkOQbLIE8EFaCGvBBmsgosgaDcg3HIbHwaIbIvVVIZTkGHVUtv9IOHRHBU+D"
|
||||
"g5DJBx//QRTr69fr/+3X+I+v/pa//v/9N0Q2XnshsshsjIaMyGjMhlOQIHycZAhyDUOQy+IZ"
|
||||
"xzWQUWUOQYc7kGMyGdyTkH41kH4scnZB4JwQxhrIYp/64hF56DCLzBF4aLzQNF8+DyuCguuF"
|
||||
"Kw/ApXIvMFTCI7FhU0XmgYUL/ap0tow3/6TdN2XCTpB0rVJqJHmHD6BYbNhoDEjzSbDDLhJo"
|
||||
"NnHSdQ4cMJoMJQ0DpBphVC//x9v/ScMEkwqf9Lpp6dJum18cQwX3V9XXWv/pN9OkKX/9f6X1"
|
||||
"1/TpdX+6umrDdRSS2yBGFv4iQZu/9D//4r//f/58CP3XI/p7pL9F9peEYv/zAF8NL/hFP///"
|
||||
"/t/utrrutN6SQYr0F//7Ff+3////g3/11dJ+l+I/+ld7ey4KP+3//fpX5DOOD/3sb8j+6X/9"
|
||||
"en1+v/b//dLr//Vuo0rY0ib//aphKGYdtAinbLfROC//Yf/8NKGEmwvaUOwvtK3SX/7DPcUG"
|
||||
"NjhsUEHhBwwg8JuEGEGEHDCDhhiopiCKcIOKeJHTd8JNuh/+IiIiIsubERxEREREZcNKIiIi"
|
||||
"IiNDj+En/X/IbQdf/+Cj/9Npd6SXq3WLDSrwSEdigkEGCDrEREf/////////////////////"
|
||||
"///////4AIAIAA4AAAEDAAEAAABBBAAAAQEDAAEAAAA6AgAAAgEDAAEAAAABAAAAAwEDAAEA"
|
||||
"AAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAAFQEDAAEAAAABAAAA"
|
||||
"FgEDAAEAAAA6AgAAFwEEAAEAAADBBgAAGgEFAAEAAAB4BwAAGwEFAAEAAACABwAAHAEDAAEA"
|
||||
"AAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
|
||||
|
||||
static const char fontdata_8[] =
|
||||
"SUkqALIIAAAmoHcGf/////////////////////////////////kMgMsfUgeDaOQLjkHHIZAN"
|
||||
"T5A8K5AiDQQ0OW7kMqCEHIZthNJkcMwuGQG8g34gYcgo8go4hmwQIDIGIIL1EGOIKO1/wRmG"
|
||||
"cvBqEX3S3dBGJhUwmlQSpGINF2/9cIxkfa9U+k2Q2OlpNgqaNzWwgWk2k33Veluk2q6STadJ"
|
||||
"U2jHlzcJtZcGlS4RJOt9f9f9L62GMw+vC0np5HXS/0n/6Vf9dapwxpdj7rr6Wl/f//v9dJLa"
|
||||
"kG76X/XXpf//v/j62kl4I2i4ZVd8caX8UrS/xEgvV7aVMUP19f615+S7/6BmGXBh70tK21ev"
|
||||
"60lxefkmGla/8WxVZM9Y31/RDYOEl5uappMV/1sGKhNfYX/1EOuEHiR57DbXfUMOieIxwZgN"
|
||||
"vjpfrI7a9XQdJF9sSOv+QL+qLzSt//9IW6x6tUg21+Q2qpHnS3Tf5BtTkNSi/06710rYpeDM"
|
||||
"MuBi6pNq3+QZX6/S0J8DHdUn8f+v3S/Fb9L/63r8hnH9f26/rS0sgXj9fXpV+vuP9X9Igofy"
|
||||
"DD1el6WQPCR/pL+w7XIZUEGx660nS3V0vSrv/qm0m2UBr61T7S0dAd13XSTdBL+r0l6YYX+t"
|
||||
"JtK1hhK7CTDCSthJLpeIpIMUGJHaf9rYohsQsQiBhDEIMQtiECCxESCjKESKPdDQqIiIiIig"
|
||||
"sGhF1Wh16pfbSSrFtKh3odkcHWI/////////////////////////////////////////////"
|
||||
"////5A7AyfkDqG265DJBRxDKmQanIZWpDKDIOnIaBhB05BQGQwgkcgiCCIIIglxBEEG/kGPI"
|
||||
"J5DzIN6EG+pDKoQ2akDFCGBBBDkdCCUI5kE8iuRfIPxCwCZBHIYGMFhMI2w8M42COFBnCDIN"
|
||||
"7JWQz2SsEcKQzwDBENEENkENkQRDRANwQNgwQRthhnDYRthgzZhhGG5cjZQYIGXDOCBhNYYW"
|
||||
"k2rMBNcu2ECBhptBtAgdoGHQPQdFwTv+l6T4QIGG0Gwi4UOg2gg0777dNXg2gg9Qq+m0g37p"
|
||||
"eG/8Jf/pd96Cb7Sb9f//1pvbS0vV0rT9L3/0v/0vWCKjV91fdJ//dK/0n1Xx6eXX0vvHGv/0"
|
||||
"uXTkde9Jv0m//6+/T20rSevIZCggrxpErPFpX+O36j/6C/X2//7/Ecf95dUnSdIUvCsNLCCC"
|
||||
"I6vvpL+RR8ij//pe3++lfpev+2l1ffdJeQPCOQ0OEEw9Un6+q3/0v/S/S9v/S/q//tfYp1S9"
|
||||
"NMIIMNKkq1uwS////0vb/b9+t9KZg0fdL3Wm0v/CCDBpdfvF/wwsMLx/pfpff+Evz+ygMr9+"
|
||||
"ldPdJe00EEQbpww0tV0rmDf8cfNhfxD9/2/8/foEw//f/Y0vEQQQgw6+l3wb/mB5gfoP8wn9"
|
||||
"pe/+P4bBv90vfvS9Ag2l10lff++//7fv+3/3+Qau/vtK0kXTaX6bq9ePe9L/shZ/+39pfff/"
|
||||
"th/3S9/+vhhL/SkcJ//HHBr/2/f9v0vS23/vdL0m9LwwwgmRwb20R1SW/f/d//b+0vff2/b/"
|
||||
"3r70m9LwwyDdOEENsHpHH3+9LIUfv/9vIUff9vuvryGcf9dY2KX1IUfwYMQgnFik0r1b0v2/"
|
||||
"/2++K+9tLbXbuu+Oum9L8geEchogMMEEQzXbFBb9N6Wvf/7f7+xvX1t6+k0+k/X6ahhhAk2G"
|
||||
"kt6TZDj4S/b//b0v92GEttLb0tgwvTS3pL/QbQWGDBL7CQYMFTCVhbDBrffbaYW2r3YYSthh"
|
||||
"K7gwguKr0m9Jfaw8JoMQgQYIMIQgxCQhAhkHQGIRBhBI5BEZBhAYaGCB4IGQSmGIRBugMQiG"
|
||||
"hDDiiCg4YT+EoZDOhD8aERERERERERxERERDiIMIRERERERH1xb+qQfpJBF2UAZhn9EDUFTK"
|
||||
"B7xoQYSB7Qjj/////////////////////////////////////////////////kDxf7IHgQOQ"
|
||||
"VbIH1kCSyCrZA8cEMyCBqHcgYcgYfIHh7IF4TChVCkM1yGhwoVe+loHBwi8gdNMOHS2/tL6H"
|
||||
"/yGSCkP/6BFOvrtNeE//Sv9cR+v/p1////W6////p1zZkNnZAv2bCDcchsHyLGQ2DmwnZAuO"
|
||||
"bCBfiBcc3EGochoHNBAjsg3HIQcguOSHLHLHIJMm5LiC7kMocmOWOWOQXciv/62JDZPQZBv5"
|
||||
"DYhF5z4Zy8yr0yDGEGM1yDGJoMgxyYRiDIEYmQboIYxNF2HPg8lkaH6hMjhDjQ//p0Xb0XmE"
|
||||
"YmEYcJNhNJj0Xn+gtUXqL3ReaQbVF5ou1qk4TVQwgYQYWDCDoIMIMKXH/9bSbig6CDoIOlyO"
|
||||
"jAbFVthw+gsG4qwbbSsGKDYQQcMSPJRSBwd6dPbSfpL/6f6tdXqx1YVf6XTCevem168GYDR9"
|
||||
"fSutLS/9WxeuqrV/9/wl/7pXXXQ/91p7pXjSW5DRhFH+sLuor///6C//33X4P91bl1pjdJKt"
|
||||
"hovBr4iQPKn/x/X/F////7NAz/v0tavW9aYaXhG3/+YDM2l/zCf///+3+9e3TvSTeglDFegv"
|
||||
"//bS/9v//+vw3/q3Wt6pf0PpfV3+xX/t//3635DNv9utb0R9t1X4/+vreyOGZ/2//+uvyGx3"
|
||||
"/16elvVIjH//Xp3/X/2//3X3//WKjjSeNb/+10rtWyMfX/2//7q0rX6u1d2kraSr/3RdYaTD"
|
||||
"LdsIv2GvJAZ/+w//2GErCCbCLr2EoNiR161b0l/9g0HI6FBimKg2KCB2CBwwQPBA2wQMEDBA"
|
||||
"4MEDhhiFFBisETgwITTCg2vCTDaQ//ERERERZg2IjiIiIiIzAa8REREREccfwgg/9f6X+v+Q"
|
||||
"ZK///0x/+m0sF0q9W0sW6XyGSGkOkI7YSr4rYhAkEGCDrFhCI4//////////////////////"
|
||||
"///////////8AEAEDgAAAQMAAQAAAP8EAAABAQMAAQAAAFUCAAACAQMAAQAAAAEAAAADAQMA"
|
||||
"AQAAAAQAAAAGAQMAAQAAAAEAAAARAQQAAQAAAAgAAAASAQMAAQAAAAEAAAAVAQMAAQAAAAEA"
|
||||
"AAAWAQMAAQAAAFUCAAAXAQQAAQAAAKoIAAAaAQUAAQAAAGAJAAAbAQUAAQAAAGgJAAAcAQMA"
|
||||
"AQAAAAEAAAAoAQMAAQAAAAIAAAAAAAAAAADAEgAABAAAAMASAAAEAA==";
|
||||
|
||||
static const char fontdata_10[] =
|
||||
"SUkqAGwKAAAmoFQGz///////////////////////////5DIBocgZg0PkDwy3JvkFdyB4Qchl"
|
||||
"DkGB7yB5OnZBQ5J8hmckQ0rBNUyDSOkQWnIZXkMqZBrghs0INDkM/kdkDfsLqqhGYKDEHp0k"
|
||||
"G0HkFEwoQaaqCcWQzzCMMPXfwg0m0gi89KyCgekkYmCpppYQKgjc0m//0Yy8/16VtP0EGwqN"
|
||||
"to22ugtBBtJv2vpLdJtJJ1SbTpJKwjnoOgg2swGmFLgiStb3+lXf/69v1bYLpuuR1pLVX//X"
|
||||
"r/S60mwYorKXH/dfS69J/2vX/9UvYyGU699PXXpa/3//4+l1S2EcXqvXHX1qr/8RIMCP17SS"
|
||||
"pwggnqvj1XpClpf1+3SWlS2l/v6S+btbr/IKbknv62KH2Fel/VJeEGlTDS/1W9tJKiGL8f/1"
|
||||
"Sri83qxVr/sQ2K1JBpXel/RAuOFXm29On//YMUk/dhf+qEOuEHQtWG2v+w9GEwZuXj1/Uuw1"
|
||||
"6bnzaSDtF1/wbSI+Sdx/X9IQ6WPCb0YbYr38MvvCMTVv8gqlyGsR/pX/ukkHaS8gqiMOkk2l"
|
||||
"f/pfpOlvXSTYa/9/b2/yBO9f9cTQMzuu4/RBSgnHpJe2l+KX6Wv6ST1j//7f/2lpdf/pfkM8"
|
||||
"el+xVr0/pEMofIZV16+v//9tda/pdZAh1vS+sge4/0kv3fyGbBBVeutK126dLtJLuq+ttJuH"
|
||||
"+FTV/SOR19dJPSWqr6SX2gyx+ur7S0LbS20n/oJf8PS20mwjeNtf0noINYMJBBwwk2kk2kEF"
|
||||
"texFJBiExCYXXTWwwkCBrEIEDimGEErDCQILERBgsQwgafFRSDEIRDCEMIMUIYhQWQyAaHER"
|
||||
"bSrERER/0q90tfukqxbWh3odtLbSxH//////////////////////////////////////////"
|
||||
"////yBTDMpkFsFhyB4YOQyAboILYFByB4hyB4vkMgCIK4iOQsFWQ07IZxyBEeQyQ1PINNLIZ"
|
||||
"icEDIMeWcgoBkFy4IGQIIIoZByCDhkHIInkMEEDFCGyhBJkFzggyDcYCDINxgQMgwoIIGRDk"
|
||||
"EIIp0O0MhjrIPyZDCj0GCD4aOEHEN3CPDDaDTQaapp6bwjxByc2EeIOTmGEcbw1TTT7ppJ1U"
|
||||
"4B46aPGGmQabJeECIJZDPZEmDNhIM2JQIHBggwQMEDBAwSBAwQNo4DdkCHQIGyCiw2gQNkFF"
|
||||
"htBB5cZwWGCIMOGCBhBglBggdBA6U2Ca5c2EbDvwbSayCZh8Ogg+/6C329JvbSb3SD777/q3"
|
||||
"TdQq9INoIN/oL2/9J//S7W9IN9pBvv//tJ720m0tL/SbT3X2/9L/9L+XXSvdK90v//1p0nrS"
|
||||
"+npuXX0vb66X/9Ll0176b/b///eu++1/yGQxyBwOOk63+++ONV/6X8uu3r+l/iOP2t6uk9Cl"
|
||||
"4WHqR8e7r6SH/Uf/S+19v3/f/96dGF7q0kvCw0qCBAn6vpff//pe9e39/3pX/a9XTaTql5A9"
|
||||
"wQ2QEmHWgmKer6X8iPkR1/9L7X30vSS///991bpL1TCCDBpKv76Vb/9f+l719+/W+lD/erXW"
|
||||
"K0v7wggw0qS9K4YIL////QX3+3/pfpMoBq/a9XTTapfWCCIFy4MNL694g/44+P9fdL2/8Jfn"
|
||||
"mzoGZ96dX+6S92ggsMNLS9bmyD///i/v9v/P/6BMP+/r22KS8RCBCGGl+teDf84POD82DH79"
|
||||
"1//5HDL+Gw3+6/a/XhBBhpddK+/9PT//N7/r2/8b9yGpT/q1ek2l9BBuvS6vu9f+yDuRj/+3"
|
||||
"9r7ff/2D/2r16MLpfT9+kh7/X/xf/t+9e39fW2/71q2qV6XsML+qV//jjkCM/9h/a+36+u2/"
|
||||
"/9dU3peGDCCbdtalw/2/93/9v3r/f2/b/20r71frwwyGWXBBVbaL8JK/+l9//t/a+33X1//7"
|
||||
"G+levhh4QIXYqKNFX7fWQR9v/9vIO+9e3uu2ltkND/rHUaTekQw/hhiEE2IpK+l6///7elx+"
|
||||
"33X+313TXX6X5A9uQUQGGEEQa4tKr9vS/b//b/a9jbS20tvX16dJvS/TChgwgk2Gkr6TDILj"
|
||||
"4S/Yf/7f/+2ltpfdbaX6Tfr90GwgtsJd4JNhcEtLb//b/r3YaWw0tu0uDBJp9fSX/B4WGeNB"
|
||||
"NNCEGZkghCCGEGGZlCDCDCDwg2GhhN0GE3YYJBBsMEEEGw4YJBBsV00kw0Gh+1QeE0xCCDBB"
|
||||
"hBMQkCChBsQggwQYQeEG2FBA8IGCBuGIQQYYoINuIQINr8JWCBr4qIiDCERBhCIgygDw1IiI"
|
||||
"tCLhghBghEGEIMJrxER+hEaERDiIiPpaB/0g/SIGwCcdJFzOgGgr6jEGvGgamgH2EL4j////"
|
||||
"//////////////////////////////////////////+QP6EDob+QPBoHIElkDw9kCyyBJBA8"
|
||||
"F7INVkDYDEZDLjyGVCZBXmCqQZPIaUENEAoKlt5A8sTSfV00/S2/6BwdF3D+Dg//pr6Q/+QW"
|
||||
"wbj//MKvrtNeC/9JN1/iP//+vr//+k3////9r///+k9ZeECzPy+IZY5BuP5AuOXhHhDKHL4g"
|
||||
"tOXxBowscg3HLjIGByHHIG9CMci+Qzv/+3BEMyeEGQMUCGQLzyBimgwUgRmRewVNBgqDIZXg"
|
||||
"qYQsFTIEUyGzAUgucuippgmRLIOcuhDFX/pYhPTChGHCNzROBBuKAXpgoLoLBU0wVMIwwwVN"
|
||||
"Fzgqow2icEgoYIGCDBYMK0EGEDClxP/7YRtvl20YOgg6CDYVBNaMXfQXovNGK6MUIJt0XbCT"
|
||||
"WqCDhX336B6apJL/0ug3bpB0nSsGbDZZsNghBsHB9BYNhiE2GIQbSbBsNoJwYkergzYN4P1p"
|
||||
"9pXXX/q3vTaWrr6V1/pf9at02vTX/t7fTaT+l/9Y/rr0370/6XTT0/fr44/6WnuukKpdkFFk"
|
||||
"K/pN+9DWv//6C//S/rq/7+XVJum9Kt0DXxEF9V///9f/991+ZgY+6Tf8VrQSww0YwaXkDwOE"
|
||||
"f/H3X/H////sH/+k2k1dJN6SQYrwjj//Ng1dL/m0////9h/t1/tvpN6SQa9Av//ev/b////w"
|
||||
"3/rpN6ekrelQ+v//sMJf+3///X4N/3t+lt6X4+l6V33hiF/7f/9+t+D/ulr6L70q////+XBp"
|
||||
"/7f//XX5BQO/9/TdJNvpER//16d1fS/9v/919//1emONK71r//0rtb1/9h//3Wla/XrHWrxS"
|
||||
"S//YRdbpsijtourZFfT/9v/9+0E2vrZ3hourW0k26X/7aWgwgmGFYaVsMJJzWBDtPTYaaYTt"
|
||||
"O20oaTYRhUGnUUxV76V0kF/9ioOXQpigxUNiggbYQOGEDwg3CBggwg4MIHDYaCimIWEHDCCa"
|
||||
"ah9OrDeP/2ENBoNMIQwhbERxkcMgYqbQTCxDEJpoX8RocfxEREUYE4jiOIiIj/2En/r/IG5d"
|
||||
"J/1/////H69JtLIH9NJf3S6uq9ISh0CxdL8gt46iO2kl6FbYSCQIMIHWGISCTCbWIiI/////"
|
||||
"/////////////////////////wAQAQ4AAAEDAAEAAACoBQAAAQEDAAEAAABCAgAAAgEDAAEA"
|
||||
"AAABAAAAAwEDAAEAAAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAA"
|
||||
"FQEDAAEAAAABAAAAFgEDAAEAAABCAgAAFwEEAAEAAABkCgAAGgEFAAEAAAAaCwAAGwEFAAEA"
|
||||
"AAAiCwAAHAEDAAEAAAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
|
||||
|
||||
static const char fontdata_12[] =
|
||||
"SUkqAFAMAAAmoFsNP/////////////////////////////////kMgNpyBoLGQPBocjfIEkED"
|
||||
"wU3ILjrkDxwmnkGmKIa+ENfFshpj0Qy5kNIcg0UIHhxyCjCLhDSHIa9kG8yGZPCqpAvBK4YR"
|
||||
"oCU0km4PTChBkMqgJxhMhnCBBhB6u/QIoBubbpPSb0gjbYKmEH4S0bNo43/rhBpNqjHpKyBh"
|
||||
"/SDYVNNLCBUkG0EG//0Yi7fdJOqt3S02CzjaPNroLSdJv6qtLDS2qT1TaaVLo5UEDwQb5gGx"
|
||||
"TAYXdf/ql9PS+t3rVwurp0XXS6SdW+v9f9fpJwxRcUrj7/9JUv/7v1X/Wkl2DGv9aTpel16X"
|
||||
"v66/6/pbkMyK79/S+tf2///H6tJLbBHv6/4/66Vpf4iQYUfqulXhAioHSrx6S9If//9uq0kk"
|
||||
"tL/f0v9K0v/v62KHbq9f60vNNdhpX+QJ4JXe6pV7X1+qSXhB0kw0tf6Ye2l0RNFxb1/oEF8W"
|
||||
"pf0xC/14gwxCSTXv6/yBiiXON4Qattr/sGOmtcL/0oNeEDappMO1+thpIxyIRuOl+kjDdcJ4"
|
||||
"lzemwwjC/4byL6TbNgp//6ENpY3CDpBG5sV/qQaCEgjc0rfyDKTIbWiX6T+9WqCDbVbkGRRL"
|
||||
"t6Tav/1/pWl9PShsNL14dJK6b/1X9LXLHf1Scf//bVv8gtRVfpPEX71vXRAnslG6SX2l+K39"
|
||||
"a/qlrjX/+3/1paX/pb1+Qbj+l+2la/+lkM26/9L1T/+26/Sf1IZg9f6X//0l+xT1/6VrkNDp"
|
||||
"N0vSWQPOOvX+2/yGlBBkdetLr/WrVLTX+km0m2H+Cp1a6RB3b+0n1eku/9L+0DLHtLpNXrQu"
|
||||
"0t6tKrUJfXD0knpgwQt/+rSTW0EnYSbpW0kF/weEtsJMTcF/Tqw0iBepYYSIZurDCTDCSsMJ"
|
||||
"BLa1DEQkgxCYQa0taoMV8QriExVMQiCjsREGFiGEGm8aHaEQYQsIMIQwoWQyA2nER6pIRERH"
|
||||
"3Vf26pf0kq9v1xbSSHdKFtpDt11WI///////////////////////////////////////////"
|
||||
"/kC0GD5AzAxBA8DCCGQCoQQMw0yCB4EEEDwYoQyA1YNxDuQ8Hwg2YQ24vIZILHkNQ+QaS4IG"
|
||||
"QzqyGWkILkwQMhs1ITUg+pB9SD6kJQhjUhmHIGDkMUIZyAgyBgGEGQMBAgZDPQhaEEqIQggm"
|
||||
"hCoQ1QyBFqQX5MgwGQl1hBgg7hhHyBw/CPkD///vCPEHDCPEHDRxhx/r+CeE6i5wDwxTCPkG"
|
||||
"pDSmT9GwSQ0TIzkMuZF8homR+EcB2Q2eQI8g38g38g3+cBQfDUaPgoZDZYQIGGQMTJTCBAwy"
|
||||
"BiZKaBA+QI4hnsGfAgEDBWQe00CbWvRttGwR7CDYQQdhEE9hA0wgaQQdpppppBNPTtIINsIN"
|
||||
"oINsINpPLhDgmmnaaVyGzkgepgCPwg2EEGHe2k+GHvuk//pdrek3uk3uk//6/t02lSX7aTa+"
|
||||
"l4f/Sf/0v70m9tJvbX/967SbV60vS0nvdL2/9Kv/S9b0n9J//3+9td0m0tL90m5dfX2/9L/9"
|
||||
"Ll0+XT9vfb3Sr/3S/ur9J8erX9L7xxX/9L+XXb1/X/f6/+6dJ0q/IZAdyBY+pCQ9X+O/0P/o"
|
||||
"L7X36v6v8Rx+/RhVbW0hS8LD6BBny1fpL/X/0vevb1f1f/90r/un0vCw0lRyddXr9//+l9r9"
|
||||
"/f96V/3ule6TaSXkDzggogJMHVIJjdX6/yFfIV//0vf9vS9JL//dL3Suuv00wggw1Vf7wku/"
|
||||
"+l/6X2l7f//pQ//691bVL1sEEGGlpVpeEFX///6Xv+/vpb6TB/36t7FaSX+EEDDqkv3iv//h"
|
||||
"hf0vtL2/9L8IKdQ0/uk39U3SXvhBEMomGGgv+rg/44+P9ff+/8JfnOynBp/f1q+qXtMIIFhh"
|
||||
"paXq84Qf//8X9pe3/nP/BBv961b7Yr8RCCww0vSXvITv58efH5wNH79/2/9hfuG/9ev3S8II"
|
||||
"QwaX9Je3/CDwg//zif2l7/4/tkNQP9vbXpPS8IINpdfvvf///7fv+339/kNqf+l7a20l8IN1"
|
||||
"fpJX36/9kGCP/Df6Xt//7Yf+/r0Y//v+lx7/X/3/7f3/fpeltv+9at0lel8MEt/ST9/33chs"
|
||||
"//2/evb39/b/9f1pvS8MMIJvbRHWpgMfv8cbD/+39r79/f7/t02l6vpeGGQaSYQT3YXX/9L/"
|
||||
"/9v3r2/r62//X29K9Lww8IIXYrCR4Sv2/9v/9h5Bgftfb3XbXbINx/1/rpX8gw/hg8IKwwmI"
|
||||
"S76V6WQXf//29divvuvrbuu9uo46vS/DDEIJsWkkr9vS12//2//29tLbrtV+o3dJvS/IHnBA"
|
||||
"vYMMEEQ04bFLfpvS62//2/39jettLfrdWqpX0v0woYYQSbaS3pNkM4+l+3/+3/Xu2l2lt69p"
|
||||
"fpXr+tBhhArbCVPhJhhcJft//t67+7DS20tu62GvT030v+G0FsMJLagkygWmRaYLsNdf21BV"
|
||||
"q12GEsMMJd2EtgwSafX0gv9B4WGfMIEUAgNCgxSEIhlkyC+oZoOQY0IXQhjXIZ9GDQyGEOCI"
|
||||
"YYKAIsGCRAvoydogX0YcGEiGXoxX0CTBkC+iH7Sh4TQYhJqgQYSBLhiCu/t1vTtwxCsMQrbY"
|
||||
"hWwunSbv8aERDCERBghEQZIA8GWIiNCLhghBghEGCEGF+IiP0IjQiJA8C+CIiK64QP6pB+kk"
|
||||
"gf+i4zUBoDN0iBKb0INfCigak4HhI0QMw1IvYQjj////////////////////////////////"
|
||||
"////////////kD9BA6hrjkM2CGYP5DIDUggeBiyB9hBYsgeGVBDVggbQ2ZiVHkGiCB4rkDfy"
|
||||
"B4bJqQN5kNdyCiCBEyDVNBbeQPHyqqqqaf/e6aRBYsgeBfEXcgUYnZDRZDUtLb/90hf//9NL"
|
||||
"1/8gtgsP/8xtfS2mvBf/X/8R//6ptfX+v/Xr///+m1////V////9K0iGb/kMz8g0fkD4fyB4"
|
||||
"ZxyG3MhmjkDwUp5DMHIYHIHgTj//uwQTycyDTMhl0wnhPLmQy4BcheyBeC5kfgpcwQYKXMg1"
|
||||
"0M5DZBPAg8FBSBBBM5DCCK5EoQx5C4QcgmcguI/9KxT0wQYQ0bmiQGgwyGBFMhsmQInpZDPN"
|
||||
"NBkNk00cYZAiaDCGQXmFRttEgHkWbuune7//7hGDeEGEbOEbOEEGwqQfT10C9NNU0EG1QYRs"
|
||||
"uqQcL4YIGCBgkyFsG0CDBAwUwFX/pXQfRt0EGggg6V6TWjDZBRZDZmlkFFow2jDkFGIw2k5D"
|
||||
"RiMG0EGiGy1p1Bwd6fp0n6S/+n24hBtXSDpNgzYF84CgQg3voLiEGIQbYhBtJtiEDaTxLuuQ"
|
||||
"0W76991paX/rdPCdLp/0un/S6rp+6dLhP//WtNq36//TY+366X71/pdNPWr02vjtft72rpdV"
|
||||
"SXZAxhBx/X66f9v/f8Jf+9X/1Y/62i602lqKXug0/pv9RS1///QX/6/pfD/br3WKbpJBbaDS"
|
||||
"8RIHgYPv/DC//+v//7/ygDH/dbprVIJYbRuBhLwRmv/x9pf8X//v/7B/6V17vShh4QVBj8I8"
|
||||
"f/4L6/5tP////Yf7fq2vfTeqQa9Av/5wNS2l/7f///+G/9J66vVK9KgYXpf/+w0v/b///r8G"
|
||||
"/2+9+26Sf8fX6u/2K/9v/+/W/Iav/6WlaSL71S/H69f7wwv/b//66/D///pb0v//16vouGp/"
|
||||
"2//3X/yGU7+rdOrGrd9EKP/+vttr6/+3//daTf/36xVJNukkv/66Xe3pf+3///Wv16sfpXGl"
|
||||
"//aLraTbYRhYZCPp/+3/+2laTYX1u0XWmnV9L/+wl3CbIjsMJbDCXIwG//Yf/7aVoKGEbXus"
|
||||
"zthLfqm2kl/9iFMwXBhJhhJiFMwzjIMEWQYRBkMEZBghhkEIIYIMRMwwDg2GlDCTELIMaQwS"
|
||||
"ioqZgY7glB6H/7XL4pimlYVtp3fbV3dp2xCimF6EJ2uq92v/2hoMIMINCGEIbERxDBCIiIhh"
|
||||
"TeEGsQwmgwhd6EccfsREREIwE4jiOIiIjX+Egf//1f9f8gVq6/6////S1H0vSb8gfo0v90vu"
|
||||
"v0m4WLrXkFsGsdRHtJL7S2GCCr4rDFEDwUYQyQ0yCCqGlhgqXaxERH//////////////////"
|
||||
"/////////////////////4AIAIAOAAABAwABAAAAYwYAAAEBAwABAAAAeAIAAAIBAwABAAAA"
|
||||
"AQAAAAMBAwABAAAABAAAAAYBAwABAAAAAQAAABEBBAABAAAACAAAABIBAwABAAAAAQAAABUB"
|
||||
"AwABAAAAAQAAABYBAwABAAAAeAIAABcBBAABAAAASAwAABoBBQABAAAA/gwAABsBBQABAAAA"
|
||||
"Bg0AABwBAwABAAAAAQAAACgBAwABAAAAAgAAAAAAAAAAAMASAAAEAAAAwBIAAAQA";
|
||||
|
||||
static const char fontdata_14[] =
|
||||
"SUkqAKINAAAmoCAz/////////////////////////yGQBw/kMgGYcgw5DJBpvIHg1wR3kCuC"
|
||||
"B4NFhbrIHiwnZAxZFjIafUQ2+BJJshrRkGnyGtBBqmQ05kNqyBcQQ1YINyZBRMhpfhf1CMwz"
|
||||
"S5hqg9W4aggwoIGCDCWC4QYIPXrwR1BQm6Wkm6pGzYKmn2EFQRsgwjhB/9UjeXg0m1RifVkM"
|
||||
"t1VBNhUGE1pAtBBtBN//hBYdboJOkk2nVJNgj3R4s8b8JUk6TftfpYfdafV09VbQXCDcEHWX"
|
||||
"BWCmAIraTf/9eldL0ld1VcLp6bRddKkqff91Vf9fXbDeqtwum0v9L11v/+v+uqSwxR+rx/3S"
|
||||
"9LS+vfqtf9da7DHr+/pel/79f1/9dKr5Boha9Lr/9L1/a/8fXSqsI/ev/HS9Kkrrv/IZ0n9V"
|
||||
"aSXYIEU467ePX6j2v+I/tqulSulfX+qX0ldf/e9U6Q9wr1X6pfJ+u2l/kFqyO/tJYr2vr/qv"
|
||||
"BA9JhpX/XeG0qqtq9f1SS9NIl3DS1/pg8MQlyJWuP/9JfF4QaTFN//EMaVd36/SIZrhNLnCe"
|
||||
"EGob1/2U4bUJ/cLX/iDXQQb06Ydr0uw6RvZCaePX6V106EwdK2GF38NqQnJOzgE/1/SkcbS2"
|
||||
"nhBtQjc2JfX6kGrSgjDDW3/r+hDfi3CekEG2v62XmoQTdN/kDgCIKtS/pOl+2qQba/IHCTD0"
|
||||
"rat//X6Ta/XSuGEl/htaur/0v9et91SbH/+l1evIH0a/pOhJAaf0t/ogtWRY3Wm9v/GutLX/"
|
||||
"S0sdfpfbS/X9L/0t/r9L9v/pv63r19L8gXH//tL9ddKiDVn9fX19JfbFPXXWkQan+npekv//"
|
||||
"99df0tLIbHW+vXIHjj11S6bf8hrWQJHp/Sb/rVfS01/rddu/BUH2lpaW2k9JNpJa63pJX3D6"
|
||||
"6TX9IoZddrf+gvrvS3psIMk7/9N1odpbpOkraQS/70km0mGEcxWvWrpJqwwknDCCbSStJL+o"
|
||||
"PCW2EmKDXWtUwwkQy06xCINQyKYaWGGEECC2vDEQkgxBMINN/TSsV9bCYhJMUCBYiJBppiGC"
|
||||
"DC0hxoMIRBghYIMIQwULIZAHDiIvpKIiIj91X7qtfdUvuklXtrS4t0o+lC20h263SxH/////"
|
||||
"////////////////////////////////////yBlyPyBmCy5A8NUMhkrQgaA6CB4NKCB4ZhyG"
|
||||
"QBxZCDkHcg8EUcg3cgr35BbB5kGw6kNRQQ1QZAgwQaBogwBkGgGQ0VkPWQxWQxWQxWQShBes"
|
||||
"g0oINBBDCCDcMhmJyGWrIaichmKwQMhoEyD1kEDIPUQQiPjIMTIaOIL0IKMIEDc8B4WCBggd"
|
||||
"sMIMMgYZkOCDDQYQaDCDShoNwg7QQMMGEDYYQeGE0GEGg0mGk1uutMIPBnthGYRAzwIGQaMO"
|
||||
"nIKMPWEZhiQL8DBEMrgYIhldOBlngbcEDZDKgIzEYM8EYRmIyGbhCURwJwZ4C5gFAIGEGCwY"
|
||||
"QNoEHSr7CMxA03ISYQIgxjkGJ5BiMgvCBB6apqkqtK9AgYbg2gQMPBsIINTAU8FT70/T0G1m"
|
||||
"A2L5gbRwF34dBB8N/4QT/+gv70E3toJveuv/XT20m6pfSDhBBhp7aT4b/pBV/6Xa3oIN7oIN"
|
||||
"7aT/+3X7aTpaX02k/ul7f+k//pf+k/aT+v1/+qT1daX/TaML6Xt/6X/6XMJowswnre63vX/7"
|
||||
"ave2rpaXi6Tffpff///hL/9vSb9Jv1//6/0m168hkA3H0np/r3xxS//S9tL2/f9/xHH/tGF2"
|
||||
"6ehXwpA/foh7bW/Ue/Uf/S//b0r9K//20vtK0rSS8LDpIEzZ19Vv9f+l9pf+/7//+9e6vpeF"
|
||||
"hrhHmR/at6r/r/6Xv+3r9L9X+2lq3t1aSXkDyggYgJMHSSCjf+vvIO+Qd//0v0vb6/q9f/79"
|
||||
"LSbSr00wggw10mtJ9Kt/+v/QXt/t/ev6V//pPtpevqmEEGGlr/eEl//X/0v0vb1fpX6Yf7aT"
|
||||
"98baSX3ggQYaSSXpPhAv///9L2/2/9L8JSQCr/+vadJL/CCDDS6r7j//+P9L9L//S/CTNYa/"
|
||||
"3S1dJq+vpoIIg0AQYaWv1yXDZ+OP/0/b/b/wl+ZDIgNP999+6S+00EFhh116vOCB///xf6Xt"
|
||||
"/5Z/4Jh//pe3el4iEFhhpaql3g3//OAX/ft/t/8L9wb/bSferYpLwghBg0F9aT7f84D5wH//"
|
||||
"Ob/S9v/H9shr1f/1arpeEEGGvX97f1///t+3///7kFU/7pWr6MJtV4QINpeqST7////7f6Xt"
|
||||
"9/f2Df9//7r8IPX1xfd6/9kNGn/t+3+39fW2//ulaSTel9+36Xu//7//t/17e/v7b/tpe+k3"
|
||||
"pfDBf1pf+scchld/7ftr7fr2u7//1ev14MMIJvdUpgGH96/b/+3//919d/71a9U3peGGEE7d"
|
||||
"yOqSX79e//7ftpe3v/7f/avuqV6+GDINYEEEO2EnCW39/9//t//t91t1t/09aV6vpeGHhArY"
|
||||
"qKLtL6fSyGd9//28hoftL2/X12yDd69bX/Sb0iGx/DDwQTYaYSW3rel/f/7f7/t7dbdf/f8b"
|
||||
"1V9fhhiEE2IpL9N6/t//hv+K9vbXtdv/V6qNX0vyB5QQy7DDCCINsWtPq3pft//sPXf/tLet"
|
||||
"vS26jd0r1/TBIGGEEm2l3pN6X7f/7f9extpbaW3a9r1Svpfrhgwgk20l9JhkNj4S12H/+3+/"
|
||||
"u2lsNL+uwk19N6S/dBhhBbDCVN4JMMJYIL9h//t6XXuw0ttLbhhLYYS/Svpf8PBYYMIJO0KY"
|
||||
"MFQhIUmwYVNNPTbQ03TTdhhBJsMJJtwwkmxVNOraaH9JB4TTFEFAZDGqCDEIIIg0AZBisMUQ"
|
||||
"z1kPWQxXkNlbBhSC+mQlRDGmGKIZVYZQwiGVWwcQiDTW0/QJQZDKrX2sPCaBgvRTg2BIhA0u"
|
||||
"GS4KP+/te4YLDEL2Fhr+n/xoREGCERIKgYiJBVDERxERxEODBCDBCIMEIMF04iI+oiNCIkDw"
|
||||
"1bEREfrCB/WEH60gf0qMMH6VIIGU4GoKfSIEsGKCDV9UQNA9IeNA1JAHnhD4j///////////"
|
||||
"//////////////////////////////+QPkEDMFW+yGQBPBA8NSAmQZ4IHhqQQ2oIEoDFkGuC"
|
||||
"GlHkDwN4ILMyB4NM1ILMyB4NMyGrNLYeQPF4g14kFC4UgqQQLwFCpbe9pEGbiB4NfIu5As5N"
|
||||
"Mg34hr9X+qu6Qd1t3Xb+0vUf//9G1/S+vIGYZj//tr67TXhf/S6/xH1//bX///9L/X///bX/"
|
||||
"//9Lr///9Jtf/////8l/kNTiHwg2f/+k3LhpGgZclMhqeQaJ5Bp/INU9BkGiCBeMgnZDLgIM"
|
||||
"IMhmwgyDXMg1QSmQ1KE3IF4JYQUHyGbBBdyBGhJBDXchrcQfCC4ZGggwE//xCDwgwQMIYIPJ"
|
||||
"OCD0wUF1yCj00wVMEDBUGEMFCgg8gY8h+8hjRSEQE1//9JsJ6YUKEcMMIYRsjqBFMhsOC6BY"
|
||||
"KmmQ0HTRsgwUINSDB1RgcI6BiCgz4OCBnwSDBBtAgz4OCmARf/thGxvTCOFCODoINhJJrRg3"
|
||||
"+gvRt0YN6MGwgg3phGxVqkGgvvvbh6dqkv/S6D6MDaCDoIHS9J9BByBjCDfNLIGJhtJyBfEE"
|
||||
"HSbIKMRgVoIHIKMVJ1IaMIJnTrTaTpaX/7e8Qm0mknSbIN8VnAMCn/S6YpuKem4hB0uJdpcg"
|
||||
"oz3+9tb//9Lq6DpaTr9XV/hBdV1avTaXQff+61S66pL/9t3r/6b1en/S6aenW/Xof/dW/bSd"
|
||||
"dL8gpD+lj7aTrr//+l//T02vVj/1ownTaV0KSW2QzMv6b/xr///0F//39ff9r1r060luEDXx"
|
||||
"ELuq///+l/+vv/B/vTa3TFeqWw0DS8hkBoI/+Gv1/xf/+/r7JAZn7+n2m6Sr0bMMJeQyAXmb"
|
||||
"P/j7X/v////Z1Av90v19UmHhBJBj8I8P/8iAMXr/nE////9h/3tpN03dJN/QYXoL/+cBs2l/"
|
||||
"7f///+G/3S/W3XfSSBr0vr/2GEv/b///r8H//W6+kr9ofS//9iF/7f///+Q16f39Poum3pfj"
|
||||
"6X93+GC/9v/+61vwf90m10lb1S//9L+9mA1v+3///X7/39N6T3SX//07r6X/t//v+/kMt3/d"
|
||||
"LX0rdVId//11u9vS/9v/+0tK//19jikm+q//16bbX1/9v/9/rX69YqnVtvS//tdL0XWyDj6/"
|
||||
"+3//aVpNr39our/XFJf/6L+GgmGQo7aW2vf/t//t1DSsIwvpWW8NL6pJt0l/9sJcMJMMKwwl"
|
||||
"sMLyXAv/2H/+2lDCCYaX2lFMVbTurdKl/7EKDiExTFScNAogRrDIMazQMHUGJAjVsg+pDGpt"
|
||||
"JOCHUQ0DQGEopiFkCKoYSdqThlfBKD0P/60Y07WGFt/+wuv9iFCDXxCaa3pqnf/8MIWgYQME"
|
||||
"DCEMEIcRHFghEREQwU5BBhYhhNBhDT4jQ4/iIiIhGw7xHEcRERH/0g/9f4Sf//yB+Bf+l/6X"
|
||||
"/9f/+ra+PVfXWCf/q2uC6r9NoLpuq9RHHS/IGeOltpV9rtpJehWwwSIHg08EDCDrDEKECDIM"
|
||||
"tVYYIfaxER/////////////////////////////+ACACAA4AAAEDAAEAAAATBwAAAQEDAAEA"
|
||||
"AABKAgAAAgEDAAEAAAABAAAAAwEDAAEAAAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAA"
|
||||
"EgEDAAEAAAABAAAAFQEDAAEAAAABAAAAFgEDAAEAAABKAgAAFwEEAAEAAACZDQAAGgEFAAEA"
|
||||
"AABQDgAAGwEFAAEAAABYDgAAHAEDAAEAAAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQA"
|
||||
"AADAEgAABAA=";
|
||||
|
||||
static const char fontdata_16[] =
|
||||
"SUkqAHAPAAAmoCQP/////////////////////////////////IZJx0QyQzjkM45DJA3vIHhr"
|
||||
"2RbyB9BA8Gy00/IHg8XZDMsiXkGzqIK/Akk2Q2nSINUyG25DVoQ1aEGSCGUoINjkFEyGPIZU"
|
||||
"yGrPBVXqwQahNUm4PCBhQQYQMFwQcYIGED131IZoaNsOk6SbVII4bBQgwmlhAtHDDCOEH79Y"
|
||||
"QNINqnrZBoHrQQbCpp+EFSCDYQQb/1wjkXbSekbfSbT9JsFTR82uEFpOk3/+gsOtqk6STadJ"
|
||||
"LYR9Z4bhBv0FSTdX9fpYf6SeltP6cILhBtBOswCkpsNFdX666S+m1/p7pJbgtJ6bRddBVVNp"
|
||||
"X++v69LpK2G164XT1/pa/v79a/69dWGKJ2krY+3ul6XS6V/69f9a0uGP/rX/Wkv//9f9fSps"
|
||||
"Ol/vWl6Wv7/X//1pa6kGu9f/0vS69f+v8fW6S8Izf6/xr/1uu99yGga/qtaSbBH1HS28fS9I"
|
||||
"atf8R/dVdJLwlf/6S+q9f/fdVpD9PpL9VXkvqmGl//uqxCW2r//18EDVbSv8gerIl3tpVW7C"
|
||||
"vS/VKvQekw0tevb7SVrx//pBJcXRH9MNBf/yhQxCrIUZXf/0kvahA1Ypv/qIMMJQmv+l+pBp"
|
||||
"cIOueG8J0w9f1ZLgyJNVuC/9JCDXhB9NWG2v1sNQjnIWvx0v6uug3EwTSu19cMNIh/SsGcF/"
|
||||
"/6UuNpdaBB8I5hsMI2lv4N4QaTeP6X6iG1xbptJBBtiF/5DU1SCON07//9But61SDtfkFgal"
|
||||
"29INrf5BZEyDInS/S1/bpINtJf4dJK1b/0v9JuvrVXBhf+303Tf//6Wu+9U2P/ukv3X6pdaT"
|
||||
"oSGDZ9JXrogerIl79Orf5A8S6/0v/Wtev9Jb3S/FJ/S1/pXrH//2//v0t69fX/0v20v0tdKi"
|
||||
"Gl36/X0Qyn/+20nr+tIhpj/v16XS/SX8f6X9L5BQ9dL0lr//7Vr7+k2l6V9euQPDx/pJdNv+"
|
||||
"Q2o7rS62/VdUsJ//trbD/BSBPiWulf6T0k3SXfrpJdWw3rVPetIhiel3V/0gv+9LdWwgyKP/"
|
||||
"qlfobaW2k6STapa9XpJXTDCH/XulrDSuwk3S6QS3pYelthJibabS10m0kGsMIJOwk2ltpBBd"
|
||||
"LyjggkgxCaDX9PtpEMwGsUQ0xDEJsJJMNBBBbXgxFYYTCYT/tbFfC4TELDFEMueIiQa0JCGC"
|
||||
"Bq6FIUgwhEGCEMIMIQwUFkMk3ERdaxEREf60vbVL/qkvbSX9+ku7SS8W0qHekttIdtLbS3ax"
|
||||
"H//////////////////////////////////////8gMBZD1yBoDQ5A8GXQhkg31IGgFAZA8G0"
|
||||
"MgeGsQQyQ2oIG45AkvyC2GvMgqoTIa6QhtBCGgbINQqQYFCDWoIbBBBBBDAghgQQwIIOgguI"
|
||||
"INYZDTIIYIIGKgREA0EwDYRANBMBqgyGgoIYGEMVEHrIY0IYqyC+hAiZBvMhg5DL4gQLMzA8"
|
||||
"PBAyGsn4MIHIqGZoED//9bwQcGCDgwgf/64J9pcLCYQOyG0kBGgeQboIQgg1AZBQYCMweQLz"
|
||||
"IGJkMuZDLmQy5o+GWZgqOZgYZDNxHwoZBpORaI+FDINJyKdHhNENlCBjAZoBgEDNAzyGzNHA"
|
||||
"zuv7CNBA1Z8I0CB2CIMHZ4GEzwLwgQO00001CadJtoIIGHBA2EEDDYIG0EDzYc+HtNNU1dEC"
|
||||
"9EgdJmwUL5smEfBh24NhIO4N4fDoIP/6Xe+gg27aCDe2k01u+364eg3wkvQQbQQYfugnww9/"
|
||||
"Sa/9L1vSb20m90n//p/tJ0v+nQTa7aTW3/pP/6Xfek3uk3tpfX7/dNq3Wl+2kG79L2/9L/9L"
|
||||
"1vSb7Sb///tK1V6tJUvS0nRhd0vf/S//CXcwswnpPuk+6X///tpOlpfugm+/r2/9L/9LmFX3"
|
||||
"6b+m/3/9unutJv68dbS/X28cV//S+69vW/W/X//XRhdv0tfIZAaQ5A8Ufp9/r/6//QXuv30/"
|
||||
"q/4jj7/2raTdCl4WHpEH5tb6Ue/Uf/S+69vX+v/+6tf0nVLwsOlBM3dP9b/X/pe6+39/3//q"
|
||||
"9PTdWkl4WDWkeb/vSX/X/0vuvb1fpX0r/br79XqvIHhYIZdhWHWEE6TaT//kF3yC7//pe6+/"
|
||||
"XrX//rpatpWkvhNMIIMNUko/vS9v/r/0vuvv7670r/er3punVL7UEEGHXvpegq////S9/2//"
|
||||
"/ph/3ut+k3SX9hAgw0tKvfCS//r/6X2l7er6SvpQ/9enVjtKvXCCDDSSS9bhggX///+l7/t/"
|
||||
"6X4SZ1BW+3X/T6++EEQaBMMNL/p4h/668f6C+0vf/S/CTIgGz+ut01aSX00EFhg0tV+4P+OP"
|
||||
"/0/f+/8JfmIYP96un23SS9poILDDS6rSeeCB///xf6Xt/5ZH8Ew/73XXvS8RCCwYaX6XeDf/"
|
||||
"88GX+H7f7f+wX7hh/69XVsVXgghDDrX0vb/ngfPA//57f6+3/j+2Q2hH717+6+EEGGl0l77f"
|
||||
"++//7ft17f/+2QV9f7W19PS8IEGHX6S3v9b7//t/r//9bkFNH709NqjabSXwg2v/T93///+3"
|
||||
"7de33Xf2G/7/6S9L4Qer1SQvf1/7IN6v/b/X2//9sP+66V9N9fa79V+/X+9/+37de3v7+2//"
|
||||
"Xvrevwwv6pX/+OOQzJ/+3+vt+l6W//e2ukk+l4YMIJ7fVGwz/vX7D/+37df9/f2/7pdXpN6X"
|
||||
"hhhArfRdUqf36///b/X29//b/7/f768MMhqiYIJrbS0Et/f+//7ft17fpb1t/7paWqT6+GHh"
|
||||
"BC22lpU/vpff/7f6+339r/6X33SV6RBRHhh4QVsUxCJ2t9XrkG77f/7eQUPt17e9b1tkC8V/"
|
||||
"exv76VeDB4QThhMJa9W+v//9vX/77S7S2/73Sr0m9L8MMQgmxGlf70tdv/9v+K99v39vS3X9"
|
||||
"ikr6/IHhYINEBhhBEFS7S70m9L9v/9v9/b3S20v/umKrV9fwmChhggSbaVP03hLrv/9v+vY7"
|
||||
"S7S29L136b0v7UMMILYYSW9WGQLvpft//sPS3/bS20tu67S90r0l/oMMIJNtL8JMMJYS1ww/"
|
||||
"/2//3YaW2lt2lthWqpX0v1w2gsMMElbwSYMElIOfW2Gt3fbarbXuGwgrYaCu7CVsGEv0r6C+"
|
||||
"6QPC2DCSpoQgxoQkNWDCqq6txrppuwYSUMMElbgwknFe6tpof1h4TQYhEDGpBisIIMIIIg1C"
|
||||
"hBgQGIRDQIIIIIYEZBuIDBhSC9TRDjCD1OxCIZohiEQzRDBxCINYwNNNUCTBkMsQvtUHhNBh"
|
||||
"eiXBVClWGrwZCAX/7r/4YWGFuGFhhf1/44iIMEIiDOoZIaDUGQEQiIuIhwYISCmGIgwQhgvx"
|
||||
"ER9IRHERIHgrwIiI11hGgGwCzroO+qCB+loP9JGCNQGwGXpECYGYPSCBkuBsBt9Q0qBr0ooS"
|
||||
"GciHjQMJHQDx6IGobv8IRx///////////////////////////////////////yB49PIZIsED"
|
||||
"wZIIHgxxA8rIHgqWQVrIEsM2yGnZDUvyGQoIM8yB4KnhSB/MgeDZMhtTCWw8geCTIamBIFIH"
|
||||
"g2IUgzEEFeCGXAKC1t7rXrpp+v9WpA+4geCryMHIHvk0yBfiCp1b7ql6Q/+vf2vr///o4tel"
|
||||
"015AzBmj/6tf9prwv/q/64j4X/0rS//r/vf9f//0rX///+m////9df///6b////1dL///+rg"
|
||||
"iGpTIvkG2ZDS/IaX5DUpkpkNOCGXGQf8hmOR+QTyGnBKZDXoQ04I5kNqhJyGVBLiBc+QanIZ"
|
||||
"4IZ4ISCOCOCDa5BUwgvxBeCJBFciuQz8Qxf/q4gg8EDBAwgeCB4IPCBgoLrkC/BBhBgoQMED"
|
||||
"BQgYIGFBQoI1gokMzgWOMg9VkKGQwdY44//qwnphQhhHDDR1BQbJnnpkFCCGdGlkM6EGgyDc"
|
||||
"hMI4QZBuhNDIEIVGx0ageQqAZoGAQMEoMJuCDBBhL/6unphHChGxwgg2FCCY9P9AvCp6aCDe"
|
||||
"gwjg1qEg0F9pphbCB0mg1MBhf/Vo2K9GyYQQcIIHScKrWjZMgY8go/QWQUejhsI4bIGPRsmk"
|
||||
"2QL+jZNAg5BR/ThSBHkMe9PbtpPX/+r0H0EG0g6TpXLx4MtPEJ3fS2IJiE7EJ0m3QINhIO6p"
|
||||
"Pu/6039aX/pXvEJtLSDpNj8+GWn/S6aenVuKDpcS5pXIF+9tJu1dJ1pL/6em6etf9J6b/QXT"
|
||||
"TdNpPTa9P//61aXWl/63/q6Wl/1/pdV19/XQ//dft039Vv9Nj03/7evv+l7vuk9Nr9j+6ujC"
|
||||
"aTpaQqvZBp4gQ/q/6Qpa///hL///S6v/q/7SvSrcINP6t9////9Bf/97/3+2vTdN06SSWw0D"
|
||||
"S8RIHgrU9f///0v/1//ZQDX/3XVj9IILDDQa+QyAatP15OJ+v+L//39fmoMz91dfTdbegpsg"
|
||||
"0vIZAZlDd/8ff/3////sH+66tpPqkw8JJBivCPj//KgDF0v+eT////2/+nr3fSb0kga8IF//"
|
||||
"PBt7S/9v//+vwb/bW1bq7SSfqg16X1/7df+3////hv/r9b9K/wwvS//9hhL/2////8g2Eft+"
|
||||
"l0rdfq0P/93+GIX/t//39X5BUn/pN7ejG9Uvx9L0v/Bgv/b//61/D/39apNvSX//7v3y4bf/"
|
||||
"b//f6/IZkP+6Wr0t2qX//1d74S/9v//X2//19+1Sf0iGH//XX1vS/9v/+60v//bWK6Stuv//"
|
||||
"+m219f/b//f1tfrtetjpvVJf/sLpdq3r/7f/9pXTa/+sbWk2xSX/9owtoJttGFhkHfT/9v/9"
|
||||
"urQTa9pWSHbRftbS+lX/thBcNJhkOOwwlsMJcqwyv+w//20rCUMI2v9pwwl9aTbS//xXDCCb"
|
||||
"CsQrY1hra6sGtrrbaUNBMQtbSYpit/VvSBf/ak4ZzCFMbUkBsRDPU2QYrlAOawzyBFbkHrIP"
|
||||
"WauUA5rCFAbGlEINZAhPDCCpqUBmp2gSg9D/9hdNNBrDC2//YXX+xCnkmF8U01vXTtf/hoaB"
|
||||
"hAwQaEMEIOIjiyOGQCwCwwgYWIMEGgwh/EccfoREREI2CPEcRxEREa/wgg///hJ/6/0n/X/I"
|
||||
"HiiX///pdfT+n/+tpePX9fhfX1bSyB49NKvptL7/1IHg1wEYA1CxdKvSEdtJLyBmDU/2l/YS"
|
||||
"2wkl8eGGEEQPDXcJBBhBpYYhMQgQMgUVwsGaAeCsF7WIiI//////////////////////////"
|
||||
"////////wAQAQA4AAAEDAAEAAADOBwAAAQEDAAEAAAB3AgAAAgEDAAEAAAABAAAAAwEDAAEA"
|
||||
"AAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAAFQEDAAEAAAABAAAA"
|
||||
"FgEDAAEAAAB3AgAAFwEEAAEAAABoDwAAGgEFAAEAAAAeEAAAGwEFAAEAAAAmEAAAHAEDAAEA"
|
||||
"AAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
|
||||
|
||||
static const char fontdata_18[] =
|
||||
"SUkqAEARAAAmoCq/////////////////////////////////+QyXe5DJDVchncgthMyB4NFk"
|
||||
"TMgeJBA8FKE06yB9ad5DbxIgScCpNkFYdSGnQgrOQbKENqhA3ghmWQz2QVRyBxZDMoQbJ4XU"
|
||||
"g0YQl4IHhBhUm4OggwoIGCBhYwQZBuJggYIHhf1CJwazjaSdJNpqEGFQaYWgSwmg9d6yGanQ"
|
||||
"Qb10m+gjxMKEGEGlhAtHhhhHyf/4QaVpIw3rZBpelQQbCpp+EFSCDaCDe/XSOMwbSfSDpJN3"
|
||||
"1TYKqMyraC0nQTfT/pYaW0gv06dKk4Iz8+K4Qb9BUk2k/+ugt9+npbTXVtBcINwnWYAnTNg3"
|
||||
"77f1+v1aS+k3dVXC6em0YXSqkrSv99UvX/S8N6q3C6dJ/0tLff/r9/S6pJsN0RB6rH2/S9JL"
|
||||
"XX/r0v//WwxRfqt6XvXpaX1fv9f+lqlThjrf+tfS//////6pbdf910vrS9X+tdf9LSWsKQ1L"
|
||||
"pfr/9fuv/f/H+1rcIzH+v8aS9LS17/yGwU96S0klsEf2OvePpfj3X+I/2v0l4Svr/S/SStf3"
|
||||
"/9JwkwqevXf9L+m6/rvdLihW6vpfpL8jmktpf5A8WyEu+6She16/rSXggekwwgr/XvbXr2E3"
|
||||
"1/SSXgmpHPYaWv+3tpJNEGt/H1/0viHhBpMU3/SyGoYhaZCg/v/0gSS7oINWtf9ifDVCSC6T"
|
||||
"/X+Qa9Pnx1Tph3/0yEAkpr3Ba/pQaXBBvTUMNtf9hpI4mD+PX9JpdBvRwnV2F/2HhBOQxhFj"
|
||||
"9f1mBh/TxBB0gjiDYYRxL1wbSIP6Tdj/X9QgbSxdJtQgg2xX/kNVPhA6t/1/SF/unpINwvel"
|
||||
"DMbSCOG1b/IM4vX6TaW9OqQOGvogzCmD6TaT/5BSEL+k6X7aSTbSX+G0km+/9f+r/r0nDBf+"
|
||||
"/TpN/9V1paWRjv6VNj/+kt7deQPBe9f0nQj99XS8geWEJe/6t/61fpf+lv8Kv0qb7S/FX9LX"
|
||||
"9a6x1/X2/+v0v/pXX/0v20v110t69fr6IZcf/vv9daVENXt+vX/9L7bS6/9SGo//S9Ja/1/s"
|
||||
"Va6t+ldZAu6V6X1/+l9tf11069//pZA9RX6/T/5BWhddK63p0krSSwnr9JOtsP8hteQLMpv0"
|
||||
"tLtL1fS7/177Yb1qmvWk3X7aXaSWv/SXTcHr0nTa6IGBDXbSvSeku+r0ttJhhFIBO/XXS1tL"
|
||||
"tJ0u1CXroPSSdWwj3f/ptJNbQSbaTaSTaQQXXw8JbDCCiE1117DSIZsBBlusMJENSAg4YQTD"
|
||||
"CSsMIIILetkNQgkmKDQYVr00rFRGrEKJrDOKYqmKCC2FqDEVgwmEGnodqmvhbCYShhAgsREh"
|
||||
"phpCDBBr0hUMIRBhCGCDCEMKCyGScCItpdCIiI/6S+9VX2uvvSX9qlXvWuraSVYtpUO9Jdqw"
|
||||
"ttIdtLbS2mFiP///////////////////////////////////+QEwate8gaApwQPArqIZINtZ"
|
||||
"A1DU1IHgpaEDwZCCC3wQPA4jyC2DJMgpIyG0BkFdQQUCZDUKSBAuQ1CZAuDIYBkFwZDAMguD"
|
||||
"IYDIMAyGpqQ19CGNCGYnINYMg1DRBUBkGsbBEYDchgQQwwQYLlOGCIBc1A5GAxIEVENnkMqZ"
|
||||
"BihBp4hoK5OB4KJBbBU1IbYxODBEaDORcGpYIH//63hA4MIHBhBxX/+QXDUJrwsIMIPDYRoC"
|
||||
"MMGHDhGgOGGCDBBggYQYLDBBuEHDCCMw4YYYRmHYYaPBA3DBBhMEGEwSYYV9112EGpBXoQiA"
|
||||
"gQNEDFCD6EGs5B6EDByCUCBA5AxQhmUIZtCGbQhmUR8Gg0BSonDMZBrwIEDZBqOQiAgQMMg1"
|
||||
"nIQgIINZBvQg0YDNAzQgYLIKMdHAb0p8C69MIoCB3QdBB6IaEMIhsthEM9oIGmmmmmqaurpB"
|
||||
"NsIG0E2wgbSDzAOZg9qnp9yGUdIN1BV84NozBh7hsJB3BvfdBP/6W6tukGHhtIMPDaT/7v6a"
|
||||
"Qbw2lST8INhAgbT3QT7f+En/9LvvSb2wk3vXX/dfuk/pekHSb+0vDf+k//pevpP9P6T9P/uv"
|
||||
"aVpf/aCDae6Xt/6X/4QX96Te2k3t//7pd09OlpfTpN/r7f/X/6XazCek36Tfpf/3+rat1per"
|
||||
"03ML9Vv/r/+lzCza7et7re//+62vaTrpeOk636X3/pf/pfaXt9P9P///dPe9XX/pXT+vt44/"
|
||||
"/6Xv/et+t+uOP/zCpNpNpCl5DIBocgeDj9Ot/Q/6Q/+l917+/7/j+6Wt+rpJeFh6RDH3T9Lt"
|
||||
"+v/pe6+3pfpf/9/vt1el4WDrCDNzrev/1/6X3Xt/f99f7q2l1pOlXhYapBH2//qv//9L3X2/"
|
||||
"fpX1v+6+1bStJfCw60E6t0/r+QIfIEOv/oL7r719f6//6fb30vIM9kM2wQQYaSQSf1vS9v//"
|
||||
"/S919vr+vW/3S1/SbSS9BoMIIMNLqK6fSr/+v/S+/3++u+r/vvum0ukvVMIEGGuvreEF////"
|
||||
"pe6Xt++kr6TD/enp16bX+8IIMOtL6fBBL+uq/+l9/t6+v6UH/a6+x2kl/hBBg0kl9eIL////"
|
||||
"S/S+/9L8JMpwZf/03tPSX1hBEGsXDDS6r7lQGX/XXj/S9v9v/S/BBSoDb+6WvVWqXu0EFgw0"
|
||||
"Fr6Twf8cf/p/pe/+EvzaMH/e36tulX1ggsMNLr+58IH///F+3+3/k9P4IMP966b9ul9oMIIL"
|
||||
"DDS+kqfIPT/+fBo/f6Xt/8L9oN/669NxpeIhBCGGlqut7f8+GM+GP/z6fv/f+wX7YN/39Wqb"
|
||||
"SXhAgw6/6fb/w+H//b+69v/H9sgyDP3SbV/0vCCDBpdaS+39f//7fuvt//7kDjT+//Ta/CCD"
|
||||
"aXpfe////+w/uvfuu67B/3rq6Rvel8IP/0k/d6773/4b919v//bDf+urql6Xwgem/WL3f/9y"
|
||||
"BhP/7f3X3v7+2/7f1+3pfDC/qkv/X/3/7fuvt+v+7/9Nq3SX18ML71V/f445Bqp/7f3Xt/Xp"
|
||||
"dv/a/6Tevhhggm71WbBv/1+w//t+6+/f37f+9daq3peGGEFvouqSX79e//7f3+3v7+2/+urf"
|
||||
"XpeGGEE3bfpd/f///t/pff19bf+3TddJN6XgwZDXFwghd0nCST++l9//t+3+32va/+l+uq3/"
|
||||
"hh4QVthKIRPO+r/3//byBiPS9vet62yGU9f2vt6T6RDKjww8IJtimkkn1b0sgXjv/9v9v9vt"
|
||||
"Lutv+9666pvS/DDwQLDCYKv/0v2//2/4r32/ddv911Y2Nb0vwwxCCbEV76b0utv/9v9/vdLt"
|
||||
"L7S7pivSfr8gz2Qa4DDCCIMsNpJPq3r///t6XXt91t1t/69aV6/pkMzwwYQSDYaXfTelrt//"
|
||||
"t/v7G2ltpbeltpe1vpV9qDDCCVsJK+kwyGaPpft//t/17tpbaW312rVaTekvrQYYIJNhpVeE"
|
||||
"mwuEF+w//2/3920ttL7S20t9K9L+8MNBbDCS+kwYSUJa7f/7D16/bS20tu0uDBfaV9Jf0g8F"
|
||||
"sGEltQSYYLZB0KFTDDVNNPTbUFTdNN2GEk2GEk24YSTYpqtK01C/WHhYYhINNCEGKCEJDTDB"
|
||||
"gqaaem2hp6abhhhBJsGEEmw0GEk2v1YacfvQeE0GEQzKyGcQEEGEECIahQQIBhiCINwZDAMg"
|
||||
"uDyCgGwYUgwnaIOIIYTuxCINQMMUQagcOIRDUBhhbuCTBkMwGvsLDwg0GF8hAZQUgQNnDJMM"
|
||||
"r9b1/uGFhgtwwthNVVf+KQiIMEIiDBCIgynDIBRERGhFwYISBPqIkNGogwX4iI/QiOIiQPBZ"
|
||||
"cRER9cIzA2gb+qCB/WEH60g/rQNdJJGxlOMjgbQaOpAmg2D1CBj+oaQg1egoogahpaXjQMKa"
|
||||
"gPBjRA1Dbv4Q1sIcf////////////////////////////////////IFmpA0AkvUhkhlQQPAr"
|
||||
"gIMgeFsgeBxBAkggTA0rIa9kNe/IZAJBA8vIHgT+FIHjmQPBS8gyeEth5A9HIa2BIgfkEDwU"
|
||||
"iFIHxBA8FUghtkJbeHtL/IElkMu/S291UgeL5A8Cf0YOQPHNNMhleQZP/+6d0g4dNN3rfpV9"
|
||||
"If/Xv00vX/yBoGoP/84n+l7+v/q6/7VeC//V167CDXhf/V1/xH//6tf/3/9J69f//9tf///0"
|
||||
"v////2////9LX////br///9LQIg2UyE8gqTIa08hqzyDZTIsyGu5BofyDU5F8hiZDVgizIbZ"
|
||||
"yGs5EmQVqEVyGa5F4hlnyGlBDZBA8G1yDJhA8NQC/9W2CBB4IGCBhA8EDwQPCBgpDK7ILzwU"
|
||||
"IGEGChAwQMFCBhA1BQoI1hlQUFIaE5F0IOnUgmpBc5BjyDFZE0//rEIPCYQYQwnNQGHpkMs5"
|
||||
"BufXIFzhNMhlnTCDIGDhMIZDYdQuSsgwcg5/77///VtPQYUI2OEeGwoR4iIDRTChdAsKmmFT"
|
||||
"CPjYVBhHBYVUcFhDBQUgXoQI4hsopBjg2jYFzQCDwNzYLr/6sI4L0wjwsIIHQQbBUEGsJ/oL"
|
||||
"008JoIMPTQQa1QQcF9qmug6TtV/+k9BvRwdBBoJB0m9J9HBshl+QMfoLIZfo4VHCZDL9HBtB"
|
||||
"NkC/o4NhBByBj1UOkQ2eQY+6bvbV/S//bp9Ag2gg6TpWQL8k1EJ3fS2IQYhOxCdJ3QIG0ndG"
|
||||
"3rmI8DTd/Wm60qS/9Lp4p10nSfVngzQg/6XCYTwg6txTpcQnVx/6e90m66//b7ptL3W+rq/0"
|
||||
"F003V03Ta9Nf+2utWlrpf+l709Ol/77/hL/3Xp66f/+r1bS61//bHq1/SfXr/S6p69utfHH9"
|
||||
"906em8UktshpYQ2P6X7+v/+/6Xv7pe2vV/2lzH7S1S/CBw/2/0hr7//9Bf/7/X3/9+k2r1SW"
|
||||
"2g0vS//1///CX//e/8H+2lpXvVqkltoNLxEgeBORvr/9f+v/6//shhp/991iulBAsGDRww18"
|
||||
"hkArV+vx9//F//7+vynBo+3WldNN6QMPBAkgwYS8ETv/9el/3////sP/W999JJh6SQYrwjMX"
|
||||
"/8pAy7f/zyf///+w//dLSt+m9Kg16Bf/z4K+0v/b////w3+3X3vapfpA16X1/7aX/t///1+D"
|
||||
"f+tq9JvSvpYYXpf/+wwgv/b////wb/bp6tbvSv2h9L+7/Yr/2//7/vyCuR/r/oxvSS/H/1/8"
|
||||
"ML/2//+tL8H/erSel36/9L6/vBgv/b//f/8P/a/apN2kl//+22r6MArf9v//+n8g1O//TpPS"
|
||||
"Tb6//+l/4S/9v/+0tb//Vtb7VK70iC8f/r1drel/7f//9f/69R/vpJf//q2+3pf+3/+3Wtr9"
|
||||
"er7T0k231//YXS7X1/9v//StJtf+1j40rikq//RhbQTDbRhWyBA+n/7f/7faCte0rtG1qnSb"
|
||||
"df/20uGk3YS4YXv/2//20oaTYRtf7Juwwgt3pXpJf/sILgwgmGQsMMILYYXlIGZ/2H/+2lDB"
|
||||
"BMMJfDSjiuvSt0l/9irMPFMUxVsUnDTtPTYaaYTtO2GEopiFoM0WEmqTenVukP/6jmEnakgC"
|
||||
"6IaE7DIMDJIDBThokNCdyC6cgunLGSGCEYHJANxChMLIaBEQqakMGn0CTB6/+wtIMINBrYLf"
|
||||
"/2F/+wp5INegmmFtNPW//4NDQMIMEDQgwhBsRHEMjhkhAsGEDCxBhBoGEP4jQ4/iIiIhHATi"
|
||||
"OI4iIiP/hBA3/X+Eg///pf9f6T/r/ZA8OLf//+l16T1///a6/S+k9aj//a5Arq0q9JtL//wY"
|
||||
"YQLdtKvSEcdV8gaIddtKvTS20kvj2GEkvrYYIIgeCsOEggyB6sIOtiFFEFsGRPE6AZgsLDCY"
|
||||
"XsFkDYDScREcf////////////////////////////////////4AIAIAADgAAAQMAAQAAAIEI"
|
||||
"AAABAQMAAQAAAIsCAAACAQMAAQAAAAEAAAADAQMAAQAAAAQAAAAGAQMAAQAAAAEAAAARAQQA"
|
||||
"AQAAAAgAAAASAQMAAQAAAAEAAAAVAQMAAQAAAAEAAAAWAQMAAQAAAIsCAAAXAQQAAQAAADcR"
|
||||
"AAAaAQUAAQAAAO4RAAAbAQUAAQAAAPYRAAAcAQMAAQAAAAEAAAAoAQMAAQAAAAIAAAAAAAAA"
|
||||
"AADAEgAABAAAAMASAAAEAA==";
|
||||
|
||||
static const char fontdata_20[] =
|
||||
"SUkqABATAAAmoDgf////////////////////////////+QyQy7IGwGXPIZILLkNA/kDwVrIW"
|
||||
"3IHgvBA8FqE00sgeC9pp5BWhIFSvIHhpOQPDToQK3ILYb01TTINOELmCJwypBY8FVsgy2kQ1"
|
||||
"6BSCocEDBSDQBEFfCBcWINJwQeF/qDCDSCD0m4eCBhSDZWEGFwTwQMIPC1VKQa6keMPTpJu8"
|
||||
"IMKEGmuECwg0fIP3dcIGgg2kE9JukkeGwqDQaWECwj42EEG//wiRhpN6ON0lZDSetBBsFTXw"
|
||||
"gqQQNoJv/9HnJetpIJ1201SSbCpo0JroLQTdP/+EFh6b1ekm060mwRp5mNwQb8JUrat//1uu"
|
||||
"kk+laeklhBaBA6QdZsCsKcAwqdK/qukv3/pXuvbgum4TaMLpUq3T7u9KltVaS61bfpcLp6/p"
|
||||
"Kqp1vr1/1/qlcNpJK2wvfdL0tf3//X/S+qsGMjvrHpuuvS6XS//6//SVWw0c6X/q6+lr/f//"
|
||||
"/pfXhj1b/9L0uv3+mvX/9JJLyGtiX9PX+uvr+/VePpf7YR9f/XGkvqquv/1X+u0klwUi3pL/"
|
||||
"/66Wvf+Qbi/uqWklVhGaY/Xj6XpD3X+I/37pVuCT/36SX6Vpf1/0lpQl6vS/qv0lbr/720u0"
|
||||
"h7hX+/6XkWfVpfv+6pRVbXpL+kvggaqw0r/IHgmELd7aWwldq//SSrwg6qGEtfpW9hoJKu2v"
|
||||
"S/0kvCakWisNL/Xg8MV5DNp43/9IL4h4QaTEJv/4wwSSkEUf6X6gklrhB0+v+yXBmprW//0Q"
|
||||
"06l5mK0k1DDv/5JgUIJrvBf+lB1wgbwnTDbX/Yejyh1sdL/tLhPo8TW9fqgw0kmyC/Eu//0k"
|
||||
"cGH9NxBA2kEGwwjaX6hvIYmleP6X6UEG0tp0n0cbYYS+lyGqESCDSd//+hbXF4TaQSBuK/8h"
|
||||
"tJ8I8w0m/9L9J673VINsL3+YbSQQbSv8gflZA4Cf6TaW9dJBsNJeQPyjD6Te3//+k/+2lTtf"
|
||||
"+G0ltW/+kv0rS+vScGC/9+nr/1+utcijv6STY1/6S3t1/SX6vEfuu6/7/q3+QPDZi7fpa/0r"
|
||||
"/RA8PhC56VN7a/il+lr+tdY/+vt1//pf+krr/6X9/6WulvX/1//+2k9f1pUQ1/30vS6ohmv6"
|
||||
"X22tr/6RBsH//9dV+v9uv0m/SC110vVf/pfsV/9aTrkDELel6X//9tfpfpXX06/pZA8Hj/SS"
|
||||
"6d+sgy3uul+39JWklhB//utsN/BSB4b4lddNpeler6X1rpJX3DtcKn/pdbaTpVpJaa1f/TcP"
|
||||
"+k0m0tItXaX16t0l+vpJOkw0GQg71r7+h2l2k2lVqEv+Hpba2EeRrn/S9patpJthJulbSQX/"
|
||||
"D0km0mdWmKtfdJtJNYYSuGEmwkraQS/4eEttBMQg09de2kQaUiygwiGuTk5ptKmGEEEFtexE"
|
||||
"JJimgwv+kmDBLWK2ITBgkrBgkCC2qwYWDBBhBp0hSDWGIXwuExCoMQgQLERIauiQhggwr8Ug"
|
||||
"whEGCEMEGEIYUFkMkMyMgeC/EMu+qwZwMgMo4B4axwDg8B4axwG0LxEW1SxEREfetL9Uv26p"
|
||||
"L9JfVvpL20kv+qSxbSUd1S26YW2kO2ltpb1tNYj/////////////////////////////////"
|
||||
"5AWBqr/IGoNMEMgk5DJBaGEDYGKyB4FlZA8CjQgtgYghkJ/IGYMUIHCLIKgkCKsC5QCHQNcl"
|
||||
"oaCWBqlIGYVAMFWGCoBcqwXKgCDoDBUBrmoFQ1Bg6g1EQGmVYaREwZCrDSIoCqDIGKEDGhDC"
|
||||
"ghnGEMAyBCchgvZDRWQUYQzaENEyGlMhsBfBAyCuMWRYFYjYaBKcNPQIiYF//9reEHIuG0HB"
|
||||
"hA4r//IMEZBcOuaAeGnCDBA+wg4Pwgf//94QcMIOGEH/+uE1tetMIOyDIKBFAPIKCwhpi5DK"
|
||||
"FQigGEQzCCGaQQzCCGaQQzCEaBmkgFNokBlshpzCJwcMhpaEQgInBwyGloRA0fD8g3IINPkD"
|
||||
"CCDTMgoRkDE7R8NDqvTCJAQNQzMEYQIhsoGZgQ2aBns0BiEaAXtNNNNIJp6baQIG2aAu0CBt"
|
||||
"mgLsIIPtNO01YaIGEUQMISnwy9do0Ah3g6CD5BQG5BRbkG9oIO00000gmm0naCCDDcNhBBhu"
|
||||
"G6DzYYNAxap91oNpN1BV84Kwggw120EHwb38JB//S/vSb20m90nrf+vVtJtKkvQQbQQbvcJN"
|
||||
"Yb/0E//pdrekG9tIN7aT7/v970/pfToIN+2gvb/pL/9L+9Jv0m/S//tLWm1bS/90m19L2/9J"
|
||||
"//S770n3Sb2+v/fb/SetL0m0E97r7f+l/+l6za9X3X6//3Xat02lpf6TaNr9e3/1/+lzac2u"
|
||||
"3pN7pN71//rrTaT1pfT0336Xv/r/+l+v3q/q///71362vXjq6T+vt44pf/pe3Xt9X9X6v/9q"
|
||||
"2u3Tpa/pX39ff//6C/X29X9X/Ecff5tV0m6FLyGQCm5A8ND9Pv0kO/pD/6XvXv9/3//1902l"
|
||||
"apeFg9SGKE/tL////0vtfb0n9J//7XSfb3pLwsOqCe+3qvfr/6XvXt/fXfX+9P/pWlXhYapB"
|
||||
"GZv0vqt/r/0vtfv//1v+1vbSbSdV8Fh1oJtb76X///S969vV9Vfr/f0v6bpLyB4eyDVYSDDS"
|
||||
"0unSfS/yGeMhnhf/S+19+vqvW/+v9tdJL0GEwggw9JJ//S+///9L3r2/v++r/tdJtXSbWvWw"
|
||||
"gQYaWsfTelW//X/pfa+3/pfpMP96b+rrpL7TCCDBpaXr4QS////oL+vvV/V9KH/f/sU2kv+E"
|
||||
"EGGlpV7eCC//1/9L2/2/9L9JmoFn7paTf6pf4QQYaSX6XEwGn//4/0v0vf/S/CCkICn//0mm"
|
||||
"6S/wQRDTKwYaWl/cgQZn8Lhf/X2/2/8JfkKdlICt+1dJvabSr6aCCww6+tJ4P+OP/0/0vb/y"
|
||||
"xwQX5tWD/er/v196CCww0tf+Zh3///F+3/f+1/BMP+//bbSS9hBoILDDS6VJJvBh//zMGv9/"
|
||||
"pe3/wX7Qb/dLSbS40vEQgWGDS//w3///37f7/8F+2Df/v/bVeEEIYaWte3hv6mYEZmBH/5nv"
|
||||
"9fb/x/bIKYT9tbX09Lwggw0v0kvf/ff/9v3r2//9yCwn/66bSV18EEDDrpf+////9v7X77ru"
|
||||
"tsgtB///zadJfCDaX9JN73r/3/7fvXt//9h/20tL0ndL4Qer0lj7fr/yGZZBI/9v7X3//22/"
|
||||
"/fb1vr4Qff6T3//3i//b969vf39sP+2trpJN6XwwX/X/////2/tfb9L0t//rp+vX4YX3SSv7"
|
||||
"6xxshpI/9h+9e339/b//96t6XhhhBPeqSNgY++v4f/2/v+//9v/bSdLpJvrwwYQVu3LrX/fX"
|
||||
"u//t+6XvvW9bb//e2qXpeGGEE3elqrf+v3/+39/t9r37/7df+3peGGQ2ysIJp20sIKv2+v//"
|
||||
"2/0vb+vS7/9dL0vXww8ECG2wk4SW+vX2//w37f7e37+3Xpe+2kk3peGHhBOGKiieU/t9ZDLj"
|
||||
"//28hmR6X36XaW2Qy4+9tLS9W+iDRHhg8IKwwmEq3revW3/+3+3+3t+3W///G/Xpfgw8IJsW"
|
||||
"Cqn6b0tdv/9vXivfdL/vrdW640m9fwwxCCbFL9X0v7//b639vuttLb17qOqW9L8geHshp2GG"
|
||||
"CCIG92q31D0v2//2/69vbS20tvr13dJ9L9MFDDCCCbaVPq3pft//t/v8baXpbeu3tV031+mE"
|
||||
"gwwgVtpLek3hL9v/9v/920tuvtLtL6W9JfvDBhBK2Et9JhkM2NLXb//b12ve0thpbd1tha3S"
|
||||
"fX/wwwgrYYSSvCTDCWCX7D//b//dhpbYS27CXaTtaV6S/pA6Cwwwl+CQYMElIEB6Ww17/bVd"
|
||||
"rtw2Ethpd2lsMJf7ekF/w8LYMIJO0ITIwXEJDTDBqmqemw409Ndgwgkwwwgk24MJJs1DTW0k"
|
||||
"2mh/0HhUGQyQIGCDoMUEECkNCgM1iyGxQQYVkMKMgXUMMJAgbQIiAzg3ZqJEGpQwYJEGpQw5"
|
||||
"0JENRWxXWCwyDWo/aw8JoMQgQMhsBggQYSBAuGJIAxrrYYUgQIwUhgQ4YhYYhbDQhbX4SYev"
|
||||
"sJIPBNBgvkmBwCkaBU4ZAgzf+/v7hgsMLcGFhhU71/40IiDCERILIgREgsCBEcREaEQ4MEJA"
|
||||
"sTiIMEIME9UIiP5BbBq8hkhnmQWy/EgeDIOQUuIZAuEDwZuIHgz0ER9IRHEWZgSgVf0ED9LQ"
|
||||
"f1QQP0tB/pI5g/SpBEQuSe+iByA3HqEDH6UMKINfUUQNgJXfCoGFNYHhlxhAwvogbAzB/hCO"
|
||||
"P/////////////////////////////////+QPFrIGoF8IHYG3PIZIbdkMg4CZA8CIIZAb2QJ"
|
||||
"7IE0NbMg255DIAw5A8PMhkLwpA8H8geBZMgpzCCww/CkDy0IHgVhqQPFDIHgcaEFXRLbyB4L"
|
||||
"0INvL/kFiyDRnpbe6aXrhNP17+0iB4PMhkL0bKQPB/tMhlTIKc//XfSD67vW/2l6Q/+vfqvr"
|
||||
"///zyf6W7XkDUo/9LS/6/C//Ta+uGgwvBf+lev8R//+rX/+v/V/1///q1////V////9K0v//"
|
||||
"/9v////S/////bX///9LnA2ycNKQkyDLMg2/kG2eQ26ZEoQ2oINT+Q0nIkyDEyDa5EoQVzkN"
|
||||
"qCEmQZTkRyDTBF4hmoyGq5Aw5A8FNyBxf/03BAg8EDIbWoIHggeQ19cIGFBcgwfBQgYQMFCB"
|
||||
"ggYKCBhA1ChMEU4ZkFBSGwQRKiC4yyD1EGEENHkFxhEqIaBv/1cQg8JhBhDCDwg9Mg1UIGKa"
|
||||
"4KmmQaKJhAwVBhDIGKKE8g0UIEU9V7X//6sJ6DChQjw2ERAFzxEGGygyBjQho00CyCgMJpkD"
|
||||
"AaDCPjZAvog1IaNFR4WiMB5BNCBhBDP5BQjIEUtHAUEgGAX/6ujYr0wjwsI8LCCDYSQQfX9B"
|
||||
"emE9UEG9MI8L1QQcL7TTSYaIGDpMINTYEL/6sJA+jg2gg4QQOk2FSawjxP9BejxtHieEeJpB"
|
||||
"h6ODaBA16QcF96fp96SS/9XpvhB0EHQQdJvSfQINkM2ZDKnoLIZvoEHQTZDLmgQbSchlzQIN"
|
||||
"hIOQy5qr5DRMhnn/e2ldVX/1e+kG0nSdLIZXqzMGgU7vpcUxCdinSbdIOk7o2eshl+7uk602"
|
||||
"k/pf+r08QnWldW9XhP+lwmnhOtxCbS4hPv/ff9aWv/pX9Wk6T19XTf6XTTdN03TpdOv/06aT"
|
||||
"aT+l/+33ul1rf//oL/9fbX6/9tf20rS6/9LF61169Xr/S6rr2666HH/rTp0nxSS2yGpxAu/7"
|
||||
"ft/6v/v+l7vul7a/f77c2q33SX4Qafpf9Cl///4QX/+//V/2vXulqqW6DX6b/X///9L///S+"
|
||||
"H/1q2k2k9JJbaBpeIgu///X/pf/97/sH+2rdfFWtILDDQa+QyQ31/XX//9P/9f/5qDU/1rdN"
|
||||
"PpJbaPEQzXkMgCsR6/H3/8f/+/r7IgGn7/Tq1dJBh4QVBivBFB///S/7////2H/aVr16qw8J"
|
||||
"JBrwjQT/8gYZt6/59P////Yf7703tvST6SQNegX/8zBT2l/7f//9fhv+6/Sbtav6DXhBfX/t"
|
||||
"pf+3////hv/XSvTekn6UGF6X//tpf+3////g3+9N7/6V6tD//d/sMJf+3///35Bk0/tddJNt"
|
||||
"V/H0v//Yhf+3//daX5AkR+/03o3vpL//0v28ML/2////8H/tK10km7Wv/S/d/wzCBf+3/+/1"
|
||||
"+/771elvSX//1d/pD/7f//WrfkGuP+0tX1b9IgRH//r63hL/2//7Xr/f1+/SpttJf/9em730"
|
||||
"v/b//f1v/7V6er0r9L//XSttb1/9v//rptfr+1jY0ntUq/+197X1/9v/+0rS1/9XqqVtiqX/"
|
||||
"9bQVtowrZDYPr/7D//b7SYa9pW2jCxu6V6//thG/aTdhLbC9/+3/+6VoK1/yKPYS3rSbaS//"
|
||||
"hhLhhJhkMOwwlw15AgaP+3//aVpMMEc/aVhOGEuulfS//iFoMIJhhWKthhJYd2urBra922lB"
|
||||
"ggmK1tJimK/eraSBf/asqIpgwVqGwYJBA2GCDhhA8IG2EDBAwQODBBw2GlFMLCKcDDCVVBu1"
|
||||
"hJh6H/7Cjm0ExQanQMoUQ2F7IEF50DBLhokNghyGC5DBcEDnQHIgEOgFwYIKE1kNgOUGE0wo"
|
||||
"OtoKw9f/a6DQaDC2Cw//sF/+xCn0gwvimg1vXW0//hhDQMIMEDQgwhDYiOLLhkhlBYMEDCxD"
|
||||
"BBoMEO+I44/iIkCThILGBHgTiQyQaOxHIHh+EREa/xFBEM58fH/sIJ/6/wk///pP+l/kDwIK"
|
||||
"////X/3r+uvStf///8ev0nrC+v9pZA8WvSr0g2l//7aXtpfqJTgi4GwGeP16QjtpJeQNAanX"
|
||||
"tL+0tsJJehWwwgklX2GEgkmg6wxCBIgZiCCB+DrDChfCyBtDOdkcDMMcMLEREf//////////"
|
||||
"////////////////////4AIAIAAOAAABAwABAAAATAkAAAEBAwABAAAAcwIAAAIBAwABAAAA"
|
||||
"AQAAAAMBAwABAAAABAAAAAYBAwABAAAAAQAAABEBBAABAAAACAAAABIBAwABAAAAAQAAABUB"
|
||||
"AwABAAAAAQAAABYBAwABAAAAcwIAABcBBAABAAAABxMAABoBBQABAAAAvhMAABsBBQABAAAA"
|
||||
"xhMAABwBAwABAAAAAQAAACgBAwABAAAAAgAAAAAAAAAAAMASAAAEAAAAwBIAAAQA";
|
||||
|
||||
#endif /* LEPTONICA_BMFDATA_H */
|
||||
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_BMP_H
|
||||
#define LEPTONICA_BMP_H
|
||||
|
||||
/*!
|
||||
* \file bmp.h
|
||||
*
|
||||
* <pre>
|
||||
* This file is here to describe the fields in the header of
|
||||
* the BMP file. These fields are not used directly in Leptonica.
|
||||
* The only thing we use are the sizes of these two headers.
|
||||
* Furthermore, because of potential namespace conflicts with
|
||||
* the typedefs and defined sizes, we have changed the names
|
||||
* to protect anyone who may also need to use the original definitions.
|
||||
* Thanks to J. D. Bryan for pointing out the potential problems when
|
||||
* developing on Win32 compatible systems.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*
|
||||
* BMP file header *
|
||||
*-------------------------------------------------------------*/
|
||||
|
||||
/*! BMP file header */
|
||||
struct BMP_FileHeader
|
||||
{
|
||||
l_int16 bfType; /*!< file type; must be "BM" */
|
||||
l_int16 bfSize; /*!< length of the file;
|
||||
sizeof(BMP_FileHeader) +
|
||||
sizeof(BMP_InfoHeader) +
|
||||
size of color table +
|
||||
size of DIB bits */
|
||||
l_int16 bfFill1; /*!< remainder of the bfSize field */
|
||||
l_int16 bfReserved1; /*!< don't care (set to 0) */
|
||||
l_int16 bfReserved2; /*!< don't care (set to 0) */
|
||||
l_int16 bfOffBits; /*!< offset from beginning of file */
|
||||
l_int16 bfFill2; /*!< remainder of the bfOffBits field */
|
||||
};
|
||||
typedef struct BMP_FileHeader BMP_FH;
|
||||
|
||||
/*! Number of bytes in a BMP file header */
|
||||
#define BMP_FHBYTES sizeof(BMP_FH)
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*
|
||||
* BMP info header *
|
||||
*-------------------------------------------------------------*/
|
||||
|
||||
/*! BMP info header */
|
||||
struct BMP_InfoHeader
|
||||
{
|
||||
l_int32 biSize; /*!< size of the BMP_InfoHeader struct */
|
||||
l_int32 biWidth; /*!< bitmap width in pixels */
|
||||
l_int32 biHeight; /*!< bitmap height in pixels */
|
||||
l_int16 biPlanes; /*!< number of bitmap planes */
|
||||
l_int16 biBitCount; /*!< number of bits per pixel */
|
||||
l_int32 biCompression; /*!< compress format (0 == uncompressed) */
|
||||
l_int32 biSizeImage; /*!< size of image in bytes */
|
||||
l_int32 biXPelsPerMeter; /*!< pixels per meter in x direction */
|
||||
l_int32 biYPelsPerMeter; /*!< pixels per meter in y direction */
|
||||
l_int32 biClrUsed; /*!< number of colors used */
|
||||
l_int32 biClrImportant; /*!< number of important colors used */
|
||||
};
|
||||
typedef struct BMP_InfoHeader BMP_IH;
|
||||
|
||||
/*! Number of bytes in a BMP info header */
|
||||
#define BMP_IHBYTES sizeof(BMP_IH)
|
||||
|
||||
|
||||
#endif /* LEPTONICA_BMP_H */
|
|
@ -0,0 +1,119 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_CCBORD_H
|
||||
#define LEPTONICA_CCBORD_H
|
||||
|
||||
/*!
|
||||
* \file ccbord.h
|
||||
*
|
||||
* <pre>
|
||||
* CCBord: represents a single connected component
|
||||
* CCBorda: an array of CCBord
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*! Use in ccbaStepChainsToPixCoords() */
|
||||
enum {
|
||||
CCB_LOCAL_COORDS = 1,
|
||||
CCB_GLOBAL_COORDS = 2
|
||||
};
|
||||
|
||||
/*! Use in ccbaGenerateSPGlobalLocs() */
|
||||
enum {
|
||||
CCB_SAVE_ALL_PTS = 1,
|
||||
CCB_SAVE_TURNING_PTS = 2
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* <pre>
|
||||
* CCBord contains:
|
||||
*
|
||||
* (1) a minimally-clipped bitmap of the component (pix),
|
||||
* (2) a boxa consisting of:
|
||||
* for the primary component:
|
||||
* (xul, yul) pixel location in global coords
|
||||
* (w, h) of the bitmap
|
||||
* for the hole components:
|
||||
* (x, y) in relative coordinates in primary component
|
||||
* (w, h) of the hole border (which is 2 pixels
|
||||
* larger in each direction than the hole itself)
|
||||
* (3) a pta ('start') of the initial border pixel location for each
|
||||
* closed curve, all in relative coordinates of the primary
|
||||
* component. This is given for the primary component,
|
||||
* followed by the hole components, if any.
|
||||
* (4) a refcount of the ccbord; used internally when a ccbord
|
||||
* is accessed from a ccborda (array of ccbord)
|
||||
* (5) a ptaa for the chain code for the border in relative
|
||||
* coordinates, where the first pta is the exterior border
|
||||
* and all other pta are for interior borders (holes)
|
||||
* (6) a ptaa for the global pixel loc rendition of the border,
|
||||
* where the first pta is the exterior border and all other
|
||||
* pta are for interior borders (holes).
|
||||
* This is derived from the local or step chain code.
|
||||
* (7) a numaa for the chain code for the border as orientation
|
||||
* directions between successive border pixels, where
|
||||
* the first numa is the exterior border and all other
|
||||
* numa are for interior borders (holes). This is derived
|
||||
* from the local chain code. The 8 directions are 0 - 7.
|
||||
* (8) a pta for a single chain for each c.c., comprised of outer
|
||||
* and hole borders, plus cut paths between them, all in
|
||||
* local coords.
|
||||
* (9) a pta for a single chain for each c.c., comprised of outer
|
||||
* and hole borders, plus cut paths between them, all in
|
||||
* global coords.
|
||||
* </pre>
|
||||
*/
|
||||
struct CCBord
|
||||
{
|
||||
struct Pix *pix; /*!< component bitmap (min size) */
|
||||
struct Boxa *boxa; /*!< regions of each closed curve */
|
||||
struct Pta *start; /*!< initial border pixel locations */
|
||||
l_int32 refcount; /*!< number of handles; start at 1 */
|
||||
struct Ptaa *local; /*!< ptaa of chain pixels (local) */
|
||||
struct Ptaa *global; /*!< ptaa of chain pixels (global) */
|
||||
struct Numaa *step; /*!< numaa of chain code (step dir) */
|
||||
struct Pta *splocal; /*!< pta of single chain (local) */
|
||||
struct Pta *spglobal; /*!< pta of single chain (global) */
|
||||
};
|
||||
typedef struct CCBord CCBORD;
|
||||
|
||||
/*! Array of CCBord */
|
||||
struct CCBorda
|
||||
{
|
||||
struct Pix *pix; /*!< input pix (may be null) */
|
||||
l_int32 w; /*!< width of pix */
|
||||
l_int32 h; /*!< height of pix */
|
||||
l_int32 n; /*!< number of ccbord in ptr array */
|
||||
l_int32 nalloc; /*!< number of ccbord ptrs allocated */
|
||||
struct CCBord **ccb; /*!< ccb ptr array */
|
||||
};
|
||||
typedef struct CCBorda CCBORDA;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_CCBORD_H */
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_DEWARP_H
|
||||
#define LEPTONICA_DEWARP_H
|
||||
|
||||
/*!
|
||||
* \file dewarp.h
|
||||
*
|
||||
* <pre>
|
||||
* Data structure to hold arrays and results for generating
|
||||
* horizontal and vertical disparity arrays based on textlines.
|
||||
* Each disparity array is two-dimensional. The vertical disparity
|
||||
* array gives a vertical displacement, relative to the lowest point
|
||||
* in the textlines. The horizontal disparty array gives a horizontal
|
||||
* displacement, relative to the minimum values (for even pages)
|
||||
* or maximum values (for odd pages) of the left and right ends of
|
||||
* full textlines. Horizontal alignment always involves translations
|
||||
* away from the book gutter.
|
||||
*
|
||||
* We have intentionally separated the process of building models
|
||||
* from the rendering process that uses the models. For any page,
|
||||
* the building operation either creates an actual model (that is,
|
||||
* a model with at least the vertical disparity being computed, and
|
||||
* for which the 'success' flag is set) or fails to create a model.
|
||||
* However, at rendering time, a page can have one of two different
|
||||
* types of models.
|
||||
* (1) A valid model is an actual model that meets the rendering
|
||||
* constraints, which are limits on model curvature parameters.
|
||||
* See dewarpaTestForValidModel() for details.
|
||||
* Valid models are identified by dewarpaInsertRefModels(),
|
||||
* which sets the 'vvalid' and 'hvalid' fields. Only valid
|
||||
* models are used for rendering.
|
||||
* (2) A reference model is used by a page that doesn't have
|
||||
* a valid model, but has a nearby valid model of the same
|
||||
* parity (even/odd page) that it can use. The range in pages
|
||||
* to search for a valid model is given by the 'maxdist' field.
|
||||
*
|
||||
* At the rendering stage, vertical and horizontal disparities are
|
||||
* treated differently. It is somewhat more robust to generate
|
||||
* vertical disparity models (VDM) than horizontal disparity
|
||||
* models (HDM). A valid VDM is required for any correction to
|
||||
* be made; if a valid VDM is not available, just use the input
|
||||
* image. Otherwise, assuming it is available, the use of the
|
||||
* HDM is controlled by two fields: 'useboth' and 'check_columns'.
|
||||
* (a) With useboth == 0, we use only the VDM.
|
||||
* (b) With useboth == 1, we require using the VDM and, if a valid
|
||||
* horizontal disparity model (HDM) is available, we also use it.
|
||||
* (c) With check_columns == 1, check for multiple columns and if
|
||||
* true, only use the VDM, even if a valid HDM is available.
|
||||
* Note that 'check_columns' takes precedence over 'useboth'
|
||||
* when there is more than 1 column of text. By default,
|
||||
* check_columns == 0.
|
||||
*
|
||||
* The 'maxdist' parameter is input when the dewarpa is created.
|
||||
* The other rendering parameters have default values given in dewarp1.c.
|
||||
* All parameters used by rendering can be set (or reset) using accessors.
|
||||
*
|
||||
* After dewarping, use of the VDM will cause all points on each
|
||||
* altered curve to have a y-value equal to the minimum. Use of
|
||||
* the HDA will cause the left and right edges of the textlines
|
||||
* to be vertically aligned if they had been typeset flush-left
|
||||
* and flush-right, respectively.
|
||||
*
|
||||
* The sampled disparity arrays are expanded to full resolution,
|
||||
* using linear interpolation, and this is further expanded
|
||||
* by slope continuation to the right and below if the image
|
||||
* is larger than the full resolution disparity arrays. Then
|
||||
* the disparity correction can be applied to the input image.
|
||||
* If the input pix are 2x reduced, the expansion from sampled
|
||||
* to full res uses the product of (sampling) * (redfactor).
|
||||
*
|
||||
* The most accurate results are produced at full resolution, and
|
||||
* this is generally recommended.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*! Dewarp version for serialization
|
||||
* <pre>
|
||||
* Note on versioning of the serialization of this data structure:
|
||||
* The dewarping utility and the stored data can be expected to change.
|
||||
* In most situations, the serialized version is ephemeral -- it is
|
||||
* not needed after being used. No functions will be provided to
|
||||
* convert between different versions.
|
||||
* </pre>
|
||||
*/
|
||||
#define DEWARP_VERSION_NUMBER 4
|
||||
|
||||
/*! Data structure to hold a number of Dewarp */
|
||||
struct L_Dewarpa
|
||||
{
|
||||
l_int32 nalloc; /*!< size of dewarp ptr array */
|
||||
l_int32 maxpage; /*!< maximum page number in array */
|
||||
struct L_Dewarp **dewarp; /*!< array of ptrs to page dewarp */
|
||||
struct L_Dewarp **dewarpcache; /*!< array of ptrs to cached dewarps */
|
||||
struct Numa *namodels; /*!< list of page numbers for pages */
|
||||
/*!< with page models */
|
||||
struct Numa *napages; /*!< list of page numbers with either */
|
||||
/*!< page models or ref page models */
|
||||
l_int32 redfactor; /*!< reduction factor of input: 1 or 2 */
|
||||
l_int32 sampling; /*!< disparity arrays sampling factor */
|
||||
l_int32 minlines; /*!< min number of long lines required */
|
||||
l_int32 maxdist; /*!< max distance for getting ref page */
|
||||
l_int32 max_linecurv; /*!< maximum abs line curvature, */
|
||||
/*!< in micro-units */
|
||||
l_int32 min_diff_linecurv; /*!< minimum abs diff line */
|
||||
/*!< curvature in micro-units */
|
||||
l_int32 max_diff_linecurv; /*!< maximum abs diff line */
|
||||
/*!< curvature in micro-units */
|
||||
l_int32 max_edgeslope; /*!< maximum abs left or right edge */
|
||||
/*!< slope, in milli-units */
|
||||
l_int32 max_edgecurv; /*!< maximum abs left or right edge */
|
||||
/*!< curvature, in micro-units */
|
||||
l_int32 max_diff_edgecurv; /*!< maximum abs diff left-right */
|
||||
/*!< edge curvature, in micro-units */
|
||||
l_int32 useboth; /*!< use both disparity arrays if */
|
||||
/*!< available; only vertical otherwise */
|
||||
l_int32 check_columns; /*!< if there are multiple columns, */
|
||||
/*!< only use the vertical disparity */
|
||||
/*!< array */
|
||||
l_int32 modelsready; /*!< invalid models have been removed */
|
||||
/*!< and refs built against valid set */
|
||||
};
|
||||
typedef struct L_Dewarpa L_DEWARPA;
|
||||
|
||||
|
||||
/*! Data structure for a single dewarp */
|
||||
struct L_Dewarp
|
||||
{
|
||||
struct L_Dewarpa *dewa; /*!< ptr to parent (not owned) */
|
||||
struct Pix *pixs; /*!< source pix, 1 bpp */
|
||||
struct FPix *sampvdispar; /*!< sampled vert disparity array */
|
||||
struct FPix *samphdispar; /*!< sampled horiz disparity array */
|
||||
struct FPix *sampydispar; /*!< sampled slope h-disparity array */
|
||||
struct FPix *fullvdispar; /*!< full vert disparity array */
|
||||
struct FPix *fullhdispar; /*!< full horiz disparity array */
|
||||
struct FPix *fullydispar; /*!< full slope h-disparity array */
|
||||
struct Numa *namidys; /*!< sorted y val of midpoint each line */
|
||||
struct Numa *nacurves; /*!< sorted curvature of each line */
|
||||
l_int32 w; /*!< width of source image */
|
||||
l_int32 h; /*!< height of source image */
|
||||
l_int32 pageno; /*!< page number; important for reuse */
|
||||
l_int32 sampling; /*!< sampling factor of disparity arrays */
|
||||
l_int32 redfactor; /*!< reduction factor of pixs: 1 or 2 */
|
||||
l_int32 minlines; /*!< min number of long lines required */
|
||||
l_int32 nlines; /*!< number of long lines found */
|
||||
l_int32 mincurv; /*!< min line curvature in micro-units */
|
||||
l_int32 maxcurv; /*!< max line curvature in micro-units */
|
||||
l_int32 leftslope; /*!< left edge slope in milli-units */
|
||||
l_int32 rightslope; /*!< right edge slope in milli-units */
|
||||
l_int32 leftcurv; /*!< left edge curvature in micro-units */
|
||||
l_int32 rightcurv; /*!< right edge curvature in micro-units*/
|
||||
l_int32 nx; /*!< number of sampling pts in x-dir */
|
||||
l_int32 ny; /*!< number of sampling pts in y-dir */
|
||||
l_int32 hasref; /*!< 0 if normal; 1 if has a refpage */
|
||||
l_int32 refpage; /*!< page with disparity model to use */
|
||||
l_int32 vsuccess; /*!< sets to 1 if vert disparity builds */
|
||||
l_int32 hsuccess; /*!< sets to 1 if horiz disparity builds */
|
||||
l_int32 ysuccess; /*!< sets to 1 if slope disparity builds */
|
||||
l_int32 vvalid; /*!< sets to 1 if valid vert disparity */
|
||||
l_int32 hvalid; /*!< sets to 1 if valid horiz disparity */
|
||||
l_int32 skip_horiz; /*!< if 1, skip horiz disparity */
|
||||
/*!< correction */
|
||||
l_int32 debug; /*!< set to 1 if debug output requested */
|
||||
};
|
||||
typedef struct L_Dewarp L_DEWARP;
|
||||
|
||||
#endif /* LEPTONICA_DEWARP_H */
|
|
@ -0,0 +1,11 @@
|
|||
#if !defined (L_BIG_ENDIAN) && !defined (L_LITTLE_ENDIAN)
|
||||
# if defined (__APPLE_CC__)
|
||||
# ifdef __BIG_ENDIAN__
|
||||
# define L_BIG_ENDIAN
|
||||
# else
|
||||
# define L_LITTLE_ENDIAN
|
||||
# endif
|
||||
# else
|
||||
# define L_LITTLE_ENDIAN
|
||||
# endif
|
||||
#endif
|
|
@ -0,0 +1,509 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_ENVIRON_H
|
||||
#define LEPTONICA_ENVIRON_H
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Defines and includes differ for Unix and Windows. Also for Windows, *
|
||||
* differentiate between conditionals based on platform and compiler. *
|
||||
* For platforms: *
|
||||
* _WIN32 => Windows, 32- or 64-bit *
|
||||
* _WIN64 => Windows, 64-bit only *
|
||||
* __CYGWIN__ => Cygwin *
|
||||
* For compilers: *
|
||||
* __GNUC__ => gcc *
|
||||
* _MSC_VER => msvc *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* MS VC++ does not provide stdint.h, so define the missing types here */
|
||||
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
|
||||
#else
|
||||
/* Note that _WIN32 is defined for both 32 and 64 bit applications,
|
||||
whereas _WIN64 is defined only for the latter */
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif
|
||||
|
||||
/* VC++6 doesn't seem to have powf, expf. */
|
||||
#if (_MSC_VER < 1400)
|
||||
#define powf(x, y) (float)pow((double)(x), (double)(y))
|
||||
#define expf(x) (float)exp((double)(x))
|
||||
#endif
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Windows specifics */
|
||||
#ifdef _WIN32
|
||||
/* DLL EXPORTS and IMPORTS */
|
||||
#if defined(LIBLEPT_EXPORTS)
|
||||
#define LEPT_DLL __declspec(dllexport)
|
||||
#elif defined(LIBLEPT_IMPORTS)
|
||||
#define LEPT_DLL __declspec(dllimport)
|
||||
#else
|
||||
#define LEPT_DLL
|
||||
#endif
|
||||
#else /* non-Windows specifics */
|
||||
#include <stdint.h>
|
||||
#define LEPT_DLL
|
||||
#endif /* _WIN32 */
|
||||
|
||||
typedef intptr_t l_intptr_t;
|
||||
typedef uintptr_t l_uintptr_t;
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
|
||||
* USER CONFIGURABLE *
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
|
||||
* Environment variables with I/O libraries *
|
||||
* Manual Configuration Only: NOT AUTO_CONF *
|
||||
*--------------------------------------------------------------------*/
|
||||
/*
|
||||
* Leptonica provides interfaces to link to several external image
|
||||
* I/O libraries, plus zlib. Setting any of these to 0 here causes
|
||||
* non-functioning stubs to be linked.
|
||||
*/
|
||||
#if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS)
|
||||
#define HAVE_LIBJPEG 1
|
||||
#define HAVE_LIBTIFF 1
|
||||
#define HAVE_LIBPNG 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIBGIF 0
|
||||
#define HAVE_LIBUNGIF 0
|
||||
#define HAVE_LIBWEBP 0
|
||||
#define HAVE_LIBJP2K 0
|
||||
|
||||
/* Leptonica supports both OpenJPEG 2.0 and 2.1. If you have a
|
||||
* version of openjpeg (HAVE_LIBJP2K) that is not 2.1, set the
|
||||
* path to the openjpeg.h header in angle brackets here. */
|
||||
#define LIBJP2K_HEADER <openjpeg-2.1/openjpeg.h>
|
||||
#endif /* ! HAVE_CONFIG_H etc. */
|
||||
|
||||
/*
|
||||
* On linux systems, you can do I/O between Pix and memory. Specifically,
|
||||
* you can compress (write compressed data to memory from a Pix) and
|
||||
* uncompress (read from compressed data in memory to a Pix).
|
||||
* For jpeg, png, jp2k, gif, pnm and bmp, these use the non-posix GNU
|
||||
* functions fmemopen() and open_memstream(). These functions are not
|
||||
* available on other systems.
|
||||
* To use these functions in linux, you must define HAVE_FMEMOPEN to 1.
|
||||
* To use them on MacOS, which does not support these functions, set it to 0.
|
||||
*/
|
||||
#if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS) && \
|
||||
!defined(_WIN32)
|
||||
#define HAVE_FMEMOPEN 1
|
||||
#endif /* ! HAVE_CONFIG_H etc. */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
|
||||
* USER CONFIGURABLE *
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
|
||||
* Environ variables for image I/O without external libraries *
|
||||
*--------------------------------------------------------------------*/
|
||||
/*
|
||||
* Leptonica supplies I/O support without using external libraries for:
|
||||
* * image read/write for bmp, pnm
|
||||
* * header read for jp2k
|
||||
* * image wrapping write for pdf and ps.
|
||||
* Setting any of these to 0 causes non-functioning stubs to be linked.
|
||||
*/
|
||||
#define USE_BMPIO 1
|
||||
#define USE_PNMIO 1
|
||||
#define USE_JP2KHEADER 1
|
||||
#define USE_PDFIO 1
|
||||
#define USE_PSIO 1
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* It is desirable on Windows to have all temp files written to the same
|
||||
* subdirectory of the Windows <Temp> directory, because files under <Temp>
|
||||
* persist after reboot, and the regression tests write a lot of files.
|
||||
* We write all test files to /tmp/lept or subdirectories of /tmp/lept.
|
||||
* Windows temp files are specified as in unix, but have the translation
|
||||
* /tmp/lept/xxx --> <Temp>/lept/xxx
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* Built-in types *
|
||||
*--------------------------------------------------------------------*/
|
||||
typedef signed char l_int8; /*!< signed 8-bit value */
|
||||
typedef unsigned char l_uint8; /*!< unsigned 8-bit value */
|
||||
typedef short l_int16; /*!< signed 16-bit value */
|
||||
typedef unsigned short l_uint16; /*!< unsigned 16-bit value */
|
||||
typedef int l_int32; /*!< signed 32-bit value */
|
||||
typedef unsigned int l_uint32; /*!< unsigned 32-bit value */
|
||||
typedef float l_float32; /*!< 32-bit floating point value */
|
||||
typedef double l_float64; /*!< 64-bit floating point value */
|
||||
#ifdef COMPILER_MSVC
|
||||
typedef __int64 l_int64; /*!< signed 64-bit value */
|
||||
typedef unsigned __int64 l_uint64; /*!< unsigned 64-bit value */
|
||||
#else
|
||||
typedef long long l_int64; /*!< signed 64-bit value */
|
||||
typedef unsigned long long l_uint64; /*!< unsigned 64-bit value */
|
||||
#endif /* COMPILER_MSVC */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Standard macros *
|
||||
*------------------------------------------------------------------------*/
|
||||
#ifndef L_MIN
|
||||
/*! Minimum of %x and %y */
|
||||
#define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef L_MAX
|
||||
/*! Maximum of %x and %y */
|
||||
#define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef L_ABS
|
||||
/*! Absoulute value of %x */
|
||||
#define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
|
||||
#endif
|
||||
|
||||
#ifndef L_SIGN
|
||||
/*! Sign of %x */
|
||||
#define L_SIGN(x) (((x) < 0) ? -1 : 1)
|
||||
#endif
|
||||
|
||||
#ifndef UNDEF
|
||||
/*! Undefined value */
|
||||
#define UNDEF -1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
/*! NULL value */
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
/*! True value */
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
/*! False value */
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* Environment variables for endian dependence *
|
||||
*--------------------------------------------------------------------*/
|
||||
/*
|
||||
* To control conditional compilation, one of two variables
|
||||
*
|
||||
* L_LITTLE_ENDIAN (e.g., for Intel X86)
|
||||
* L_BIG_ENDIAN (e.g., for Sun SPARC, Mac Power PC)
|
||||
*
|
||||
* is defined when the GCC compiler is invoked.
|
||||
* All code should compile properly for both hardware architectures.
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Simple search state variables *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Simple search state variables */
|
||||
enum {
|
||||
L_NOT_FOUND = 0,
|
||||
L_FOUND = 1
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Path separator conversion *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Path separator conversion */
|
||||
enum {
|
||||
UNIX_PATH_SEPCHAR = 0,
|
||||
WIN_PATH_SEPCHAR = 1
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Timing structs *
|
||||
*------------------------------------------------------------------------*/
|
||||
typedef void *L_TIMER;
|
||||
|
||||
/*! Timing struct */
|
||||
struct L_WallTimer {
|
||||
l_int32 start_sec;
|
||||
l_int32 start_usec;
|
||||
l_int32 stop_sec;
|
||||
l_int32 stop_usec;
|
||||
};
|
||||
typedef struct L_WallTimer L_WALLTIMER;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Standard memory allocation *
|
||||
* *
|
||||
* These specify the memory management functions that are used *
|
||||
* on all heap data except for Pix. Memory management for Pix *
|
||||
* also defaults to malloc and free. See pix1.c for details. *
|
||||
*------------------------------------------------------------------------*/
|
||||
#define LEPT_MALLOC(blocksize) malloc(blocksize)
|
||||
#define LEPT_CALLOC(numelem, elemsize) calloc(numelem, elemsize)
|
||||
#define LEPT_REALLOC(ptr, blocksize) realloc(ptr, blocksize)
|
||||
#define LEPT_FREE(ptr) free(ptr)
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Control printing of error, warning, and info messages *
|
||||
* *
|
||||
* To omit all messages to stderr, simply define NO_CONSOLE_IO on the *
|
||||
* command line. For finer grained control, we have a mechanism *
|
||||
* based on the message severity level. The following assumes that *
|
||||
* NO_CONSOLE_IO is not defined. *
|
||||
* *
|
||||
* Messages are printed if the message severity is greater than or equal *
|
||||
* to the current severity threshold. The current severity threshold *
|
||||
* is the greater of the compile-time severity, which is the minimum *
|
||||
* severity that can be reported, and the run-time severity, which is *
|
||||
* the severity threshold at the moment. *
|
||||
* *
|
||||
* The compile-time threshold determines which messages are compiled *
|
||||
* into the library for potential printing. Messages below the *
|
||||
* compile-time threshold are omitted and can never be printed. The *
|
||||
* default compile-time threshold is L_SEVERITY_INFO, but this may be *
|
||||
* overridden by defining MINIMUM_SEVERITY to the desired enumeration *
|
||||
* identifier on the compiler command line. Defining NO_CONSOLE_IO on *
|
||||
* the command line is the same as setting MINIMUM_SEVERITY to *
|
||||
* L_SEVERITY_NONE. *
|
||||
* *
|
||||
* The run-time threshold determines which messages are printed during *
|
||||
* library execution. It defaults to the compile-time threshold but *
|
||||
* may be changed either statically by defining DEFAULT_SEVERITY to *
|
||||
* the desired enumeration identifier on the compiler command line, or *
|
||||
* dynamically by calling setMsgSeverity() to specify a new threshold. *
|
||||
* The run-time threshold may also be set from the value of the *
|
||||
* environment variable LEPT_MSG_SEVERITY by calling setMsgSeverity() *
|
||||
* and specifying L_SEVERITY_EXTERNAL. *
|
||||
* *
|
||||
* In effect, the compile-time threshold setting says, "Generate code *
|
||||
* to permit messages of equal or greater severity than this to be *
|
||||
* printed, if desired," whereas the run-time threshold setting says, *
|
||||
* "Print messages that have an equal or greater severity than this." *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Control printing of error, warning and info messages */
|
||||
enum {
|
||||
L_SEVERITY_EXTERNAL = 0, /* Get the severity from the environment */
|
||||
L_SEVERITY_ALL = 1, /* Lowest severity: print all messages */
|
||||
L_SEVERITY_DEBUG = 2, /* Print debugging and higher messages */
|
||||
L_SEVERITY_INFO = 3, /* Print informational and higher messages */
|
||||
L_SEVERITY_WARNING = 4, /* Print warning and higher messages */
|
||||
L_SEVERITY_ERROR = 5, /* Print error and higher messages */
|
||||
L_SEVERITY_NONE = 6 /* Highest severity: print no messages */
|
||||
};
|
||||
|
||||
/* No message less than the compile-time threshold will ever be
|
||||
* reported, regardless of the current run-time threshold. This allows
|
||||
* selection of the set of messages to include in the library. For
|
||||
* example, setting the threshold to L_SEVERITY_WARNING eliminates all
|
||||
* informational messages from the library. With that setting, both
|
||||
* warning and error messages would be printed unless setMsgSeverity()
|
||||
* was called, or DEFAULT_SEVERITY was redefined, to set the run-time
|
||||
* severity to L_SEVERITY_ERROR. In that case, only error messages
|
||||
* would be printed.
|
||||
*
|
||||
* This mechanism makes the library smaller and faster, by eliminating
|
||||
* undesired message reporting and the associated run-time overhead for
|
||||
* message threshold checking, because code for messages whose severity
|
||||
* is lower than MINIMUM_SEVERITY won't be generated.
|
||||
*
|
||||
* A production library might typically permit ERROR messages to be
|
||||
* generated, and a development library might permit DEBUG and higher.
|
||||
* The actual messages printed (as opposed to generated) would depend
|
||||
* on the current run-time severity threshold.
|
||||
*
|
||||
* This is a complex mechanism and a few examples may help.
|
||||
* (1) No output permitted under any circumstances.
|
||||
* Use: -DNO_CONSOLE_IO or -DMINIMUM_SEVERITY=6
|
||||
* (2) Suppose you want to only allow error messages, and you don't
|
||||
* want to permit info or warning messages at runtime.
|
||||
* Use: -DMINIMUM_SEVERITY=5
|
||||
* (3) Suppose you want to only allow error messages by default,
|
||||
* but you will permit this to be over-ridden at runtime.
|
||||
* Use: -DDEFAULT_SEVERITY=5
|
||||
* and to allow info and warning override:
|
||||
* setMsgSeverity(L_SEVERITY_INFO);
|
||||
*/
|
||||
|
||||
#ifdef NO_CONSOLE_IO
|
||||
#undef MINIMUM_SEVERITY
|
||||
#undef DEFAULT_SEVERITY
|
||||
|
||||
#define MINIMUM_SEVERITY L_SEVERITY_NONE /*!< Compile-time default */
|
||||
#define DEFAULT_SEVERITY L_SEVERITY_NONE /*!< Run-time default */
|
||||
|
||||
#else
|
||||
#ifndef MINIMUM_SEVERITY
|
||||
#define MINIMUM_SEVERITY L_SEVERITY_INFO /*!< Compile-time default */
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_SEVERITY
|
||||
#define DEFAULT_SEVERITY MINIMUM_SEVERITY /*!< Run-time default */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*! The run-time message severity threshold is defined in utils.c. */
|
||||
LEPT_DLL extern l_int32 LeptMsgSeverity;
|
||||
|
||||
/*
|
||||
* <pre>
|
||||
* Usage
|
||||
* =====
|
||||
* Messages are of two types.
|
||||
*
|
||||
* (1) The messages
|
||||
* ERROR_INT(a,b,c) : returns l_int32
|
||||
* ERROR_FLOAT(a,b,c) : returns l_float32
|
||||
* ERROR_PTR(a,b,c) : returns void*
|
||||
* are used to return from functions and take a fixed set of parameters:
|
||||
* a : <message string>
|
||||
* b : procName
|
||||
* c : <return value from function>
|
||||
* where procName is the name of the local variable naming the function.
|
||||
*
|
||||
* (2) The purely informational L_* messages
|
||||
* L_ERROR(a,...)
|
||||
* L_WARNING(a,...)
|
||||
* L_INFO(a,...)
|
||||
* do not take a return value, but they take at least two parameters:
|
||||
* a : <message string> with optional format conversions
|
||||
* v1 : procName (this must be included as the first vararg)
|
||||
* v2, ... : optional varargs to match format converters in the message
|
||||
*
|
||||
* To return an error from a function that returns void, use:
|
||||
* L_ERROR(<message string>, procName, [...])
|
||||
* return;
|
||||
*
|
||||
* Implementation details
|
||||
* ======================
|
||||
* Messages are defined with the IF_SEV macro. The first parameter is
|
||||
* the message severity, the second is the function to call if the
|
||||
* message is to be printed, and the third is the return value if the
|
||||
* message is to be suppressed. For example, we might have an
|
||||
* informational message defined as:
|
||||
*
|
||||
* IF_SEV(L_SEVERITY_INFO, fprintf(.......), 0)
|
||||
*
|
||||
* The macro expands into a conditional. Because the first comparison
|
||||
* is between two constants, an optimizing compiler will remove either
|
||||
* the comparison (if it's true) or the entire macro expansion (if it
|
||||
* is false). This means that there is no run-time overhead for
|
||||
* messages whose severity falls below the minimum specified at compile
|
||||
* time, and for others the overhead is one (not two) comparisons.
|
||||
*
|
||||
* The L_nnn() macros below do not return a value, but because the
|
||||
* conditional operator requires one for the false condition, we
|
||||
* specify a void expression.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#ifdef NO_CONSOLE_IO
|
||||
|
||||
#define PROCNAME(name)
|
||||
#define ERROR_INT(a,b,c) ((l_int32)(c))
|
||||
#define ERROR_FLOAT(a,b,c) ((l_float32)(c))
|
||||
#define ERROR_PTR(a,b,c) ((void *)(c))
|
||||
#define L_ERROR(a,...)
|
||||
#define L_WARNING(a,...)
|
||||
#define L_INFO(a,...)
|
||||
|
||||
#else
|
||||
|
||||
#define PROCNAME(name) static const char procName[] = name
|
||||
#define IF_SEV(l,t,f) \
|
||||
((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
|
||||
|
||||
#define ERROR_INT(a,b,c) \
|
||||
IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a),(b),(c)), (l_int32)(c))
|
||||
#define ERROR_FLOAT(a,b,c) \
|
||||
IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a),(b),(c)), (l_float32)(c))
|
||||
#define ERROR_PTR(a,b,c) \
|
||||
IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a),(b),(c)), (void *)(c))
|
||||
|
||||
#define L_ERROR(a,...) \
|
||||
IF_SEV(L_SEVERITY_ERROR, \
|
||||
(void)fprintf(stderr, "Error in %s: " a, __VA_ARGS__), \
|
||||
(void)0)
|
||||
#define L_WARNING(a,...) \
|
||||
IF_SEV(L_SEVERITY_WARNING, \
|
||||
(void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
|
||||
(void)0)
|
||||
#define L_INFO(a,...) \
|
||||
IF_SEV(L_SEVERITY_INFO, \
|
||||
(void)fprintf(stderr, "Info in %s: " a, __VA_ARGS__), \
|
||||
(void)0)
|
||||
|
||||
#if 0 /* Alternative method for controlling L_* message output */
|
||||
#define L_ERROR(a,...) \
|
||||
{ if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
|
||||
L_SEVERITY_ERROR >= LeptMsgSeverity) \
|
||||
fprintf(stderr, "Error in %s: " a, __VA_ARGS__) \
|
||||
}
|
||||
#define L_WARNING(a,...) \
|
||||
{ if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
|
||||
L_SEVERITY_WARNING >= LeptMsgSeverity) \
|
||||
fprintf(stderr, "Warning in %s: " a, __VA_ARGS__) \
|
||||
}
|
||||
#define L_INFO(a,...) \
|
||||
{ if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
|
||||
L_SEVERITY_INFO >= LeptMsgSeverity) \
|
||||
fprintf(stderr, "Info in %s: " a, __VA_ARGS__) \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NO_CONSOLE_IO */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* snprintf() renamed in MSVC (pre-VS2015) *
|
||||
*------------------------------------------------------------------------*/
|
||||
#if defined _MSC_VER && _MSC_VER < 1900
|
||||
#define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* LEPTONICA_ENVIRON_H */
|
|
@ -0,0 +1,96 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_GPLOT_H
|
||||
#define LEPTONICA_GPLOT_H
|
||||
|
||||
/*!
|
||||
* \file gplot.h
|
||||
*
|
||||
* <pre>
|
||||
* Data structures and parameters for generating gnuplot files
|
||||
*
|
||||
* We used to support X11 output, but recent versions of gnuplot do not
|
||||
* support the X11 terminal. To get display to your screen, use
|
||||
* GPLOT_PNG output; e.g.,
|
||||
* gplotSimple1(na, GPLOT_PNG, "/tmp/someroot", ...);
|
||||
* l_fileDisplay("/tmp/someroot.png", ...);
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#define GPLOT_VERSION_NUMBER 1
|
||||
|
||||
#define NUM_GPLOT_STYLES 5
|
||||
enum GPLOT_STYLE {
|
||||
GPLOT_LINES = 0,
|
||||
GPLOT_POINTS = 1,
|
||||
GPLOT_IMPULSES = 2,
|
||||
GPLOT_LINESPOINTS = 3,
|
||||
GPLOT_DOTS = 4
|
||||
};
|
||||
|
||||
#define NUM_GPLOT_OUTPUTS 6
|
||||
enum GPLOT_OUTPUT {
|
||||
GPLOT_NONE = 0,
|
||||
GPLOT_PNG = 1,
|
||||
GPLOT_PS = 2,
|
||||
GPLOT_EPS = 3,
|
||||
GPLOT_LATEX = 4
|
||||
};
|
||||
|
||||
enum GPLOT_SCALING {
|
||||
GPLOT_LINEAR_SCALE = 0, /*!< default */
|
||||
GPLOT_LOG_SCALE_X = 1,
|
||||
GPLOT_LOG_SCALE_Y = 2,
|
||||
GPLOT_LOG_SCALE_X_Y = 3
|
||||
};
|
||||
|
||||
extern const char *gplotstylenames[]; /*!< used in gnuplot cmd file */
|
||||
extern const char *gplotfilestyles[]; /*!< used in simple file input */
|
||||
extern const char *gplotfileoutputs[]; /*!< used in simple file input */
|
||||
|
||||
/*! Data structure for generating gnuplot files */
|
||||
struct GPlot
|
||||
{
|
||||
char *rootname; /*!< for cmd, data, output */
|
||||
char *cmdname; /*!< command file name */
|
||||
struct Sarray *cmddata; /*!< command file contents */
|
||||
struct Sarray *datanames; /*!< data file names */
|
||||
struct Sarray *plotdata; /*!< plot data (1 string/file) */
|
||||
struct Sarray *plottitles; /*!< title for each individual plot */
|
||||
struct Numa *plotstyles; /*!< plot style for individual plots */
|
||||
l_int32 nplots; /*!< current number of plots */
|
||||
char *outname; /*!< output file name */
|
||||
l_int32 outformat; /*!< GPLOT_OUTPUT values */
|
||||
l_int32 scaling; /*!< GPLOT_SCALING values */
|
||||
char *title; /*!< optional */
|
||||
char *xlabel; /*!< optional x axis label */
|
||||
char *ylabel; /*!< optional y axis label */
|
||||
};
|
||||
typedef struct GPlot GPLOT;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_GPLOT_H */
|
|
@ -0,0 +1,87 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_HEAP_H
|
||||
#define LEPTONICA_HEAP_H
|
||||
|
||||
/*!
|
||||
* \file heap.h
|
||||
*
|
||||
* <pre>
|
||||
* Expandable priority queue configured as a heap for arbitrary void* data
|
||||
*
|
||||
* The L_Heap is used to implement a priority queue. The elements
|
||||
* in the heap are ordered in either increasing or decreasing key value.
|
||||
* The key is a float field 'keyval' that is required to be
|
||||
* contained in the elements of the queue.
|
||||
*
|
||||
* The heap is a simple binary tree with the following constraints:
|
||||
* - the key of each node is >= the keys of the two children
|
||||
* - the tree is complete, meaning that each level (1, 2, 4, ...)
|
||||
* is filled and the last level is filled from left to right
|
||||
*
|
||||
* The tree structure is implicit in the queue array, with the
|
||||
* array elements numbered as a breadth-first search of the tree
|
||||
* from left to right. It is thus guaranteed that the largest
|
||||
* (or smallest) key belongs to the first element in the array.
|
||||
*
|
||||
* Heap sort is used to sort the array. Once an array has been
|
||||
* sorted as a heap, it is convenient to use it as a priority queue,
|
||||
* because the min (or max) elements are always at the root of
|
||||
* the tree (element 0), and once removed, the heap can be
|
||||
* resorted in not more than log[n] steps, where n is the number
|
||||
* of elements on the heap. Likewise, if an arbitrary element is
|
||||
* added to the end of the array A, the sorted heap can be restored
|
||||
* in not more than log[n] steps.
|
||||
*
|
||||
* A L_Heap differs from a L_Queue in that the elements in the former
|
||||
* are sorted by a key. Internally, the array is maintained
|
||||
* as a queue, with a pointer to the end of the array. The
|
||||
* head of the array always remains at array[0]. The array is
|
||||
* maintained (sorted) as a heap. When an item is removed from
|
||||
* the head, the last item takes its place (thus reducing the
|
||||
* array length by 1), and this is followed by array element
|
||||
* swaps to restore the heap property. When an item is added,
|
||||
* it goes at the end of the array, and is swapped up to restore
|
||||
* the heap. If the ptr array is full, adding another item causes
|
||||
* the ptr array size to double.
|
||||
*
|
||||
* For further implementation details, see heap.c.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*! Heap of arbitrary void* data */
|
||||
struct L_Heap
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 n; /*!< number of elements stored in the heap */
|
||||
void **array; /*!< ptr array */
|
||||
l_int32 direction; /*!< L_SORT_INCREASING or L_SORT_DECREASING */
|
||||
};
|
||||
typedef struct L_Heap L_HEAP;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_HEAP_H */
|
|
@ -0,0 +1,237 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
/*!
|
||||
* \file imageio.h
|
||||
*
|
||||
* <pre>
|
||||
* General features of image I/O in leptonica
|
||||
*
|
||||
* At present, there are 9 file formats for images that can be read
|
||||
* and written:
|
||||
* png (requires libpng, libz)
|
||||
* jpeg (requires libjpeg)
|
||||
* tiff (requires libtiff, libz)
|
||||
* gif (requires libgif)
|
||||
* webp (requires libwebp)
|
||||
* jp2 (requires libopenjp2)
|
||||
* bmp (no library required)
|
||||
* pnm (no library required)
|
||||
* spix (no library required)
|
||||
* Additionally, there are two file formats for writing (only) images:
|
||||
* PostScript (requires libpng, libz, libjpeg, libtiff)
|
||||
* pdf (requires libpng, libz, libjpeg, libtiff)
|
||||
*
|
||||
* For all 9 read/write formats, leptonica provides interconversion
|
||||
* between pix (with raster data) and formatted image data:
|
||||
* Conversion from pix (typically compression):
|
||||
* pixWrite(): pix --> file
|
||||
* pixWriteStream(): pix --> filestream (aka FILE*)
|
||||
* pixWriteMem(): pix --> memory buffer
|
||||
* Conversion to pix (typically decompression):
|
||||
* pixRead(): file --> pix
|
||||
* pixReadStream(): filestream --> pix
|
||||
* pixReadMem(): memory buffer --> pix
|
||||
*
|
||||
* Conversions for which the image data is not compressed are:
|
||||
* * uncompressed tiff (IFF_TIFF)
|
||||
* * bmp
|
||||
* * pnm
|
||||
* * spix (fast serialization that copies the pix raster data)
|
||||
*
|
||||
* The image header (metadata) information can be read from either
|
||||
* the compressed file or a memory buffer, for all 9 formats.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#ifndef LEPTONICA_IMAGEIO_H
|
||||
#define LEPTONICA_IMAGEIO_H
|
||||
|
||||
/* --------------------------------------------------------------- *
|
||||
* Image file format types *
|
||||
* --------------------------------------------------------------- */
|
||||
/*
|
||||
* The IFF_DEFAULT flag is used to write the file out in the
|
||||
* same (input) file format that the pix was read from. If the pix
|
||||
* was not read from file, the input format field will be
|
||||
* IFF_UNKNOWN and the output file format will be chosen to
|
||||
* be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
|
||||
* and IFF_PNG for everything else.
|
||||
*
|
||||
* In the future, new format types that have defined extensions
|
||||
* will be added before IFF_DEFAULT, and will be kept in sync with
|
||||
* the file format extensions in writefile.c. The positions of
|
||||
* file formats before IFF_DEFAULT will remain invariant.
|
||||
*/
|
||||
|
||||
/*! Image file format types */
|
||||
enum {
|
||||
IFF_UNKNOWN = 0,
|
||||
IFF_BMP = 1,
|
||||
IFF_JFIF_JPEG = 2,
|
||||
IFF_PNG = 3,
|
||||
IFF_TIFF = 4,
|
||||
IFF_TIFF_PACKBITS = 5,
|
||||
IFF_TIFF_RLE = 6,
|
||||
IFF_TIFF_G3 = 7,
|
||||
IFF_TIFF_G4 = 8,
|
||||
IFF_TIFF_LZW = 9,
|
||||
IFF_TIFF_ZIP = 10,
|
||||
IFF_PNM = 11,
|
||||
IFF_PS = 12,
|
||||
IFF_GIF = 13,
|
||||
IFF_JP2 = 14,
|
||||
IFF_WEBP = 15,
|
||||
IFF_LPDF = 16,
|
||||
IFF_DEFAULT = 17,
|
||||
IFF_SPIX = 18
|
||||
};
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- *
|
||||
* Format header ids *
|
||||
* --------------------------------------------------------------- */
|
||||
|
||||
/*! Format header ids */
|
||||
enum {
|
||||
BMP_ID = 0x4d42, /*!< BM - for bitmaps */
|
||||
TIFF_BIGEND_ID = 0x4d4d, /*!< MM - for 'motorola' */
|
||||
TIFF_LITTLEEND_ID = 0x4949 /*!< II - for 'intel' */
|
||||
};
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- *
|
||||
* Hinting bit flags in jpeg reader *
|
||||
* --------------------------------------------------------------- */
|
||||
|
||||
/*! Hinting bit flags in jpeg reader */
|
||||
enum {
|
||||
L_JPEG_READ_LUMINANCE = 1, /*!< only want luminance data; no chroma */
|
||||
L_JPEG_FAIL_ON_BAD_DATA = 2 /*!< don't return possibly damaged pix */
|
||||
};
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- *
|
||||
* Pdf formatted encoding types *
|
||||
* --------------------------------------------------------------- */
|
||||
|
||||
/*! Pdf formatted encoding types */
|
||||
enum {
|
||||
L_DEFAULT_ENCODE = 0, /*!< use default encoding based on image */
|
||||
L_JPEG_ENCODE = 1, /*!< use dct encoding: 8 and 32 bpp, no cmap */
|
||||
L_G4_ENCODE = 2, /*!< use ccitt g4 fax encoding: 1 bpp */
|
||||
L_FLATE_ENCODE = 3, /*!< use flate encoding: any depth, cmap ok */
|
||||
L_JP2K_ENCODE = 4 /*!< use jp2k encoding: 8 and 32 bpp, no cmap */
|
||||
};
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- *
|
||||
* Compressed image data *
|
||||
* --------------------------------------------------------------- */
|
||||
/*
|
||||
* In use, either datacomp or data85 will be produced, depending
|
||||
* on whether the data needs to be ascii85 encoded. PostScript
|
||||
* requires ascii85 encoding; pdf does not.
|
||||
*
|
||||
* For the colormap (flate compression only), PostScript uses ascii85
|
||||
* encoding and pdf uses a bracketed array of space-separated
|
||||
* hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
|
||||
* the minisblack field.
|
||||
*/
|
||||
|
||||
/*! Compressed image data */
|
||||
struct L_Compressed_Data
|
||||
{
|
||||
l_int32 type; /*!< encoding type: L_JPEG_ENCODE, etc */
|
||||
l_uint8 *datacomp; /*!< gzipped raster data */
|
||||
size_t nbytescomp; /*!< number of compressed bytes */
|
||||
char *data85; /*!< ascii85-encoded gzipped raster data */
|
||||
size_t nbytes85; /*!< number of ascii85 encoded bytes */
|
||||
char *cmapdata85; /*!< ascii85-encoded uncompressed cmap */
|
||||
char *cmapdatahex; /*!< hex pdf array for the cmap */
|
||||
l_int32 ncolors; /*!< number of colors in cmap */
|
||||
l_int32 w; /*!< image width */
|
||||
l_int32 h; /*!< image height */
|
||||
l_int32 bps; /*!< bits/sample; typ. 1, 2, 4 or 8 */
|
||||
l_int32 spp; /*!< samples/pixel; typ. 1 or 3 */
|
||||
l_int32 minisblack; /*!< tiff g4 photometry */
|
||||
l_int32 predictor; /*!< flate data has PNG predictors */
|
||||
size_t nbytes; /*!< number of uncompressed raster bytes */
|
||||
l_int32 res; /*!< resolution (ppi) */
|
||||
};
|
||||
typedef struct L_Compressed_Data L_COMP_DATA;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Pdf multi image flags *
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/*! Pdf multi image flags */
|
||||
enum {
|
||||
L_FIRST_IMAGE = 1, /*!< first image to be used */
|
||||
L_NEXT_IMAGE = 2, /*!< intermediate image; not first or last */
|
||||
L_LAST_IMAGE = 3 /*!< last image to be used */
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- *
|
||||
* Intermediate pdf generation data *
|
||||
* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
* This accumulates data for generating a pdf of a single page consisting
|
||||
* of an arbitrary number of images.
|
||||
*
|
||||
* None of the strings have a trailing newline.
|
||||
*/
|
||||
|
||||
/*! Intermediate pdf generation data */
|
||||
struct L_Pdf_Data
|
||||
{
|
||||
char *title; /*!< optional title for pdf */
|
||||
l_int32 n; /*!< number of images */
|
||||
l_int32 ncmap; /*!< number of colormaps */
|
||||
struct L_Ptra *cida; /*!< array of compressed image data */
|
||||
char *id; /*!< %PDF-1.2 id string */
|
||||
char *obj1; /*!< catalog string */
|
||||
char *obj2; /*!< metadata string */
|
||||
char *obj3; /*!< pages string */
|
||||
char *obj4; /*!< page string (variable data) */
|
||||
char *obj5; /*!< content string (variable data) */
|
||||
char *poststream; /*!< post-binary-stream string */
|
||||
char *trailer; /*!< trailer string (variable data) */
|
||||
struct Pta *xy; /*!< store (xpt, ypt) array */
|
||||
struct Pta *wh; /*!< store (wpt, hpt) array */
|
||||
struct Box *mediabox; /*!< bounding region for all images */
|
||||
struct Sarray *saprex; /*!< pre-binary-stream xobject strings */
|
||||
struct Sarray *sacmap; /*!< colormap pdf object strings */
|
||||
struct L_Dna *objsize; /*!< sizes of each pdf string object */
|
||||
struct L_Dna *objloc; /*!< location of each pdf string object */
|
||||
l_int32 xrefloc; /*!< location of xref */
|
||||
};
|
||||
typedef struct L_Pdf_Data L_PDF_DATA;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_IMAGEIO_H */
|
|
@ -0,0 +1,141 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_JBCLASS_H
|
||||
#define LEPTONICA_JBCLASS_H
|
||||
|
||||
/*!
|
||||
* \file jbclass.h
|
||||
*
|
||||
* JbClasser
|
||||
* JbData
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* <pre>
|
||||
* The JbClasser struct holds all the data accumulated during the
|
||||
* classification process that can be used for a compressed
|
||||
* jbig2-type representation of a set of images. This is created
|
||||
* in an initialization process and added to as the selected components
|
||||
* on each successive page are analyzed.
|
||||
* </pre>
|
||||
*/
|
||||
struct JbClasser
|
||||
{
|
||||
struct Sarray *safiles; /*!< input page image file names */
|
||||
l_int32 method; /*!< JB_RANKHAUS, JB_CORRELATION */
|
||||
l_int32 components; /*!< JB_CONN_COMPS, JB_CHARACTERS or */
|
||||
/*!< JB_WORDS */
|
||||
l_int32 maxwidth; /*!< max component width allowed */
|
||||
l_int32 maxheight; /*!< max component height allowed */
|
||||
l_int32 npages; /*!< number of pages already processed */
|
||||
l_int32 baseindex; /*!< number components already processed */
|
||||
/*!< on fully processed pages */
|
||||
struct Numa *nacomps; /*!< number of components on each page */
|
||||
l_int32 sizehaus; /*!< size of square struct elem for haus */
|
||||
l_float32 rankhaus; /*!< rank val of haus match, each way */
|
||||
l_float32 thresh; /*!< thresh value for correlation score */
|
||||
l_float32 weightfactor; /*!< corrects thresh value for heaver */
|
||||
/*!< components; use 0 for no correction */
|
||||
struct Numa *naarea; /*!< w * h of each template, without */
|
||||
/*!< extra border pixels */
|
||||
l_int32 w; /*!< max width of original src images */
|
||||
l_int32 h; /*!< max height of original src images */
|
||||
l_int32 nclass; /*!< current number of classes */
|
||||
l_int32 keep_pixaa; /*!< If zero, pixaa isn't filled */
|
||||
struct Pixaa *pixaa; /*!< instances for each class; unbordered */
|
||||
struct Pixa *pixat; /*!< templates for each class; bordered */
|
||||
/*!< and not dilated */
|
||||
struct Pixa *pixatd; /*!< templates for each class; bordered */
|
||||
/*!< and dilated */
|
||||
struct L_DnaHash *dahash; /*!< Hash table to find templates by size */
|
||||
struct Numa *nafgt; /*!< fg areas of undilated templates; */
|
||||
/*!< only used for rank < 1.0 */
|
||||
struct Pta *ptac; /*!< centroids of all bordered cc */
|
||||
struct Pta *ptact; /*!< centroids of all bordered template cc */
|
||||
struct Numa *naclass; /*!< array of class ids for each component */
|
||||
struct Numa *napage; /*!< array of page nums for each component */
|
||||
struct Pta *ptaul; /*!< array of UL corners at which the */
|
||||
/*!< template is to be placed for each */
|
||||
/*!< component */
|
||||
struct Pta *ptall; /*!< similar to ptaul, but for LL corners */
|
||||
};
|
||||
typedef struct JbClasser JBCLASSER;
|
||||
|
||||
|
||||
/*!
|
||||
* <pre>
|
||||
* The JbData struct holds all the data required for
|
||||
* the compressed jbig-type representation of a set of images.
|
||||
* The data can be written to file, read back, and used
|
||||
* to regenerate an approximate version of the original,
|
||||
* which differs in two ways from the original:
|
||||
* (1) It uses a template image for each c.c. instead of the
|
||||
* original instance, for each occurrence on each page.
|
||||
* (2) It discards components with either a height or width larger
|
||||
* than the maximuma, given here by the lattice dimensions
|
||||
* used for storing the templates.
|
||||
* </pre>
|
||||
*/
|
||||
struct JbData
|
||||
{
|
||||
struct Pix *pix; /*!< template composite for all classes */
|
||||
l_int32 npages; /*!< number of pages */
|
||||
l_int32 w; /*!< max width of original page images */
|
||||
l_int32 h; /*!< max height of original page images */
|
||||
l_int32 nclass; /*!< number of classes */
|
||||
l_int32 latticew; /*!< lattice width for template composite */
|
||||
l_int32 latticeh; /*!< lattice height for template composite */
|
||||
struct Numa *naclass; /*!< array of class ids for each component */
|
||||
struct Numa *napage; /*!< array of page nums for each component */
|
||||
struct Pta *ptaul; /*!< array of UL corners at which the */
|
||||
/*!< template is to be placed for each */
|
||||
/*!< component */
|
||||
};
|
||||
typedef struct JbData JBDATA;
|
||||
|
||||
|
||||
/*! Classifier methods */
|
||||
enum {
|
||||
JB_RANKHAUS = 0,
|
||||
JB_CORRELATION = 1
|
||||
};
|
||||
|
||||
/*! For jbGetComponents(): type of component to extract from images */
|
||||
enum {
|
||||
JB_CONN_COMPS = 0,
|
||||
JB_CHARACTERS = 1,
|
||||
JB_WORDS = 2
|
||||
};
|
||||
|
||||
/*! These parameters are used for naming the two files
|
||||
* in which the jbig2-like compressed data is stored. */
|
||||
#define JB_TEMPLATE_EXT ".templates.png"
|
||||
#define JB_DATA_EXT ".data"
|
||||
|
||||
|
||||
#endif /* LEPTONICA_JBCLASS_H */
|
|
@ -0,0 +1,45 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef LEPTONICA_LEPTWIN_H
|
||||
#define LEPTONICA_LEPTWIN_H
|
||||
|
||||
#include "allheaders.h"
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
LEPT_DLL extern HBITMAP pixGetWindowsHBITMAP( PIX *pixs );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LEPTONICA_LEPTWIN_H */
|
||||
#endif /* _WIN32 */
|
|
@ -0,0 +1,90 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
|
||||
#ifndef LEPTONICA_LIST_H
|
||||
#define LEPTONICA_LIST_H
|
||||
|
||||
/*!
|
||||
* \file list.h
|
||||
*
|
||||
* <pre>
|
||||
* Cell for double-linked lists
|
||||
*
|
||||
* This allows composition of a list of cells with
|
||||
* prev, next and data pointers. Generic data
|
||||
* structures hang on the list cell data pointers.
|
||||
*
|
||||
* The list is not circular because that would add much
|
||||
* complexity in traversing the list under general
|
||||
* conditions where list cells can be added and removed.
|
||||
* The only disadvantage of not having the head point to
|
||||
* the last cell is that the list must be traversed to
|
||||
* find its tail. However, this traversal is fast, and
|
||||
* the listRemoveFromTail() function updates the tail
|
||||
* so there is no searching overhead with repeated use.
|
||||
*
|
||||
* The list macros are used to run through a list, and their
|
||||
* use is encouraged. They are invoked, e.g., as
|
||||
*
|
||||
* DLLIST *head, *elem;
|
||||
* ...
|
||||
* L_BEGIN_LIST_FORWARD(head, elem)
|
||||
* <do something with elem and/or elem->data >
|
||||
* L_END_LIST
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
struct DoubleLinkedList
|
||||
{
|
||||
struct DoubleLinkedList *prev;
|
||||
struct DoubleLinkedList *next;
|
||||
void *data;
|
||||
};
|
||||
typedef struct DoubleLinkedList DLLIST;
|
||||
|
||||
|
||||
/*! Simple list traverse macro - forward */
|
||||
#define L_BEGIN_LIST_FORWARD(head, element) \
|
||||
{ \
|
||||
DLLIST *_leptvar_nextelem_; \
|
||||
for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \
|
||||
_leptvar_nextelem_ = (element)->next;
|
||||
|
||||
|
||||
/*! Simple list traverse macro - reverse */
|
||||
#define L_BEGIN_LIST_REVERSE(tail, element) \
|
||||
{ \
|
||||
DLLIST *_leptvar_prevelem_; \
|
||||
for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \
|
||||
_leptvar_prevelem_ = (element)->prev;
|
||||
|
||||
|
||||
/*! Simple list traverse macro - end of a list traverse */
|
||||
#define L_END_LIST }}
|
||||
|
||||
|
||||
#endif /* LEPTONICA_LIST_H */
|
|
@ -0,0 +1,248 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_MORPH_H
|
||||
#define LEPTONICA_MORPH_H
|
||||
|
||||
/*!
|
||||
* \file morph.h
|
||||
*
|
||||
* <pre>
|
||||
* Contains the following structs:
|
||||
* struct Sel
|
||||
* struct Sela
|
||||
* struct Kernel
|
||||
*
|
||||
* Contains definitions for:
|
||||
* morphological b.c. flags
|
||||
* structuring element types
|
||||
* runlength flags for granulometry
|
||||
* direction flags for grayscale morphology
|
||||
* morphological operation flags
|
||||
* standard border size
|
||||
* grayscale intensity scaling flags
|
||||
* morphological tophat flags
|
||||
* arithmetic and logical operator flags
|
||||
* grayscale morphology selection flags
|
||||
* distance function b.c. flags
|
||||
* image comparison flags
|
||||
* color content flags
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Sel and Sel array *
|
||||
*-------------------------------------------------------------------------*/
|
||||
#define SEL_VERSION_NUMBER 1
|
||||
|
||||
/*! Selection */
|
||||
struct Sel
|
||||
{
|
||||
l_int32 sy; /*!< sel height */
|
||||
l_int32 sx; /*!< sel width */
|
||||
l_int32 cy; /*!< y location of sel origin */
|
||||
l_int32 cx; /*!< x location of sel origin */
|
||||
l_int32 **data; /*!< {0,1,2}; data[i][j] in [row][col] order */
|
||||
char *name; /*!< used to find sel by name */
|
||||
};
|
||||
typedef struct Sel SEL;
|
||||
|
||||
/*! Array of Sel */
|
||||
struct Sela
|
||||
{
|
||||
l_int32 n; /*!< number of sel actually stored */
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
struct Sel **sel; /*!< sel ptr array */
|
||||
};
|
||||
typedef struct Sela SELA;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Kernel *
|
||||
*-------------------------------------------------------------------------*/
|
||||
#define KERNEL_VERSION_NUMBER 2
|
||||
|
||||
/*! Kernel */
|
||||
struct L_Kernel
|
||||
{
|
||||
l_int32 sy; /*!< kernel height */
|
||||
l_int32 sx; /*!< kernel width */
|
||||
l_int32 cy; /*!< y location of kernel origin */
|
||||
l_int32 cx; /*!< x location of kernel origin */
|
||||
l_float32 **data; /*!< data[i][j] in [row][col] order */
|
||||
};
|
||||
typedef struct L_Kernel L_KERNEL;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Morphological boundary condition flags *
|
||||
* *
|
||||
* Two types of boundary condition for erosion. *
|
||||
* The global variable MORPH_BC takes on one of these two values. *
|
||||
* See notes in morph.c for usage. *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Morphological boundary condition flags */
|
||||
enum {
|
||||
SYMMETRIC_MORPH_BC = 0,
|
||||
ASYMMETRIC_MORPH_BC = 1
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Structuring element types *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Structuring element types */
|
||||
enum {
|
||||
SEL_DONT_CARE = 0,
|
||||
SEL_HIT = 1,
|
||||
SEL_MISS = 2
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Runlength flags for granulometry *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Runlength flags for granulometry */
|
||||
enum {
|
||||
L_RUN_OFF = 0,
|
||||
L_RUN_ON = 1
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Direction flags for grayscale morphology, granulometry, *
|
||||
* composable Sels, convolution, etc. *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Direction flags */
|
||||
enum {
|
||||
L_HORIZ = 1,
|
||||
L_VERT = 2,
|
||||
L_BOTH_DIRECTIONS = 3
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Morphological operation flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Morphological operation flags */
|
||||
enum {
|
||||
L_MORPH_DILATE = 1,
|
||||
L_MORPH_ERODE = 2,
|
||||
L_MORPH_OPEN = 3,
|
||||
L_MORPH_CLOSE = 4,
|
||||
L_MORPH_HMT = 5
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Grayscale intensity scaling flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Grayscale intensity scaling flags */
|
||||
enum {
|
||||
L_LINEAR_SCALE = 1,
|
||||
L_LOG_SCALE = 2
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Morphological tophat flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Morphological tophat flags */
|
||||
enum {
|
||||
L_TOPHAT_WHITE = 0,
|
||||
L_TOPHAT_BLACK = 1
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Arithmetic and logical operator flags *
|
||||
* (use on grayscale images and Numas) *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Arithmetic and logical operator flags */
|
||||
enum {
|
||||
L_ARITH_ADD = 1,
|
||||
L_ARITH_SUBTRACT = 2,
|
||||
L_ARITH_MULTIPLY = 3, /* on numas only */
|
||||
L_ARITH_DIVIDE = 4, /* on numas only */
|
||||
L_UNION = 5, /* on numas only */
|
||||
L_INTERSECTION = 6, /* on numas only */
|
||||
L_SUBTRACTION = 7, /* on numas only */
|
||||
L_EXCLUSIVE_OR = 8 /* on numas only */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Min/max selection flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Min/max selection flags */
|
||||
enum {
|
||||
L_CHOOSE_MIN = 1, /* useful in a downscaling "erosion" */
|
||||
L_CHOOSE_MAX = 2, /* useful in a downscaling "dilation" */
|
||||
L_CHOOSE_MAXDIFF = 3, /* useful in a downscaling contrast */
|
||||
L_CHOOSE_MIN_BOOST = 4, /* use a modification of the min value */
|
||||
L_CHOOSE_MAX_BOOST = 5 /* use a modification of the max value */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Distance function b.c. flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Distance function b.c. flags */
|
||||
enum {
|
||||
L_BOUNDARY_BG = 1, /* assume bg outside image */
|
||||
L_BOUNDARY_FG = 2 /* assume fg outside image */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Image comparison flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Image comparison flags */
|
||||
enum {
|
||||
L_COMPARE_XOR = 1,
|
||||
L_COMPARE_SUBTRACT = 2,
|
||||
L_COMPARE_ABS_DIFF = 3
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Color content flags *
|
||||
*-------------------------------------------------------------------------*/
|
||||
|
||||
/*! Color content flags */
|
||||
enum {
|
||||
L_MAX_DIFF_FROM_AVERAGE_2 = 1,
|
||||
L_MAX_MIN_DIFF_FROM_2 = 2,
|
||||
L_MAX_DIFF = 3
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Standard size of border added around images for special processing *
|
||||
*-------------------------------------------------------------------------*/
|
||||
static const l_int32 ADDED_BORDER = 32; /*!< pixels, not bits */
|
||||
|
||||
|
||||
#endif /* LEPTONICA_MORPH_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,95 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_PTRA_H
|
||||
#define LEPTONICA_PTRA_H
|
||||
|
||||
/*!
|
||||
* \file ptra.h
|
||||
*
|
||||
* <pre>
|
||||
* Contains the following structs:
|
||||
* struct L_Ptra
|
||||
* struct L_Ptraa
|
||||
*
|
||||
* Contains definitions for:
|
||||
* L_Ptra compaction flags for removal
|
||||
* L_Ptra shifting flags for insert
|
||||
* L_Ptraa accessor flags
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Generic Ptr Array Structs *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Generic pointer array */
|
||||
struct L_Ptra
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 imax; /*!< greatest valid index */
|
||||
l_int32 nactual; /*!< actual number of stored elements */
|
||||
void **array; /*!< ptr array */
|
||||
};
|
||||
typedef struct L_Ptra L_PTRA;
|
||||
|
||||
|
||||
/*! Array of generic pointer arrays */
|
||||
struct L_Ptraa
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
struct L_Ptra **ptra; /*!< array of ptra */
|
||||
};
|
||||
typedef struct L_Ptraa L_PTRAA;
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* Array flags *
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/*! Flags for removal from L_Ptra */
|
||||
enum {
|
||||
L_NO_COMPACTION = 1, /*!< null the pointer only */
|
||||
L_COMPACTION = 2 /*!< compact the array */
|
||||
};
|
||||
|
||||
/*! Flags for insertion into L_Ptra */
|
||||
enum {
|
||||
L_AUTO_DOWNSHIFT = 0, /*!< choose based on number of holes */
|
||||
L_MIN_DOWNSHIFT = 1, /*!< downshifts min # of ptrs below insert */
|
||||
L_FULL_DOWNSHIFT = 2 /*!< downshifts all ptrs below insert */
|
||||
};
|
||||
|
||||
/*! Accessor flags for L_Ptraa */
|
||||
enum {
|
||||
L_HANDLE_ONLY = 0, /*!< ptr to L_Ptra; caller can inspect only */
|
||||
L_REMOVE = 1 /*!< caller owns; destroy or save in L_Ptraa */
|
||||
};
|
||||
|
||||
|
||||
#endif /* LEPTONICA_PTRA_H */
|
|
@ -0,0 +1,77 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_QUEUE_H
|
||||
#define LEPTONICA_QUEUE_H
|
||||
|
||||
/*!
|
||||
* \file queue.h
|
||||
*
|
||||
* <pre>
|
||||
* Expandable pointer queue for arbitrary void* data.
|
||||
*
|
||||
* The L_Queue is a fifo that implements a queue of void* pointers.
|
||||
* It can be used to hold a queue of any type of struct.
|
||||
*
|
||||
* Internally, it maintains two counters:
|
||||
* nhead: location of head (in ptrs) from the beginning
|
||||
* of the array.
|
||||
* nelem: number of ptr elements stored in the queue.
|
||||
*
|
||||
* The element at the head of the queue, which is the next to
|
||||
* be removed, is array[nhead]. The location at the tail of the
|
||||
* queue to which the next element will be added is
|
||||
* array[nhead + nelem].
|
||||
*
|
||||
* As items are added to the queue, nelem increases.
|
||||
* As items are removed, nhead increases and nelem decreases.
|
||||
* Any time the tail reaches the end of the allocated array,
|
||||
* all the pointers are shifted to the left, so that the head
|
||||
* is at the beginning of the array.
|
||||
* If the array becomes more than 3/4 full, it doubles in size.
|
||||
*
|
||||
* The auxiliary stack can be used in a wrapper for re-using
|
||||
* items popped from the queue. It is not made by default.
|
||||
*
|
||||
* For further implementation details, see queue.c.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*! Expandable pointer queue for arbitrary void* data */
|
||||
struct L_Queue
|
||||
{
|
||||
l_int32 nalloc; /*!< size of allocated ptr array */
|
||||
l_int32 nhead; /*!< location of head (in ptrs) from the */
|
||||
/*!< beginning of the array */
|
||||
l_int32 nelem; /*!< number of elements stored in the queue */
|
||||
void **array; /*!< ptr array */
|
||||
struct L_Stack *stack; /*!< auxiliary stack */
|
||||
|
||||
};
|
||||
typedef struct L_Queue L_QUEUE;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_QUEUE_H */
|
|
@ -0,0 +1,90 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
/*
|
||||
* Modified from the excellent code here:
|
||||
* http://en.literateprograms.org/Red-black_tree_(C)?oldid=19567
|
||||
* which has been placed in the public domain under the Creative Commons
|
||||
* CC0 1.0 waiver (http://creativecommons.org/publicdomain/zero/1.0/).
|
||||
*
|
||||
* When the key is generated from a hash (e.g., string --> uint64),
|
||||
* there is always the possibility of having collisions, but to make
|
||||
* the collision probability very low requires using a large hash.
|
||||
* For that reason, the key types are 64 bit quantities, which will result
|
||||
* in a negligible probabililty of collisions for millions of hashed values.
|
||||
* Using 8 byte keys instead of 4 byte keys requires a little more
|
||||
* storage, but the simplification in being able to ignore collisions
|
||||
* with the red-black trees for most applications is worth it.
|
||||
*/
|
||||
|
||||
#ifndef LEPTONICA_RBTREE_H
|
||||
#define LEPTONICA_RBTREE_H
|
||||
|
||||
/*! The three valid key types for red-black trees, maps and sets. */
|
||||
enum {
|
||||
L_INT_TYPE = 1,
|
||||
L_UINT_TYPE = 2,
|
||||
L_FLOAT_TYPE = 3
|
||||
};
|
||||
|
||||
/*!
|
||||
* Storage for keys and values for red-black trees, maps and sets.
|
||||
* <pre>
|
||||
* Note:
|
||||
* (1) Keys and values of the valid key types are all 64-bit
|
||||
* (2) (void *) can be used for values but not for keys.
|
||||
* </pre>
|
||||
*/
|
||||
union Rb_Type {
|
||||
l_int64 itype;
|
||||
l_uint64 utype;
|
||||
l_float64 ftype;
|
||||
void *ptype;
|
||||
};
|
||||
typedef union Rb_Type RB_TYPE;
|
||||
|
||||
struct L_Rbtree {
|
||||
struct L_Rbtree_Node *root;
|
||||
l_int32 keytype;
|
||||
};
|
||||
typedef struct L_Rbtree L_RBTREE;
|
||||
typedef struct L_Rbtree L_AMAP; /* hide underlying implementation for map */
|
||||
typedef struct L_Rbtree L_ASET; /* hide underlying implementation for set */
|
||||
|
||||
struct L_Rbtree_Node {
|
||||
union Rb_Type key;
|
||||
union Rb_Type value;
|
||||
struct L_Rbtree_Node *left;
|
||||
struct L_Rbtree_Node *right;
|
||||
struct L_Rbtree_Node *parent;
|
||||
l_int32 color;
|
||||
};
|
||||
typedef struct L_Rbtree_Node L_RBTREE_NODE;
|
||||
typedef struct L_Rbtree_Node L_AMAP_NODE; /* hide tree implementation */
|
||||
typedef struct L_Rbtree_Node L_ASET_NODE; /* hide tree implementation */
|
||||
|
||||
|
||||
#endif /* LEPTONICA_RBTREE_H */
|
|
@ -0,0 +1,239 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_READBARCODE_H
|
||||
#define LEPTONICA_READBARCODE_H
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Flags for method of extracting barcode widths *
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/*! Flags for method of extracting barcode widths */
|
||||
enum {
|
||||
L_USE_WIDTHS = 1, /*!< use histogram of barcode widths */
|
||||
L_USE_WINDOWS = 2 /*!< find best window for decoding transitions */
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Flags for barcode formats *
|
||||
* These are used both to identify a barcode format and to identify *
|
||||
* the decoding method to use on a barcode. *
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/*! Flags for barcode formats */
|
||||
enum {
|
||||
L_BF_UNKNOWN = 0, /*!< unknown format */
|
||||
L_BF_ANY = 1, /*!< try decoding with all known formats */
|
||||
L_BF_CODE128 = 2, /*!< decode with Code128 format */
|
||||
L_BF_EAN8 = 3, /*!< decode with EAN8 format */
|
||||
L_BF_EAN13 = 4, /*!< decode with EAN13 format */
|
||||
L_BF_CODE2OF5 = 5, /*!< decode with Code 2 of 5 format */
|
||||
L_BF_CODEI2OF5 = 6, /*!< decode with Interleaved 2 of 5 format */
|
||||
L_BF_CODE39 = 7, /*!< decode with Code39 format */
|
||||
L_BF_CODE93 = 8, /*!< decode with Code93 format */
|
||||
L_BF_CODABAR = 9, /*!< decode with Code93 format */
|
||||
L_BF_UPCA = 10 /*!< decode with UPC A format */
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Currently supported formats *
|
||||
* Update these arrays as new formats are added. *
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/*! Currently supported formats */
|
||||
static const l_int32 SupportedBarcodeFormat[] = {
|
||||
L_BF_CODE2OF5,
|
||||
L_BF_CODEI2OF5,
|
||||
L_BF_CODE93,
|
||||
L_BF_CODE39,
|
||||
L_BF_CODABAR,
|
||||
L_BF_UPCA,
|
||||
L_BF_EAN13
|
||||
};
|
||||
|
||||
/*! Currently supported format names */
|
||||
static const char *SupportedBarcodeFormatName[] = {
|
||||
"Code2of5",
|
||||
"CodeI2of5",
|
||||
"Code93",
|
||||
"Code39",
|
||||
"Codabar",
|
||||
"Upca",
|
||||
"Ean13"
|
||||
};
|
||||
static const l_int32 NumSupportedBarcodeFormats = 7; /*!< Number of formats */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Code 2 of 5 symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Code2of5[] = {
|
||||
"111121211", "211111112", "112111112", "212111111", /* 0 - 3 */
|
||||
"111121112", "211121111", "112121111", "111111212", /* 4 - 7 */
|
||||
"211111211", "112111211", /* 8 - 9 */
|
||||
"21211", "21112" /* Start, Stop */
|
||||
};
|
||||
|
||||
static const l_int32 C25_START = 10;
|
||||
static const l_int32 C25_STOP = 11;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Code Interleaved 2 of 5 symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *CodeI2of5[] = {
|
||||
"11221", "21112", "12112", "22111", "11212", /* 0 - 4 */
|
||||
"21211", "12211", "11122", "21121", "12121", /* 5 - 9 */
|
||||
"1111", "211" /* start, stop */
|
||||
};
|
||||
|
||||
static const l_int32 CI25_START = 10;
|
||||
static const l_int32 CI25_STOP = 11;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Code 93 symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Code93[] = {
|
||||
"131112", "111213", "111312", "111411", "121113", /* 0: 0 - 4 */
|
||||
"121212", "121311", "111114", "131211", "141111", /* 5: 5 - 9 */
|
||||
"211113", "211212", "211311", "221112", "221211", /* 10: A - E */
|
||||
"231111", "112113", "112212", "112311", "122112", /* 15: F - J */
|
||||
"132111", "111123", "111222", "111321", "121122", /* 20: K - O */
|
||||
"131121", "212112", "212211", "211122", "211221", /* 25: P - T */
|
||||
"221121", "222111", "112122", "112221", "122121", /* 30: U - Y */
|
||||
"123111", "121131", "311112", "311211", "321111", /* 35: Z,-,.,SP,$ */
|
||||
"112131", "113121", "211131", "131221", "312111", /* 40: /,+,%,($),(%) */
|
||||
"311121", "122211", "111141" /* 45: (/),(+), Start */
|
||||
};
|
||||
|
||||
/* Use "[]{}#" to represent special codes 43-47 */
|
||||
static const char Code93Val[] =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%[]{}#";
|
||||
|
||||
static const l_int32 C93_START = 47;
|
||||
static const l_int32 C93_STOP = 47;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Code 39 symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Code39[] = {
|
||||
"111221211", "211211112", "112211112", "212211111", /* 0: 0 - 3 */
|
||||
"111221112", "211221111", "112221111", "111211212", /* 4: 4 - 7 */
|
||||
"211211211", "112211211", "211112112", "112112112", /* 8: 8 - B */
|
||||
"212112111", "111122112", "211122111", "112122111", /* 12: C - F */
|
||||
"111112212", "211112211", "112112211", "111122211", /* 16: G - J */
|
||||
"211111122", "112111122", "212111121", "111121122", /* 20: K - N */
|
||||
"211121121", "112121121", "111111222", "211111221", /* 24: O - R */
|
||||
"112111221", "111121221", "221111112", "122111112", /* 28: S - V */
|
||||
"222111111", "121121112", "221121111", "122121111", /* 32: W - Z */
|
||||
"121111212", "221111211", "122111211", "121212111", /* 36: -,.,SP,$ */
|
||||
"121211121", "121112121", "111212121", "121121211" /* 40: /,+,%,* */
|
||||
};
|
||||
|
||||
/* Use "*" to represent the Start and Stop codes (43) */
|
||||
static const char Code39Val[] =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";
|
||||
|
||||
static const l_int32 C39_START = 43;
|
||||
static const l_int32 C39_STOP = 43;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Codabar symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Codabar[] = {
|
||||
"1111122", "1111221", "1112112", "2211111", "1121121", /* 0: 0 - 4 */
|
||||
"2111121", "1211112", "1211211", "1221111", "2112111", /* 5: 5 - 9 */
|
||||
"1112211", "1122111", "2111212", "2121112", "2121211", /* 10: -,$,:,/,. */
|
||||
"1121212", "1122121", "1212112", "1112122", "1112221" /* 15: +,A,B,C,D */
|
||||
};
|
||||
|
||||
/* Ascii representations for codes 16-19: (A or T), (B or N), (C or *),
|
||||
* (D or E). These are used in pairs for the Start and Stop codes. */
|
||||
static const char CodabarVal[] = "0123456789-$:/.+ABCD";
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* UPC-A symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Upca[] = {
|
||||
"3211", "2221", "2122", "1411", "1132", /* 0: 0 - 4 */
|
||||
"1231", "1114", "1312", "1213", "3112", /* 5: 5 - 9 */
|
||||
"111", "111", "11111" /* 10: Start, Stop, Mid */
|
||||
};
|
||||
|
||||
static const l_int32 UPCA_START = 10;
|
||||
static const l_int32 UPCA_STOP = 11;
|
||||
static const l_int32 UPCA_MID = 12;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- *
|
||||
* Code128 symbology *
|
||||
* ----------------------------------------------------------------- */
|
||||
static const char *Code128[] = {
|
||||
"212222", "222122", "222221", "121223", "121322", /* 0 - 4 */
|
||||
"131222", "122213", "122312", "132212", "221213", /* 5 - 9 */
|
||||
"221312", "231212", "112232", "122132", "122231", /* 10 - 14 */
|
||||
"113222", "123122", "123221", "223211", "221132", /* 15 - 19 */
|
||||
"221231", "213212", "223112", "312131", "311222", /* 20 - 24 */
|
||||
"321122", "321221", "312212", "322112", "322211", /* 25 - 29 */
|
||||
"212123", "212321", "232121", "111323", "131123", /* 30 - 34 */
|
||||
"131321", "112313", "132113", "132311", "211313", /* 35 - 39 */
|
||||
"231113", "231311", "112133", "112331", "132131", /* 40 - 44 */
|
||||
"113123", "113321", "133121", "313121", "211331", /* 45 - 49 */
|
||||
"231131", "213113", "213311", "213131", "311123", /* 50 - 54 */
|
||||
"311321", "331121", "312113", "312311", "332111", /* 55 - 59 */
|
||||
"314111", "221411", "431111", "111224", "111422", /* 60 - 64 */
|
||||
"121124", "121421", "141122", "141221", "112214", /* 65 - 69 */
|
||||
"112412", "122114", "122411", "142112", "142211", /* 70 - 74 */
|
||||
"241211", "221114", "413111", "241112", "134111", /* 75 - 79 */
|
||||
"111242", "121142", "121241", "114212", "124112", /* 80 - 84 */
|
||||
"124211", "411212", "421112", "421211", "212141", /* 85 - 89 */
|
||||
"214121", "412121", "111143", "111341", "131141", /* 90 - 94 */
|
||||
"114113", "114311", "411113", "411311", "113141", /* 95 - 99 */
|
||||
"114131", "311141", "411131", "211412", "211214", /* 100 - 104 */
|
||||
"211232", "2331112" /* 105 - 106 */
|
||||
};
|
||||
|
||||
static const l_int32 C128_FUN_3 = 96; /* in A or B only; in C it is 96 */
|
||||
static const l_int32 C128_FUNC_2 = 97; /* in A or B only; in C it is 97 */
|
||||
static const l_int32 C128_SHIFT = 98; /* in A or B only; in C it is 98 */
|
||||
static const l_int32 C128_GOTO_C = 99; /* in A or B only; in C it is 99 */
|
||||
static const l_int32 C128_GOTO_B = 100;
|
||||
static const l_int32 C128_GOTO_A = 101;
|
||||
static const l_int32 C128_FUNC_1 = 102;
|
||||
static const l_int32 C128_START_A = 103;
|
||||
static const l_int32 C128_START_B = 104;
|
||||
static const l_int32 C128_START_C = 105;
|
||||
static const l_int32 C128_STOP = 106;
|
||||
/* code 128 symbols are 11 units */
|
||||
static const l_int32 C128_SYMBOL_WIDTH = 11;
|
||||
|
||||
|
||||
|
||||
#endif /* LEPTONICA_READBARCODE_H */
|
|
@ -0,0 +1,263 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_RECOG_H
|
||||
#define LEPTONICA_RECOG_H
|
||||
|
||||
/*!
|
||||
* \file recog.h
|
||||
*
|
||||
* <pre>
|
||||
* This is a simple utility for training and recognizing individual
|
||||
* machine-printed text characters. It is designed to be adapted
|
||||
* to a particular set of character images; e.g., from a book.
|
||||
*
|
||||
* There are two methods of training the recognizer. In the most
|
||||
* simple, a set of bitmaps has been labeled by some means, such
|
||||
* a generic OCR program. This is input either one template at a time
|
||||
* or as a pixa of templates, to a function that creates a recog.
|
||||
* If in a pixa, the text string label must be embedded in the
|
||||
* text field of each pix.
|
||||
*
|
||||
* If labeled data is not available, we start with a bootstrap
|
||||
* recognizer (BSR) that has labeled data from a variety of sources.
|
||||
* These images are scaled, typically to a fixed height, and then
|
||||
* fed similarly scaled unlabeled images from the source (e.g., book),
|
||||
* and the BSR attempts to identify them. All images that have
|
||||
* a high enough correlation score with one of the templates in the
|
||||
* BSR are emitted in a pixa, which now holds unscaled and labeled
|
||||
* templates from the source. This is the generator for a book adapted
|
||||
* recognizer (BAR).
|
||||
*
|
||||
* The pixa should always be thought of as the primary structure.
|
||||
* It is the generator for the recog, because a recog is built
|
||||
* from a pixa of unscaled images.
|
||||
*
|
||||
* New image templates can be added to a recog as long as it is
|
||||
* in training mode. Once training is finished, to add templates
|
||||
* it is necessary to extract the generating pixa, add templates
|
||||
* to that pixa, and make a new recog. Similarly, we do not
|
||||
* join two recog; instead, we simply join their generating pixa,
|
||||
* and make a recog from that.
|
||||
*
|
||||
* To remove outliers from a pixa of labeled pix, make a recog,
|
||||
* determine the outliers, and generate a new pixa with the
|
||||
* outliers removed. The outliers are determined by building
|
||||
* special templates for each character set that are scaled averages
|
||||
* of the individual templates. Then a correlation score is found
|
||||
* between each template and the averaged templates. There are
|
||||
* two implementations; outliers are determined as either:
|
||||
* (1) a template having a correlation score with its class average
|
||||
* that is below a threshold, or
|
||||
* (2) a template having a correlation score with its class average
|
||||
* that is smaller than the correlation score with the average
|
||||
* of another class.
|
||||
* Outliers are removed from the generating pixa. Scaled averaging
|
||||
* is only performed for determining outliers and for splitting
|
||||
* characters; it is never used in a trained recognizer for identifying
|
||||
* unlabeled samples.
|
||||
*
|
||||
* Two methods using averaged templates are provided for splitting
|
||||
* touching characters:
|
||||
* (1) greedy matching
|
||||
* (2) document image decoding (DID)
|
||||
* The DID method is the default. It is about 5x faster and
|
||||
* possibly more accurate.
|
||||
*
|
||||
* Once a BAR has been made, unlabeled sample images are identified
|
||||
* by finding the individual template in the BAR with highest
|
||||
* correlation. The input images and images in the BAR can be
|
||||
* represented in two ways:
|
||||
* (1) as scanned, binarized to 1 bpp
|
||||
* (2) as a width-normalized outline formed by thinning to a
|
||||
* skeleton and then dilating by a fixed amount.
|
||||
*
|
||||
* The recog can be serialized to file and read back. The serialized
|
||||
* version holds the templates used for correlation (which may have
|
||||
* been modified by scaling and turning into lines from the unscaled
|
||||
* templates), plus, for arbitrary character sets, the UTF8
|
||||
* representation and the lookup table mapping from the character
|
||||
* representation to index.
|
||||
*
|
||||
* Why do we not use averaged templates for recognition?
|
||||
* Letterforms can take on significantly different shapes (eg.,
|
||||
* the letters 'a' and 'g'), and it makes no sense to average these.
|
||||
* The previous version of this utility allowed multiple recognizers
|
||||
* to exist, but this is an unnecessary complication if recognition
|
||||
* is done on all samples instead of on averages.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
#define RECOG_VERSION_NUMBER 2
|
||||
|
||||
struct L_Recog {
|
||||
l_int32 scalew; /*!< scale all examples to this width; */
|
||||
/*!< use 0 prevent horizontal scaling */
|
||||
l_int32 scaleh; /*!< scale all examples to this height; */
|
||||
/*!< use 0 prevent vertical scaling */
|
||||
l_int32 linew; /*!< use a value > 0 to convert the bitmap */
|
||||
/*!< to lines of fixed width; 0 to skip */
|
||||
l_int32 templ_use; /*!< template use: use either the average */
|
||||
/*!< or all temmplates (L_USE_AVERAGE or */
|
||||
/*!< L_USE_ALL) */
|
||||
l_int32 maxarraysize; /*!< initialize container arrays to this */
|
||||
l_int32 setsize; /*!< size of character set */
|
||||
l_int32 threshold; /*!< for binarizing if depth > 1 */
|
||||
l_int32 maxyshift; /*!< vertical jiggle on nominal centroid */
|
||||
/*!< alignment; typically 0 or 1 */
|
||||
l_int32 charset_type; /*!< one of L_ARABIC_NUMERALS, etc. */
|
||||
l_int32 charset_size; /*!< expected number of classes in charset */
|
||||
l_int32 min_nopad; /*!< min number of samples without padding */
|
||||
l_int32 num_samples; /*!< number of training samples */
|
||||
l_int32 minwidth_u; /*!< min width averaged unscaled templates */
|
||||
l_int32 maxwidth_u; /*!< max width averaged unscaled templates */
|
||||
l_int32 minheight_u; /*!< min height averaged unscaled templates */
|
||||
l_int32 maxheight_u; /*!< max height averaged unscaled templates */
|
||||
l_int32 minwidth; /*!< min width averaged scaled templates */
|
||||
l_int32 maxwidth; /*!< max width averaged scaled templates */
|
||||
l_int32 ave_done; /*!< set to 1 when averaged bitmaps are made */
|
||||
l_int32 train_done; /*!< set to 1 when training is complete or */
|
||||
/*!< identification has started */
|
||||
l_float32 max_wh_ratio; /*!< max width/height ratio to split */
|
||||
l_float32 max_ht_ratio; /*!< max of max/min template height ratio */
|
||||
l_int32 min_splitw; /*!< min component width kept in splitting */
|
||||
l_int32 max_splith; /*!< max component height kept in splitting */
|
||||
struct Sarray *sa_text; /*!< text array for arbitrary char set */
|
||||
struct L_Dna *dna_tochar; /*!< index-to-char lut for arbitrary charset */
|
||||
l_int32 *centtab; /*!< table for finding centroids */
|
||||
l_int32 *sumtab; /*!< table for finding pixel sums */
|
||||
struct Pixaa *pixaa_u; /*!< all unscaled templates for each class */
|
||||
struct Ptaa *ptaa_u; /*!< centroids of all unscaled templates */
|
||||
struct Numaa *naasum_u; /*!< area of all unscaled templates */
|
||||
struct Pixaa *pixaa; /*!< all (scaled) templates for each class */
|
||||
struct Ptaa *ptaa; /*!< centroids of all (scaledl) templates */
|
||||
struct Numaa *naasum; /*!< area of all (scaled) templates */
|
||||
struct Pixa *pixa_u; /*!< averaged unscaled templates per class */
|
||||
struct Pta *pta_u; /*!< centroids of unscaled ave. templates */
|
||||
struct Numa *nasum_u; /*!< area of unscaled averaged templates */
|
||||
struct Pixa *pixa; /*!< averaged (scaled) templates per class */
|
||||
struct Pta *pta; /*!< centroids of (scaled) ave. templates */
|
||||
struct Numa *nasum; /*!< area of (scaled) averaged templates */
|
||||
struct Pixa *pixa_tr; /*!< all input training images */
|
||||
struct Pixa *pixadb_ave; /*!< unscaled and scaled averaged bitmaps */
|
||||
struct Pixa *pixa_id; /*!< input images for identifying */
|
||||
struct Pix *pixdb_ave; /*!< debug: best match of input against ave. */
|
||||
struct Pix *pixdb_range; /*!< debug: best matches within range */
|
||||
struct Pixa *pixadb_boot; /*!< debug: bootstrap training results */
|
||||
struct Pixa *pixadb_split; /*!< debug: splitting results */
|
||||
struct L_Bmf *bmf; /*!< bmf fonts */
|
||||
l_int32 bmf_size; /*!< font size of bmf; default is 6 pt */
|
||||
struct L_Rdid *did; /*!< temp data used for image decoding */
|
||||
struct L_Rch *rch; /*!< temp data used for holding best char */
|
||||
struct L_Rcha *rcha; /*!< temp data used for array of best chars */
|
||||
};
|
||||
typedef struct L_Recog L_RECOG;
|
||||
|
||||
/*!
|
||||
* Data returned from correlation matching on a single character
|
||||
*/
|
||||
struct L_Rch {
|
||||
l_int32 index; /*!< index of best template */
|
||||
l_float32 score; /*!< correlation score of best template */
|
||||
char *text; /*!< character string of best template */
|
||||
l_int32 sample; /*!< index of best sample (within the best */
|
||||
/*!< template class, if all samples are used) */
|
||||
l_int32 xloc; /*!< x-location of template (delx + shiftx) */
|
||||
l_int32 yloc; /*!< y-location of template (dely + shifty) */
|
||||
l_int32 width; /*!< width of best template */
|
||||
};
|
||||
typedef struct L_Rch L_RCH;
|
||||
|
||||
/*!
|
||||
* Data returned from correlation matching on an array of characters
|
||||
*/
|
||||
struct L_Rcha {
|
||||
struct Numa *naindex; /*!< indices of best templates */
|
||||
struct Numa *nascore; /*!< correlation scores of best templates */
|
||||
struct Sarray *satext; /*!< character strings of best templates */
|
||||
struct Numa *nasample; /*!< indices of best samples */
|
||||
struct Numa *naxloc; /*!< x-locations of templates (delx + shiftx) */
|
||||
struct Numa *nayloc; /*!< y-locations of templates (dely + shifty) */
|
||||
struct Numa *nawidth; /*!< widths of best templates */
|
||||
};
|
||||
typedef struct L_Rcha L_RCHA;
|
||||
|
||||
/*!
|
||||
* Data used for decoding a line of characters.
|
||||
*/
|
||||
struct L_Rdid {
|
||||
struct Pix *pixs; /*!< clone of pix to be decoded */
|
||||
l_int32 **counta; /*!< count array for each averaged template */
|
||||
l_int32 **delya; /*!< best y-shift array per average template */
|
||||
l_int32 narray; /*!< number of averaged templates */
|
||||
l_int32 size; /*!< size of count array (width of pixs) */
|
||||
l_int32 *setwidth; /*!< setwidths for each template */
|
||||
struct Numa *nasum; /*!< pixel count in pixs by column */
|
||||
struct Numa *namoment; /*!< first moment of pixels in pixs by cols */
|
||||
l_int32 fullarrays; /*!< 1 if full arrays are made; 0 otherwise */
|
||||
l_float32 *beta; /*!< channel coeffs for template fg term */
|
||||
l_float32 *gamma; /*!< channel coeffs for bit-and term */
|
||||
l_float32 *trellisscore; /*!< score on trellis */
|
||||
l_int32 *trellistempl; /*!< template on trellis (for backtrack) */
|
||||
struct Numa *natempl; /*!< indices of best path templates */
|
||||
struct Numa *naxloc; /*!< x locations of best path templates */
|
||||
struct Numa *nadely; /*!< y locations of best path templates */
|
||||
struct Numa *nawidth; /*!< widths of best path templates */
|
||||
struct Boxa *boxa; /*!< Viterbi result for splitting input pixs */
|
||||
struct Numa *nascore; /*!< correlation scores: best path templates */
|
||||
struct Numa *natempl_r; /*!< indices of best rescored templates */
|
||||
struct Numa *nasample_r; /*!< samples of best scored templates */
|
||||
struct Numa *naxloc_r; /*!< x locations of best rescoredtemplates */
|
||||
struct Numa *nadely_r; /*!< y locations of best rescoredtemplates */
|
||||
struct Numa *nawidth_r; /*!< widths of best rescoredtemplates */
|
||||
struct Numa *nascore_r; /*!< correlation scores: rescored templates */
|
||||
};
|
||||
typedef struct L_Rdid L_RDID;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Flags for describing limited character sets *
|
||||
*-------------------------------------------------------------------------*/
|
||||
/*! Flags for describing limited character sets */
|
||||
enum {
|
||||
L_UNKNOWN = 0, /*!< character set type is not specified */
|
||||
L_ARABIC_NUMERALS = 1, /*!< 10 digits */
|
||||
L_LC_ROMAN_NUMERALS = 2, /*!< 7 lower-case letters (i,v,x,l,c,d,m) */
|
||||
L_UC_ROMAN_NUMERALS = 3, /*!< 7 upper-case letters (I,V,X,L,C,D,M) */
|
||||
L_LC_ALPHA = 4, /*!< 26 lower-case letters */
|
||||
L_UC_ALPHA = 5 /*!< 26 upper-case letters */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*
|
||||
* Flags for selecting between using average and all templates *
|
||||
*-------------------------------------------------------------------------*/
|
||||
/*! Flags for selecting average or all templates: recog->templ_use */
|
||||
enum {
|
||||
L_USE_ALL_TEMPLATES = 0, /*!< use all templates; default */
|
||||
L_USE_AVERAGE_TEMPLATES = 1 /*!< use average templates; special cases */
|
||||
};
|
||||
|
||||
#endif /* LEPTONICA_RECOG_H */
|
|
@ -0,0 +1,140 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_REGUTILS_H
|
||||
#define LEPTONICA_REGUTILS_H
|
||||
|
||||
/*!
|
||||
* \file regutils.h
|
||||
*
|
||||
* <pre>
|
||||
* Contains this regression test parameter packaging struct
|
||||
* struct L_RegParams
|
||||
*
|
||||
* The regression test utility allows you to write regression tests
|
||||
* that compare results with existing "golden files" and with
|
||||
* compiled in data.
|
||||
*
|
||||
* Regression tests can be called in three ways.
|
||||
* For example, for distance_reg:
|
||||
*
|
||||
* Case 1: distance_reg [compare]
|
||||
* This runs the test against the set of golden files. It
|
||||
* appends to 'outfile.txt' either "SUCCESS" or "FAILURE",
|
||||
* as well as the details of any parts of the test that failed.
|
||||
* It writes to a temporary file stream (fp).
|
||||
* Using 'compare' on the command line is optional.
|
||||
*
|
||||
* Case 2: distance_reg generate
|
||||
* This generates golden files in /tmp for the reg test.
|
||||
*
|
||||
* Case 3: distance_reg display
|
||||
* This runs the test but makes no comparison of the output
|
||||
* against the set of golden files. In addition, this displays
|
||||
* images and plots that are specified in the test under
|
||||
* control of the display variable. Display is enabled only
|
||||
* for this case.
|
||||
*
|
||||
* Regression tests follow the pattern given below. Tests are
|
||||
* automatically numbered sequentially, and it is convenient to
|
||||
* comment each with a number to keep track (for comparison tests
|
||||
* and for debugging). In an actual case, comparisons of pix and
|
||||
* of files can occur in any order. We give a specific order here
|
||||
* for clarity.
|
||||
*
|
||||
* L_REGPARAMS *rp; // holds data required by the test functions
|
||||
*
|
||||
* // Setup variables; optionally open stream
|
||||
* if (regTestSetup(argc, argv, &rp))
|
||||
* return 1;
|
||||
*
|
||||
* // Test pairs of generated pix for identity. This compares
|
||||
* // two pix; no golden file is generated.
|
||||
* regTestComparePix(rp, pix1, pix2); // 0
|
||||
*
|
||||
* // Test pairs of generated pix for similarity. This compares
|
||||
* // two pix; no golden file is generated. The last arg determines
|
||||
* // if stats are to be written to stderr.
|
||||
* regTestCompareSimilarPix(rp, pix1, pix2, 15, 0.001, 0); // 1
|
||||
*
|
||||
* // Generation of <newfile*> outputs and testing for identity
|
||||
* // These files can be anything, of course.
|
||||
* regTestCheckFile(rp, <newfile0>); // 2
|
||||
* regTestCheckFile(rp, <newfile1>); // 3
|
||||
*
|
||||
* // Test pairs of output golden files for identity. Here we
|
||||
* // are comparing golden files 2 and 3.
|
||||
* regTestCompareFiles(rp, 2, 3); // 4
|
||||
*
|
||||
* // "Write and check". This writes a pix using a canonical
|
||||
* // formulation for the local filename and either:
|
||||
* // case 1: generates a golden file
|
||||
* // case 2: compares the local file with a golden file
|
||||
* // case 3: generates local files and displays
|
||||
* // Here we write the pix compressed with png and jpeg, respectively;
|
||||
* // Then check against the golden file. The internal %index
|
||||
* // is incremented; it is embedded in the local filename and,
|
||||
* // if generating, in the golden file as well.
|
||||
* regTestWritePixAndCheck(rp, pix1, IFF_PNG); // 5
|
||||
* regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); // 6
|
||||
*
|
||||
* // Display if reg test was called in 'display' mode
|
||||
* pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);
|
||||
*
|
||||
* // Clean up and output result
|
||||
* regTestCleanup(rp);
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* Regression test parameter packer *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*! Regression test parameter packer */
|
||||
struct L_RegParams
|
||||
{
|
||||
FILE *fp; /*!< stream to temporary output file for compare mode */
|
||||
char *testname; /*!< name of test, without '_reg' */
|
||||
char *tempfile; /*!< name of temp file for compare mode output */
|
||||
l_int32 mode; /*!< generate, compare or display */
|
||||
l_int32 index; /*!< index into saved files for this test; 0-based */
|
||||
l_int32 success; /*!< overall result of the test */
|
||||
l_int32 display; /*!< 1 if in display mode; 0 otherwise */
|
||||
L_TIMER tstart; /*!< marks beginning of the reg test */
|
||||
};
|
||||
typedef struct L_RegParams L_REGPARAMS;
|
||||
|
||||
|
||||
/*! Running modes for the test */
|
||||
enum {
|
||||
L_REG_GENERATE = 0,
|
||||
L_REG_COMPARE = 1,
|
||||
L_REG_DISPLAY = 2
|
||||
};
|
||||
|
||||
|
||||
#endif /* LEPTONICA_REGUTILS_H */
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_STACK_H
|
||||
#define LEPTONICA_STACK_H
|
||||
|
||||
/*!
|
||||
* \file stack.h
|
||||
*
|
||||
* <pre>
|
||||
* Expandable pointer stack for arbitrary void* data.
|
||||
*
|
||||
* The L_Stack is an array of void * ptrs, onto which arbitrary
|
||||
* objects can be stored. At any time, the number of
|
||||
* stored objects is stack->n. The object at the bottom
|
||||
* of the stack is at array[0]; the object at the top of
|
||||
* the stack is at array[n-1]. New objects are added
|
||||
* to the top of the stack, at the first available location,
|
||||
* which is array[n]. Objects are removed from the top of the
|
||||
* stack. When an attempt is made to remove an object from an
|
||||
* empty stack, the result is null. When the stack becomes
|
||||
* filled, so that n = nalloc, the size is doubled.
|
||||
*
|
||||
* The auxiliary stack can be used to store and remove
|
||||
* objects for re-use. It must be created by a separate
|
||||
* call to pstackCreate(). [Just imagine the chaos if
|
||||
* pstackCreate() created the auxiliary stack!]
|
||||
* pstackDestroy() checks for the auxiliary stack and removes it.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
||||
/*! Expandable pointer stack for arbitrary void* data.
|
||||
* Note that array[n] is the first null ptr in the array
|
||||
*/
|
||||
struct L_Stack
|
||||
{
|
||||
l_int32 nalloc; /*!< size of ptr array */
|
||||
l_int32 n; /*!< number of stored elements */
|
||||
void **array; /*!< ptr array */
|
||||
struct L_Stack *auxstack; /*!< auxiliary stack */
|
||||
};
|
||||
typedef struct L_Stack L_STACK;
|
||||
|
||||
|
||||
#endif /* LEPTONICA_STACK_H */
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_STRINGCODE_H
|
||||
#define LEPTONICA_STRINGCODE_H
|
||||
|
||||
/*!
|
||||
* \file stringcode.h
|
||||
*
|
||||
* Data structure to hold accumulating generated code for storing
|
||||
* and extracing serializable leptonica objects (e.g., pixa, recog).
|
||||
*
|
||||
* Also a flag for selecting a string from the L_GenAssoc struct
|
||||
* in stringcode.
|
||||
*/
|
||||
|
||||
struct L_StrCode
|
||||
{
|
||||
l_int32 fileno; /*!< index for function and output file names */
|
||||
l_int32 ifunc; /*!< index into struct currently being stored */
|
||||
SARRAY *function; /*!< store case code for extraction */
|
||||
SARRAY *data; /*!< store base64 encoded data as strings */
|
||||
SARRAY *descr; /*!< store line in description table */
|
||||
l_int32 n; /*!< number of data strings */
|
||||
};
|
||||
typedef struct L_StrCode L_STRCODE;
|
||||
|
||||
|
||||
/*! Select string in stringcode for a specific serializable data type */
|
||||
enum {
|
||||
L_STR_TYPE = 0, /*!< typedef for the data type */
|
||||
L_STR_NAME = 1, /*!< name of the data type */
|
||||
L_STR_READER = 2, /*!< reader to get the data type from file */
|
||||
L_STR_MEMREADER = 3 /*!< reader to get the compressed string in memory */
|
||||
};
|
||||
|
||||
#endif /* LEPTONICA_STRINGCODE_H */
|
|
@ -0,0 +1,76 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef SUDOKU_H_INCLUDED
|
||||
#define SUDOKU_H_INCLUDED
|
||||
|
||||
/*!
|
||||
* \file sudoku.h
|
||||
*
|
||||
* <pre>
|
||||
* The L_Sudoku holds all the information of the current state.
|
||||
*
|
||||
* The input to sudokuCreate() is a file with any number of lines
|
||||
* starting with '#', followed by 9 lines consisting of 9 numbers
|
||||
* in each line. These have the known values and use 0 for the unknowns.
|
||||
* Blank lines are ignored.
|
||||
*
|
||||
* The %locs array holds the indices of the unknowns, numbered
|
||||
* left-to-right and top-to-bottom from 0 to 80. The array size
|
||||
* is initialized to %num. %current is the index into the %locs
|
||||
* array of the current guess: locs[current].
|
||||
*
|
||||
* The %state array is used to determine the validity of each guess.
|
||||
* It is of size 81, and is initialized by setting the unknowns to 0
|
||||
* and the knowns to their input values.
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
struct L_Sudoku
|
||||
{
|
||||
l_int32 num; /*!< number of unknowns */
|
||||
l_int32 *locs; /*!< location of unknowns */
|
||||
l_int32 current; /*!< index into %locs of current location */
|
||||
l_int32 *init; /*!< initial state, with 0 representing */
|
||||
/*!< the unknowns */
|
||||
l_int32 *state; /*!< present state, including inits and */
|
||||
/*!< guesses of unknowns up to %current */
|
||||
l_int32 nguess; /*!< shows current number of guesses */
|
||||
l_int32 finished; /*!< set to 1 when solved */
|
||||
l_int32 failure; /*!< set to 1 if no solution is possible */
|
||||
};
|
||||
typedef struct L_Sudoku L_SUDOKU;
|
||||
|
||||
|
||||
/*! For printing out array data */
|
||||
enum {
|
||||
L_SUDOKU_INIT = 0,
|
||||
L_SUDOKU_STATE = 1
|
||||
};
|
||||
|
||||
#endif /* SUDOKU_H_INCLUDED */
|
||||
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*====================================================================*
|
||||
- Copyright (C) 2001 Leptonica. All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions
|
||||
- are met:
|
||||
- 1. Redistributions of source code must retain the above copyright
|
||||
- notice, this list of conditions and the following disclaimer.
|
||||
- 2. Redistributions in binary form must reproduce the above
|
||||
- copyright notice, this list of conditions and the following
|
||||
- disclaimer in the documentation and/or other materials
|
||||
- provided with the distribution.
|
||||
-
|
||||
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
|
||||
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*====================================================================*/
|
||||
|
||||
#ifndef LEPTONICA_WATERSHED_H
|
||||
#define LEPTONICA_WATERSHED_H
|
||||
|
||||
/*!
|
||||
* \file watershed.h
|
||||
*
|
||||
* Simple data structure to hold watershed data.
|
||||
* All data here is owned by the L_WShed and must be freed.
|
||||
*/
|
||||
|
||||
/*! Simple data structure to hold watershed data. */
|
||||
struct L_WShed
|
||||
{
|
||||
struct Pix *pixs; /*!< clone of input 8 bpp pixs */
|
||||
struct Pix *pixm; /*!< clone of input 1 bpp seed (marker) pixm */
|
||||
l_int32 mindepth; /*!< minimum depth allowed for a watershed */
|
||||
struct Pix *pixlab; /*!< 16 bpp label pix */
|
||||
struct Pix *pixt; /*!< scratch pix for computing wshed regions */
|
||||
void **lines8; /*!< line ptrs for pixs */
|
||||
void **linem1; /*!< line ptrs for pixm */
|
||||
void **linelab32; /*!< line ptrs for pixlab */
|
||||
void **linet1; /*!< line ptrs for pixt */
|
||||
struct Pixa *pixad; /*!< result: 1 bpp pixa of watersheds */
|
||||
struct Pta *ptas; /*!< pta of initial seed pixels */
|
||||
struct Numa *nasi; /*!< numa of seed indicators; 0 if completed */
|
||||
struct Numa *nash; /*!< numa of initial seed heights */
|
||||
struct Numa *namh; /*!< numa of initial minima heights */
|
||||
struct Numa *nalevels; /*!< result: numa of watershed levels */
|
||||
l_int32 nseeds; /*!< number of seeds (markers) */
|
||||
l_int32 nother; /*!< number of minima different from seeds */
|
||||
l_int32 *lut; /*!< lut for pixel indices */
|
||||
struct Numa **links; /*!< back-links into lut, for updates */
|
||||
l_int32 arraysize; /*!< size of links array */
|
||||
l_int32 debug; /*!< set to 1 for debug output */
|
||||
};
|
||||
typedef struct L_WShed L_WSHED;
|
||||
|
||||
#endif /* LEPTONICA_WATERSHED_H */
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
prefix=/home/SW2023/sane/code_app/third_party/leptonica/leptonica-1.74.4/leptonica-1.74.4/build/release
|
||||
exec_prefix=${prefix}/bin
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: leptonica
|
||||
Description: An open source C library for efficient image processing and image analysis operations
|
||||
Version: 1.74.4
|
||||
Libs: -L${libdir} -lleptonica_OUTPUT_NAME-NOTFOUND
|
||||
Libs.private:
|
||||
Cflags: -I${includedir} -I${includedir}/leptonica
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: apitypes.h
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 09:22:53 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_APITYPES_H_
|
||||
#define TESSERACT_API_APITYPES_H_
|
||||
|
||||
#include "publictypes.h"
|
||||
|
||||
// The types used by the API and Page/ResultIterator can be found in:
|
||||
// ccstruct/publictypes.h
|
||||
// ccmain/resultiterator.h
|
||||
// ccmain/pageiterator.h
|
||||
// API interfaces and API users should be sure to include this file, rather
|
||||
// than the lower-level one, and lower-level code should be sure to include
|
||||
// only the lower-level file.
|
||||
|
||||
#endif // TESSERACT_API_APITYPES_H_
|
|
@ -0,0 +1,946 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: baseapi.h
|
||||
// Description: Simple API for calling tesseract.
|
||||
// Author: Ray Smith
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_BASEAPI_H_
|
||||
#define TESSERACT_API_BASEAPI_H_
|
||||
|
||||
#include <cstdio>
|
||||
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
|
||||
// complexity of includes here. Use forward declarations wherever possible
|
||||
// and hide includes of complex types in baseapi.cpp.
|
||||
#include "apitypes.h"
|
||||
#include "pageiterator.h"
|
||||
#include "platform.h"
|
||||
#include "publictypes.h"
|
||||
#include "resultiterator.h"
|
||||
#include "serialis.h"
|
||||
#include "tess_version.h"
|
||||
#include "tesscallback.h"
|
||||
#include "thresholder.h"
|
||||
#include "unichar.h"
|
||||
|
||||
template <typename T> class GenericVector;
|
||||
class PAGE_RES;
|
||||
class PAGE_RES_IT;
|
||||
class ParagraphModel;
|
||||
struct BlamerBundle;
|
||||
class BLOCK_LIST;
|
||||
class DENORM;
|
||||
class MATRIX;
|
||||
class ROW;
|
||||
class STRING;
|
||||
class WERD;
|
||||
struct Pix;
|
||||
struct Box;
|
||||
struct Pixa;
|
||||
struct Boxa;
|
||||
class ETEXT_DESC;
|
||||
struct OSResults;
|
||||
class TBOX;
|
||||
class UNICHARSET;
|
||||
class WERD_CHOICE_LIST;
|
||||
|
||||
struct INT_FEATURE_STRUCT;
|
||||
using INT_FEATURE = INT_FEATURE_STRUCT *;
|
||||
struct TBLOB;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Dawg;
|
||||
class Dict;
|
||||
class EquationDetect;
|
||||
class PageIterator;
|
||||
class LTRResultIterator;
|
||||
class ResultIterator;
|
||||
class MutableIterator;
|
||||
class TessResultRenderer;
|
||||
class Tesseract;
|
||||
class Trie;
|
||||
class Wordrec;
|
||||
|
||||
using DictFunc = int (Dict::*)(void *, const UNICHARSET &, UNICHAR_ID, bool) const;
|
||||
using ProbabilityInContextFunc = double (Dict::*)(const char *, const char *, int, const char *, int);
|
||||
using ParamsModelClassifyFunc = float (Dict::*)(const char *, void *);
|
||||
using FillLatticeFunc = void (Wordrec::*)(const MATRIX &, const WERD_CHOICE_LIST &, const UNICHARSET &, BlamerBundle *);
|
||||
typedef TessCallback4<const UNICHARSET &, int, PageIterator *, Pix *>
|
||||
TruthCallback;
|
||||
|
||||
/**
|
||||
* Base class for all tesseract APIs.
|
||||
* Specific classes can add ability to work on different inputs or produce
|
||||
* different outputs.
|
||||
* This class is mostly an interface layer on top of the Tesseract instance
|
||||
* class to hide the data types so that users of this class don't have to
|
||||
* include any other Tesseract headers.
|
||||
*/
|
||||
class TESS_API TessBaseAPI {
|
||||
public:
|
||||
TessBaseAPI();
|
||||
virtual ~TessBaseAPI();
|
||||
|
||||
int MyOSD();
|
||||
|
||||
/**
|
||||
* Returns the version identifier as a static string. Do not delete.
|
||||
*/
|
||||
static const char* Version();
|
||||
|
||||
/**
|
||||
* If compiled with OpenCL AND an available OpenCL
|
||||
* device is deemed faster than serial code, then
|
||||
* "device" is populated with the cl_device_id
|
||||
* and returns sizeof(cl_device_id)
|
||||
* otherwise *device=nullptr and returns 0.
|
||||
*/
|
||||
static size_t getOpenCLDevice(void **device);
|
||||
|
||||
/**
|
||||
* Writes the thresholded image to stderr as a PBM file on receipt of a
|
||||
* SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only).
|
||||
*/
|
||||
static void CatchSignals();
|
||||
|
||||
/**
|
||||
* Set the name of the input file. Needed for training and
|
||||
* reading a UNLV zone file, and for searchable PDF output.
|
||||
*/
|
||||
void SetInputName(const char* name);
|
||||
/**
|
||||
* These functions are required for searchable PDF output.
|
||||
* We need our hands on the input file so that we can include
|
||||
* it in the PDF without transcoding. If that is not possible,
|
||||
* we need the original image. Finally, resolution metadata
|
||||
* is stored in the PDF so we need that as well.
|
||||
*/
|
||||
const char* GetInputName();
|
||||
// Takes ownership of the input pix.
|
||||
void SetInputImage(Pix *pix);
|
||||
Pix* GetInputImage();
|
||||
int GetSourceYResolution();
|
||||
const char* GetDatapath();
|
||||
|
||||
/** Set the name of the bonus output files. Needed only for debugging. */
|
||||
void SetOutputName(const char* name);
|
||||
|
||||
/**
|
||||
* Set the value of an internal "parameter."
|
||||
* Supply the name of the parameter and the value as a string, just as
|
||||
* you would in a config file.
|
||||
* Returns false if the name lookup failed.
|
||||
* Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z.
|
||||
* Or SetVariable("classify_bln_numeric_mode", "1"); to set numeric-only mode.
|
||||
* SetVariable may be used before Init, but settings will revert to
|
||||
* defaults on End().
|
||||
*
|
||||
* Note: Must be called after Init(). Only works for non-init variables
|
||||
* (init variables should be passed to Init()).
|
||||
*/
|
||||
bool SetVariable(const char* name, const char* value);
|
||||
bool SetDebugVariable(const char* name, const char* value);
|
||||
|
||||
/**
|
||||
* Returns true if the parameter was found among Tesseract parameters.
|
||||
* Fills in value with the value of the parameter.
|
||||
*/
|
||||
bool GetIntVariable(const char *name, int *value) const;
|
||||
bool GetBoolVariable(const char *name, bool *value) const;
|
||||
bool GetDoubleVariable(const char *name, double *value) const;
|
||||
|
||||
/**
|
||||
* Returns the pointer to the string that represents the value of the
|
||||
* parameter if it was found among Tesseract parameters.
|
||||
*/
|
||||
const char *GetStringVariable(const char *name) const;
|
||||
|
||||
/**
|
||||
* Print Tesseract parameters to the given file.
|
||||
*/
|
||||
void PrintVariables(FILE *fp) const;
|
||||
|
||||
/**
|
||||
* Get value of named variable as a string, if it exists.
|
||||
*/
|
||||
bool GetVariableAsString(const char *name, STRING *val);
|
||||
|
||||
/**
|
||||
* Instances are now mostly thread-safe and totally independent,
|
||||
* but some global parameters remain. Basically it is safe to use multiple
|
||||
* TessBaseAPIs in different threads in parallel, UNLESS:
|
||||
* you use SetVariable on some of the Params in classify and textord.
|
||||
* If you do, then the effect will be to change it for all your instances.
|
||||
*
|
||||
* Start tesseract. Returns zero on success and -1 on failure.
|
||||
* NOTE that the only members that may be called before Init are those
|
||||
* listed above here in the class definition.
|
||||
*
|
||||
* The datapath must be the name of the tessdata directory.
|
||||
* The language is (usually) an ISO 639-3 string or nullptr will default to eng.
|
||||
* It is entirely safe (and eventually will be efficient too) to call
|
||||
* Init multiple times on the same instance to change language, or just
|
||||
* to reset the classifier.
|
||||
* The language may be a string of the form [~]<lang>[+[~]<lang>]* indicating
|
||||
* that multiple languages are to be loaded. Eg hin+eng will load Hindi and
|
||||
* English. Languages may specify internally that they want to be loaded
|
||||
* with one or more other languages, so the ~ sign is available to override
|
||||
* that. Eg if hin were set to load eng by default, then hin+~eng would force
|
||||
* loading only hin. The number of loaded languages is limited only by
|
||||
* memory, with the caveat that loading additional languages will impact
|
||||
* both speed and accuracy, as there is more work to do to decide on the
|
||||
* applicable language, and there is more chance of hallucinating incorrect
|
||||
* words.
|
||||
* WARNING: On changing languages, all Tesseract parameters are reset
|
||||
* back to their default values. (Which may vary between languages.)
|
||||
* If you have a rare need to set a Variable that controls
|
||||
* initialization for a second call to Init you should explicitly
|
||||
* call End() and then use SetVariable before Init. This is only a very
|
||||
* rare use case, since there are very few uses that require any parameters
|
||||
* to be set before Init.
|
||||
*
|
||||
* If set_only_non_debug_params is true, only params that do not contain
|
||||
* "debug" in the name will be set.
|
||||
*/
|
||||
int Init(const char* datapath, const char* language, OcrEngineMode mode,
|
||||
char **configs, int configs_size,
|
||||
const GenericVector<STRING> *vars_vec,
|
||||
const GenericVector<STRING> *vars_values,
|
||||
bool set_only_non_debug_params);
|
||||
int Init(const char* datapath, const char* language, OcrEngineMode oem) {
|
||||
return Init(datapath, language, oem, nullptr, 0, nullptr, nullptr, false);
|
||||
}
|
||||
int Init(const char* datapath, const char* language) {
|
||||
return Init(datapath, language, OEM_DEFAULT, nullptr, 0, nullptr, nullptr, false);
|
||||
}
|
||||
// In-memory version reads the traineddata file directly from the given
|
||||
// data[data_size] array, and/or reads data via a FileReader.
|
||||
int Init(const char* data, int data_size, const char* language,
|
||||
OcrEngineMode mode, char** configs, int configs_size,
|
||||
const GenericVector<STRING>* vars_vec,
|
||||
const GenericVector<STRING>* vars_values,
|
||||
bool set_only_non_debug_params, FileReader reader);
|
||||
|
||||
/**
|
||||
* Returns the languages string used in the last valid initialization.
|
||||
* If the last initialization specified "deu+hin" then that will be
|
||||
* returned. If hin loaded eng automatically as well, then that will
|
||||
* not be included in this list. To find the languages actually
|
||||
* loaded use GetLoadedLanguagesAsVector.
|
||||
* The returned string should NOT be deleted.
|
||||
*/
|
||||
const char* GetInitLanguagesAsString() const;
|
||||
|
||||
/**
|
||||
* Returns the loaded languages in the vector of STRINGs.
|
||||
* Includes all languages loaded by the last Init, including those loaded
|
||||
* as dependencies of other loaded languages.
|
||||
*/
|
||||
void GetLoadedLanguagesAsVector(GenericVector<STRING>* langs) const;
|
||||
|
||||
/**
|
||||
* Returns the available languages in the sorted vector of STRINGs.
|
||||
*/
|
||||
void GetAvailableLanguagesAsVector(GenericVector<STRING>* langs) const;
|
||||
|
||||
/**
|
||||
* Init only the lang model component of Tesseract. The only functions
|
||||
* that work after this init are SetVariable and IsValidWord.
|
||||
* WARNING: temporary! This function will be removed from here and placed
|
||||
* in a separate API at some future time.
|
||||
*/
|
||||
int InitLangMod(const char* datapath, const char* language);
|
||||
|
||||
/**
|
||||
* Init only for page layout analysis. Use only for calls to SetImage and
|
||||
* AnalysePage. Calls that attempt recognition will generate an error.
|
||||
*/
|
||||
void InitForAnalysePage();
|
||||
|
||||
/**
|
||||
* Read a "config" file containing a set of param, value pairs.
|
||||
* Searches the standard places: tessdata/configs, tessdata/tessconfigs
|
||||
* and also accepts a relative or absolute path name.
|
||||
* Note: only non-init params will be set (init params are set by Init()).
|
||||
*/
|
||||
void ReadConfigFile(const char* filename);
|
||||
/** Same as above, but only set debug params from the given config file. */
|
||||
void ReadDebugConfigFile(const char* filename);
|
||||
|
||||
/**
|
||||
* Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK.
|
||||
* The mode is stored as an IntParam so it can also be modified by
|
||||
* ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string).
|
||||
*/
|
||||
void SetPageSegMode(PageSegMode mode);
|
||||
|
||||
/** Return the current page segmentation mode. */
|
||||
PageSegMode GetPageSegMode() const;
|
||||
|
||||
/**
|
||||
* Recognize a rectangle from an image and return the result as a string.
|
||||
* May be called many times for a single Init.
|
||||
* Currently has no error checking.
|
||||
* Greyscale of 8 and color of 24 or 32 bits per pixel may be given.
|
||||
* Palette color images will not work properly and must be converted to
|
||||
* 24 bit.
|
||||
* Binary images of 1 bit per pixel may also be given but they must be
|
||||
* byte packed with the MSB of the first byte being the first pixel, and a
|
||||
* 1 represents WHITE. For binary images set bytes_per_pixel=0.
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UTF8 and must be freed with the delete [] operator.
|
||||
*
|
||||
* Note that TesseractRect is the simplified convenience interface.
|
||||
* For advanced uses, use SetImage, (optionally) SetRectangle, Recognize,
|
||||
* and one or more of the Get*Text functions below.
|
||||
*/
|
||||
char* TesseractRect(const unsigned char* imagedata,
|
||||
int bytes_per_pixel, int bytes_per_line,
|
||||
int left, int top, int width, int height);
|
||||
|
||||
/**
|
||||
* Call between pages or documents etc to free up memory and forget
|
||||
* adaptive data.
|
||||
*/
|
||||
void ClearAdaptiveClassifier();
|
||||
|
||||
/**
|
||||
* @defgroup AdvancedAPI Advanced API
|
||||
* The following methods break TesseractRect into pieces, so you can
|
||||
* get hold of the thresholded image, get the text in different formats,
|
||||
* get bounding boxes, confidences etc.
|
||||
*/
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* Provide an image for Tesseract to recognize. Format is as
|
||||
* TesseractRect above. Copies the image buffer and converts to Pix.
|
||||
* SetImage clears all recognition results, and sets the rectangle to the
|
||||
* full image, so it may be followed immediately by a GetUTF8Text, and it
|
||||
* will automatically perform recognition.
|
||||
*/
|
||||
void SetImage(const unsigned char* imagedata, int width, int height,
|
||||
int bytes_per_pixel, int bytes_per_line);
|
||||
|
||||
/**
|
||||
* Provide an image for Tesseract to recognize. As with SetImage above,
|
||||
* Tesseract takes its own copy of the image, so it need not persist until
|
||||
* after Recognize.
|
||||
* Pix vs raw, which to use?
|
||||
* Use Pix where possible. Tesseract uses Pix as its internal representation
|
||||
* and it is therefore more efficient to provide a Pix directly.
|
||||
*/
|
||||
void SetImage(Pix* pix);
|
||||
|
||||
/**
|
||||
* Set the resolution of the source image in pixels per inch so font size
|
||||
* information can be calculated in results. Call this after SetImage().
|
||||
*/
|
||||
void SetSourceResolution(int ppi);
|
||||
|
||||
/**
|
||||
* Restrict recognition to a sub-rectangle of the image. Call after SetImage.
|
||||
* Each SetRectangle clears the recogntion results so multiple rectangles
|
||||
* can be recognized with the same image.
|
||||
*/
|
||||
void SetRectangle(int left, int top, int width, int height);
|
||||
|
||||
/**
|
||||
* In extreme cases only, usually with a subclass of Thresholder, it
|
||||
* is possible to provide a different Thresholder. The Thresholder may
|
||||
* be preloaded with an image, settings etc, or they may be set after.
|
||||
* Note that Tesseract takes ownership of the Thresholder and will
|
||||
* delete it when it it is replaced or the API is destructed.
|
||||
*/
|
||||
void SetThresholder(ImageThresholder* thresholder) {
|
||||
delete thresholder_;
|
||||
thresholder_ = thresholder;
|
||||
ClearResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the internal thresholded image from Tesseract.
|
||||
* Caller takes ownership of the Pix and must pixDestroy it.
|
||||
* May be called any time after SetImage, or after TesseractRect.
|
||||
*/
|
||||
Pix* GetThresholdedImage();
|
||||
|
||||
/**
|
||||
* Get the result of page layout analysis as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
*/
|
||||
Boxa* GetRegions(Pixa** pixa);
|
||||
|
||||
/**
|
||||
* Get the textlines as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* If raw_image is true, then extract from the original image instead of the
|
||||
* thresholded image and pad by raw_padding pixels.
|
||||
* If blockids is not nullptr, the block-id of each line is also returned as an
|
||||
* array of one element per line. delete [] after use.
|
||||
* If paraids is not nullptr, the paragraph-id of each line within its block is
|
||||
* also returned as an array of one element per line. delete [] after use.
|
||||
*/
|
||||
Boxa* GetTextlines(bool raw_image, int raw_padding,
|
||||
Pixa** pixa, int** blockids, int** paraids);
|
||||
/*
|
||||
Helper method to extract from the thresholded image. (most common usage)
|
||||
*/
|
||||
Boxa* GetTextlines(Pixa** pixa, int** blockids) {
|
||||
return GetTextlines(false, 0, pixa, blockids, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get textlines and strips of image regions as a leptonica-style Boxa, Pixa
|
||||
* pair, in reading order. Enables downstream handling of non-rectangular
|
||||
* regions.
|
||||
* Can be called before or after Recognize.
|
||||
* If blockids is not nullptr, the block-id of each line is also returned as an
|
||||
* array of one element per line. delete [] after use.
|
||||
*/
|
||||
Boxa* GetStrips(Pixa** pixa, int** blockids);
|
||||
|
||||
/**
|
||||
* Get the words as a leptonica-style
|
||||
* Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
*/
|
||||
Boxa* GetWords(Pixa** pixa);
|
||||
|
||||
/**
|
||||
* Gets the individual connected (text) components (created
|
||||
* after pages segmentation step, but before recognition)
|
||||
* as a leptonica-style Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* Note: the caller is responsible for calling boxaDestroy()
|
||||
* on the returned Boxa array and pixaDestroy() on cc array.
|
||||
*/
|
||||
Boxa* GetConnectedComponents(Pixa** cc);
|
||||
|
||||
/**
|
||||
* Get the given level kind of components (block, textline, word etc.) as a
|
||||
* leptonica-style Boxa, Pixa pair, in reading order.
|
||||
* Can be called before or after Recognize.
|
||||
* If blockids is not nullptr, the block-id of each component is also returned
|
||||
* as an array of one element per component. delete [] after use.
|
||||
* If blockids is not nullptr, the paragraph-id of each component with its block
|
||||
* is also returned as an array of one element per component. delete [] after
|
||||
* use.
|
||||
* If raw_image is true, then portions of the original image are extracted
|
||||
* instead of the thresholded image and padded with raw_padding.
|
||||
* If text_only is true, then only text components are returned.
|
||||
*/
|
||||
Boxa* GetComponentImages(PageIteratorLevel level,
|
||||
bool text_only, bool raw_image,
|
||||
int raw_padding,
|
||||
Pixa** pixa, int** blockids, int** paraids);
|
||||
// Helper function to get binary images with no padding (most common usage).
|
||||
Boxa* GetComponentImages(const PageIteratorLevel level,
|
||||
const bool text_only,
|
||||
Pixa** pixa, int** blockids) {
|
||||
return GetComponentImages(level, text_only, false, 0, pixa, blockids, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scale factor of the thresholded image that would be returned by
|
||||
* GetThresholdedImage() and the various GetX() methods that call
|
||||
* GetComponentImages().
|
||||
* Returns 0 if no thresholder has been set.
|
||||
*/
|
||||
int GetThresholdedImageScaleFactor() const;
|
||||
|
||||
/**
|
||||
* Runs page layout analysis in the mode set by SetPageSegMode.
|
||||
* May optionally be called prior to Recognize to get access to just
|
||||
* the page layout results. Returns an iterator to the results.
|
||||
* If merge_similar_words is true, words are combined where suitable for use
|
||||
* with a line recognizer. Use if you want to use AnalyseLayout to find the
|
||||
* textlines, and then want to process textline fragments with an external
|
||||
* line recognizer.
|
||||
* Returns nullptr on error or an empty page.
|
||||
* The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
PageIterator* AnalyseLayout();
|
||||
PageIterator* AnalyseLayout(bool merge_similar_words);
|
||||
|
||||
/**
|
||||
* Recognize the image from SetAndThresholdImage, generating Tesseract
|
||||
* internal structures. Returns 0 on success.
|
||||
* Optional. The Get*Text functions below will call Recognize if needed.
|
||||
* After Recognize, the output is kept internally until the next SetImage.
|
||||
*/
|
||||
int Recognize(ETEXT_DESC* monitor);
|
||||
|
||||
/**
|
||||
* Methods to retrieve information after SetAndThresholdImage(),
|
||||
* Recognize() or TesseractRect(). (Recognize is called implicitly if needed.)
|
||||
*/
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
/** Variant on Recognize used for testing chopper. */
|
||||
int RecognizeForChopTest(ETEXT_DESC* monitor);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Turns images into symbolic text.
|
||||
*
|
||||
* filename can point to a single image, a multi-page TIFF,
|
||||
* or a plain text list of image filenames.
|
||||
*
|
||||
* retry_config is useful for debugging. If not nullptr, you can fall
|
||||
* back to an alternate configuration if a page fails for some
|
||||
* reason.
|
||||
*
|
||||
* timeout_millisec terminates processing if any single page
|
||||
* takes too long. Set to 0 for unlimited time.
|
||||
*
|
||||
* renderer is responible for creating the output. For example,
|
||||
* use the TessTextRenderer if you want plaintext output, or
|
||||
* the TessPDFRender to produce searchable PDF.
|
||||
*
|
||||
* If tessedit_page_number is non-negative, will only process that
|
||||
* single page. Works for multi-page tiff file, or filelist.
|
||||
*
|
||||
* Returns true if successful, false on error.
|
||||
*/
|
||||
bool ProcessPages(const char* filename, const char* retry_config,
|
||||
int timeout_millisec, TessResultRenderer* renderer);
|
||||
// Does the real work of ProcessPages.
|
||||
bool ProcessPagesInternal(const char* filename, const char* retry_config,
|
||||
int timeout_millisec, TessResultRenderer* renderer);
|
||||
|
||||
/**
|
||||
* Turn a single image into symbolic text.
|
||||
*
|
||||
* The pix is the image processed. filename and page_index are
|
||||
* metadata used by side-effect processes, such as reading a box
|
||||
* file or formatting as hOCR.
|
||||
*
|
||||
* See ProcessPages for desciptions of other parameters.
|
||||
*/
|
||||
bool ProcessPage(Pix* pix, int page_index, const char* filename,
|
||||
const char* retry_config, int timeout_millisec,
|
||||
TessResultRenderer* renderer);
|
||||
|
||||
/**
|
||||
* Get a reading-order iterator to the results of LayoutAnalysis and/or
|
||||
* Recognize. The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
ResultIterator* GetIterator();
|
||||
|
||||
/**
|
||||
* Get a mutable iterator to the results of LayoutAnalysis and/or Recognize.
|
||||
* The returned iterator must be deleted after use.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
*/
|
||||
MutableIterator* GetMutableIterator();
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UTF8 and must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetUTF8Text();
|
||||
|
||||
/**
|
||||
* Make a HTML-formatted string with hOCR markup from the internal
|
||||
* data structures.
|
||||
* page_number is 0-based but will appear in the output as 1-based.
|
||||
* monitor can be used to
|
||||
* cancel the recognition
|
||||
* receive progress callbacks
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetHOCRText(ETEXT_DESC* monitor, int page_number);
|
||||
|
||||
/**
|
||||
* Make a HTML-formatted string with hOCR markup from the internal
|
||||
* data structures.
|
||||
* page_number is 0-based but will appear in the output as 1-based.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetHOCRText(int page_number);
|
||||
|
||||
/**
|
||||
* Make an XML-formatted string with Alto markup from the internal
|
||||
* data structures.
|
||||
*/
|
||||
char* GetAltoText(ETEXT_DESC* monitor, int page_number);
|
||||
|
||||
|
||||
/**
|
||||
* Make an XML-formatted string with Alto markup from the internal
|
||||
* data structures.
|
||||
*/
|
||||
char* GetAltoText(int page_number);
|
||||
|
||||
/**
|
||||
* Make a TSV-formatted string from the internal data structures.
|
||||
* page_number is 0-based but will appear in the output as 1-based.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetTSVText(int page_number);
|
||||
|
||||
/**
|
||||
* Make a box file for LSTM training from the internal data structures.
|
||||
* Constructs coordinates in the original image - not just the rectangle.
|
||||
* page_number is a 0-based page index that will appear in the box file.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetLSTMBoxText(int page_number);
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded in the same
|
||||
* format as a box file used in training.
|
||||
* Constructs coordinates in the original image - not just the rectangle.
|
||||
* page_number is a 0-based page index that will appear in the box file.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetBoxText(int page_number);
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded in the same
|
||||
* format as a WordStr box file used in training.
|
||||
* page_number is a 0-based page index that will appear in the box file.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetWordStrBoxText(int page_number);
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UNLV format Latin-1 with specific reject and suspect codes.
|
||||
* Returned string must be freed with the delete [] operator.
|
||||
*/
|
||||
char* GetUNLVText();
|
||||
|
||||
/**
|
||||
* Detect the orientation of the input image and apparent script (alphabet).
|
||||
* orient_deg is the detected clockwise rotation of the input image in degrees
|
||||
* (0, 90, 180, 270)
|
||||
* orient_conf is the confidence (15.0 is reasonably confident)
|
||||
* script_name is an ASCII string, the name of the script, e.g. "Latin"
|
||||
* script_conf is confidence level in the script
|
||||
* Returns true on success and writes values to each parameter as an output
|
||||
*/
|
||||
bool DetectOrientationScript(int* orient_deg, float* orient_conf,
|
||||
const char** script_name, float* script_conf);
|
||||
|
||||
/**
|
||||
* The recognized text is returned as a char* which is coded
|
||||
* as UTF8 and must be freed with the delete [] operator.
|
||||
* page_number is a 0-based page index that will appear in the osd file.
|
||||
*/
|
||||
char* GetOsdText(int page_number);
|
||||
|
||||
/** Returns the (average) confidence value between 0 and 100. */
|
||||
int MeanTextConf();
|
||||
/**
|
||||
* Returns all word confidences (between 0 and 100) in an array, terminated
|
||||
* by -1. The calling function must delete [] after use.
|
||||
* The number of confidences should correspond to the number of space-
|
||||
* delimited words in GetUTF8Text.
|
||||
*/
|
||||
int* AllWordConfidences();
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
/**
|
||||
* Applies the given word to the adaptive classifier if possible.
|
||||
* The word must be SPACE-DELIMITED UTF-8 - l i k e t h i s , so it can
|
||||
* tell the boundaries of the graphemes.
|
||||
* Assumes that SetImage/SetRectangle have been used to set the image
|
||||
* to the given word. The mode arg should be PSM_SINGLE_WORD or
|
||||
* PSM_CIRCLE_WORD, as that will be used to control layout analysis.
|
||||
* The currently set PageSegMode is preserved.
|
||||
* Returns false if adaption was not possible for some reason.
|
||||
*/
|
||||
bool AdaptToWordStr(PageSegMode mode, const char* wordstr);
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
/**
|
||||
* Free up recognition results and any stored image data, without actually
|
||||
* freeing any recognition data that would be time-consuming to reload.
|
||||
* Afterwards, you must call SetImage or TesseractRect before doing
|
||||
* any Recognize or Get* operation.
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* Close down tesseract and free up all memory. End() is equivalent to
|
||||
* destructing and reconstructing your TessBaseAPI.
|
||||
* Once End() has been used, none of the other API functions may be used
|
||||
* other than Init and anything declared above it in the class definition.
|
||||
*/
|
||||
void End();
|
||||
|
||||
/**
|
||||
* Clear any library-level memory caches.
|
||||
* There are a variety of expensive-to-load constant data structures (mostly
|
||||
* language dictionaries) that are cached globally -- surviving the Init()
|
||||
* and End() of individual TessBaseAPI's. This function allows the clearing
|
||||
* of these caches.
|
||||
**/
|
||||
static void ClearPersistentCache();
|
||||
|
||||
/**
|
||||
* Check whether a word is valid according to Tesseract's language model
|
||||
* @return 0 if the word is invalid, non-zero if valid.
|
||||
* @warning temporary! This function will be removed from here and placed
|
||||
* in a separate API at some future time.
|
||||
*/
|
||||
int IsValidWord(const char *word);
|
||||
// Returns true if utf8_character is defined in the UniCharset.
|
||||
bool IsValidCharacter(const char *utf8_character);
|
||||
|
||||
|
||||
bool GetTextDirection(int* out_offset, float* out_slope);
|
||||
|
||||
/** Sets Dict::letter_is_okay_ function to point to the given function. */
|
||||
void SetDictFunc(DictFunc f);
|
||||
|
||||
/** Sets Dict::probability_in_context_ function to point to the given
|
||||
* function.
|
||||
*/
|
||||
void SetProbabilityInContextFunc(ProbabilityInContextFunc f);
|
||||
|
||||
/**
|
||||
* Estimates the Orientation And Script of the image.
|
||||
* @return true if the image was processed successfully.
|
||||
*/
|
||||
bool DetectOS(OSResults*);
|
||||
|
||||
/**
|
||||
* Return text orientation of each block as determined by an earlier run
|
||||
* of layout analysis.
|
||||
*/
|
||||
void GetBlockTextOrientations(int** block_orientation,
|
||||
bool** vertical_writing);
|
||||
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
/** Sets Wordrec::fill_lattice_ function to point to the given function. */
|
||||
void SetFillLatticeFunc(FillLatticeFunc f);
|
||||
|
||||
/** Find lines from the image making the BLOCK_LIST. */
|
||||
BLOCK_LIST* FindLinesCreateBlockList();
|
||||
|
||||
/**
|
||||
* Delete a block list.
|
||||
* This is to keep BLOCK_LIST pointer opaque
|
||||
* and let go of including the other headers.
|
||||
*/
|
||||
static void DeleteBlockList(BLOCK_LIST* block_list);
|
||||
|
||||
/** Returns a ROW object created from the input row specification. */
|
||||
static ROW *MakeTessOCRRow(float baseline, float xheight,
|
||||
float descender, float ascender);
|
||||
|
||||
/** Returns a TBLOB corresponding to the entire input image. */
|
||||
static TBLOB *MakeTBLOB(Pix *pix);
|
||||
|
||||
/**
|
||||
* This method baseline normalizes a TBLOB in-place. The input row is used
|
||||
* for normalization. The denorm is an optional parameter in which the
|
||||
* normalization-antidote is returned.
|
||||
*/
|
||||
static void NormalizeTBLOB(TBLOB *tblob, ROW *row, bool numeric_mode);
|
||||
|
||||
/** This method returns the features associated with the input image. */
|
||||
void GetFeaturesForBlob(TBLOB* blob, INT_FEATURE_STRUCT* int_features,
|
||||
int* num_features, int* feature_outline_index);
|
||||
|
||||
/**
|
||||
* This method returns the row to which a box of specified dimensions would
|
||||
* belong. If no good match is found, it returns nullptr.
|
||||
*/
|
||||
static ROW* FindRowForBox(BLOCK_LIST* blocks, int left, int top,
|
||||
int right, int bottom);
|
||||
|
||||
/**
|
||||
* Method to run adaptive classifier on a blob.
|
||||
* It returns at max num_max_matches results.
|
||||
*/
|
||||
void RunAdaptiveClassifier(TBLOB* blob,
|
||||
int num_max_matches,
|
||||
int* unichar_ids,
|
||||
float* ratings,
|
||||
int* num_matches_returned);
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
/** This method returns the string form of the specified unichar. */
|
||||
const char* GetUnichar(int unichar_id);
|
||||
|
||||
/** Return the pointer to the i-th dawg loaded into tesseract_ object. */
|
||||
const Dawg *GetDawg(int i) const;
|
||||
|
||||
/** Return the number of dawgs loaded into tesseract_ object. */
|
||||
int NumDawgs() const;
|
||||
|
||||
Tesseract* tesseract() const { return tesseract_; }
|
||||
|
||||
OcrEngineMode oem() const { return last_oem_requested_; }
|
||||
|
||||
void InitTruthCallback(TruthCallback *cb) { truth_cb_ = cb; }
|
||||
|
||||
void set_min_orientation_margin(double margin);
|
||||
/* @} */
|
||||
|
||||
protected:
|
||||
|
||||
/** Common code for setting the image. Returns true if Init has been called. */
|
||||
TESS_LOCAL bool InternalSetImage();
|
||||
|
||||
/**
|
||||
* Run the thresholder to make the thresholded image. If pix is not nullptr,
|
||||
* the source is thresholded to pix instead of the internal IMAGE.
|
||||
*/
|
||||
TESS_LOCAL virtual bool Threshold(Pix** pix);
|
||||
|
||||
/**
|
||||
* Find lines from the image making the BLOCK_LIST.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
TESS_LOCAL int FindLines();
|
||||
|
||||
/** Delete the pageres and block list ready for a new page. */
|
||||
void ClearResults();
|
||||
|
||||
/**
|
||||
* Return an LTR Result Iterator -- used only for training, as we really want
|
||||
* to ignore all BiDi smarts at that point.
|
||||
* delete once you're done with it.
|
||||
*/
|
||||
TESS_LOCAL LTRResultIterator* GetLTRIterator();
|
||||
|
||||
/**
|
||||
* Return the length of the output text string, as UTF8, assuming
|
||||
* one newline per line and one per block, with a terminator,
|
||||
* and assuming a single character reject marker for each rejected character.
|
||||
* Also return the number of recognized blobs in blob_count.
|
||||
*/
|
||||
TESS_LOCAL int TextLength(int* blob_count);
|
||||
|
||||
//// paragraphs.cpp ////////////////////////////////////////////////////
|
||||
TESS_LOCAL void DetectParagraphs(bool after_text_recognition);
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
/** @defgroup ocropusAddOns ocropus add-ons */
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* Adapt to recognize the current image as the given character.
|
||||
* The image must be preloaded and be just an image of a single character.
|
||||
*/
|
||||
TESS_LOCAL void AdaptToCharacter(const char *unichar_repr,
|
||||
int length,
|
||||
float baseline,
|
||||
float xheight,
|
||||
float descender,
|
||||
float ascender);
|
||||
|
||||
/** Recognize text doing one pass only, using settings for a given pass. */
|
||||
TESS_LOCAL PAGE_RES* RecognitionPass1(BLOCK_LIST* block_list);
|
||||
|
||||
TESS_LOCAL PAGE_RES* RecognitionPass2(BLOCK_LIST* block_list,
|
||||
PAGE_RES* pass1_result);
|
||||
|
||||
/**
|
||||
* Extract the OCR results, costs (penalty points for uncertainty),
|
||||
* and the bounding boxes of the characters.
|
||||
*/
|
||||
TESS_LOCAL static int TesseractExtractResult(char** text,
|
||||
int** lengths,
|
||||
float** costs,
|
||||
int** x0,
|
||||
int** y0,
|
||||
int** x1,
|
||||
int** y1,
|
||||
PAGE_RES* page_res);
|
||||
|
||||
TESS_LOCAL const PAGE_RES* GetPageRes() const { return page_res_; }
|
||||
/* @} */
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
protected:
|
||||
Tesseract* tesseract_; ///< The underlying data object.
|
||||
Tesseract* osd_tesseract_; ///< For orientation & script detection.
|
||||
EquationDetect* equ_detect_; ///<The equation detector.
|
||||
FileReader reader_; ///< Reads files from any filesystem.
|
||||
ImageThresholder* thresholder_; ///< Image thresholding module.
|
||||
GenericVector<ParagraphModel *>* paragraph_models_;
|
||||
BLOCK_LIST* block_list_; ///< The page layout.
|
||||
PAGE_RES* page_res_; ///< The page-level data.
|
||||
STRING* input_file_; ///< Name used by training code.
|
||||
STRING* output_file_; ///< Name used by debug code.
|
||||
STRING* datapath_; ///< Current location of tessdata.
|
||||
STRING* language_; ///< Last initialized language.
|
||||
OcrEngineMode last_oem_requested_; ///< Last ocr language mode requested.
|
||||
bool recognition_done_; ///< page_res_ contains recognition data.
|
||||
TruthCallback *truth_cb_; /// fxn for setting truth_* in WERD_RES
|
||||
|
||||
/**
|
||||
* @defgroup ThresholderParams Thresholder Parameters
|
||||
* Parameters saved from the Thresholder. Needed to rebuild coordinates.
|
||||
*/
|
||||
/* @{ */
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
int image_width_;
|
||||
int image_height_;
|
||||
/* @} */
|
||||
|
||||
private:
|
||||
// A list of image filenames gets special consideration
|
||||
bool ProcessPagesFileList(FILE *fp,
|
||||
STRING *buf,
|
||||
const char* retry_config, int timeout_millisec,
|
||||
TessResultRenderer* renderer,
|
||||
int tessedit_page_number);
|
||||
// TIFF supports multipage so gets special consideration.
|
||||
bool ProcessPagesMultipageTiff(const unsigned char *data,
|
||||
size_t size,
|
||||
const char* filename,
|
||||
const char* retry_config,
|
||||
int timeout_millisec,
|
||||
TessResultRenderer* renderer,
|
||||
int tessedit_page_number);
|
||||
// There's currently no way to pass a document title from the
|
||||
// Tesseract command line, and we have multiple places that choose
|
||||
// to set the title to an empty string. Using a single named
|
||||
// variable will hopefully reduce confusion if the situation changes
|
||||
// in the future.
|
||||
const char *unknown_title_ = "";
|
||||
}; // class TessBaseAPI.
|
||||
|
||||
/** Escape a char string - remove &<>"' with HTML codes. */
|
||||
STRING HOcrEscape(const char* text);
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_API_BASEAPI_H_
|
|
@ -0,0 +1,630 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: capi.h
|
||||
// Description: C-API TessBaseAPI
|
||||
//
|
||||
// (C) Copyright 2012, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef API_CAPI_H_
|
||||
#define API_CAPI_H_
|
||||
|
||||
#if defined(TESSERACT_API_BASEAPI_H_) && !defined(TESS_CAPI_INCLUDE_BASEAPI)
|
||||
# define TESS_CAPI_INCLUDE_BASEAPI
|
||||
#endif
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
# include "baseapi.h"
|
||||
# include "ocrclass.h"
|
||||
# include "pageiterator.h"
|
||||
# include "renderer.h"
|
||||
# include "resultiterator.h"
|
||||
#else
|
||||
# include <stdbool.h>
|
||||
# include <stdio.h>
|
||||
# include "platform.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef TESS_CALL
|
||||
# if defined(WIN32)
|
||||
# define TESS_CALL __cdecl
|
||||
# else
|
||||
# define TESS_CALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOL
|
||||
# define BOOL int
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
typedef tesseract::TessResultRenderer TessResultRenderer;
|
||||
typedef tesseract::TessTextRenderer TessTextRenderer;
|
||||
typedef tesseract::TessHOcrRenderer TessHOcrRenderer;
|
||||
typedef tesseract::TessAltoRenderer TessAltoRenderer;
|
||||
typedef tesseract::TessTsvRenderer TessTsvRenderer;
|
||||
typedef tesseract::TessPDFRenderer TessPDFRenderer;
|
||||
typedef tesseract::TessUnlvRenderer TessUnlvRenderer;
|
||||
typedef tesseract::TessBoxTextRenderer TessBoxTextRenderer;
|
||||
typedef tesseract::TessWordStrBoxRenderer TessWordStrBoxRenderer;
|
||||
typedef tesseract::TessLSTMBoxRenderer TessLSTMBoxRenderer;
|
||||
typedef tesseract::TessBaseAPI TessBaseAPI;
|
||||
typedef tesseract::PageIterator TessPageIterator;
|
||||
typedef tesseract::ResultIterator TessResultIterator;
|
||||
typedef tesseract::MutableIterator TessMutableIterator;
|
||||
typedef tesseract::ChoiceIterator TessChoiceIterator;
|
||||
typedef tesseract::OcrEngineMode TessOcrEngineMode;
|
||||
typedef tesseract::PageSegMode TessPageSegMode;
|
||||
typedef tesseract::ImageThresholder TessImageThresholder;
|
||||
typedef tesseract::PageIteratorLevel TessPageIteratorLevel;
|
||||
typedef tesseract::DictFunc TessDictFunc;
|
||||
typedef tesseract::ProbabilityInContextFunc TessProbabilityInContextFunc;
|
||||
// typedef tesseract::ParamsModelClassifyFunc TessParamsModelClassifyFunc;
|
||||
typedef tesseract::FillLatticeFunc TessFillLatticeFunc;
|
||||
typedef tesseract::Dawg TessDawg;
|
||||
typedef tesseract::TruthCallback TessTruthCallback;
|
||||
typedef tesseract::Orientation TessOrientation;
|
||||
typedef tesseract::ParagraphJustification TessParagraphJustification;
|
||||
typedef tesseract::WritingDirection TessWritingDirection;
|
||||
typedef tesseract::TextlineOrder TessTextlineOrder;
|
||||
typedef PolyBlockType TessPolyBlockType;
|
||||
#else
|
||||
typedef struct TessResultRenderer TessResultRenderer;
|
||||
typedef struct TessTextRenderer TessTextRenderer;
|
||||
typedef struct TessHOcrRenderer TessHOcrRenderer;
|
||||
typedef struct TessPDFRenderer TessPDFRenderer;
|
||||
typedef struct TessUnlvRenderer TessUnlvRenderer;
|
||||
typedef struct TessBoxTextRenderer TessBoxTextRenderer;
|
||||
typedef struct TessBaseAPI TessBaseAPI;
|
||||
typedef struct TessPageIterator TessPageIterator;
|
||||
typedef struct TessResultIterator TessResultIterator;
|
||||
typedef struct TessMutableIterator TessMutableIterator;
|
||||
typedef struct TessChoiceIterator TessChoiceIterator;
|
||||
typedef enum TessOcrEngineMode {
|
||||
OEM_TESSERACT_ONLY,
|
||||
OEM_LSTM_ONLY,
|
||||
OEM_TESSERACT_LSTM_COMBINED,
|
||||
OEM_DEFAULT
|
||||
} TessOcrEngineMode;
|
||||
typedef enum TessPageSegMode {
|
||||
PSM_OSD_ONLY,
|
||||
PSM_AUTO_OSD,
|
||||
PSM_AUTO_ONLY,
|
||||
PSM_AUTO,
|
||||
PSM_SINGLE_COLUMN,
|
||||
PSM_SINGLE_BLOCK_VERT_TEXT,
|
||||
PSM_SINGLE_BLOCK,
|
||||
PSM_SINGLE_LINE,
|
||||
PSM_SINGLE_WORD,
|
||||
PSM_CIRCLE_WORD,
|
||||
PSM_SINGLE_CHAR,
|
||||
PSM_SPARSE_TEXT,
|
||||
PSM_SPARSE_TEXT_OSD,
|
||||
PSM_RAW_LINE,
|
||||
PSM_COUNT
|
||||
} TessPageSegMode;
|
||||
typedef enum TessPageIteratorLevel {
|
||||
RIL_BLOCK,
|
||||
RIL_PARA,
|
||||
RIL_TEXTLINE,
|
||||
RIL_WORD,
|
||||
RIL_SYMBOL
|
||||
} TessPageIteratorLevel;
|
||||
typedef enum TessPolyBlockType {
|
||||
PT_UNKNOWN,
|
||||
PT_FLOWING_TEXT,
|
||||
PT_HEADING_TEXT,
|
||||
PT_PULLOUT_TEXT,
|
||||
PT_EQUATION,
|
||||
PT_INLINE_EQUATION,
|
||||
PT_TABLE,
|
||||
PT_VERTICAL_TEXT,
|
||||
PT_CAPTION_TEXT,
|
||||
PT_FLOWING_IMAGE,
|
||||
PT_HEADING_IMAGE,
|
||||
PT_PULLOUT_IMAGE,
|
||||
PT_HORZ_LINE,
|
||||
PT_VERT_LINE,
|
||||
PT_NOISE,
|
||||
PT_COUNT
|
||||
} TessPolyBlockType;
|
||||
typedef enum TessOrientation {
|
||||
ORIENTATION_PAGE_UP,
|
||||
ORIENTATION_PAGE_RIGHT,
|
||||
ORIENTATION_PAGE_DOWN,
|
||||
ORIENTATION_PAGE_LEFT
|
||||
} TessOrientation;
|
||||
typedef enum TessParagraphJustification {
|
||||
JUSTIFICATION_UNKNOWN,
|
||||
JUSTIFICATION_LEFT,
|
||||
JUSTIFICATION_CENTER,
|
||||
JUSTIFICATION_RIGHT
|
||||
} TessParagraphJustification;
|
||||
typedef enum TessWritingDirection {
|
||||
WRITING_DIRECTION_LEFT_TO_RIGHT,
|
||||
WRITING_DIRECTION_RIGHT_TO_LEFT,
|
||||
WRITING_DIRECTION_TOP_TO_BOTTOM
|
||||
} TessWritingDirection;
|
||||
typedef enum TessTextlineOrder {
|
||||
TEXTLINE_ORDER_LEFT_TO_RIGHT,
|
||||
TEXTLINE_ORDER_RIGHT_TO_LEFT,
|
||||
TEXTLINE_ORDER_TOP_TO_BOTTOM
|
||||
} TessTextlineOrder;
|
||||
typedef struct ETEXT_DESC ETEXT_DESC;
|
||||
#endif
|
||||
|
||||
typedef bool (*TessCancelFunc)(void* cancel_this, int words);
|
||||
typedef bool (*TessProgressFunc)(ETEXT_DESC* ths, int left, int right, int top,
|
||||
int bottom);
|
||||
|
||||
struct Pix;
|
||||
struct Boxa;
|
||||
struct Pixa;
|
||||
|
||||
TESS_API int MyOSD(TessBaseAPI* api);
|
||||
|
||||
/* General free functions */
|
||||
|
||||
TESS_API const char* TESS_CALL TessVersion();
|
||||
TESS_API void TESS_CALL TessDeleteText(const char* text);
|
||||
TESS_API void TESS_CALL TessDeleteTextArray(char** arr);
|
||||
TESS_API void TESS_CALL TessDeleteIntArray(const int* arr);
|
||||
|
||||
/* Renderer API */
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessTextRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessHOcrRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessHOcrRendererCreate2(const char* outputbase, BOOL font_info);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessAltoRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessTsvRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(
|
||||
const char* outputbase, const char* datadir, BOOL textonly);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessUnlvRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessBoxTextRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessLSTMBoxRendererCreate(const char* outputbase);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessWordStrBoxRendererCreate(const char* outputbase);
|
||||
|
||||
TESS_API void TESS_CALL TessDeleteResultRenderer(TessResultRenderer* renderer);
|
||||
TESS_API void TESS_CALL TessResultRendererInsert(TessResultRenderer* renderer,
|
||||
TessResultRenderer* next);
|
||||
TESS_API TessResultRenderer* TESS_CALL
|
||||
TessResultRendererNext(TessResultRenderer* renderer);
|
||||
TESS_API BOOL TESS_CALL TessResultRendererBeginDocument(
|
||||
TessResultRenderer* renderer, const char* title);
|
||||
TESS_API BOOL TESS_CALL TessResultRendererAddImage(TessResultRenderer* renderer,
|
||||
TessBaseAPI* api);
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultRendererEndDocument(TessResultRenderer* renderer);
|
||||
|
||||
TESS_API const char* TESS_CALL
|
||||
TessResultRendererExtention(TessResultRenderer* renderer);
|
||||
TESS_API const char* TESS_CALL
|
||||
TessResultRendererTitle(TessResultRenderer* renderer);
|
||||
TESS_API int TESS_CALL TessResultRendererImageNum(TessResultRenderer* renderer);
|
||||
|
||||
/* Base API */
|
||||
|
||||
TESS_API TessBaseAPI* TESS_CALL TessBaseAPICreate();
|
||||
TESS_API void TESS_CALL TessBaseAPIDelete(TessBaseAPI* handle);
|
||||
|
||||
TESS_API size_t TESS_CALL TessBaseAPIGetOpenCLDevice(TessBaseAPI* handle,
|
||||
void** device);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetInputName(TessBaseAPI* handle,
|
||||
const char* name);
|
||||
TESS_API const char* TESS_CALL TessBaseAPIGetInputName(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetInputImage(TessBaseAPI* handle,
|
||||
struct Pix* pix);
|
||||
TESS_API struct Pix* TESS_CALL TessBaseAPIGetInputImage(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIGetSourceYResolution(TessBaseAPI* handle);
|
||||
TESS_API const char* TESS_CALL TessBaseAPIGetDatapath(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetOutputName(TessBaseAPI* handle,
|
||||
const char* name);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI* handle,
|
||||
const char* name,
|
||||
const char* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI* handle,
|
||||
const char* name,
|
||||
const char* value);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable(const TessBaseAPI* handle,
|
||||
const char* name, int* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable(const TessBaseAPI* handle,
|
||||
const char* name,
|
||||
BOOL* value);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI* handle,
|
||||
const char* name,
|
||||
double* value);
|
||||
TESS_API const char* TESS_CALL
|
||||
TessBaseAPIGetStringVariable(const TessBaseAPI* handle, const char* name);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIPrintVariables(const TessBaseAPI* handle,
|
||||
FILE* fp);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIPrintVariablesToFile(
|
||||
const TessBaseAPI* handle, const char* filename);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetVariableAsString(TessBaseAPI* handle,
|
||||
const char* name,
|
||||
STRING* val);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIInit(
|
||||
TessBaseAPI* handle, const char* datapath, const char* language,
|
||||
TessOcrEngineMode mode, char** configs, int configs_size,
|
||||
const STRING* vars_vec, size_t vars_vec_size, const STRING* vars_values,
|
||||
size_t vars_values_size, BOOL set_only_init_params);
|
||||
|
||||
#endif // def TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIInit1(TessBaseAPI* handle,
|
||||
const char* datapath,
|
||||
const char* language,
|
||||
TessOcrEngineMode oem, char** configs,
|
||||
int configs_size);
|
||||
TESS_API int TESS_CALL TessBaseAPIInit2(TessBaseAPI* handle,
|
||||
const char* datapath,
|
||||
const char* language,
|
||||
TessOcrEngineMode oem);
|
||||
TESS_API int TESS_CALL TessBaseAPIInit3(TessBaseAPI* handle,
|
||||
const char* datapath,
|
||||
const char* language);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIInit4(
|
||||
TessBaseAPI* handle, const char* datapath, const char* language,
|
||||
TessOcrEngineMode mode, char** configs, int configs_size, char** vars_vec,
|
||||
char** vars_values, size_t vars_vec_size, BOOL set_only_non_debug_params);
|
||||
|
||||
TESS_API const char* TESS_CALL
|
||||
TessBaseAPIGetInitLanguagesAsString(const TessBaseAPI* handle);
|
||||
TESS_API char** TESS_CALL
|
||||
TessBaseAPIGetLoadedLanguagesAsVector(const TessBaseAPI* handle);
|
||||
TESS_API char** TESS_CALL
|
||||
TessBaseAPIGetAvailableLanguagesAsVector(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIInitLangMod(TessBaseAPI* handle,
|
||||
const char* datapath,
|
||||
const char* language);
|
||||
TESS_API void TESS_CALL TessBaseAPIInitForAnalysePage(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIReadConfigFile(TessBaseAPI* handle,
|
||||
const char* filename);
|
||||
TESS_API void TESS_CALL TessBaseAPIReadDebugConfigFile(TessBaseAPI* handle,
|
||||
const char* filename);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetPageSegMode(TessBaseAPI* handle,
|
||||
TessPageSegMode mode);
|
||||
TESS_API TessPageSegMode TESS_CALL
|
||||
TessBaseAPIGetPageSegMode(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIRect(TessBaseAPI* handle,
|
||||
const unsigned char* imagedata,
|
||||
int bytes_per_pixel,
|
||||
int bytes_per_line, int left, int top,
|
||||
int width, int height);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIClearAdaptiveClassifier(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetImage(TessBaseAPI* handle,
|
||||
const unsigned char* imagedata,
|
||||
int width, int height,
|
||||
int bytes_per_pixel,
|
||||
int bytes_per_line);
|
||||
TESS_API void TESS_CALL TessBaseAPISetImage2(TessBaseAPI* handle,
|
||||
struct Pix* pix);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetSourceResolution(TessBaseAPI* handle,
|
||||
int ppi);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetRectangle(TessBaseAPI* handle, int left,
|
||||
int top, int width, int height);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessBaseAPISetThresholder(
|
||||
TessBaseAPI* handle, TessImageThresholder* thresholder);
|
||||
#endif
|
||||
|
||||
TESS_API struct Pix* TESS_CALL
|
||||
TessBaseAPIGetThresholdedImage(TessBaseAPI* handle);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetRegions(TessBaseAPI* handle,
|
||||
struct Pixa** pixa);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetTextlines(TessBaseAPI* handle,
|
||||
struct Pixa** pixa,
|
||||
int** blockids);
|
||||
TESS_API struct Boxa* TESS_CALL
|
||||
TessBaseAPIGetTextlines1(TessBaseAPI* handle, BOOL raw_image, int raw_padding,
|
||||
struct Pixa** pixa, int** blockids, int** paraids);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetStrips(TessBaseAPI* handle,
|
||||
struct Pixa** pixa,
|
||||
int** blockids);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetWords(TessBaseAPI* handle,
|
||||
struct Pixa** pixa);
|
||||
TESS_API struct Boxa* TESS_CALL
|
||||
TessBaseAPIGetConnectedComponents(TessBaseAPI* handle, struct Pixa** cc);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetComponentImages(
|
||||
TessBaseAPI* handle, TessPageIteratorLevel level, BOOL text_only,
|
||||
struct Pixa** pixa, int** blockids);
|
||||
TESS_API struct Boxa* TESS_CALL TessBaseAPIGetComponentImages1(
|
||||
TessBaseAPI* handle, TessPageIteratorLevel level, BOOL text_only,
|
||||
BOOL raw_image, int raw_padding, struct Pixa** pixa, int** blockids,
|
||||
int** paraids);
|
||||
|
||||
TESS_API int TESS_CALL
|
||||
TessBaseAPIGetThresholdedImageScaleFactor(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API TessPageIterator* TESS_CALL
|
||||
TessBaseAPIAnalyseLayout(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIRecognize(TessBaseAPI* handle,
|
||||
ETEXT_DESC* monitor);
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI* handle,
|
||||
ETEXT_DESC* monitor);
|
||||
#endif
|
||||
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle,
|
||||
const char* filename,
|
||||
const char* retry_config,
|
||||
int timeout_millisec,
|
||||
TessResultRenderer* renderer);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIProcessPage(TessBaseAPI* handle,
|
||||
struct Pix* pix, int page_index,
|
||||
const char* filename,
|
||||
const char* retry_config,
|
||||
int timeout_millisec,
|
||||
TessResultRenderer* renderer);
|
||||
|
||||
TESS_API TessResultIterator* TESS_CALL
|
||||
TessBaseAPIGetIterator(TessBaseAPI* handle);
|
||||
TESS_API TessMutableIterator* TESS_CALL
|
||||
TessBaseAPIGetMutableIterator(TessBaseAPI* handle);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetAltoText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetTsvText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetLSTMBoxText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetWordStrBoxText(TessBaseAPI* handle,
|
||||
int page_number);
|
||||
|
||||
TESS_API char* TESS_CALL TessBaseAPIGetUNLVText(TessBaseAPI* handle);
|
||||
TESS_API int TESS_CALL TessBaseAPIMeanTextConf(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int* TESS_CALL TessBaseAPIAllWordConfidences(TessBaseAPI* handle);
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIAdaptToWordStr(TessBaseAPI* handle,
|
||||
TessPageSegMode mode,
|
||||
const char* wordstr);
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIClear(TessBaseAPI* handle);
|
||||
TESS_API void TESS_CALL TessBaseAPIEnd(TessBaseAPI* handle);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPIIsValidWord(TessBaseAPI* handle,
|
||||
const char* word);
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIGetTextDirection(TessBaseAPI* handle,
|
||||
int* out_offset,
|
||||
float* out_slope);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetDictFunc(TessBaseAPI* handle,
|
||||
TessDictFunc f);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIClearPersistentCache(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetProbabilityInContextFunc(
|
||||
TessBaseAPI* handle, TessProbabilityInContextFunc f);
|
||||
|
||||
// Call TessDeleteText(*best_script_name) to free memory allocated by this
|
||||
// function
|
||||
TESS_API BOOL TESS_CALL TessBaseAPIDetectOrientationScript(
|
||||
TessBaseAPI* handle, int* orient_deg, float* orient_conf,
|
||||
const char** script_name, float* script_conf);
|
||||
|
||||
#endif // def TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
TESS_API const char* TESS_CALL TessBaseAPIGetUnichar(TessBaseAPI* handle,
|
||||
int unichar_id);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI* handle,
|
||||
double margin);
|
||||
|
||||
#ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
TESS_API const TessDawg* TESS_CALL TessBaseAPIGetDawg(const TessBaseAPI* handle,
|
||||
int i);
|
||||
|
||||
TESS_API int TESS_CALL TessBaseAPINumDawgs(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API TessOcrEngineMode TESS_CALL TessBaseAPIOem(const TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle,
|
||||
TessTruthCallback* cb);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseGetBlockTextOrientations(
|
||||
TessBaseAPI* handle, int** block_orientation, bool** vertical_writing);
|
||||
|
||||
#endif
|
||||
|
||||
/* Page iterator */
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorDelete(TessPageIterator* handle);
|
||||
|
||||
TESS_API TessPageIterator* TESS_CALL
|
||||
TessPageIteratorCopy(const TessPageIterator* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorBegin(TessPageIterator* handle);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorNext(TessPageIterator* handle,
|
||||
TessPageIteratorLevel level);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorIsAtBeginningOf(
|
||||
const TessPageIterator* handle, TessPageIteratorLevel level);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorIsAtFinalElement(
|
||||
const TessPageIterator* handle, TessPageIteratorLevel level,
|
||||
TessPageIteratorLevel element);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorBoundingBox(
|
||||
const TessPageIterator* handle, TessPageIteratorLevel level, int* left,
|
||||
int* top, int* right, int* bottom);
|
||||
|
||||
TESS_API TessPolyBlockType TESS_CALL
|
||||
TessPageIteratorBlockType(const TessPageIterator* handle);
|
||||
|
||||
TESS_API struct Pix* TESS_CALL TessPageIteratorGetBinaryImage(
|
||||
const TessPageIterator* handle, TessPageIteratorLevel level);
|
||||
|
||||
TESS_API struct Pix* TESS_CALL TessPageIteratorGetImage(
|
||||
const TessPageIterator* handle, TessPageIteratorLevel level, int padding,
|
||||
struct Pix* original_image, int* left, int* top);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessPageIteratorBaseline(const TessPageIterator* handle,
|
||||
TessPageIteratorLevel level,
|
||||
int* x1, int* y1, int* x2,
|
||||
int* y2);
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorOrientation(
|
||||
TessPageIterator* handle, TessOrientation* orientation,
|
||||
TessWritingDirection* writing_direction, TessTextlineOrder* textline_order,
|
||||
float* deskew_angle);
|
||||
|
||||
TESS_API void TESS_CALL TessPageIteratorParagraphInfo(
|
||||
TessPageIterator* handle, TessParagraphJustification* justification,
|
||||
BOOL* is_list_item, BOOL* is_crown, int* first_line_indent);
|
||||
|
||||
/* Result iterator */
|
||||
|
||||
TESS_API void TESS_CALL TessResultIteratorDelete(TessResultIterator* handle);
|
||||
TESS_API TessResultIterator* TESS_CALL
|
||||
TessResultIteratorCopy(const TessResultIterator* handle);
|
||||
TESS_API TessPageIterator* TESS_CALL
|
||||
TessResultIteratorGetPageIterator(TessResultIterator* handle);
|
||||
TESS_API const TessPageIterator* TESS_CALL
|
||||
TessResultIteratorGetPageIteratorConst(const TessResultIterator* handle);
|
||||
TESS_API TessChoiceIterator* TESS_CALL
|
||||
TessResultIteratorGetChoiceIterator(const TessResultIterator* handle);
|
||||
|
||||
TESS_API BOOL TESS_CALL TessResultIteratorNext(TessResultIterator* handle,
|
||||
TessPageIteratorLevel level);
|
||||
TESS_API char* TESS_CALL TessResultIteratorGetUTF8Text(
|
||||
const TessResultIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API float TESS_CALL TessResultIteratorConfidence(
|
||||
const TessResultIterator* handle, TessPageIteratorLevel level);
|
||||
TESS_API const char* TESS_CALL
|
||||
TessResultIteratorWordRecognitionLanguage(const TessResultIterator* handle);
|
||||
TESS_API const char* TESS_CALL TessResultIteratorWordFontAttributes(
|
||||
const TessResultIterator* handle, BOOL* is_bold, BOOL* is_italic,
|
||||
BOOL* is_underlined, BOOL* is_monospace, BOOL* is_serif, BOOL* is_smallcaps,
|
||||
int* pointsize, int* font_id);
|
||||
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultIteratorWordIsFromDictionary(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultIteratorWordIsNumeric(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultIteratorSymbolIsSuperscript(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultIteratorSymbolIsSubscript(const TessResultIterator* handle);
|
||||
TESS_API BOOL TESS_CALL
|
||||
TessResultIteratorSymbolIsDropcap(const TessResultIterator* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessChoiceIteratorDelete(TessChoiceIterator* handle);
|
||||
TESS_API BOOL TESS_CALL TessChoiceIteratorNext(TessChoiceIterator* handle);
|
||||
TESS_API const char* TESS_CALL
|
||||
TessChoiceIteratorGetUTF8Text(const TessChoiceIterator* handle);
|
||||
TESS_API float TESS_CALL
|
||||
TessChoiceIteratorConfidence(const TessChoiceIterator* handle);
|
||||
|
||||
/* Progress monitor */
|
||||
|
||||
TESS_API ETEXT_DESC* TESS_CALL TessMonitorCreate();
|
||||
TESS_API void TESS_CALL TessMonitorDelete(ETEXT_DESC* monitor);
|
||||
TESS_API void TESS_CALL TessMonitorSetCancelFunc(ETEXT_DESC* monitor,
|
||||
TessCancelFunc cancelFunc);
|
||||
TESS_API void TESS_CALL TessMonitorSetCancelThis(ETEXT_DESC* monitor,
|
||||
void* cancelThis);
|
||||
TESS_API void* TESS_CALL TessMonitorGetCancelThis(ETEXT_DESC* monitor);
|
||||
TESS_API void TESS_CALL
|
||||
TessMonitorSetProgressFunc(ETEXT_DESC* monitor, TessProgressFunc progressFunc);
|
||||
TESS_API int TESS_CALL TessMonitorGetProgress(ETEXT_DESC* monitor);
|
||||
TESS_API void TESS_CALL TessMonitorSetDeadlineMSecs(ETEXT_DESC* monitor,
|
||||
int deadline);
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
# ifdef TESS_CAPI_INCLUDE_BASEAPI
|
||||
TESS_API void TESS_CALL TessBaseAPISetFillLatticeFunc(TessBaseAPI* handle,
|
||||
TessFillLatticeFunc f);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIGetFeaturesForBlob(
|
||||
TessBaseAPI* handle, TBLOB* blob, INT_FEATURE_STRUCT* int_features,
|
||||
int* num_features, int* FeatureOutlineIndex);
|
||||
|
||||
TESS_API ROW* TESS_CALL TessFindRowForBox(BLOCK_LIST* blocks, int left, int top,
|
||||
int right, int bottom);
|
||||
|
||||
TESS_API void TESS_CALL TessBaseAPIRunAdaptiveClassifier(
|
||||
TessBaseAPI* handle, TBLOB* blob, int num_max_matches, int* unichar_ids,
|
||||
float* ratings, int* num_matches_returned);
|
||||
|
||||
TESS_API ROW* TESS_CALL TessMakeTessOCRRow(float baseline, float xheight,
|
||||
float descender, float ascender);
|
||||
|
||||
TESS_API TBLOB* TESS_CALL TessMakeTBLOB(Pix* pix);
|
||||
|
||||
TESS_API void TESS_CALL TessNormalizeTBLOB(TBLOB* tblob, ROW* row,
|
||||
BOOL numeric_mode);
|
||||
|
||||
TESS_API BLOCK_LIST* TESS_CALL
|
||||
TessBaseAPIFindLinesCreateBlockList(TessBaseAPI* handle);
|
||||
|
||||
TESS_API void TESS_CALL TessDeleteBlockList(BLOCK_LIST* block_list);
|
||||
|
||||
# endif // def TESS_CAPI_INCLUDE_BASEAPI
|
||||
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // API_CAPI_H_
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,211 @@
|
|||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: helpers.h
|
||||
* Description: General utility functions
|
||||
* Author: Daria Antonova
|
||||
*
|
||||
* (c) Copyright 2009, Google Inc.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_HELPERS_H_
|
||||
#define TESSERACT_CCUTIL_HELPERS_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
// TODO(rays) Put the rest of the helpers in the namespace.
|
||||
namespace tesseract {
|
||||
|
||||
// A simple linear congruential random number generator, using Knuth's
|
||||
// constants from:
|
||||
// http://en.wikipedia.org/wiki/Linear_congruential_generator.
|
||||
class TRand {
|
||||
public:
|
||||
TRand() = default;
|
||||
// Sets the seed to the given value.
|
||||
void set_seed(uint64_t seed) {
|
||||
seed_ = seed;
|
||||
}
|
||||
// Sets the seed using a hash of a string.
|
||||
void set_seed(const std::string& str) {
|
||||
std::hash<std::string> hasher;
|
||||
set_seed(static_cast<uint64_t>(hasher(str)));
|
||||
}
|
||||
|
||||
// Returns an integer in the range 0 to INT32_MAX.
|
||||
int32_t IntRand() {
|
||||
Iterate();
|
||||
return seed_ >> 33;
|
||||
}
|
||||
// Returns a floating point value in the range [-range, range].
|
||||
double SignedRand(double range) {
|
||||
return range * 2.0 * IntRand() / INT32_MAX - range;
|
||||
}
|
||||
// Returns a floating point value in the range [0, range].
|
||||
double UnsignedRand(double range) {
|
||||
return range * IntRand() / INT32_MAX;
|
||||
}
|
||||
|
||||
private:
|
||||
// Steps the generator to the next value.
|
||||
void Iterate() {
|
||||
seed_ *= 6364136223846793005ULL;
|
||||
seed_ += 1442695040888963407ULL;
|
||||
}
|
||||
|
||||
// The current value of the seed.
|
||||
uint64_t seed_{1};
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
// Remove newline (if any) at the end of the string.
|
||||
inline void chomp_string(char* str) {
|
||||
int last_index = static_cast<int>(strlen(str)) - 1;
|
||||
while (last_index >= 0 &&
|
||||
(str[last_index] == '\n' || str[last_index] == '\r')) {
|
||||
str[last_index--] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Advance the current pointer of the file if it points to a newline character.
|
||||
inline void SkipNewline(FILE* file) {
|
||||
if (fgetc(file) != '\n') {
|
||||
fseek(file, -1, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
// Swaps the two args pointed to by the pointers.
|
||||
// Operator= and copy constructor must work on T.
|
||||
template <typename T>
|
||||
inline void Swap(T* p1, T* p2) {
|
||||
T tmp(*p2);
|
||||
*p2 = *p1;
|
||||
*p1 = tmp;
|
||||
}
|
||||
|
||||
// return the smallest multiple of block_size greater than or equal to n.
|
||||
inline int RoundUp(int n, int block_size) {
|
||||
return block_size * ((n + block_size - 1) / block_size);
|
||||
}
|
||||
|
||||
// Clip a numeric value to the interval [lower_bound, upper_bound].
|
||||
template <typename T>
|
||||
inline T ClipToRange(const T& x, const T& lower_bound, const T& upper_bound) {
|
||||
if (x < lower_bound) {
|
||||
return lower_bound;
|
||||
}
|
||||
if (x > upper_bound) {
|
||||
return upper_bound;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// Extend the range [lower_bound, upper_bound] to include x.
|
||||
template <typename T1, typename T2>
|
||||
inline void UpdateRange(const T1& x, T2* lower_bound, T2* upper_bound) {
|
||||
if (x < *lower_bound) {
|
||||
*lower_bound = x;
|
||||
}
|
||||
if (x > *upper_bound) {
|
||||
*upper_bound = x;
|
||||
}
|
||||
}
|
||||
|
||||
// Decrease lower_bound to be <= x_lo AND increase upper_bound to be >= x_hi.
|
||||
template <typename T1, typename T2>
|
||||
inline void UpdateRange(const T1& x_lo, const T1& x_hi, T2* lower_bound,
|
||||
T2* upper_bound) {
|
||||
if (x_lo < *lower_bound) {
|
||||
*lower_bound = x_lo;
|
||||
}
|
||||
if (x_hi > *upper_bound) {
|
||||
*upper_bound = x_hi;
|
||||
}
|
||||
}
|
||||
|
||||
// Intersect the range [*lower2, *upper2] with the range [lower1, upper1],
|
||||
// putting the result back in [*lower2, *upper2].
|
||||
// If non-intersecting ranges are given, we end up with *lower2 > *upper2.
|
||||
template <typename T>
|
||||
inline void IntersectRange(const T& lower1, const T& upper1, T* lower2,
|
||||
T* upper2) {
|
||||
if (lower1 > *lower2) {
|
||||
*lower2 = lower1;
|
||||
}
|
||||
if (upper1 < *upper2) {
|
||||
*upper2 = upper1;
|
||||
}
|
||||
}
|
||||
|
||||
// Proper modulo arithmetic operator. Returns a mod b that works for -ve a.
|
||||
// For any integer a and positive b, returns r : 0<=r<b and a=n*b + r for
|
||||
// some integer n.
|
||||
inline int Modulo(int a, int b) {
|
||||
return (a % b + b) % b;
|
||||
}
|
||||
|
||||
// Integer division operator with rounding that works for negative input.
|
||||
// Returns a divided by b, rounded to the nearest integer, without double
|
||||
// counting at 0. With simple rounding 1/3 = 0, 0/3 = 0 -1/3 = 0, -2/3 = 0,
|
||||
// -3/3 = 0 and -4/3 = -1.
|
||||
// I want 1/3 = 0, 0/3 = 0, -1/3 = 0, -2/3 = -1, -3/3 = -1 and -4/3 = -1.
|
||||
inline int DivRounded(int a, int b) {
|
||||
if (b < 0) {
|
||||
return -DivRounded(a, -b);
|
||||
}
|
||||
return a >= 0 ? (a + b / 2) / b : (a - b / 2) / b;
|
||||
}
|
||||
|
||||
// Return a double cast to int with rounding.
|
||||
inline int IntCastRounded(double x) {
|
||||
return x >= 0.0 ? static_cast<int>(x + 0.5) : -static_cast<int>(-x + 0.5);
|
||||
}
|
||||
|
||||
// Return a float cast to int with rounding.
|
||||
inline int IntCastRounded(float x) {
|
||||
return x >= 0.0F ? static_cast<int>(x + 0.5F) : -static_cast<int>(-x + 0.5F);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a n byte quantity for big/little-endian switch.
|
||||
inline void ReverseN(void* ptr, int num_bytes) {
|
||||
assert(num_bytes == 1 || num_bytes == 2 || num_bytes == 4 || num_bytes == 8);
|
||||
char* cptr = static_cast<char*>(ptr);
|
||||
int halfsize = num_bytes / 2;
|
||||
for (int i = 0; i < halfsize; ++i) {
|
||||
char tmp = cptr[i];
|
||||
cptr[i] = cptr[num_bytes - 1 - i];
|
||||
cptr[num_bytes - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 16 bit quantity for big/little-endian switch.
|
||||
inline void Reverse16(void* ptr) {
|
||||
ReverseN(ptr, 2);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 32 bit quantity for big/little-endian switch.
|
||||
inline void Reverse32(void* ptr) {
|
||||
ReverseN(ptr, 4);
|
||||
}
|
||||
|
||||
// Reverse the order of bytes in a 64 bit quantity for big/little-endian switch.
|
||||
inline void Reverse64(void* ptr) {
|
||||
ReverseN(ptr, 8);
|
||||
}
|
||||
|
||||
#endif // TESSERACT_CCUTIL_HELPERS_H_
|
228
third_party/ocr/tesseract-ocr/uos/sw_64/include/tesseract/ltrresultiterator.h
vendored
Normal file
228
third_party/ocr/tesseract-ocr/uos/sw_64/include/tesseract/ltrresultiterator.h
vendored
Normal file
|
@ -0,0 +1,228 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: ltrresultiterator.h
|
||||
// Description: Iterator for tesseract results in strict left-to-right
|
||||
// order that avoids using tesseract internal data structures.
|
||||
// Author: Ray Smith
|
||||
// Created: Fri Feb 26 11:01:06 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H_
|
||||
#define TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H_
|
||||
|
||||
#include "pageiterator.h" // for PageIterator
|
||||
#include "platform.h" // for TESS_API
|
||||
#include "publictypes.h" // for PageIteratorLevel
|
||||
#include "unichar.h" // for StrongScriptDirection
|
||||
|
||||
class BLOB_CHOICE_IT;
|
||||
class PAGE_RES;
|
||||
class WERD_RES;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
// Class to iterate over tesseract results, providing access to all levels
|
||||
// of the page hierarchy, without including any tesseract headers or having
|
||||
// to handle any tesseract structures.
|
||||
// WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
// therefore can only be used while the TessBaseAPI class still exists and
|
||||
// has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
// DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
// See apitypes.h for the definition of PageIteratorLevel.
|
||||
// See also base class PageIterator, which contains the bulk of the interface.
|
||||
// LTRResultIterator adds text-specific methods for access to OCR output.
|
||||
|
||||
class TESS_API LTRResultIterator : public PageIterator {
|
||||
friend class ChoiceIterator;
|
||||
public:
|
||||
// page_res and tesseract come directly from the BaseAPI.
|
||||
// The rectangle parameters are copied indirectly from the Thresholder,
|
||||
// via the BaseAPI. They represent the coordinates of some rectangle in an
|
||||
// original image (in top-left-origin coordinates) and therefore the top-left
|
||||
// needs to be added to any output boxes in order to specify coordinates
|
||||
// in the original image. See TessBaseAPI::SetRectangle.
|
||||
// The scale and scaled_yres are in case the Thresholder scaled the image
|
||||
// rectangle prior to thresholding. Any coordinates in tesseract's image
|
||||
// must be divided by scale before adding (rect_left, rect_top).
|
||||
// The scaled_yres indicates the effective resolution of the binary image
|
||||
// that tesseract has been given by the Thresholder.
|
||||
// After the constructor, Begin has already been called.
|
||||
LTRResultIterator(PAGE_RES* page_res, Tesseract* tesseract,
|
||||
int scale, int scaled_yres,
|
||||
int rect_left, int rect_top,
|
||||
int rect_width, int rect_height);
|
||||
|
||||
~LTRResultIterator() override;
|
||||
|
||||
// LTRResultIterators may be copied! This makes it possible to iterate over
|
||||
// all the objects at a lower level, while maintaining an iterator to
|
||||
// objects at a higher level. These constructors DO NOT CALL Begin, so
|
||||
// iterations will continue from the location of src.
|
||||
// TODO: For now the copy constructor and operator= only need the base class
|
||||
// versions, but if new data members are added, don't forget to add them!
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
|
||||
// See PageIterator.
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
// Returns the null terminated UTF-8 encoded text string for the current
|
||||
// object at the given level. Use delete [] to free after use.
|
||||
char* GetUTF8Text(PageIteratorLevel level) const;
|
||||
|
||||
// Set the string inserted at the end of each text line. "\n" by default.
|
||||
void SetLineSeparator(const char *new_line);
|
||||
|
||||
// Set the string inserted at the end of each paragraph. "\n" by default.
|
||||
void SetParagraphSeparator(const char *new_para);
|
||||
|
||||
// Returns the mean confidence of the current object at the given level.
|
||||
// The number should be interpreted as a percent probability. (0.0f-100.0f)
|
||||
float Confidence(PageIteratorLevel level) const;
|
||||
|
||||
// Returns the attributes of the current row.
|
||||
void RowAttributes(float* row_height, float* descenders,
|
||||
float* ascenders) const;
|
||||
|
||||
// ============= Functions that refer to words only ============.
|
||||
|
||||
// Returns the font attributes of the current word. If iterating at a higher
|
||||
// level object than words, eg textlines, then this will return the
|
||||
// attributes of the first word in that textline.
|
||||
// The actual return value is a string representing a font name. It points
|
||||
// to an internal table and SHOULD NOT BE DELETED. Lifespan is the same as
|
||||
// the iterator itself, ie rendered invalid by various members of
|
||||
// TessBaseAPI, including Init, SetImage, End or deleting the TessBaseAPI.
|
||||
// Pointsize is returned in printers points (1/72 inch.)
|
||||
const char* WordFontAttributes(bool* is_bold,
|
||||
bool* is_italic,
|
||||
bool* is_underlined,
|
||||
bool* is_monospace,
|
||||
bool* is_serif,
|
||||
bool* is_smallcaps,
|
||||
int* pointsize,
|
||||
int* font_id) const;
|
||||
|
||||
// Return the name of the language used to recognize this word.
|
||||
// On error, nullptr. Do not delete this pointer.
|
||||
const char* WordRecognitionLanguage() const;
|
||||
|
||||
// Return the overall directionality of this word.
|
||||
StrongScriptDirection WordDirection() const;
|
||||
|
||||
// Returns true if the current word was found in a dictionary.
|
||||
bool WordIsFromDictionary() const;
|
||||
|
||||
// Returns the number of blanks before the current word.
|
||||
int BlanksBeforeWord() const;
|
||||
|
||||
// Returns true if the current word is numeric.
|
||||
bool WordIsNumeric() const;
|
||||
|
||||
// Returns true if the word contains blamer information.
|
||||
bool HasBlamerInfo() const;
|
||||
|
||||
// Returns the pointer to ParamsTrainingBundle stored in the BlamerBundle
|
||||
// of the current word.
|
||||
const void *GetParamsTrainingBundle() const;
|
||||
|
||||
// Returns a pointer to the string with blamer information for this word.
|
||||
// Assumes that the word's blamer_bundle is not nullptr.
|
||||
const char *GetBlamerDebug() const;
|
||||
|
||||
// Returns a pointer to the string with misadaption information for this word.
|
||||
// Assumes that the word's blamer_bundle is not nullptr.
|
||||
const char *GetBlamerMisadaptionDebug() const;
|
||||
|
||||
// Returns true if a truth string was recorded for the current word.
|
||||
bool HasTruthString() const;
|
||||
|
||||
// Returns true if the given string is equivalent to the truth string for
|
||||
// the current word.
|
||||
bool EquivalentToTruth(const char *str) const;
|
||||
|
||||
// Returns a null terminated UTF-8 encoded truth string for the current word.
|
||||
// Use delete [] to free after use.
|
||||
char* WordTruthUTF8Text() const;
|
||||
|
||||
// Returns a null terminated UTF-8 encoded normalized OCR string for the
|
||||
// current word. Use delete [] to free after use.
|
||||
char* WordNormedUTF8Text() const;
|
||||
|
||||
// Returns a pointer to serialized choice lattice.
|
||||
// Fills lattice_size with the number of bytes in lattice data.
|
||||
const char *WordLattice(int *lattice_size) const;
|
||||
|
||||
// ============= Functions that refer to symbols only ============.
|
||||
|
||||
// Returns true if the current symbol is a superscript.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsSuperscript() const;
|
||||
// Returns true if the current symbol is a subscript.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsSubscript() const;
|
||||
// Returns true if the current symbol is a dropcap.
|
||||
// If iterating at a higher level object than symbols, eg words, then
|
||||
// this will return the attributes of the first symbol in that word.
|
||||
bool SymbolIsDropcap() const;
|
||||
|
||||
protected:
|
||||
const char *line_separator_;
|
||||
const char *paragraph_separator_;
|
||||
};
|
||||
|
||||
// Class to iterate over the classifier choices for a single RIL_SYMBOL.
|
||||
class ChoiceIterator {
|
||||
public:
|
||||
// Construction is from a LTRResultIterator that points to the symbol of
|
||||
// interest. The ChoiceIterator allows a one-shot iteration over the
|
||||
// choices for this symbol and after that is is useless.
|
||||
explicit ChoiceIterator(const LTRResultIterator& result_it);
|
||||
~ChoiceIterator();
|
||||
|
||||
// Moves to the next choice for the symbol and returns false if there
|
||||
// are none left.
|
||||
bool Next();
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
// Returns the null terminated UTF-8 encoded text string for the current
|
||||
// choice.
|
||||
// NOTE: Unlike LTRResultIterator::GetUTF8Text, the return points to an
|
||||
// internal structure and should NOT be delete[]ed to free after use.
|
||||
const char* GetUTF8Text() const;
|
||||
|
||||
// Returns the confidence of the current choice depending on the used language
|
||||
// data. If only LSTM traineddata is used the value range is 0.0f - 1.0f. All
|
||||
// choices for one symbol should roughly add up to 1.0f.
|
||||
// If only traineddata of the legacy engine is used, the number should be
|
||||
// interpreted as a percent probability. (0.0f-100.0f) In this case
|
||||
// probabilities won't add up to 100. Each one stands on its own.
|
||||
float Confidence() const;
|
||||
|
||||
private:
|
||||
// Pointer to the WERD_RES object owned by the API.
|
||||
WERD_RES* word_res_;
|
||||
// Iterator over the blob choices.
|
||||
BLOB_CHOICE_IT* choice_it_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H_
|
|
@ -0,0 +1,167 @@
|
|||
/**********************************************************************
|
||||
* File: ocrclass.h
|
||||
* Description: Class definitions and constants for the OCR API.
|
||||
* Author: Hewlett-Packard Co
|
||||
*
|
||||
* (C) Copyright 1996, Hewlett-Packard Co.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* This file contains typedefs for all the structures used by
|
||||
* the HP OCR interface.
|
||||
* The structures are designed to allow them to be used with any
|
||||
* structure alignment up to 8.
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef CCUTIL_OCRCLASS_H_
|
||||
#define CCUTIL_OCRCLASS_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h> // for timeval
|
||||
#endif
|
||||
|
||||
/**********************************************************************
|
||||
* EANYCODE_CHAR
|
||||
* Description of a single character. The character code is defined by
|
||||
* the character set of the current font.
|
||||
* Output text is sent as an array of these structures.
|
||||
* Spaces and line endings in the output are represented in the
|
||||
* structures of the surrounding characters. They are not directly
|
||||
* represented as characters.
|
||||
* The first character in a word has a positive value of blanks.
|
||||
* Missing information should be set to the defaults in the comments.
|
||||
* If word bounds are known, but not character bounds, then the top and
|
||||
* bottom of each character should be those of the word. The left of the
|
||||
* first and right of the last char in each word should be set. All other
|
||||
* lefts and rights should be set to -1.
|
||||
* If set, the values of right and bottom are left+width and top+height.
|
||||
* Most of the members come directly from the parameters to ocr_append_char.
|
||||
* The formatting member uses the enhancement parameter and combines the
|
||||
* line direction stuff into the top 3 bits.
|
||||
* The coding is 0=RL char, 1=LR char, 2=DR NL, 3=UL NL, 4=DR Para,
|
||||
* 5=UL Para, 6=TB char, 7=BT char. API users do not need to know what
|
||||
* the coding is, only that it is backwards compatible with the previous
|
||||
* version.
|
||||
**********************************************************************/
|
||||
|
||||
typedef struct { /*single character */
|
||||
// It should be noted that the format for char_code for version 2.0 and beyond
|
||||
// is UTF8 which means that ASCII characters will come out as one structure
|
||||
// but other characters will be returned in two or more instances of this
|
||||
// structure with a single byte of the UTF8 code in each, but each will have
|
||||
// the same bounding box. Programs which want to handle languagues with
|
||||
// different characters sets will need to handle extended characters
|
||||
// appropriately, but *all* code needs to be prepared to receive UTF8 coded
|
||||
// characters for characters such as bullet and fancy quotes.
|
||||
uint16_t char_code; /*character itself */
|
||||
int16_t left; /*of char (-1) */
|
||||
int16_t right; /*of char (-1) */
|
||||
int16_t top; /*of char (-1) */
|
||||
int16_t bottom; /*of char (-1) */
|
||||
int16_t font_index; /*what font (0) */
|
||||
uint8_t confidence; /*0=perfect, 100=reject (0/100) */
|
||||
uint8_t point_size; /*of char, 72=i inch, (10) */
|
||||
int8_t blanks; /*no of spaces before this char (1) */
|
||||
uint8_t formatting; /*char formatting (0) */
|
||||
} EANYCODE_CHAR; /*single character */
|
||||
|
||||
/**********************************************************************
|
||||
* ETEXT_DESC
|
||||
* Description of the output of the OCR engine.
|
||||
* This structure is used as both a progress monitor and the final
|
||||
* output header, since it needs to be a valid progress monitor while
|
||||
* the OCR engine is storing its output to shared memory.
|
||||
* During progress, all the buffer info is -1.
|
||||
* Progress starts at 0 and increases to 100 during OCR. No other constraint.
|
||||
* Additionally the progress callback contains the bounding box of the word that
|
||||
* is currently being processed.
|
||||
* Every progress callback, the OCR engine must set ocr_alive to 1.
|
||||
* The HP side will set ocr_alive to 0. Repeated failure to reset
|
||||
* to 1 indicates that the OCR engine is dead.
|
||||
* If the cancel function is not null then it is called with the number of
|
||||
* user words found. If it returns true then operation is cancelled.
|
||||
**********************************************************************/
|
||||
class ETEXT_DESC;
|
||||
|
||||
using CANCEL_FUNC = bool (*)(void*, int);
|
||||
using PROGRESS_FUNC = bool (*)(int, int, int, int, int);
|
||||
using PROGRESS_FUNC2 = bool (*)(ETEXT_DESC*, int, int, int, int);
|
||||
|
||||
class ETEXT_DESC { // output header
|
||||
public:
|
||||
int16_t count{0}; /// chars in this buffer(0)
|
||||
int16_t progress{0}; /// percent complete increasing (0-100)
|
||||
/** Progress monitor covers word recognition and it does not cover layout
|
||||
* analysis.
|
||||
* See Ray comment in https://github.com/tesseract-ocr/tesseract/pull/27 */
|
||||
int8_t more_to_come{0}; /// true if not last
|
||||
volatile int8_t ocr_alive{0}; /// ocr sets to 1, HP 0
|
||||
int8_t err_code{0}; /// for errcode use
|
||||
CANCEL_FUNC cancel{nullptr}; /// returns true to cancel
|
||||
PROGRESS_FUNC progress_callback{
|
||||
nullptr}; /// called whenever progress increases
|
||||
PROGRESS_FUNC2 progress_callback2; /// monitor-aware progress callback
|
||||
void* cancel_this{nullptr}; /// this or other data for cancel
|
||||
struct timeval end_time;
|
||||
/// Time to stop. Expected to be set only
|
||||
/// by call to set_deadline_msecs().
|
||||
EANYCODE_CHAR text[1]{}; /// character data
|
||||
|
||||
ETEXT_DESC() : progress_callback2(&default_progress_func) {
|
||||
auto chrono_end_time = std::chrono::time_point<std::chrono::steady_clock,
|
||||
std::chrono::milliseconds>();
|
||||
timePointToTimeval(chrono_end_time, &end_time);
|
||||
}
|
||||
|
||||
// Sets the end time to be deadline_msecs milliseconds from now.
|
||||
void set_deadline_msecs(int32_t deadline_msecs) {
|
||||
if (deadline_msecs > 0) {
|
||||
auto chrono_end_time = std::chrono::steady_clock::now() +
|
||||
std::chrono::milliseconds(deadline_msecs);
|
||||
timePointToTimeval(chrono_end_time, &end_time);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns false if we've not passed the end_time, or have not set a deadline.
|
||||
bool deadline_exceeded() const {
|
||||
if (end_time.tv_sec == 0 && end_time.tv_usec == 0)
|
||||
return false;
|
||||
auto chrono_now = std::chrono::steady_clock::now();
|
||||
struct timeval now;
|
||||
timePointToTimeval(chrono_now, &now);
|
||||
return (now.tv_sec > end_time.tv_sec ||
|
||||
(now.tv_sec == end_time.tv_sec && now.tv_usec > end_time.tv_usec));
|
||||
}
|
||||
|
||||
private:
|
||||
static void timePointToTimeval(
|
||||
std::chrono::steady_clock::time_point chrono_point, struct timeval* tv) {
|
||||
auto millisecs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
chrono_point.time_since_epoch());
|
||||
tv->tv_sec = millisecs.count() / 1000;
|
||||
tv->tv_usec = (millisecs.count() % 1000) * 1000;
|
||||
}
|
||||
|
||||
static bool default_progress_func(ETEXT_DESC* ths, int left, int right,
|
||||
int top, int bottom) {
|
||||
if (ths->progress_callback != nullptr) {
|
||||
return (*(ths->progress_callback))(ths->progress, left, right, top,
|
||||
bottom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CCUTIL_OCRCLASS_H_
|
|
@ -0,0 +1,140 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: osdetect.h
|
||||
// Description: Orientation and script detection.
|
||||
// Author: Samuel Charron
|
||||
// Ranjith Unnikrishnan
|
||||
//
|
||||
// (C) Copyright 2008, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_OSDETECT_H_
|
||||
#define TESSERACT_CCMAIN_OSDETECT_H_
|
||||
|
||||
#include "platform.h" // for TESS_API
|
||||
|
||||
class BLOBNBOX;
|
||||
class BLOBNBOX_CLIST;
|
||||
class BLOB_CHOICE_LIST;
|
||||
class STRING;
|
||||
class TO_BLOCK_LIST;
|
||||
class UNICHARSET;
|
||||
template <typename T> class GenericVector;
|
||||
|
||||
namespace tesseract {
|
||||
class Tesseract;
|
||||
}
|
||||
|
||||
// Max number of scripts in ICU + "NULL" + Japanese and Korean + Fraktur
|
||||
const int kMaxNumberOfScripts = 116 + 1 + 2 + 1;
|
||||
|
||||
struct OSBestResult {
|
||||
OSBestResult() : orientation_id(0), script_id(0), sconfidence(0.0),
|
||||
oconfidence(0.0) {}
|
||||
int orientation_id;
|
||||
int script_id;
|
||||
float sconfidence;
|
||||
float oconfidence;
|
||||
};
|
||||
|
||||
struct OSResults {
|
||||
OSResults() : unicharset(nullptr) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < kMaxNumberOfScripts; ++j)
|
||||
scripts_na[i][j] = 0;
|
||||
orientations[i] = 0;
|
||||
}
|
||||
}
|
||||
void update_best_orientation();
|
||||
// Set the estimate of the orientation to the given id.
|
||||
void set_best_orientation(int orientation_id);
|
||||
// Update/Compute the best estimate of the script assuming the given
|
||||
// orientation id.
|
||||
void update_best_script(int orientation_id);
|
||||
// Return the index of the script with the highest score for this orientation.
|
||||
TESS_API int get_best_script(int orientation_id) const;
|
||||
// Accumulate scores with given OSResults instance and update the best script.
|
||||
void accumulate(const OSResults& osr);
|
||||
|
||||
// Print statistics.
|
||||
void print_scores(void) const;
|
||||
void print_scores(int orientation_id) const;
|
||||
|
||||
// Array holding scores for each orientation id [0,3].
|
||||
// Orientation ids [0..3] map to [0, 270, 180, 90] degree orientations of the
|
||||
// page respectively, where the values refer to the amount of clockwise
|
||||
// rotation to be applied to the page for the text to be upright and readable.
|
||||
float orientations[4];
|
||||
// Script confidence scores for each of 4 possible orientations.
|
||||
float scripts_na[4][kMaxNumberOfScripts];
|
||||
|
||||
UNICHARSET* unicharset;
|
||||
OSBestResult best_result;
|
||||
};
|
||||
|
||||
class OrientationDetector {
|
||||
public:
|
||||
OrientationDetector(const GenericVector<int>* allowed_scripts,
|
||||
OSResults* results);
|
||||
bool detect_blob(BLOB_CHOICE_LIST* scores);
|
||||
int get_orientation();
|
||||
private:
|
||||
OSResults* osr_;
|
||||
const GenericVector<int>* allowed_scripts_;
|
||||
};
|
||||
|
||||
class ScriptDetector {
|
||||
public:
|
||||
ScriptDetector(const GenericVector<int>* allowed_scripts,
|
||||
OSResults* osr, tesseract::Tesseract* tess);
|
||||
void detect_blob(BLOB_CHOICE_LIST* scores);
|
||||
bool must_stop(int orientation);
|
||||
private:
|
||||
OSResults* osr_;
|
||||
static const char* korean_script_;
|
||||
static const char* japanese_script_;
|
||||
static const char* fraktur_script_;
|
||||
int korean_id_;
|
||||
int japanese_id_;
|
||||
int katakana_id_;
|
||||
int hiragana_id_;
|
||||
int han_id_;
|
||||
int hangul_id_;
|
||||
int latin_id_;
|
||||
int fraktur_id_;
|
||||
tesseract::Tesseract* tess_;
|
||||
const GenericVector<int>* allowed_scripts_;
|
||||
};
|
||||
|
||||
int orientation_and_script_detection(STRING& filename,
|
||||
OSResults*,
|
||||
tesseract::Tesseract*);
|
||||
|
||||
int os_detect(TO_BLOCK_LIST* port_blocks,
|
||||
OSResults* osr,
|
||||
tesseract::Tesseract* tess);
|
||||
|
||||
int os_detect_blobs(const GenericVector<int>* allowed_scripts,
|
||||
BLOBNBOX_CLIST* blob_list,
|
||||
OSResults* osr,
|
||||
tesseract::Tesseract* tess);
|
||||
|
||||
bool os_detect_blob(BLOBNBOX* bbox, OrientationDetector* o,
|
||||
ScriptDetector* s, OSResults*,
|
||||
tesseract::Tesseract* tess);
|
||||
|
||||
// Helper method to convert an orientation index to its value in degrees.
|
||||
// The value represents the amount of clockwise rotation in degrees that must be
|
||||
// applied for the text to be upright (readable).
|
||||
TESS_API int OrientationIdToValue(const int& id);
|
||||
|
||||
#endif // TESSERACT_CCMAIN_OSDETECT_H_
|
|
@ -0,0 +1,364 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: pageiterator.h
|
||||
// Description: Iterator for tesseract page structure that avoids using
|
||||
// tesseract internal data structures.
|
||||
// Author: Ray Smith
|
||||
// Created: Fri Feb 26 11:01:06 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_PAGEITERATOR_H_
|
||||
#define TESSERACT_CCMAIN_PAGEITERATOR_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "publictypes.h"
|
||||
|
||||
struct BlamerBundle;
|
||||
class C_BLOB_IT;
|
||||
class PAGE_RES;
|
||||
class PAGE_RES_IT;
|
||||
class WERD;
|
||||
struct Pix;
|
||||
struct Pta;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
/**
|
||||
* Class to iterate over tesseract page structure, providing access to all
|
||||
* levels of the page hierarchy, without including any tesseract headers or
|
||||
* having to handle any tesseract structures.
|
||||
* WARNING! This class points to data held within the TessBaseAPI class, and
|
||||
* therefore can only be used while the TessBaseAPI class still exists and
|
||||
* has not been subjected to a call of Init, SetImage, Recognize, Clear, End
|
||||
* DetectOS, or anything else that changes the internal PAGE_RES.
|
||||
* See apitypes.h for the definition of PageIteratorLevel.
|
||||
* See also ResultIterator, derived from PageIterator, which adds in the
|
||||
* ability to access OCR output with text-specific methods.
|
||||
*/
|
||||
|
||||
class TESS_API PageIterator {
|
||||
public:
|
||||
/**
|
||||
* page_res and tesseract come directly from the BaseAPI.
|
||||
* The rectangle parameters are copied indirectly from the Thresholder,
|
||||
* via the BaseAPI. They represent the coordinates of some rectangle in an
|
||||
* original image (in top-left-origin coordinates) and therefore the top-left
|
||||
* needs to be added to any output boxes in order to specify coordinates
|
||||
* in the original image. See TessBaseAPI::SetRectangle.
|
||||
* The scale and scaled_yres are in case the Thresholder scaled the image
|
||||
* rectangle prior to thresholding. Any coordinates in tesseract's image
|
||||
* must be divided by scale before adding (rect_left, rect_top).
|
||||
* The scaled_yres indicates the effective resolution of the binary image
|
||||
* that tesseract has been given by the Thresholder.
|
||||
* After the constructor, Begin has already been called.
|
||||
*/
|
||||
PageIterator(PAGE_RES* page_res, Tesseract* tesseract,
|
||||
int scale, int scaled_yres,
|
||||
int rect_left, int rect_top,
|
||||
int rect_width, int rect_height);
|
||||
virtual ~PageIterator();
|
||||
|
||||
/**
|
||||
* Page/ResultIterators may be copied! This makes it possible to iterate over
|
||||
* all the objects at a lower level, while maintaining an iterator to
|
||||
* objects at a higher level. These constructors DO NOT CALL Begin, so
|
||||
* iterations will continue from the location of src.
|
||||
*/
|
||||
PageIterator(const PageIterator& src);
|
||||
const PageIterator& operator=(const PageIterator& src);
|
||||
|
||||
/** Are we positioned at the same location as other? */
|
||||
bool PositionedAtSameWord(const PAGE_RES_IT* other) const;
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
|
||||
/**
|
||||
* Moves the iterator to point to the start of the page to begin an
|
||||
* iteration.
|
||||
*/
|
||||
virtual void Begin();
|
||||
|
||||
/**
|
||||
* Moves the iterator to the beginning of the paragraph.
|
||||
* This class implements this functionality by moving it to the zero indexed
|
||||
* blob of the first (leftmost) word on the first row of the paragraph.
|
||||
*/
|
||||
virtual void RestartParagraph();
|
||||
|
||||
/**
|
||||
* Return whether this iterator points anywhere in the first textline of a
|
||||
* paragraph.
|
||||
*/
|
||||
bool IsWithinFirstTextlineOfParagraph() const;
|
||||
|
||||
/**
|
||||
* Moves the iterator to the beginning of the text line.
|
||||
* This class implements this functionality by moving it to the zero indexed
|
||||
* blob of the first (leftmost) word of the row.
|
||||
*/
|
||||
virtual void RestartRow();
|
||||
|
||||
/**
|
||||
* Moves to the start of the next object at the given level in the
|
||||
* page hierarchy, and returns false if the end of the page was reached.
|
||||
* NOTE that RIL_SYMBOL will skip non-text blocks, but all other
|
||||
* PageIteratorLevel level values will visit each non-text block once.
|
||||
* Think of non text blocks as containing a single para, with a single line,
|
||||
* with a single imaginary word.
|
||||
* Calls to Next with different levels may be freely intermixed.
|
||||
* This function iterates words in right-to-left scripts correctly, if
|
||||
* the appropriate language has been loaded into Tesseract.
|
||||
*/
|
||||
virtual bool Next(PageIteratorLevel level);
|
||||
|
||||
/**
|
||||
* Returns true if the iterator is at the start of an object at the given
|
||||
* level.
|
||||
*
|
||||
* For instance, suppose an iterator it is pointed to the first symbol of the
|
||||
* first word of the third line of the second paragraph of the first block in
|
||||
* a page, then:
|
||||
* it.IsAtBeginningOf(RIL_BLOCK) = false
|
||||
* it.IsAtBeginningOf(RIL_PARA) = false
|
||||
* it.IsAtBeginningOf(RIL_TEXTLINE) = true
|
||||
* it.IsAtBeginningOf(RIL_WORD) = true
|
||||
* it.IsAtBeginningOf(RIL_SYMBOL) = true
|
||||
*/
|
||||
virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns whether the iterator is positioned at the last element in a
|
||||
* given level. (e.g. the last word in a line, the last line in a block)
|
||||
*
|
||||
* Here's some two-paragraph example
|
||||
* text. It starts off innocuously
|
||||
* enough but quickly turns bizarre.
|
||||
* The author inserts a cornucopia
|
||||
* of words to guard against confused
|
||||
* references.
|
||||
*
|
||||
* Now take an iterator it pointed to the start of "bizarre."
|
||||
* it.IsAtFinalElement(RIL_PARA, RIL_SYMBOL) = false
|
||||
* it.IsAtFinalElement(RIL_PARA, RIL_WORD) = true
|
||||
* it.IsAtFinalElement(RIL_BLOCK, RIL_WORD) = false
|
||||
*/
|
||||
virtual bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const;
|
||||
|
||||
/**
|
||||
* Returns whether this iterator is positioned
|
||||
* before other: -1
|
||||
* equal to other: 0
|
||||
* after other: 1
|
||||
*/
|
||||
int Cmp(const PageIterator &other) const;
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
// Coordinate system:
|
||||
// Integer coordinates are at the cracks between the pixels.
|
||||
// The top-left corner of the top-left pixel in the image is at (0,0).
|
||||
// The bottom-right corner of the bottom-right pixel in the image is at
|
||||
// (width, height).
|
||||
// Every bounding box goes from the top-left of the top-left contained
|
||||
// pixel to the bottom-right of the bottom-right contained pixel, so
|
||||
// the bounding box of the single top-left pixel in the image is:
|
||||
// (0,0)->(1,1).
|
||||
// If an image rectangle has been set in the API, then returned coordinates
|
||||
// relate to the original (full) image, rather than the rectangle.
|
||||
|
||||
/**
|
||||
* Controls what to include in a bounding box. Bounding boxes of all levels
|
||||
* between RIL_WORD and RIL_BLOCK can include or exclude potential diacritics.
|
||||
* Between layout analysis and recognition, it isn't known where all
|
||||
* diacritics belong, so this control is used to include or exclude some
|
||||
* diacritics that are above or below the main body of the word. In most cases
|
||||
* where the placement is obvious, and after recognition, it doesn't make as
|
||||
* much difference, as the diacritics will already be included in the word.
|
||||
*/
|
||||
void SetBoundingBoxComponents(bool include_upper_dots,
|
||||
bool include_lower_dots) {
|
||||
include_upper_dots_ = include_upper_dots;
|
||||
include_lower_dots_ = include_lower_dots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding rectangle of the current object at the given level.
|
||||
* See comment on coordinate system above.
|
||||
* Returns false if there is no such object at the current position.
|
||||
* The returned bounding box is guaranteed to match the size and position
|
||||
* of the image returned by GetBinaryImage, but may clip foreground pixels
|
||||
* from a grey image. The padding argument to GetImage can be used to expand
|
||||
* the image to include more foreground pixels. See GetImage below.
|
||||
*/
|
||||
bool BoundingBox(PageIteratorLevel level,
|
||||
int* left, int* top, int* right, int* bottom) const;
|
||||
bool BoundingBox(PageIteratorLevel level, int padding,
|
||||
int* left, int* top, int* right, int* bottom) const;
|
||||
/**
|
||||
* Returns the bounding rectangle of the object in a coordinate system of the
|
||||
* working image rectangle having its origin at (rect_left_, rect_top_) with
|
||||
* respect to the original image and is scaled by a factor scale_.
|
||||
*/
|
||||
bool BoundingBoxInternal(PageIteratorLevel level,
|
||||
int* left, int* top, int* right, int* bottom) const;
|
||||
|
||||
/** Returns whether there is no object of a given level. */
|
||||
bool Empty(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns the type of the current block. See apitypes.h for
|
||||
* PolyBlockType.
|
||||
*/
|
||||
PolyBlockType BlockType() const;
|
||||
|
||||
/**
|
||||
* Returns the polygon outline of the current block. The returned Pta must
|
||||
* be ptaDestroy-ed after use. Note that the returned Pta lists the vertices
|
||||
* of the polygon, and the last edge is the line segment between the last
|
||||
* point and the first point. nullptr will be returned if the iterator is
|
||||
* at the end of the document or layout analysis was not used.
|
||||
*/
|
||||
Pta* BlockPolygon() const;
|
||||
|
||||
/**
|
||||
* Returns a binary image of the current object at the given level.
|
||||
* The position and size match the return from BoundingBoxInternal, and so
|
||||
* this could be upscaled with respect to the original input image.
|
||||
* Use pixDestroy to delete the image after use.
|
||||
*/
|
||||
Pix* GetBinaryImage(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns an image of the current object at the given level in greyscale
|
||||
* if available in the input. To guarantee a binary image use BinaryImage.
|
||||
* NOTE that in order to give the best possible image, the bounds are
|
||||
* expanded slightly over the binary connected component, by the supplied
|
||||
* padding, so the top-left position of the returned image is returned
|
||||
* in (left,top). These will most likely not match the coordinates
|
||||
* returned by BoundingBox.
|
||||
* If you do not supply an original image, you will get a binary one.
|
||||
* Use pixDestroy to delete the image after use.
|
||||
*/
|
||||
Pix* GetImage(PageIteratorLevel level, int padding, Pix* original_img,
|
||||
int* left, int* top) const;
|
||||
|
||||
/**
|
||||
* Returns the baseline of the current object at the given level.
|
||||
* The baseline is the line that passes through (x1, y1) and (x2, y2).
|
||||
* WARNING: with vertical text, baselines may be vertical!
|
||||
* Returns false if there is no baseline at the current position.
|
||||
*/
|
||||
bool Baseline(PageIteratorLevel level,
|
||||
int* x1, int* y1, int* x2, int* y2) const;
|
||||
|
||||
/**
|
||||
* Returns orientation for the block the iterator points to.
|
||||
* orientation, writing_direction, textline_order: see publictypes.h
|
||||
* deskew_angle: after rotating the block so the text orientation is
|
||||
* upright, how many radians does one have to rotate the
|
||||
* block anti-clockwise for it to be level?
|
||||
* -Pi/4 <= deskew_angle <= Pi/4
|
||||
*/
|
||||
void Orientation(tesseract::Orientation *orientation,
|
||||
tesseract::WritingDirection *writing_direction,
|
||||
tesseract::TextlineOrder *textline_order,
|
||||
float *deskew_angle) const;
|
||||
|
||||
/**
|
||||
* Returns information about the current paragraph, if available.
|
||||
*
|
||||
* justification -
|
||||
* LEFT if ragged right, or fully justified and script is left-to-right.
|
||||
* RIGHT if ragged left, or fully justified and script is right-to-left.
|
||||
* unknown if it looks like source code or we have very few lines.
|
||||
* is_list_item -
|
||||
* true if we believe this is a member of an ordered or unordered list.
|
||||
* is_crown -
|
||||
* true if the first line of the paragraph is aligned with the other
|
||||
* lines of the paragraph even though subsequent paragraphs have first
|
||||
* line indents. This typically indicates that this is the continuation
|
||||
* of a previous paragraph or that it is the very first paragraph in
|
||||
* the chapter.
|
||||
* first_line_indent -
|
||||
* For LEFT aligned paragraphs, the first text line of paragraphs of
|
||||
* this kind are indented this many pixels from the left edge of the
|
||||
* rest of the paragraph.
|
||||
* for RIGHT aligned paragraphs, the first text line of paragraphs of
|
||||
* this kind are indented this many pixels from the right edge of the
|
||||
* rest of the paragraph.
|
||||
* NOTE 1: This value may be negative.
|
||||
* NOTE 2: if *is_crown == true, the first line of this paragraph is
|
||||
* actually flush, and first_line_indent is set to the "common"
|
||||
* first_line_indent for subsequent paragraphs in this block
|
||||
* of text.
|
||||
*/
|
||||
void ParagraphInfo(tesseract::ParagraphJustification *justification,
|
||||
bool *is_list_item,
|
||||
bool *is_crown,
|
||||
int *first_line_indent) const;
|
||||
|
||||
// If the current WERD_RES (it_->word()) is not nullptr, sets the BlamerBundle
|
||||
// of the current word to the given pointer (takes ownership of the pointer)
|
||||
// and returns true.
|
||||
// Can only be used when iterating on the word level.
|
||||
bool SetWordBlamerBundle(BlamerBundle *blamer_bundle);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Sets up the internal data for iterating the blobs of a new word, then
|
||||
* moves the iterator to the given offset.
|
||||
*/
|
||||
TESS_LOCAL void BeginWord(int offset);
|
||||
|
||||
/** Pointer to the page_res owned by the API. */
|
||||
PAGE_RES* page_res_;
|
||||
/** Pointer to the Tesseract object owned by the API. */
|
||||
Tesseract* tesseract_;
|
||||
/**
|
||||
* The iterator to the page_res_. Owned by this ResultIterator.
|
||||
* A pointer just to avoid dragging in Tesseract includes.
|
||||
*/
|
||||
PAGE_RES_IT* it_;
|
||||
/**
|
||||
* The current input WERD being iterated. If there is an output from OCR,
|
||||
* then word_ is nullptr. Owned by the API
|
||||
*/
|
||||
WERD* word_;
|
||||
/** The length of the current word_. */
|
||||
int word_length_;
|
||||
/** The current blob index within the word. */
|
||||
int blob_index_;
|
||||
/**
|
||||
* Iterator to the blobs within the word. If nullptr, then we are iterating
|
||||
* OCR results in the box_word.
|
||||
* Owned by this ResultIterator.
|
||||
*/
|
||||
C_BLOB_IT* cblob_it_;
|
||||
/** Control over what to include in bounding boxes. */
|
||||
bool include_upper_dots_;
|
||||
bool include_lower_dots_;
|
||||
/** Parameters saved from the Thresholder. Needed to rebuild coordinates.*/
|
||||
int scale_;
|
||||
int scaled_yres_;
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_PAGEITERATOR_H_
|
|
@ -0,0 +1,59 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: platform.h
|
||||
// Description: Place holder
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_PLATFORM_H_
|
||||
#define TESSERACT_CCUTIL_PLATFORM_H_
|
||||
|
||||
#define DLLSYM
|
||||
#ifndef _WIN32
|
||||
# ifdef __cplusplus
|
||||
# include <climits>
|
||||
# else /* C compiler*/
|
||||
# include <limits.h>
|
||||
# endif /* __cplusplus */
|
||||
# ifndef PATH_MAX
|
||||
# define MAX_PATH 4096
|
||||
# else
|
||||
# define MAX_PATH PATH_MAX
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# if defined(TESS_EXPORTS)
|
||||
# define TESS_API __declspec(dllexport)
|
||||
# elif defined(TESS_IMPORTS)
|
||||
# define TESS_API __declspec(dllimport)
|
||||
# else
|
||||
# define TESS_API
|
||||
# endif
|
||||
# define TESS_LOCAL
|
||||
#else
|
||||
# if __GNUC__ >= 4
|
||||
# if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
|
||||
# define TESS_API __attribute__((visibility("default")))
|
||||
# define TESS_LOCAL __attribute__((visibility("hidden")))
|
||||
# else
|
||||
# define TESS_API
|
||||
# define TESS_LOCAL
|
||||
# endif
|
||||
# else
|
||||
# define TESS_API
|
||||
# define TESS_LOCAL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // TESSERACT_CCUTIL_PLATFORM_H_
|
|
@ -0,0 +1,286 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: publictypes.h
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 09:22:53 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H_
|
||||
#define TESSERACT_CCSTRUCT_PUBLICTYPES_H_
|
||||
|
||||
// This file contains types that are used both by the API and internally
|
||||
// to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
|
||||
// dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
|
||||
// Restated: It is OK for low-level Tesseract files to include publictypes.h,
|
||||
// but not for the low-level tesseract code to include top-level API code.
|
||||
// This file should not use other Tesseract types, as that would drag
|
||||
// their includes into the API-level.
|
||||
// API-level code should include apitypes.h in preference to this file.
|
||||
|
||||
/** Number of printers' points in an inch. The unit of the pointsize return. */
|
||||
constexpr int kPointsPerInch = 72;
|
||||
/**
|
||||
* Minimum believable resolution. Used as a default if there is no other
|
||||
* information, as it is safer to under-estimate than over-estimate.
|
||||
*/
|
||||
constexpr int kMinCredibleResolution = 70;
|
||||
/** Maximum believable resolution. */
|
||||
constexpr int kMaxCredibleResolution = 2400;
|
||||
/**
|
||||
* Ratio between median blob size and likely resolution. Used to estimate
|
||||
* resolution when none is provided. This is basically 1/usual text size in
|
||||
* inches. */
|
||||
constexpr int kResolutionEstimationFactor = 10;
|
||||
|
||||
/**
|
||||
* Possible types for a POLY_BLOCK or ColPartition.
|
||||
* Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
|
||||
* below, as well as kPolyBlockNames in publictypes.cpp.
|
||||
* Used extensively by ColPartition, and POLY_BLOCK.
|
||||
*/
|
||||
enum PolyBlockType {
|
||||
PT_UNKNOWN, // Type is not yet known. Keep as the first element.
|
||||
PT_FLOWING_TEXT, // Text that lives inside a column.
|
||||
PT_HEADING_TEXT, // Text that spans more than one column.
|
||||
PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
|
||||
PT_EQUATION, // Partition belonging to an equation region.
|
||||
PT_INLINE_EQUATION, // Partition has inline equation.
|
||||
PT_TABLE, // Partition belonging to a table region.
|
||||
PT_VERTICAL_TEXT, // Text-line runs vertically.
|
||||
PT_CAPTION_TEXT, // Text that belongs to an image.
|
||||
PT_FLOWING_IMAGE, // Image that lives inside a column.
|
||||
PT_HEADING_IMAGE, // Image that spans more than one column.
|
||||
PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
|
||||
PT_HORZ_LINE, // Horizontal Line.
|
||||
PT_VERT_LINE, // Vertical Line.
|
||||
PT_NOISE, // Lies outside of any column.
|
||||
PT_COUNT
|
||||
};
|
||||
|
||||
/** Returns true if PolyBlockType is of horizontal line type */
|
||||
inline bool PTIsLineType(PolyBlockType type) {
|
||||
return type == PT_HORZ_LINE || type == PT_VERT_LINE;
|
||||
}
|
||||
/** Returns true if PolyBlockType is of image type */
|
||||
inline bool PTIsImageType(PolyBlockType type) {
|
||||
return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
|
||||
type == PT_PULLOUT_IMAGE;
|
||||
}
|
||||
/** Returns true if PolyBlockType is of text type */
|
||||
inline bool PTIsTextType(PolyBlockType type) {
|
||||
return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
|
||||
type == PT_PULLOUT_TEXT || type == PT_TABLE ||
|
||||
type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
|
||||
type == PT_INLINE_EQUATION;
|
||||
}
|
||||
// Returns true if PolyBlockType is of pullout(inter-column) type
|
||||
inline bool PTIsPulloutType(PolyBlockType type) {
|
||||
return type == PT_PULLOUT_IMAGE || type == PT_PULLOUT_TEXT;
|
||||
}
|
||||
|
||||
/** String name for each block type. Keep in sync with PolyBlockType. */
|
||||
extern const char* kPolyBlockNames[];
|
||||
|
||||
namespace tesseract {
|
||||
/**
|
||||
* +------------------+ Orientation Example:
|
||||
* | 1 Aaaa Aaaa Aaaa | ====================
|
||||
* | Aaa aa aaa aa | To left is a diagram of some (1) English and
|
||||
* | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit.
|
||||
* | 2 |
|
||||
* | ####### c c C | Upright Latin characters are represented as A and a.
|
||||
* | ####### c c c | '<' represents a latin character rotated
|
||||
* | < ####### c c c | anti-clockwise 90 degrees.
|
||||
* | < ####### c c |
|
||||
* | < ####### . c | Upright Chinese characters are represented C and c.
|
||||
* | 3 ####### c |
|
||||
* +------------------+ NOTA BENE: enum values here should match goodoc.proto
|
||||
|
||||
* If you orient your head so that "up" aligns with Orientation,
|
||||
* then the characters will appear "right side up" and readable.
|
||||
*
|
||||
* In the example above, both the English and Chinese paragraphs are oriented
|
||||
* so their "up" is the top of the page (page up). The photo credit is read
|
||||
* with one's head turned leftward ("up" is to page left).
|
||||
*
|
||||
* The values of this enum match the convention of Tesseract's osdetect.h
|
||||
*/
|
||||
enum Orientation {
|
||||
ORIENTATION_PAGE_UP = 0,
|
||||
ORIENTATION_PAGE_RIGHT = 1,
|
||||
ORIENTATION_PAGE_DOWN = 2,
|
||||
ORIENTATION_PAGE_LEFT = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* The grapheme clusters within a line of text are laid out logically
|
||||
* in this direction, judged when looking at the text line rotated so that
|
||||
* its Orientation is "page up".
|
||||
*
|
||||
* For English text, the writing direction is left-to-right. For the
|
||||
* Chinese text in the above example, the writing direction is top-to-bottom.
|
||||
*/
|
||||
enum WritingDirection {
|
||||
WRITING_DIRECTION_LEFT_TO_RIGHT = 0,
|
||||
WRITING_DIRECTION_RIGHT_TO_LEFT = 1,
|
||||
WRITING_DIRECTION_TOP_TO_BOTTOM = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* The text lines are read in the given sequence.
|
||||
*
|
||||
* In English, the order is top-to-bottom.
|
||||
* In Chinese, vertical text lines are read right-to-left. Mongolian is
|
||||
* written in vertical columns top to bottom like Chinese, but the lines
|
||||
* order left-to right.
|
||||
*
|
||||
* Note that only some combinations make sense. For example,
|
||||
* WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
|
||||
*/
|
||||
enum TextlineOrder {
|
||||
TEXTLINE_ORDER_LEFT_TO_RIGHT = 0,
|
||||
TEXTLINE_ORDER_RIGHT_TO_LEFT = 1,
|
||||
TEXTLINE_ORDER_TOP_TO_BOTTOM = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Possible modes for page layout analysis. These *must* be kept in order
|
||||
* of decreasing amount of layout analysis to be done, except for OSD_ONLY,
|
||||
* so that the inequality test macros below work.
|
||||
*/
|
||||
enum PageSegMode {
|
||||
PSM_OSD_ONLY = 0, ///< Orientation and script detection only.
|
||||
PSM_AUTO_OSD = 1, ///< Automatic page segmentation with orientation and
|
||||
///< script detection. (OSD)
|
||||
PSM_AUTO_ONLY = 2, ///< Automatic page segmentation, but no OSD, or OCR.
|
||||
PSM_AUTO = 3, ///< Fully automatic page segmentation, but no OSD.
|
||||
PSM_SINGLE_COLUMN = 4, ///< Assume a single column of text of variable sizes.
|
||||
PSM_SINGLE_BLOCK_VERT_TEXT = 5, ///< Assume a single uniform block of vertically
|
||||
///< aligned text.
|
||||
PSM_SINGLE_BLOCK = 6, ///< Assume a single uniform block of text. (Default.)
|
||||
PSM_SINGLE_LINE = 7, ///< Treat the image as a single text line.
|
||||
PSM_SINGLE_WORD = 8, ///< Treat the image as a single word.
|
||||
PSM_CIRCLE_WORD = 9, ///< Treat the image as a single word in a circle.
|
||||
PSM_SINGLE_CHAR = 10, ///< Treat the image as a single character.
|
||||
PSM_SPARSE_TEXT = 11, ///< Find as much text as possible in no particular order.
|
||||
PSM_SPARSE_TEXT_OSD = 12, ///< Sparse text with orientation and script det.
|
||||
PSM_RAW_LINE = 13, ///< Treat the image as a single text line, bypassing
|
||||
///< hacks that are Tesseract-specific.
|
||||
|
||||
PSM_COUNT ///< Number of enum entries.
|
||||
};
|
||||
|
||||
/**
|
||||
* Inline functions that act on a PageSegMode to determine whether components of
|
||||
* layout analysis are enabled.
|
||||
* *Depend critically on the order of elements of PageSegMode.*
|
||||
* NOTE that arg is an int for compatibility with INT_PARAM.
|
||||
*/
|
||||
inline bool PSM_OSD_ENABLED(int pageseg_mode) {
|
||||
return pageseg_mode <= PSM_AUTO_OSD || pageseg_mode == PSM_SPARSE_TEXT_OSD;
|
||||
}
|
||||
inline bool PSM_ORIENTATION_ENABLED(int pageseg_mode) {
|
||||
return pageseg_mode <= PSM_AUTO || pageseg_mode == PSM_SPARSE_TEXT_OSD;
|
||||
}
|
||||
inline bool PSM_COL_FIND_ENABLED(int pageseg_mode) {
|
||||
return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_AUTO;
|
||||
}
|
||||
inline bool PSM_SPARSE(int pageseg_mode) {
|
||||
return pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
|
||||
}
|
||||
inline bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode) {
|
||||
return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_COLUMN;
|
||||
}
|
||||
inline bool PSM_LINE_FIND_ENABLED(int pageseg_mode) {
|
||||
return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_BLOCK;
|
||||
}
|
||||
inline bool PSM_WORD_FIND_ENABLED(int pageseg_mode) {
|
||||
return (pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_LINE) ||
|
||||
pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
|
||||
}
|
||||
|
||||
/**
|
||||
* enum of the elements of the page hierarchy, used in ResultIterator
|
||||
* to provide functions that operate on each level without having to
|
||||
* have 5x as many functions.
|
||||
*/
|
||||
enum PageIteratorLevel {
|
||||
RIL_BLOCK, // Block of text/image/separator line.
|
||||
RIL_PARA, // Paragraph within a block.
|
||||
RIL_TEXTLINE, // Line within a paragraph.
|
||||
RIL_WORD, // Word within a textline.
|
||||
RIL_SYMBOL // Symbol/character within a word.
|
||||
};
|
||||
|
||||
/**
|
||||
* JUSTIFICATION_UNKNOWN
|
||||
* The alignment is not clearly one of the other options. This could happen
|
||||
* for example if there are only one or two lines of text or the text looks
|
||||
* like source code or poetry.
|
||||
*
|
||||
* NOTA BENE: Fully justified paragraphs (text aligned to both left and right
|
||||
* margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text
|
||||
* is written with a left-to-right script and with JUSTIFICATION_RIGHT if
|
||||
* their text is written in a right-to-left script.
|
||||
*
|
||||
* Interpretation for text read in vertical lines:
|
||||
* "Left" is wherever the starting reading position is.
|
||||
*
|
||||
* JUSTIFICATION_LEFT
|
||||
* Each line, except possibly the first, is flush to the same left tab stop.
|
||||
*
|
||||
* JUSTIFICATION_CENTER
|
||||
* The text lines of the paragraph are centered about a line going
|
||||
* down through their middle of the text lines.
|
||||
*
|
||||
* JUSTIFICATION_RIGHT
|
||||
* Each line, except possibly the first, is flush to the same right tab stop.
|
||||
*/
|
||||
enum ParagraphJustification {
|
||||
JUSTIFICATION_UNKNOWN,
|
||||
JUSTIFICATION_LEFT,
|
||||
JUSTIFICATION_CENTER,
|
||||
JUSTIFICATION_RIGHT,
|
||||
};
|
||||
|
||||
/**
|
||||
* When Tesseract/Cube is initialized we can choose to instantiate/load/run
|
||||
* only the Tesseract part, only the Cube part or both along with the combiner.
|
||||
* The preference of which engine to use is stored in tessedit_ocr_engine_mode.
|
||||
*
|
||||
* ATTENTION: When modifying this enum, please make sure to make the
|
||||
* appropriate changes to all the enums mirroring it (e.g. OCREngine in
|
||||
* cityblock/workflow/detection/detection_storage.proto). Such enums will
|
||||
* mention the connection to OcrEngineMode in the comments.
|
||||
*/
|
||||
enum OcrEngineMode {
|
||||
OEM_TESSERACT_ONLY, // Run Tesseract only - fastest; deprecated
|
||||
OEM_LSTM_ONLY, // Run just the LSTM line recognizer.
|
||||
OEM_TESSERACT_LSTM_COMBINED, // Run the LSTM recognizer, but allow fallback
|
||||
// to Tesseract when things get difficult.
|
||||
// deprecated
|
||||
OEM_DEFAULT, // Specify this mode when calling init_*(),
|
||||
// to indicate that any of the above modes
|
||||
// should be automatically inferred from the
|
||||
// variables in the language-specific config,
|
||||
// command-line configs, or if not specified
|
||||
// in any of the above should be set to the
|
||||
// default OEM_TESSERACT_ONLY.
|
||||
OEM_COUNT // Number of OEMs
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H_
|
|
@ -0,0 +1,310 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: renderer.h
|
||||
// Description: Rendering interface to inject into TessBaseAPI
|
||||
//
|
||||
// (C) Copyright 2011, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_RENDERER_H_
|
||||
#define TESSERACT_API_RENDERER_H_
|
||||
|
||||
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
|
||||
// complexity of includes here. Use forward declarations wherever possible
|
||||
// and hide includes of complex types in baseapi.cpp.
|
||||
#include <string> // for std::string
|
||||
#include "genericvector.h"
|
||||
#include "platform.h"
|
||||
#include "strngs.h" // for STRING
|
||||
|
||||
struct Pix;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class TessBaseAPI;
|
||||
|
||||
/**
|
||||
* Interface for rendering tesseract results into a document, such as text,
|
||||
* HOCR or pdf. This class is abstract. Specific classes handle individual
|
||||
* formats. This interface is then used to inject the renderer class into
|
||||
* tesseract when processing images.
|
||||
*
|
||||
* For simplicity implementing this with tesesract version 3.01,
|
||||
* the renderer contains document state that is cleared from document
|
||||
* to document just as the TessBaseAPI is. This way the base API can just
|
||||
* delegate its rendering functionality to injected renderers, and the
|
||||
* renderers can manage the associated state needed for the specific formats
|
||||
* in addition to the heuristics for producing it.
|
||||
*/
|
||||
class TESS_API TessResultRenderer {
|
||||
public:
|
||||
virtual ~TessResultRenderer();
|
||||
|
||||
// Takes ownership of pointer so must be new'd instance.
|
||||
// Renderers aren't ordered, but appends the sequences of next parameter
|
||||
// and existing next(). The renderers should be unique across both lists.
|
||||
void insert(TessResultRenderer* next);
|
||||
|
||||
// Returns the next renderer or nullptr.
|
||||
TessResultRenderer* next() {
|
||||
return next_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new document with the given title.
|
||||
* This clears the contents of the output data.
|
||||
* Title should use UTF-8 encoding.
|
||||
*/
|
||||
bool BeginDocument(const char* title);
|
||||
|
||||
/**
|
||||
* Adds the recognized text from the source image to the current document.
|
||||
* Invalid if BeginDocument not yet called.
|
||||
*
|
||||
* Note that this API is a bit weird but is designed to fit into the
|
||||
* current TessBaseAPI implementation where the api has lots of state
|
||||
* information that we might want to add in.
|
||||
*/
|
||||
bool AddImage(TessBaseAPI* api);
|
||||
|
||||
/**
|
||||
* Finishes the document and finalizes the output data
|
||||
* Invalid if BeginDocument not yet called.
|
||||
*/
|
||||
bool EndDocument();
|
||||
|
||||
const char* file_extension() const {
|
||||
return file_extension_;
|
||||
}
|
||||
const char* title() const {
|
||||
return title_.c_str();
|
||||
}
|
||||
|
||||
// Is everything fine? Otherwise something went wrong.
|
||||
bool happy() {
|
||||
return happy_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the last image given to AddImage
|
||||
* (i.e. images are incremented whether the image succeeded or not)
|
||||
*
|
||||
* This is always defined. It means either the number of the
|
||||
* current image, the last image ended, or in the completed document
|
||||
* depending on when in the document lifecycle you are looking at it.
|
||||
* Will return -1 if a document was never started.
|
||||
*/
|
||||
int imagenum() const {
|
||||
return imagenum_;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called by concrete classes.
|
||||
*
|
||||
* outputbase is the name of the output file excluding
|
||||
* extension. For example, "/path/to/chocolate-chip-cookie-recipe"
|
||||
*
|
||||
* extension indicates the file extension to be used for output
|
||||
* files. For example "pdf" will produce a .pdf file, and "hocr"
|
||||
* will produce .hocr files.
|
||||
*/
|
||||
TessResultRenderer(const char* outputbase, const char* extension);
|
||||
|
||||
// Hook for specialized handling in BeginDocument()
|
||||
virtual bool BeginDocumentHandler();
|
||||
|
||||
// This must be overridden to render the OCR'd results
|
||||
virtual bool AddImageHandler(TessBaseAPI* api) = 0;
|
||||
|
||||
// Hook for specialized handling in EndDocument()
|
||||
virtual bool EndDocumentHandler();
|
||||
|
||||
// Renderers can call this to append '\0' terminated strings into
|
||||
// the output string returned by GetOutput.
|
||||
// This method will grow the output buffer if needed.
|
||||
void AppendString(const char* s);
|
||||
|
||||
// Renderers can call this to append binary byte sequences into
|
||||
// the output string returned by GetOutput. Note that s is not necessarily
|
||||
// '\0' terminated (and can contain '\0' within it).
|
||||
// This method will grow the output buffer if needed.
|
||||
void AppendData(const char* s, int len);
|
||||
|
||||
private:
|
||||
const char* file_extension_; // standard extension for generated output
|
||||
STRING title_; // title of document being renderered
|
||||
int imagenum_; // index of last image added
|
||||
|
||||
FILE* fout_; // output file pointer
|
||||
TessResultRenderer* next_; // Can link multiple renderers together
|
||||
bool happy_; // I get grumpy when the disk fills up, etc.
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into a plain UTF-8 text string
|
||||
*/
|
||||
class TESS_API TessTextRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessTextRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into an hocr text string
|
||||
*/
|
||||
class TESS_API TessHOcrRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessHOcrRenderer(const char* outputbase, bool font_info);
|
||||
explicit TessHOcrRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool BeginDocumentHandler() override;
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
bool EndDocumentHandler() override;
|
||||
|
||||
private:
|
||||
bool font_info_; // whether to print font information
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into an alto text string
|
||||
*/
|
||||
class TESS_API TessAltoRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessAltoRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool BeginDocumentHandler() override;
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
bool EndDocumentHandler() override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders Tesseract output into a TSV string
|
||||
*/
|
||||
class TESS_API TessTsvRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessTsvRenderer(const char* outputbase, bool font_info);
|
||||
explicit TessTsvRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool BeginDocumentHandler() override;
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
bool EndDocumentHandler() override;
|
||||
|
||||
private:
|
||||
bool font_info_; // whether to print font information
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into searchable PDF
|
||||
*/
|
||||
class TESS_API TessPDFRenderer : public TessResultRenderer {
|
||||
public:
|
||||
// datadir is the location of the TESSDATA. We need it because
|
||||
// we load a custom PDF font from this location.
|
||||
TessPDFRenderer(const char* outputbase, const char* datadir,
|
||||
bool textonly = false);
|
||||
|
||||
protected:
|
||||
bool BeginDocumentHandler() override;
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
bool EndDocumentHandler() override;
|
||||
|
||||
private:
|
||||
// We don't want to have every image in memory at once,
|
||||
// so we store some metadata as we go along producing
|
||||
// PDFs one page at a time. At the end, that metadata is
|
||||
// used to make everything that isn't easily handled in a
|
||||
// streaming fashion.
|
||||
long int obj_; // counter for PDF objects
|
||||
GenericVector<long int> offsets_; // offset of every PDF object in bytes
|
||||
GenericVector<long int> pages_; // object number for every /Page object
|
||||
std::string datadir_; // where to find the custom font
|
||||
bool textonly_; // skip images if set
|
||||
// Bookkeeping only. DIY = Do It Yourself.
|
||||
void AppendPDFObjectDIY(size_t objectsize);
|
||||
// Bookkeeping + emit data.
|
||||
void AppendPDFObject(const char* data);
|
||||
// Create the /Contents object for an entire page.
|
||||
char* GetPDFTextObjects(TessBaseAPI* api, double width, double height);
|
||||
// Turn an image into a PDF object. Only transcode if we have to.
|
||||
static bool imageToPDFObj(Pix* pix, const char* filename, long int objnum,
|
||||
char** pdf_object, long int* pdf_object_size,
|
||||
int jpg_quality);
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into a plain UTF-8 text string
|
||||
*/
|
||||
class TESS_API TessUnlvRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessUnlvRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into a plain UTF-8 text string for LSTMBox
|
||||
*/
|
||||
class TESS_API TessLSTMBoxRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessLSTMBoxRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into a plain UTF-8 text string
|
||||
*/
|
||||
class TESS_API TessBoxTextRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessBoxTextRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders tesseract output into a plain UTF-8 text string in WordStr format
|
||||
*/
|
||||
class TESS_API TessWordStrBoxRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessWordStrBoxRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
/**
|
||||
* Renders tesseract output into an osd text string
|
||||
*/
|
||||
class TESS_API TessOsdRenderer : public TessResultRenderer {
|
||||
public:
|
||||
explicit TessOsdRenderer(const char* outputbase);
|
||||
|
||||
protected:
|
||||
bool AddImageHandler(TessBaseAPI* api) override;
|
||||
};
|
||||
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_API_RENDERER_H_
|
|
@ -0,0 +1,257 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: resultiterator.h
|
||||
// Description: Iterator for tesseract results that is capable of
|
||||
// iterating in proper reading order over Bi Directional
|
||||
// (e.g. mixed Hebrew and English) text.
|
||||
// Author: David Eger
|
||||
// Created: Fri May 27 13:58:06 PST 2011
|
||||
//
|
||||
// (C) Copyright 2011, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
#define TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
|
||||
#include <set> // for std::pair
|
||||
#include <vector> // for std::vector
|
||||
#include "ltrresultiterator.h" // for LTRResultIterator
|
||||
#include "platform.h" // for TESS_API, TESS_LOCAL
|
||||
#include "publictypes.h" // for PageIteratorLevel
|
||||
#include "unichar.h" // for StrongScriptDirection
|
||||
|
||||
template <typename T> class GenericVector;
|
||||
template <typename T> class GenericVectorEqEq;
|
||||
|
||||
class STRING;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
class TESS_API ResultIterator : public LTRResultIterator {
|
||||
public:
|
||||
static ResultIterator *StartOfParagraph(const LTRResultIterator &resit);
|
||||
|
||||
/**
|
||||
* ResultIterator is copy constructible!
|
||||
* The default copy constructor works just fine for us.
|
||||
*/
|
||||
~ResultIterator() override = default;
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
/**
|
||||
* Moves the iterator to point to the start of the page to begin
|
||||
* an iteration.
|
||||
*/
|
||||
void Begin() override;
|
||||
|
||||
/**
|
||||
* Moves to the start of the next object at the given level in the
|
||||
* page hierarchy in the appropriate reading order and returns false if
|
||||
* the end of the page was reached.
|
||||
* NOTE that RIL_SYMBOL will skip non-text blocks, but all other
|
||||
* PageIteratorLevel level values will visit each non-text block once.
|
||||
* Think of non text blocks as containing a single para, with a single line,
|
||||
* with a single imaginary word.
|
||||
* Calls to Next with different levels may be freely intermixed.
|
||||
* This function iterates words in right-to-left scripts correctly, if
|
||||
* the appropriate language has been loaded into Tesseract.
|
||||
*/
|
||||
bool Next(PageIteratorLevel level) override;
|
||||
|
||||
/**
|
||||
* IsAtBeginningOf() returns whether we're at the logical beginning of the
|
||||
* given level. (as opposed to ResultIterator's left-to-right top-to-bottom
|
||||
* order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
|
||||
* For a full description, see pageiterator.h
|
||||
*/
|
||||
bool IsAtBeginningOf(PageIteratorLevel level) const override;
|
||||
|
||||
/**
|
||||
* Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
|
||||
* For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
|
||||
* point at the last word in a paragraph. See PageIterator for full comment.
|
||||
*/
|
||||
bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const override;
|
||||
|
||||
// ============= Functions that refer to words only ============.
|
||||
// Returns the number of blanks before the current word.
|
||||
int BlanksBeforeWord() const;
|
||||
|
||||
// ============= Accessing data ==============.
|
||||
|
||||
/**
|
||||
* Returns the null terminated UTF-8 encoded text string for the current
|
||||
* object at the given level. Use delete [] to free after use.
|
||||
*/
|
||||
virtual char* GetUTF8Text(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns the LSTM choices for every LSTM timestep for the current word.
|
||||
*/
|
||||
virtual std::vector<std::vector<std::pair<const char*, float>>>*
|
||||
GetBestLSTMSymbolChoices() const;
|
||||
|
||||
/**
|
||||
* Return whether the current paragraph's dominant reading direction
|
||||
* is left-to-right (as opposed to right-to-left).
|
||||
*/
|
||||
bool ParagraphIsLtr() const;
|
||||
|
||||
// ============= Exposed only for testing =============.
|
||||
|
||||
/**
|
||||
* Yields the reading order as a sequence of indices and (optional)
|
||||
* meta-marks for a set of words (given left-to-right).
|
||||
* The meta marks are passed as negative values:
|
||||
* kMinorRunStart Start of minor direction text.
|
||||
* kMinorRunEnd End of minor direction text.
|
||||
* kComplexWord The next indexed word contains both left-to-right and
|
||||
* right-to-left characters and was treated as neutral.
|
||||
*
|
||||
* For example, suppose we have five words in a text line,
|
||||
* indexed [0,1,2,3,4] from the leftmost side of the text line.
|
||||
* The following are all believable reading_orders:
|
||||
*
|
||||
* Left-to-Right (in ltr paragraph):
|
||||
* { 0, 1, 2, 3, 4 }
|
||||
* Left-to-Right (in rtl paragraph):
|
||||
* { kMinorRunStart, 0, 1, 2, 3, 4, kMinorRunEnd }
|
||||
* Right-to-Left (in rtl paragraph):
|
||||
* { 4, 3, 2, 1, 0 }
|
||||
* Left-to-Right except for an RTL phrase in words 2, 3 in an ltr paragraph:
|
||||
* { 0, 1, kMinorRunStart, 3, 2, kMinorRunEnd, 4 }
|
||||
*/
|
||||
static void CalculateTextlineOrder(
|
||||
bool paragraph_is_ltr,
|
||||
const GenericVector<StrongScriptDirection> &word_dirs,
|
||||
GenericVectorEqEq<int> *reading_order);
|
||||
|
||||
static const int kMinorRunStart;
|
||||
static const int kMinorRunEnd;
|
||||
static const int kComplexWord;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* We presume the data associated with the given iterator will outlive us.
|
||||
* NB: This is private because it does something that is non-obvious:
|
||||
* it resets to the beginning of the paragraph instead of staying wherever
|
||||
* resit might have pointed.
|
||||
*/
|
||||
TESS_LOCAL explicit ResultIterator(const LTRResultIterator &resit);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculates the current paragraph's dominant writing direction.
|
||||
* Typically, members should use current_paragraph_ltr_ instead.
|
||||
*/
|
||||
bool CurrentParagraphIsLtr() const;
|
||||
|
||||
/**
|
||||
* Returns word indices as measured from resit->RestartRow() = index 0
|
||||
* for the reading order of words within a textline given an iterator
|
||||
* into the middle of the text line.
|
||||
* In addition to non-negative word indices, the following negative values
|
||||
* may be inserted:
|
||||
* kMinorRunStart Start of minor direction text.
|
||||
* kMinorRunEnd End of minor direction text.
|
||||
* kComplexWord The previous word contains both left-to-right and
|
||||
* right-to-left characters and was treated as neutral.
|
||||
*/
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
/** Same as above, but the caller's ssd gets filled in if ssd != nullptr. */
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVector<StrongScriptDirection> *ssd,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
|
||||
/**
|
||||
* What is the index of the current word in a strict left-to-right reading
|
||||
* of the row?
|
||||
*/
|
||||
int LTRWordIndex() const;
|
||||
|
||||
/**
|
||||
* Given an iterator pointing at a word, returns the logical reading order
|
||||
* of blob indices for the word.
|
||||
*/
|
||||
void CalculateBlobOrder(GenericVector<int> *blob_indices) const;
|
||||
|
||||
/** Precondition: current_paragraph_is_ltr_ is set. */
|
||||
void MoveToLogicalStartOfTextline();
|
||||
|
||||
/**
|
||||
* Precondition: current_paragraph_is_ltr_ and in_minor_direction_
|
||||
* are set.
|
||||
*/
|
||||
void MoveToLogicalStartOfWord();
|
||||
|
||||
/** Are we pointing at the final (reading order) symbol of the word? */
|
||||
bool IsAtFinalSymbolOfWord() const;
|
||||
|
||||
/** Are we pointing at the first (reading order) symbol of the word? */
|
||||
bool IsAtFirstSymbolOfWord() const;
|
||||
|
||||
/**
|
||||
* Append any extra marks that should be appended to this word when printed.
|
||||
* Mostly, these are Unicode BiDi control characters.
|
||||
*/
|
||||
void AppendSuffixMarks(STRING *text) const;
|
||||
|
||||
/** Appends the current word in reading order to the given buffer.*/
|
||||
void AppendUTF8WordText(STRING *text) const;
|
||||
|
||||
/**
|
||||
* Appends the text of the current text line, *assuming this iterator is
|
||||
* positioned at the beginning of the text line* This function
|
||||
* updates the iterator to point to the first position past the text line.
|
||||
* Each textline is terminated in a single newline character.
|
||||
* If the textline ends a paragraph, it gets a second terminal newline.
|
||||
*/
|
||||
void IterateAndAppendUTF8TextlineText(STRING *text);
|
||||
|
||||
/**
|
||||
* Appends the text of the current paragraph in reading order
|
||||
* to the given buffer.
|
||||
* Each textline is terminated in a single newline character, and the
|
||||
* paragraph gets an extra newline at the end.
|
||||
*/
|
||||
void AppendUTF8ParagraphText(STRING *text) const;
|
||||
|
||||
/** Returns whether the bidi_debug flag is set to at least min_level. */
|
||||
bool BidiDebug(int min_level) const;
|
||||
|
||||
bool current_paragraph_is_ltr_;
|
||||
|
||||
/**
|
||||
* Is the currently pointed-at character at the beginning of
|
||||
* a minor-direction run?
|
||||
*/
|
||||
bool at_beginning_of_minor_run_;
|
||||
|
||||
/** Is the currently pointed-at character in a minor-direction sequence? */
|
||||
bool in_minor_direction_;
|
||||
|
||||
/**
|
||||
* Should detected inter-word spaces be preserved, or "compressed" to a single
|
||||
* space character (default behavior).
|
||||
*/
|
||||
bool preserve_interword_spaces_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
|
@ -0,0 +1,162 @@
|
|||
/**********************************************************************
|
||||
* File: serialis.h (Formerly serialmac.h)
|
||||
* Description: Inline routines and macros for serialisation functions
|
||||
* Author: Phil Cheatle
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef SERIALIS_H
|
||||
#define SERIALIS_H
|
||||
|
||||
#include <cstdint> // uint8_t
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
class GenericVector;
|
||||
class STRING;
|
||||
|
||||
/***********************************************************************
|
||||
QUOTE_IT MACRO DEFINITION
|
||||
===========================
|
||||
Replace <parm> with "<parm>". <parm> may be an arbitrary number of tokens
|
||||
***********************************************************************/
|
||||
|
||||
#define QUOTE_IT(parm) #parm
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
// Return number of elements of an array.
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t countof(T const (&)[N]) noexcept {
|
||||
return N;
|
||||
}
|
||||
|
||||
// Function to read a GenericVector<char> from a whole file.
|
||||
// Returns false on failure.
|
||||
using FileReader = bool (*)(const STRING&, GenericVector<char>*);
|
||||
// Function to write a GenericVector<char> to a whole file.
|
||||
// Returns false on failure.
|
||||
using FileWriter = bool (*)(const GenericVector<char>&, const STRING&);
|
||||
|
||||
// Deserialize data from file.
|
||||
bool DeSerialize(FILE* fp, char* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, float* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, int8_t* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, int16_t* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, int32_t* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, uint8_t* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, uint16_t* data, size_t n = 1);
|
||||
bool DeSerialize(FILE* fp, uint32_t* data, size_t n = 1);
|
||||
|
||||
// Serialize data to file.
|
||||
bool Serialize(FILE* fp, const char* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const float* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const int8_t* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const int16_t* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const int32_t* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const uint8_t* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const uint16_t* data, size_t n = 1);
|
||||
bool Serialize(FILE* fp, const uint32_t* data, size_t n = 1);
|
||||
|
||||
// Simple file class.
|
||||
// Allows for portable file input from memory and from foreign file systems.
|
||||
class TFile {
|
||||
public:
|
||||
TFile();
|
||||
~TFile();
|
||||
|
||||
// All the Open methods load the whole file into memory for reading.
|
||||
// Opens a file with a supplied reader, or nullptr to use the default.
|
||||
// Note that mixed read/write is not supported.
|
||||
bool Open(const STRING& filename, FileReader reader);
|
||||
// From an existing memory buffer.
|
||||
bool Open(const char* data, int size);
|
||||
// From an open file and an end offset.
|
||||
bool Open(FILE* fp, int64_t end_offset);
|
||||
// Sets the value of the swap flag, so that FReadEndian does the right thing.
|
||||
void set_swap(bool value) {
|
||||
swap_ = value;
|
||||
}
|
||||
|
||||
// Deserialize data.
|
||||
bool DeSerialize(char* data, size_t count = 1);
|
||||
bool DeSerialize(double* data, size_t count = 1);
|
||||
bool DeSerialize(float* data, size_t count = 1);
|
||||
bool DeSerialize(int8_t* data, size_t count = 1);
|
||||
bool DeSerialize(int16_t* data, size_t count = 1);
|
||||
bool DeSerialize(int32_t* data, size_t count = 1);
|
||||
bool DeSerialize(int64_t* data, size_t count = 1);
|
||||
bool DeSerialize(uint8_t* data, size_t count = 1);
|
||||
bool DeSerialize(uint16_t* data, size_t count = 1);
|
||||
bool DeSerialize(uint32_t* data, size_t count = 1);
|
||||
bool DeSerialize(uint64_t* data, size_t count = 1);
|
||||
|
||||
// Serialize data.
|
||||
bool Serialize(const char* data, size_t count = 1);
|
||||
bool Serialize(const double* data, size_t count = 1);
|
||||
bool Serialize(const float* data, size_t count = 1);
|
||||
bool Serialize(const int8_t* data, size_t count = 1);
|
||||
bool Serialize(const int16_t* data, size_t count = 1);
|
||||
bool Serialize(const int32_t* data, size_t count = 1);
|
||||
bool Serialize(const int64_t* data, size_t count = 1);
|
||||
bool Serialize(const uint8_t* data, size_t count = 1);
|
||||
bool Serialize(const uint16_t* data, size_t count = 1);
|
||||
bool Serialize(const uint32_t* data, size_t count = 1);
|
||||
bool Serialize(const uint64_t* data, size_t count = 1);
|
||||
|
||||
// Skip data.
|
||||
bool Skip(size_t count);
|
||||
|
||||
// Reads a line like fgets. Returns nullptr on EOF, otherwise buffer.
|
||||
// Reads at most buffer_size bytes, including '\0' terminator, even if
|
||||
// the line is longer. Does nothing if buffer_size <= 0.
|
||||
char* FGets(char* buffer, int buffer_size);
|
||||
// Replicates fread, followed by a swap of the bytes if needed, returning the
|
||||
// number of items read. If swap_ is true then the count items will each have
|
||||
// size bytes reversed.
|
||||
int FReadEndian(void* buffer, size_t size, int count);
|
||||
// Replicates fread, returning the number of items read.
|
||||
int FRead(void* buffer, size_t size, int count);
|
||||
// Resets the TFile as if it has been Opened, but nothing read.
|
||||
// Only allowed while reading!
|
||||
void Rewind();
|
||||
|
||||
// Open for writing. Either supply a non-nullptr data with OpenWrite before
|
||||
// calling FWrite, (no close required), or supply a nullptr data to OpenWrite
|
||||
// and call CloseWrite to write to a file after the FWrites.
|
||||
void OpenWrite(GenericVector<char>* data);
|
||||
bool CloseWrite(const STRING& filename, FileWriter writer);
|
||||
|
||||
// Replicates fwrite, returning the number of items written.
|
||||
// To use fprintf, use snprintf and FWrite.
|
||||
int FWrite(const void* buffer, size_t size, int count);
|
||||
|
||||
private:
|
||||
// The number of bytes used so far.
|
||||
int offset_;
|
||||
// The buffered data from the file.
|
||||
GenericVector<char>* data_;
|
||||
// True if the data_ pointer is owned by *this.
|
||||
bool data_is_owned_;
|
||||
// True if the TFile is open for writing.
|
||||
bool is_writing_;
|
||||
// True if bytes need to be swapped in FReadEndian.
|
||||
bool swap_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif
|
|
@ -0,0 +1,188 @@
|
|||
/**********************************************************************
|
||||
* File: strngs.h (Formerly strings.h)
|
||||
* Description: STRING class definition.
|
||||
* Author: Ray Smith
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef STRNGS_H
|
||||
#define STRNGS_H
|
||||
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for uint32_t
|
||||
#include <cstdio> // for FILE
|
||||
#include <cstring> // for strncpy
|
||||
#include "platform.h" // for TESS_API
|
||||
|
||||
namespace tesseract {
|
||||
class TFile;
|
||||
} // namespace tesseract.
|
||||
|
||||
// STRING_IS_PROTECTED means that string[index] = X is invalid
|
||||
// because you have to go through strings interface to modify it.
|
||||
// This allows the string to ensure internal integrity and maintain
|
||||
// its own string length. Unfortunately this is not possible because
|
||||
// STRINGS are used as direct-manipulation data buffers for things
|
||||
// like length arrays and many places cast away the const on string()
|
||||
// to mutate the string. Turning this off means that internally we
|
||||
// cannot assume we know the strlen.
|
||||
#define STRING_IS_PROTECTED 0
|
||||
|
||||
template <typename T>
|
||||
class GenericVector;
|
||||
|
||||
class TESS_API STRING {
|
||||
public:
|
||||
STRING();
|
||||
STRING(const STRING& string);
|
||||
STRING(const char* string);
|
||||
STRING(const char* data, int length);
|
||||
~STRING();
|
||||
|
||||
// Writes to the given file. Returns false in case of error.
|
||||
bool Serialize(FILE* fp) const;
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerialize(bool swap, FILE* fp);
|
||||
// Writes to the given file. Returns false in case of error.
|
||||
bool Serialize(tesseract::TFile* fp) const;
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerialize(tesseract::TFile* fp);
|
||||
// As DeSerialize, but only seeks past the data - hence a static method.
|
||||
static bool SkipDeSerialize(tesseract::TFile* fp);
|
||||
|
||||
bool contains(char c) const;
|
||||
int32_t length() const;
|
||||
int32_t size() const {
|
||||
return length();
|
||||
}
|
||||
// Workaround to avoid g++ -Wsign-compare warnings.
|
||||
uint32_t unsigned_size() const {
|
||||
const int32_t len = length();
|
||||
assert(0 <= len);
|
||||
return static_cast<uint32_t>(len);
|
||||
}
|
||||
const char* string() const;
|
||||
const char* c_str() const;
|
||||
|
||||
inline char* strdup() const {
|
||||
int32_t len = length() + 1;
|
||||
return strncpy(new char[len], GetCStr(), len);
|
||||
}
|
||||
|
||||
#if STRING_IS_PROTECTED
|
||||
const char& operator[](int32_t index) const;
|
||||
// len is number of chars in s to insert starting at index in this string
|
||||
void insert_range(int32_t index, const char* s, int len);
|
||||
void erase_range(int32_t index, int len);
|
||||
#else
|
||||
char& operator[](int32_t index) const;
|
||||
#endif
|
||||
void split(char c, GenericVector<STRING>* splited);
|
||||
void truncate_at(int32_t index);
|
||||
|
||||
bool operator==(const STRING& string) const;
|
||||
bool operator!=(const STRING& string) const;
|
||||
bool operator!=(const char* string) const;
|
||||
|
||||
STRING& operator=(const char* string);
|
||||
STRING& operator=(const STRING& string);
|
||||
|
||||
STRING operator+(const STRING& string) const;
|
||||
STRING operator+(char ch) const;
|
||||
|
||||
STRING& operator+=(const char* string);
|
||||
STRING& operator+=(const STRING& string);
|
||||
STRING& operator+=(char ch);
|
||||
|
||||
// Assignment for strings which are not null-terminated.
|
||||
void assign(const char* cstr, int len);
|
||||
|
||||
// Appends the given string and int (as a %d) to this.
|
||||
// += cannot be used for ints as there as a char += operator that would
|
||||
// be ambiguous, and ints usually need a string before or between them
|
||||
// anyway.
|
||||
void add_str_int(const char* str, int number);
|
||||
// Appends the given string and double (as a %.8g) to this.
|
||||
void add_str_double(const char* str, double number);
|
||||
|
||||
// ensure capacity but keep pointer encapsulated
|
||||
inline void ensure(int32_t min_capacity) {
|
||||
ensure_cstr(min_capacity);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef struct STRING_HEADER {
|
||||
// How much space was allocated in the string buffer for char data.
|
||||
int capacity_;
|
||||
|
||||
// used_ is how much of the capacity is currently being used,
|
||||
// including a '\0' terminator.
|
||||
//
|
||||
// If used_ is 0 then string is nullptr (not even the '\0')
|
||||
// else if used_ > 0 then it is strlen() + 1 (because it includes '\0')
|
||||
// else strlen is >= 0 (not nullptr) but needs to be computed.
|
||||
// this condition is set when encapsulation is violated because
|
||||
// an API returned a mutable string.
|
||||
//
|
||||
// capacity_ - used_ = excess capacity that the string can grow
|
||||
// without reallocating
|
||||
mutable int used_;
|
||||
} STRING_HEADER;
|
||||
|
||||
// To preserve the behavior of the old serialization, we only have space
|
||||
// for one pointer in this structure. So we are embedding a data structure
|
||||
// at the start of the storage that will hold additional state variables,
|
||||
// then storing the actual string contents immediately after.
|
||||
STRING_HEADER* data_;
|
||||
|
||||
// returns the header part of the storage
|
||||
inline STRING_HEADER* GetHeader() {
|
||||
return data_;
|
||||
}
|
||||
inline const STRING_HEADER* GetHeader() const {
|
||||
return data_;
|
||||
}
|
||||
|
||||
// returns the string data part of storage
|
||||
inline char* GetCStr() {
|
||||
return (reinterpret_cast<char*>(data_)) + sizeof(STRING_HEADER);
|
||||
}
|
||||
|
||||
inline const char* GetCStr() const {
|
||||
return (reinterpret_cast<const char*>(data_)) + sizeof(STRING_HEADER);
|
||||
}
|
||||
inline bool InvariantOk() const {
|
||||
#if STRING_IS_PROTECTED
|
||||
return (GetHeader()->used_ == 0)
|
||||
? (string() == nullptr)
|
||||
: (GetHeader()->used_ == (strlen(string()) + 1));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Ensure string has requested capacity as optimization
|
||||
// to avoid unnecessary reallocations.
|
||||
// The return value is a cstr buffer with at least requested capacity
|
||||
char* ensure_cstr(int32_t min_capacity);
|
||||
|
||||
void FixHeader() const; // make used_ non-negative, even if const
|
||||
|
||||
char* AllocData(int used, int capacity);
|
||||
void DiscardData();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,30 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: version.h
|
||||
// Description: Version information
|
||||
//
|
||||
// (C) Copyright 2018, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_API_VERSION_H_
|
||||
#define TESSERACT_API_VERSION_H_
|
||||
|
||||
#define TESSERACT_MAJOR_VERSION 4
|
||||
#define TESSERACT_MINOR_VERSION 1
|
||||
#define TESSERACT_MICRO_VERSION 1
|
||||
#define TESSERACT_VERSION \
|
||||
(TESSERACT_MAJOR_VERSION << 16 | \
|
||||
TESSERACT_MINOR_VERSION << 8 | \
|
||||
TESSERACT_MICRO_VERSION)
|
||||
#define TESSERACT_VERSION_STR "4.1.1"
|
||||
|
||||
#endif // TESSERACT_API_VERSION_H_
|
|
@ -0,0 +1,915 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: tesscallback.h
|
||||
// Description: classes and functions to replace pointer-to-functions
|
||||
// Author: Samuel Charron
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESS_CALLBACK_SPECIALIZATIONS_H_
|
||||
#define TESS_CALLBACK_SPECIALIZATIONS_H_
|
||||
|
||||
class TessClosure {
|
||||
public:
|
||||
virtual ~TessClosure();
|
||||
virtual void Run() = 0;
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class TessResultCallback {
|
||||
public:
|
||||
virtual ~TessResultCallback() = default;
|
||||
virtual R Run() = 0;
|
||||
};
|
||||
|
||||
template <bool del, class R, class T>
|
||||
class _TessMemberResultCallback_0_0 : public TessResultCallback<R> {
|
||||
public:
|
||||
using base = TessResultCallback<R>;
|
||||
using MemberSignature = R (T::*)();
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_0(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
R Run() override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)();
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)();
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T>
|
||||
class _TessMemberResultCallback_0_0<del, void, T> : public TessClosure {
|
||||
public:
|
||||
using base = TessClosure;
|
||||
using MemberSignature = void (T::*)();
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_0(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
void Run() override {
|
||||
if (!del) {
|
||||
(object_->*member_)();
|
||||
} else {
|
||||
(object_->*member_)();
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R>
|
||||
inline typename _TessMemberResultCallback_0_0<true, R, T1>::base*
|
||||
NewTessCallback(T1* obj, R (T2::*member)()) {
|
||||
return new _TessMemberResultCallback_0_0<true, R, T1>(obj, member);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R>
|
||||
class _TessFunctionResultCallback_0_0 : public TessResultCallback<R> {
|
||||
public:
|
||||
using base = TessResultCallback<R>;
|
||||
using FunctionSignature = R (*)();
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_0(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
virtual R Run() {
|
||||
if (!del) {
|
||||
R result = (*function_)();
|
||||
return result;
|
||||
}
|
||||
R result = (*function_)();
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del>
|
||||
class _TessFunctionResultCallback_0_0<del, void> : public TessClosure {
|
||||
public:
|
||||
using base = TessClosure;
|
||||
using FunctionSignature = void (*)();
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_0(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
void Run() override {
|
||||
if (!del) {
|
||||
(*function_)();
|
||||
} else {
|
||||
(*function_)();
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R>
|
||||
inline typename _TessFunctionResultCallback_0_0<true, R>::base* NewTessCallback(
|
||||
R (*function)()) {
|
||||
return new _TessFunctionResultCallback_0_0<true, R>(function);
|
||||
}
|
||||
|
||||
// Specified by TR1 [4.7.2] Reference modifications.
|
||||
template <class T>
|
||||
struct remove_reference;
|
||||
template <typename T>
|
||||
struct remove_reference {
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_reference<T&> {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
// Identity<T>::type is a typedef of T. Useful for preventing the
|
||||
// compiler from inferring the type of an argument in templates.
|
||||
template <typename T>
|
||||
struct Identity {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <bool del, class R, class T, class P1, class P2, class P3, class P4,
|
||||
class P5>
|
||||
class _ConstTessMemberResultCallback_5_0 : public TessResultCallback<R> {
|
||||
public:
|
||||
using base = TessResultCallback<R>;
|
||||
using MemberSignature = R (T::*)(P1, P2, P3, P4, P5) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
typename remove_reference<P2>::type p2_;
|
||||
typename remove_reference<P3>::type p3_;
|
||||
typename remove_reference<P4>::type p4_;
|
||||
typename remove_reference<P5>::type p5_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_5_0(const T* object,
|
||||
MemberSignature member, P1 p1,
|
||||
P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
: object_(object),
|
||||
member_(member),
|
||||
p1_(p1),
|
||||
p2_(p2),
|
||||
p3_(p3),
|
||||
p4_(p4),
|
||||
p5_(p5) {}
|
||||
|
||||
R Run() override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(p1_, p2_, p3_, p4_, p5_);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(p1_, p2_, p3_, p4_, p5_);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T, class P1, class P2, class P3, class P4, class P5>
|
||||
class _ConstTessMemberResultCallback_5_0<del, void, T, P1, P2, P3, P4, P5>
|
||||
: public TessClosure {
|
||||
public:
|
||||
using base = TessClosure;
|
||||
using MemberSignature = void (T::*)(P1, P2, P3, P4, P5) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
typename remove_reference<P2>::type p2_;
|
||||
typename remove_reference<P3>::type p3_;
|
||||
typename remove_reference<P4>::type p4_;
|
||||
typename remove_reference<P5>::type p5_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_5_0(const T* object,
|
||||
MemberSignature member, P1 p1,
|
||||
P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
: object_(object),
|
||||
member_(member),
|
||||
p1_(p1),
|
||||
p2_(p2),
|
||||
p3_(p3),
|
||||
p4_(p4),
|
||||
p5_(p5) {}
|
||||
|
||||
void Run() override {
|
||||
if (!del) {
|
||||
(object_->*member_)(p1_, p2_, p3_, p4_, p5_);
|
||||
} else {
|
||||
(object_->*member_)(p1_, p2_, p3_, p4_, p5_);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class P1, class P2, class P3, class P4,
|
||||
class P5>
|
||||
inline typename _ConstTessMemberResultCallback_5_0<false, R, T1, P1, P2, P3, P4,
|
||||
P5>::base*
|
||||
NewPermanentTessCallback(const T1* obj,
|
||||
R (T2::*member)(P1, P2, P3, P4, P5) const,
|
||||
typename Identity<P1>::type p1,
|
||||
typename Identity<P2>::type p2,
|
||||
typename Identity<P3>::type p3,
|
||||
typename Identity<P4>::type p4,
|
||||
typename Identity<P5>::type p5) {
|
||||
return new _ConstTessMemberResultCallback_5_0<false, R, T1, P1, P2, P3, P4,
|
||||
P5>(obj, member, p1, p2, p3, p4,
|
||||
p5);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class T, class P1, class P2, class P3, class P4,
|
||||
class P5, class P6>
|
||||
class _ConstTessMemberResultCallback_6_0 : public TessResultCallback<R> {
|
||||
public:
|
||||
using base = TessResultCallback<R>;
|
||||
using MemberSignature = R (T::*)(P1, P2, P3, P4, P5, P6) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
typename remove_reference<P2>::type p2_;
|
||||
typename remove_reference<P3>::type p3_;
|
||||
typename remove_reference<P4>::type p4_;
|
||||
typename remove_reference<P5>::type p5_;
|
||||
typename remove_reference<P6>::type p6_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_6_0(const T* object,
|
||||
MemberSignature member, P1 p1,
|
||||
P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
|
||||
: object_(object),
|
||||
member_(member),
|
||||
p1_(p1),
|
||||
p2_(p2),
|
||||
p3_(p3),
|
||||
p4_(p4),
|
||||
p5_(p5),
|
||||
p6_(p6) {}
|
||||
|
||||
R Run() override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(p1_, p2_, p3_, p4_, p5_, p6_);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(p1_, p2_, p3_, p4_, p5_, p6_);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T, class P1, class P2, class P3, class P4, class P5,
|
||||
class P6>
|
||||
class _ConstTessMemberResultCallback_6_0<del, void, T, P1, P2, P3, P4, P5, P6>
|
||||
: public TessClosure {
|
||||
public:
|
||||
using base = TessClosure;
|
||||
using MemberSignature = void (T::*)(P1, P2, P3, P4, P5, P6) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
typename remove_reference<P2>::type p2_;
|
||||
typename remove_reference<P3>::type p3_;
|
||||
typename remove_reference<P4>::type p4_;
|
||||
typename remove_reference<P5>::type p5_;
|
||||
typename remove_reference<P6>::type p6_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_6_0(const T* object,
|
||||
MemberSignature member, P1 p1,
|
||||
P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
|
||||
: object_(object),
|
||||
member_(member),
|
||||
p1_(p1),
|
||||
p2_(p2),
|
||||
p3_(p3),
|
||||
p4_(p4),
|
||||
p5_(p5),
|
||||
p6_(p6) {}
|
||||
|
||||
void Run() override {
|
||||
if (!del) {
|
||||
(object_->*member_)(p1_, p2_, p3_, p4_, p5_, p6_);
|
||||
} else {
|
||||
(object_->*member_)(p1_, p2_, p3_, p4_, p5_, p6_);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class P1, class P2, class P3, class P4,
|
||||
class P5, class P6>
|
||||
inline typename _ConstTessMemberResultCallback_6_0<false, R, T1, P1, P2, P3, P4,
|
||||
P5, P6>::base*
|
||||
NewPermanentTessCallback(
|
||||
const T1* obj, R (T2::*member)(P1, P2, P3, P4, P5, P6) const,
|
||||
typename Identity<P1>::type p1, typename Identity<P2>::type p2,
|
||||
typename Identity<P3>::type p3, typename Identity<P4>::type p4,
|
||||
typename Identity<P5>::type p5, typename Identity<P6>::type p6) {
|
||||
return new _ConstTessMemberResultCallback_6_0<false, R, T1, P1, P2, P3, P4,
|
||||
P5, P6>(obj, member, p1, p2, p3,
|
||||
p4, p5, p6);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class A1>
|
||||
class TessCallback1 {
|
||||
public:
|
||||
virtual ~TessCallback1() = default;
|
||||
virtual void Run(A1) = 0;
|
||||
};
|
||||
|
||||
template <class R, class A1>
|
||||
class TessResultCallback1 {
|
||||
public:
|
||||
virtual ~TessResultCallback1() = default;
|
||||
virtual R Run(A1) = 0;
|
||||
};
|
||||
|
||||
template <class A1, class A2>
|
||||
class TessCallback2 {
|
||||
public:
|
||||
virtual ~TessCallback2() = default;
|
||||
virtual void Run(A1, A2) = 0;
|
||||
};
|
||||
|
||||
template <class R, class A1, class A2>
|
||||
class TessResultCallback2 {
|
||||
public:
|
||||
virtual ~TessResultCallback2() = default;
|
||||
virtual R Run(A1, A2) = 0;
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
class TessCallback3 {
|
||||
public:
|
||||
virtual ~TessCallback3() = default;
|
||||
virtual void Run(A1, A2, A3) = 0;
|
||||
};
|
||||
|
||||
template <class R, class A1, class A2, class A3>
|
||||
class TessResultCallback3 {
|
||||
public:
|
||||
virtual ~TessResultCallback3() = default;
|
||||
virtual R Run(A1, A2, A3) = 0;
|
||||
};
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
class TessCallback4 {
|
||||
public:
|
||||
virtual ~TessCallback4() = default;
|
||||
virtual void Run(A1, A2, A3, A4) = 0;
|
||||
};
|
||||
|
||||
template <class R, class A1, class A2, class A3, class A4>
|
||||
class TessResultCallback4 {
|
||||
public:
|
||||
virtual ~TessResultCallback4() = default;
|
||||
virtual R Run(A1, A2, A3, A4) = 0;
|
||||
};
|
||||
|
||||
template <bool del, class R, class T, class A1>
|
||||
class _TessMemberResultCallback_0_1 : public TessResultCallback1<R, A1> {
|
||||
public:
|
||||
typedef TessResultCallback1<R, A1> base;
|
||||
using MemberSignature = R (T::*)(A1);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_1(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
R Run(A1 a1) override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(a1);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T, class A1>
|
||||
class _TessMemberResultCallback_0_1<del, void, T, A1>
|
||||
: public TessCallback1<A1> {
|
||||
public:
|
||||
using base = TessCallback1<A1>;
|
||||
using MemberSignature = void (T::*)(A1);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_1(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
void Run(A1 a1) override {
|
||||
if (!del) {
|
||||
(object_->*member_)(a1);
|
||||
} else {
|
||||
(object_->*member_)(a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class A1>
|
||||
inline typename _TessMemberResultCallback_0_1<false, R, T1, A1>::base*
|
||||
NewPermanentTessCallback(T1* obj, R (T2::*member)(A1)) {
|
||||
return new _TessMemberResultCallback_0_1<false, R, T1, A1>(obj, member);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class A1>
|
||||
class _TessFunctionResultCallback_0_1 : public TessResultCallback1<R, A1> {
|
||||
public:
|
||||
typedef TessResultCallback1<R, A1> base;
|
||||
using FunctionSignature = R (*)(A1);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_1(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
virtual R Run(A1 a1) {
|
||||
if (!del) {
|
||||
R result = (*function_)(a1);
|
||||
return result;
|
||||
}
|
||||
R result = (*function_)(a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class A1>
|
||||
class _TessFunctionResultCallback_0_1<del, void, A1>
|
||||
: public TessCallback1<A1> {
|
||||
public:
|
||||
using base = TessCallback1<A1>;
|
||||
using FunctionSignature = void (*)(A1);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_1(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
void Run(A1 a1) override {
|
||||
if (!del) {
|
||||
(*function_)(a1);
|
||||
} else {
|
||||
(*function_)(a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R, class A1>
|
||||
inline typename _TessFunctionResultCallback_0_1<false, R, A1>::base*
|
||||
NewPermanentTessCallback(R (*function)(A1)) {
|
||||
return new _TessFunctionResultCallback_0_1<false, R, A1>(function);
|
||||
}
|
||||
|
||||
template <bool del, class R, class P1, class A1>
|
||||
class _TessFunctionResultCallback_1_1 : public TessResultCallback1<R, A1> {
|
||||
public:
|
||||
typedef TessResultCallback1<R, A1> base;
|
||||
using FunctionSignature = R (*)(P1, A1);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
|
||||
public:
|
||||
inline _TessFunctionResultCallback_1_1(FunctionSignature function, P1 p1)
|
||||
: function_(function), p1_(p1) {}
|
||||
|
||||
virtual R Run(A1 a1) {
|
||||
if (!del) {
|
||||
R result = (*function_)(p1_, a1);
|
||||
return result;
|
||||
}
|
||||
R result = (*function_)(p1_, a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class P1, class A1>
|
||||
class _TessFunctionResultCallback_1_1<del, void, P1, A1>
|
||||
: public TessCallback1<A1> {
|
||||
public:
|
||||
using base = TessCallback1<A1>;
|
||||
using FunctionSignature = void (*)(P1, A1);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
|
||||
public:
|
||||
inline _TessFunctionResultCallback_1_1(FunctionSignature function, P1 p1)
|
||||
: function_(function), p1_(p1) {}
|
||||
|
||||
void Run(A1 a1) override {
|
||||
if (!del) {
|
||||
(*function_)(p1_, a1);
|
||||
} else {
|
||||
(*function_)(p1_, a1);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R, class P1, class A1>
|
||||
inline typename _TessFunctionResultCallback_1_1<false, R, P1, A1>::base*
|
||||
NewPermanentTessCallback(R (*function)(P1, A1),
|
||||
typename Identity<P1>::type p1) {
|
||||
return new _TessFunctionResultCallback_1_1<false, R, P1, A1>(function, p1);
|
||||
}
|
||||
|
||||
template <bool del, class R, class T, class A1, class A2>
|
||||
class _ConstTessMemberResultCallback_0_2
|
||||
: public TessResultCallback2<R, A1, A2> {
|
||||
public:
|
||||
typedef TessResultCallback2<R, A1, A2> base;
|
||||
using MemberSignature = R (T::*)(A1, A2) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_0_2(const T* object,
|
||||
MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
R Run(A1 a1, A2 a2) override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(a1, a2);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T, class A1, class A2>
|
||||
class _ConstTessMemberResultCallback_0_2<del, void, T, A1, A2>
|
||||
: public TessCallback2<A1, A2> {
|
||||
public:
|
||||
typedef TessCallback2<A1, A2> base;
|
||||
using MemberSignature = void (T::*)(A1, A2) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_0_2(const T* object,
|
||||
MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
virtual void Run(A1 a1, A2 a2) {
|
||||
if (!del) {
|
||||
(object_->*member_)(a1, a2);
|
||||
} else {
|
||||
(object_->*member_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class A1, class A2>
|
||||
inline typename _ConstTessMemberResultCallback_0_2<false, R, T1, A1, A2>::base*
|
||||
NewPermanentTessCallback(const T1* obj, R (T2::*member)(A1, A2) const) {
|
||||
return new _ConstTessMemberResultCallback_0_2<false, R, T1, A1, A2>(obj,
|
||||
member);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class T, class A1, class A2>
|
||||
class _TessMemberResultCallback_0_2 : public TessResultCallback2<R, A1, A2> {
|
||||
public:
|
||||
typedef TessResultCallback2<R, A1, A2> base;
|
||||
using MemberSignature = R (T::*)(A1, A2);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_2(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
R Run(A1 a1, A2 a2) override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(a1, a2);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class T, class A1, class A2>
|
||||
class _TessMemberResultCallback_0_2<del, void, T, A1, A2>
|
||||
: public TessCallback2<A1, A2> {
|
||||
public:
|
||||
typedef TessCallback2<A1, A2> base;
|
||||
using MemberSignature = void (T::*)(A1, A2);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_2(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
virtual void Run(A1 a1, A2 a2) {
|
||||
if (!del) {
|
||||
(object_->*member_)(a1, a2);
|
||||
} else {
|
||||
(object_->*member_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class A1, class A2>
|
||||
inline typename _TessMemberResultCallback_0_2<false, R, T1, A1, A2>::base*
|
||||
NewPermanentTessCallback(T1* obj, R (T2::*member)(A1, A2)) {
|
||||
return new _TessMemberResultCallback_0_2<false, R, T1, A1, A2>(obj, member);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class A1, class A2>
|
||||
class _TessFunctionResultCallback_0_2 : public TessResultCallback2<R, A1, A2> {
|
||||
public:
|
||||
typedef TessResultCallback2<R, A1, A2> base;
|
||||
using FunctionSignature = R (*)(A1, A2);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_2(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
R Run(A1 a1, A2 a2) override {
|
||||
if (!del) {
|
||||
R result = (*function_)(a1, a2);
|
||||
return result;
|
||||
}
|
||||
R result = (*function_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool del, class A1, class A2>
|
||||
class _TessFunctionResultCallback_0_2<del, void, A1, A2>
|
||||
: public TessCallback2<A1, A2> {
|
||||
public:
|
||||
typedef TessCallback2<A1, A2> base;
|
||||
using FunctionSignature = void (*)(A1, A2);
|
||||
|
||||
private:
|
||||
FunctionSignature function_;
|
||||
|
||||
public:
|
||||
inline explicit _TessFunctionResultCallback_0_2(FunctionSignature function)
|
||||
: function_(function) {}
|
||||
|
||||
virtual void Run(A1 a1, A2 a2) {
|
||||
if (!del) {
|
||||
(*function_)(a1, a2);
|
||||
} else {
|
||||
(*function_)(a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
function_ = nullptr;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class R, class A1, class A2>
|
||||
inline typename _TessFunctionResultCallback_0_2<false, R, A1, A2>::base*
|
||||
NewPermanentTessCallback(R (*function)(A1, A2)) {
|
||||
return new _TessFunctionResultCallback_0_2<false, R, A1, A2>(function);
|
||||
}
|
||||
|
||||
template <bool del, class R, class T, class P1, class P2, class A1, class A2>
|
||||
class _TessMemberResultCallback_2_2 : public TessResultCallback2<R, A1, A2> {
|
||||
public:
|
||||
typedef TessResultCallback2<R, A1, A2> base;
|
||||
using MemberSignature = R (T::*)(P1, P2, A1, A2);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
typename remove_reference<P1>::type p1_;
|
||||
typename remove_reference<P2>::type p2_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_2_2(T* object, MemberSignature member, P1 p1,
|
||||
P2 p2)
|
||||
: object_(object), member_(member), p1_(p1), p2_(p2) {}
|
||||
|
||||
R Run(A1 a1, A2 a2) override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(p1_, p2_, a1, a2);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(p1_, p2_, a1, a2);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class P1, class P2, class A1, class A2>
|
||||
inline
|
||||
typename _TessMemberResultCallback_2_2<false, R, T1, P1, P2, A1, A2>::base*
|
||||
NewPermanentTessCallback(T1* obj, R (T2::*member)(P1, P2, A1, A2),
|
||||
typename Identity<P1>::type p1,
|
||||
typename Identity<P2>::type p2) {
|
||||
return new _TessMemberResultCallback_2_2<false, R, T1, P1, P2, A1, A2>(
|
||||
obj, member, p1, p2);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class T, class A1, class A2, class A3>
|
||||
class _ConstTessMemberResultCallback_0_3
|
||||
: public TessResultCallback3<R, A1, A2, A3> {
|
||||
public:
|
||||
typedef TessResultCallback3<R, A1, A2, A3> base;
|
||||
using MemberSignature = R (T::*)(A1, A2, A3) const;
|
||||
|
||||
private:
|
||||
const T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _ConstTessMemberResultCallback_0_3(const T* object,
|
||||
MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
R Run(A1 a1, A2 a2, A3 a3) override {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(a1, a2, a3);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(a1, a2, a3);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class A1, class A2, class A3>
|
||||
inline
|
||||
typename _ConstTessMemberResultCallback_0_3<false, R, T1, A1, A2, A3>::base*
|
||||
NewPermanentTessCallback(const T1* obj, R (T2::*member)(A1, A2, A3) const) {
|
||||
return new _ConstTessMemberResultCallback_0_3<false, R, T1, A1, A2, A3>(
|
||||
obj, member);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <bool del, class R, class T, class A1, class A2, class A3, class A4>
|
||||
class _TessMemberResultCallback_0_4
|
||||
: public TessResultCallback4<R, A1, A2, A3, A4> {
|
||||
public:
|
||||
typedef TessResultCallback4<R, A1, A2, A3, A4> base;
|
||||
using MemberSignature = R (T::*)(A1, A2, A3, A4);
|
||||
|
||||
private:
|
||||
T* object_;
|
||||
MemberSignature member_;
|
||||
|
||||
public:
|
||||
inline _TessMemberResultCallback_0_4(T* object, MemberSignature member)
|
||||
: object_(object), member_(member) {}
|
||||
|
||||
virtual R Run(A1 a1, A2 a2, A3 a3, A4 a4) {
|
||||
if (!del) {
|
||||
R result = (object_->*member_)(a1, a2, a3, a4);
|
||||
return result;
|
||||
}
|
||||
R result = (object_->*member_)(a1, a2, a3, a4);
|
||||
// zero out the pointer to ensure segfault if used again
|
||||
member_ = nullptr;
|
||||
delete this;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
template <class T1, class T2, class R, class A1, class A2, class A3, class A4>
|
||||
inline
|
||||
typename _TessMemberResultCallback_0_4<false, R, T1, A1, A2, A3, A4>::base*
|
||||
NewPermanentTessCallback(T1* obj, R (T2::*member)(A1, A2, A3, A4)) {
|
||||
return new _TessMemberResultCallback_0_4<false, R, T1, A1, A2, A3, A4>(
|
||||
obj, member);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TESS_CALLBACK_SPECIALIZATIONS_H_
|
|
@ -0,0 +1,189 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: thresholder.h
|
||||
// Description: Base API for thresholding images in tesseract.
|
||||
// Author: Ray Smith
|
||||
//
|
||||
// (C) Copyright 2008, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCMAIN_THRESHOLDER_H_
|
||||
#define TESSERACT_CCMAIN_THRESHOLDER_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "publictypes.h"
|
||||
|
||||
struct Pix;
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
/// Base class for all tesseract image thresholding classes.
|
||||
/// Specific classes can add new thresholding methods by
|
||||
/// overriding ThresholdToPix.
|
||||
/// Each instance deals with a single image, but the design is intended to
|
||||
/// be useful for multiple calls to SetRectangle and ThresholdTo* if
|
||||
/// desired.
|
||||
class TESS_API ImageThresholder {
|
||||
public:
|
||||
ImageThresholder();
|
||||
virtual ~ImageThresholder();
|
||||
|
||||
/// Destroy the Pix if there is one, freeing memory.
|
||||
virtual void Clear();
|
||||
|
||||
/// Return true if no image has been set.
|
||||
bool IsEmpty() const;
|
||||
|
||||
/// SetImage makes a copy of all the image data, so it may be deleted
|
||||
/// immediately after this call.
|
||||
/// Greyscale of 8 and color of 24 or 32 bits per pixel may be given.
|
||||
/// Palette color images will not work properly and must be converted to
|
||||
/// 24 bit.
|
||||
/// Binary images of 1 bit per pixel may also be given but they must be
|
||||
/// byte packed with the MSB of the first byte being the first pixel, and a
|
||||
/// one pixel is WHITE. For binary images set bytes_per_pixel=0.
|
||||
void SetImage(const unsigned char* imagedata, int width, int height,
|
||||
int bytes_per_pixel, int bytes_per_line);
|
||||
|
||||
/// Store the coordinates of the rectangle to process for later use.
|
||||
/// Doesn't actually do any thresholding.
|
||||
void SetRectangle(int left, int top, int width, int height);
|
||||
|
||||
/// Get enough parameters to be able to rebuild bounding boxes in the
|
||||
/// original image (not just within the rectangle).
|
||||
/// Left and top are enough with top-down coordinates, but
|
||||
/// the height of the rectangle and the image are needed for bottom-up.
|
||||
virtual void GetImageSizes(int* left, int* top, int* width, int* height,
|
||||
int* imagewidth, int* imageheight);
|
||||
|
||||
/// Return true if the source image is color.
|
||||
bool IsColor() const {
|
||||
return pix_channels_ >= 3;
|
||||
}
|
||||
|
||||
/// Returns true if the source image is binary.
|
||||
bool IsBinary() const {
|
||||
return pix_channels_ == 0;
|
||||
}
|
||||
|
||||
int GetScaleFactor() const {
|
||||
return scale_;
|
||||
}
|
||||
|
||||
// Set the resolution of the source image in pixels per inch.
|
||||
// This should be called right after SetImage(), and will let us return
|
||||
// appropriate font sizes for the text.
|
||||
void SetSourceYResolution(int ppi) {
|
||||
yres_ = ppi;
|
||||
estimated_res_ = ppi;
|
||||
}
|
||||
int GetSourceYResolution() const {
|
||||
return yres_;
|
||||
}
|
||||
int GetScaledYResolution() const {
|
||||
return scale_ * yres_;
|
||||
}
|
||||
// Set the resolution of the source image in pixels per inch, as estimated
|
||||
// by the thresholder from the text size found during thresholding.
|
||||
// This value will be used to set internal size thresholds during recognition
|
||||
// and will not influence the output "point size." The default value is
|
||||
// the same as the source resolution. (yres_)
|
||||
void SetEstimatedResolution(int ppi) {
|
||||
estimated_res_ = ppi;
|
||||
}
|
||||
// Returns the estimated resolution, including any active scaling.
|
||||
// This value will be used to set internal size thresholds during recognition.
|
||||
int GetScaledEstimatedResolution() const {
|
||||
return scale_ * estimated_res_;
|
||||
}
|
||||
|
||||
/// Pix vs raw, which to use? Pix is the preferred input for efficiency,
|
||||
/// since raw buffers are copied.
|
||||
/// SetImage for Pix clones its input, so the source pix may be pixDestroyed
|
||||
/// immediately after, but may not go away until after the Thresholder has
|
||||
/// finished with it.
|
||||
void SetImage(const Pix* pix);
|
||||
|
||||
/// Threshold the source image as efficiently as possible to the output Pix.
|
||||
/// Creates a Pix and sets pix to point to the resulting pointer.
|
||||
/// Caller must use pixDestroy to free the created Pix.
|
||||
/// Returns false on error.
|
||||
virtual bool ThresholdToPix(PageSegMode pageseg_mode, Pix** pix);
|
||||
|
||||
// Gets a pix that contains an 8 bit threshold value at each pixel. The
|
||||
// returned pix may be an integer reduction of the binary image such that
|
||||
// the scale factor may be inferred from the ratio of the sizes, even down
|
||||
// to the extreme of a 1x1 pixel thresholds image.
|
||||
// Ideally the 8 bit threshold should be the exact threshold used to generate
|
||||
// the binary image in ThresholdToPix, but this is not a hard constraint.
|
||||
// Returns nullptr if the input is binary. PixDestroy after use.
|
||||
virtual Pix* GetPixRectThresholds();
|
||||
|
||||
/// Get a clone/copy of the source image rectangle.
|
||||
/// The returned Pix must be pixDestroyed.
|
||||
/// This function will be used in the future by the page layout analysis, and
|
||||
/// the layout analysis that uses it will only be available with Leptonica,
|
||||
/// so there is no raw equivalent.
|
||||
Pix* GetPixRect();
|
||||
|
||||
// Get a clone/copy of the source image rectangle, reduced to greyscale,
|
||||
// and at the same resolution as the output binary.
|
||||
// The returned Pix must be pixDestroyed.
|
||||
// Provided to the classifier to extract features from the greyscale image.
|
||||
virtual Pix* GetPixRectGrey();
|
||||
|
||||
protected:
|
||||
// ----------------------------------------------------------------------
|
||||
// Utility functions that may be useful components for other thresholders.
|
||||
|
||||
/// Common initialization shared between SetImage methods.
|
||||
virtual void Init();
|
||||
|
||||
/// Return true if we are processing the full image.
|
||||
bool IsFullImage() const {
|
||||
return rect_left_ == 0 && rect_top_ == 0 &&
|
||||
rect_width_ == image_width_ && rect_height_ == image_height_;
|
||||
}
|
||||
|
||||
// Otsu thresholds the rectangle, taking the rectangle from *this.
|
||||
void OtsuThresholdRectToPix(Pix* src_pix, Pix** out_pix) const;
|
||||
|
||||
/// Threshold the rectangle, taking everything except the src_pix
|
||||
/// from the class, using thresholds/hi_values to the output pix.
|
||||
/// NOTE that num_channels is the size of the thresholds and hi_values
|
||||
// arrays and also the bytes per pixel in src_pix.
|
||||
void ThresholdRectToPix(Pix* src_pix, int num_channels,
|
||||
const int* thresholds, const int* hi_values,
|
||||
Pix** pix) const;
|
||||
|
||||
protected:
|
||||
/// Clone or other copy of the source Pix.
|
||||
/// The pix will always be PixDestroy()ed on destruction of the class.
|
||||
Pix* pix_;
|
||||
|
||||
int image_width_; ///< Width of source pix_.
|
||||
int image_height_; ///< Height of source pix_.
|
||||
int pix_channels_; ///< Number of 8-bit channels in pix_.
|
||||
int pix_wpl_; ///< Words per line of pix_.
|
||||
// Limits of image rectangle to be processed.
|
||||
int scale_; ///< Scale factor from original image.
|
||||
int yres_; ///< y pixels/inch in source image.
|
||||
int estimated_res_; ///< Resolution estimate from text size.
|
||||
int rect_left_;
|
||||
int rect_top_;
|
||||
int rect_width_;
|
||||
int rect_height_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_THRESHOLDER_H_
|
|
@ -0,0 +1,176 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
// File: unichar.h
|
||||
// Description: Unicode character/ligature class.
|
||||
// Author: Ray Smith
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TESSERACT_CCUTIL_UNICHAR_H_
|
||||
#define TESSERACT_CCUTIL_UNICHAR_H_
|
||||
|
||||
#include <memory.h>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "platform.h"
|
||||
|
||||
// Maximum number of characters that can be stored in a UNICHAR. Must be
|
||||
// at least 4. Must not exceed 31 without changing the coding of length.
|
||||
#define UNICHAR_LEN 30
|
||||
|
||||
// TODO(rays) Move these to the tesseract namespace.
|
||||
// A UNICHAR_ID is the unique id of a unichar.
|
||||
using UNICHAR_ID = int;
|
||||
|
||||
// A variable to indicate an invalid or uninitialized unichar id.
|
||||
static const int INVALID_UNICHAR_ID = -1;
|
||||
// A special unichar that corresponds to INVALID_UNICHAR_ID.
|
||||
static const char INVALID_UNICHAR[] = "__INVALID_UNICHAR__";
|
||||
|
||||
enum StrongScriptDirection {
|
||||
DIR_NEUTRAL = 0, // Text contains only neutral characters.
|
||||
DIR_LEFT_TO_RIGHT = 1, // Text contains no Right-to-Left characters.
|
||||
DIR_RIGHT_TO_LEFT = 2, // Text contains no Left-to-Right characters.
|
||||
DIR_MIX = 3, // Text contains a mixture of left-to-right
|
||||
// and right-to-left characters.
|
||||
};
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
using char32 = signed int;
|
||||
|
||||
// The UNICHAR class holds a single classification result. This may be
|
||||
// a single Unicode character (stored as between 1 and 4 utf8 bytes) or
|
||||
// multiple Unicode characters representing the NFKC expansion of a ligature
|
||||
// such as fi, ffl etc. These are also stored as utf8.
|
||||
class UNICHAR {
|
||||
public:
|
||||
UNICHAR() {
|
||||
memset(chars, 0, UNICHAR_LEN);
|
||||
}
|
||||
|
||||
// Construct from a utf8 string. If len<0 then the string is null terminated.
|
||||
// If the string is too long to fit in the UNICHAR then it takes only what
|
||||
// will fit.
|
||||
UNICHAR(const char* utf8_str, int len);
|
||||
|
||||
// Construct from a single UCS4 character.
|
||||
explicit UNICHAR(int unicode);
|
||||
|
||||
// Default copy constructor and operator= are OK.
|
||||
|
||||
// Get the first character as UCS-4.
|
||||
int first_uni() const;
|
||||
|
||||
// Get the length of the UTF8 string.
|
||||
int utf8_len() const {
|
||||
int len = chars[UNICHAR_LEN - 1];
|
||||
return len >= 0 && len < UNICHAR_LEN ? len : UNICHAR_LEN;
|
||||
}
|
||||
|
||||
// Get a UTF8 string, but NOT nullptr terminated.
|
||||
const char* utf8() const {
|
||||
return chars;
|
||||
}
|
||||
|
||||
// Get a terminated UTF8 string: Must delete[] it after use.
|
||||
char* utf8_str() const;
|
||||
|
||||
// Get the number of bytes in the first character of the given utf8 string.
|
||||
static int utf8_step(const char* utf8_str);
|
||||
|
||||
// A class to simplify iterating over and accessing elements of a UTF8
|
||||
// string. Note that unlike the UNICHAR class, const_iterator does NOT COPY or
|
||||
// take ownership of the underlying byte array. It also does not permit
|
||||
// modification of the array (as the name suggests).
|
||||
//
|
||||
// Example:
|
||||
// for (UNICHAR::const_iterator it = UNICHAR::begin(str, str_len);
|
||||
// it != UNICHAR::end(str, len);
|
||||
// ++it) {
|
||||
// tprintf("UCS-4 symbol code = %d\n", *it);
|
||||
// char buf[5];
|
||||
// int char_len = it.get_utf8(buf); buf[char_len] = '\0';
|
||||
// tprintf("Char = %s\n", buf);
|
||||
// }
|
||||
class const_iterator {
|
||||
using CI = const_iterator;
|
||||
|
||||
public:
|
||||
// Step to the next UTF8 character.
|
||||
// If the current position is at an illegal UTF8 character, then print an
|
||||
// error message and step by one byte. If the current position is at a
|
||||
// nullptr value, don't step past it.
|
||||
const_iterator& operator++();
|
||||
|
||||
// Return the UCS-4 value at the current position.
|
||||
// If the current position is at an illegal UTF8 value, return a single
|
||||
// space character.
|
||||
int operator*() const;
|
||||
|
||||
// Store the UTF-8 encoding of the current codepoint into buf, which must be
|
||||
// at least 4 bytes long. Return the number of bytes written.
|
||||
// If the current position is at an illegal UTF8 value, writes a single
|
||||
// space character and returns 1.
|
||||
// Note that this method does not null-terminate the buffer.
|
||||
int get_utf8(char* buf) const;
|
||||
// Returns the number of bytes of the current codepoint. Returns 1 if the
|
||||
// current position is at an illegal UTF8 value.
|
||||
int utf8_len() const;
|
||||
// Returns true if the UTF-8 encoding at the current position is legal.
|
||||
bool is_legal() const;
|
||||
|
||||
// Return the pointer into the string at the current position.
|
||||
const char* utf8_data() const {
|
||||
return it_;
|
||||
}
|
||||
|
||||
// Iterator equality operators.
|
||||
friend bool operator==(const CI& lhs, const CI& rhs) {
|
||||
return lhs.it_ == rhs.it_;
|
||||
}
|
||||
friend bool operator!=(const CI& lhs, const CI& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class UNICHAR;
|
||||
explicit const_iterator(const char* it) : it_(it) {}
|
||||
|
||||
const char* it_; // Pointer into the string.
|
||||
};
|
||||
|
||||
// Create a start/end iterator pointing to a string. Note that these methods
|
||||
// are static and do NOT create a copy or take ownership of the underlying
|
||||
// array.
|
||||
static const_iterator begin(const char* utf8_str, int byte_length);
|
||||
static const_iterator end(const char* utf8_str, int byte_length);
|
||||
|
||||
// Converts a utf-8 string to a vector of unicodes.
|
||||
// Returns an empty vector if the input contains invalid UTF-8.
|
||||
static std::vector<char32> UTF8ToUTF32(const char* utf8_str);
|
||||
// Converts a vector of unicodes to a utf8 string.
|
||||
// Returns an empty string if the input contains an invalid unicode.
|
||||
static std::string UTF32ToUTF8(const std::vector<char32>& str32);
|
||||
|
||||
private:
|
||||
// A UTF-8 representation of 1 or more Unicode characters.
|
||||
// The last element (chars[UNICHAR_LEN - 1]) is a length if
|
||||
// its value < UNICHAR_LEN, otherwise it is a genuine character.
|
||||
char chars[UNICHAR_LEN]{};
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
#endif // TESSERACT_CCUTIL_UNICHAR_H_
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
prefix=/data/home/SW2023/sane/code_app/third_party/ocr/tesseract-ocr/tesseract-4.1.1/tesseract-4.1.1/build/release
|
||||
exec_prefix=${prefix}/bin
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libtesseract
|
||||
Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
|
||||
URL: https://github.com/tesseract-ocr/tesseract
|
||||
Version: 4.1.1
|
||||
Libs: -L${libdir} -ltesseract
|
||||
Libs.private:
|
||||
Cflags: -I${includedir}
|
|
@ -0,0 +1,73 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_CV_H
|
||||
#define OPENCV_OLD_CV_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define CV_DO_PRAGMA(x) __pragma(x)
|
||||
#define __CVSTR2__(x) #x
|
||||
#define __CVSTR1__(x) __CVSTR2__(x)
|
||||
#define __CVMSVCLOC__ __FILE__ "("__CVSTR1__(__LINE__)") : "
|
||||
#define CV_MSG_PRAGMA(_msg) CV_DO_PRAGMA(message (__CVMSVCLOC__ _msg))
|
||||
#elif defined(__GNUC__)
|
||||
#define CV_DO_PRAGMA(x) _Pragma (#x)
|
||||
#define CV_MSG_PRAGMA(_msg) CV_DO_PRAGMA(message (_msg))
|
||||
#else
|
||||
#define CV_DO_PRAGMA(x)
|
||||
#define CV_MSG_PRAGMA(_msg)
|
||||
#endif
|
||||
#define CV_WARNING(x) CV_MSG_PRAGMA("Warning: " #x)
|
||||
|
||||
//CV_WARNING("This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module")
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/photo/photo_c.h"
|
||||
#include "opencv2/video/tracking_c.h"
|
||||
#include "opencv2/objdetect/objdetect_c.h"
|
||||
|
||||
#if !defined(CV_IMPL)
|
||||
#define CV_IMPL extern "C"
|
||||
#endif //CV_IMPL
|
||||
|
||||
#endif // __OPENCV_OLD_CV_H_
|
|
@ -0,0 +1,60 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_CV_HPP
|
||||
#define OPENCV_OLD_CV_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
//#endif
|
||||
|
||||
#include "cv.h"
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/photo.hpp"
|
||||
#include "opencv2/video.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/features2d.hpp"
|
||||
#include "opencv2/calib3d.hpp"
|
||||
#include "opencv2/objdetect.hpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_AUX_H
|
||||
#define OPENCV_OLD_AUX_H
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
//#endif
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include "opencv2/photo/photo_c.h"
|
||||
#include "opencv2/video/tracking_c.h"
|
||||
#include "opencv2/objdetect/objdetect_c.h"
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
|
@ -0,0 +1,52 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_AUX_HPP
|
||||
#define OPENCV_OLD_AUX_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
//#endif
|
||||
|
||||
#include "cvaux.h"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to
|
||||
// this license. If you do not agree to this license, do not download,
|
||||
// install, copy or use the software.
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2008, Google, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation or contributors may not be used to endorse
|
||||
// or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is"
|
||||
// and any express or implied warranties, including, but not limited to, the
|
||||
// implied warranties of merchantability and fitness for a particular purpose
|
||||
// are disclaimed. In no event shall the Intel Corporation or contributors be
|
||||
// liable for any direct, indirect, incidental, special, exemplary, or
|
||||
// consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
|
||||
|
||||
#ifndef OPENCV_OLD_WIMAGE_HPP
|
||||
#define OPENCV_OLD_WIMAGE_HPP
|
||||
|
||||
#include "opencv2/core/wimage.hpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,52 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_CXCORE_H
|
||||
#define OPENCV_OLD_CXCORE_H
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
//#endif
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,53 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_CXCORE_HPP
|
||||
#define OPENCV_OLD_CXCORE_HPP
|
||||
|
||||
//#if defined(__GNUC__)
|
||||
//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
|
||||
//#endif
|
||||
|
||||
#include "cxcore.h"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,48 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_EIGEN_HPP
|
||||
#define OPENCV_OLD_EIGEN_HPP
|
||||
|
||||
#include "opencv2/core/eigen.hpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef OPENCV_OLD_CXMISC_H
|
||||
#define OPENCV_OLD_CXMISC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "opencv2/core/utility.hpp"
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,48 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_HIGHGUI_H
|
||||
#define OPENCV_OLD_HIGHGUI_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OLD_ML_H
|
||||
#define OPENCV_OLD_ML_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/ml.hpp"
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,48 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/calib3d.hpp"
|
|
@ -0,0 +1,427 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CALIB3D_C_H
|
||||
#define OPENCV_CALIB3D_C_H
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup calib3d_c
|
||||
@{
|
||||
*/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Camera Calibration, Pose Estimation and Stereo *
|
||||
\****************************************************************************************/
|
||||
|
||||
typedef struct CvPOSITObject CvPOSITObject;
|
||||
|
||||
/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
|
||||
CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
|
||||
|
||||
|
||||
/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
|
||||
an object given its model and projection in a weak-perspective case */
|
||||
CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
|
||||
double focal_length, CvTermCriteria criteria,
|
||||
float* rotation_matrix, float* translation_vector);
|
||||
|
||||
/* Releases CvPOSITObject structure */
|
||||
CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
|
||||
|
||||
/* updates the number of RANSAC iterations */
|
||||
CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
|
||||
int model_points, int max_iters );
|
||||
|
||||
CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
|
||||
|
||||
/* Calculates fundamental matrix given a set of corresponding points */
|
||||
#define CV_FM_7POINT 1
|
||||
#define CV_FM_8POINT 2
|
||||
|
||||
#define CV_LMEDS 4
|
||||
#define CV_RANSAC 8
|
||||
|
||||
#define CV_FM_LMEDS_ONLY CV_LMEDS
|
||||
#define CV_FM_RANSAC_ONLY CV_RANSAC
|
||||
#define CV_FM_LMEDS CV_LMEDS
|
||||
#define CV_FM_RANSAC CV_RANSAC
|
||||
|
||||
enum
|
||||
{
|
||||
CV_ITERATIVE = 0,
|
||||
CV_EPNP = 1, // F.Moreno-Noguer, V.Lepetit and P.Fua "EPnP: Efficient Perspective-n-Point Camera Pose Estimation"
|
||||
CV_P3P = 2, // X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang; "Complete Solution Classification for the Perspective-Three-Point Problem"
|
||||
CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP"
|
||||
};
|
||||
|
||||
CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
|
||||
CvMat* fundamental_matrix,
|
||||
int method CV_DEFAULT(CV_FM_RANSAC),
|
||||
double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
|
||||
CvMat* status CV_DEFAULT(NULL) );
|
||||
|
||||
/* For each input point on one of images
|
||||
computes parameters of the corresponding
|
||||
epipolar line on the other image */
|
||||
CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
|
||||
int which_image,
|
||||
const CvMat* fundamental_matrix,
|
||||
CvMat* correspondent_lines );
|
||||
|
||||
/* Triangulation functions */
|
||||
|
||||
CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
|
||||
CvMat* projPoints1, CvMat* projPoints2,
|
||||
CvMat* points4D);
|
||||
|
||||
CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
|
||||
CvMat* new_points1, CvMat* new_points2);
|
||||
|
||||
|
||||
/* Computes the optimal new camera matrix according to the free scaling parameter alpha:
|
||||
alpha=0 - only valid pixels will be retained in the undistorted image
|
||||
alpha=1 - all the source image pixels will be retained in the undistorted image
|
||||
*/
|
||||
CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
|
||||
const CvMat* dist_coeffs,
|
||||
CvSize image_size, double alpha,
|
||||
CvMat* new_camera_matrix,
|
||||
CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
|
||||
CvRect* valid_pixel_ROI CV_DEFAULT(0),
|
||||
int center_principal_point CV_DEFAULT(0));
|
||||
|
||||
/* Converts rotation vector to rotation matrix or vice versa */
|
||||
CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
|
||||
CvMat* jacobian CV_DEFAULT(0) );
|
||||
|
||||
/* Finds perspective transformation between the object plane and image (view) plane */
|
||||
CVAPI(int) cvFindHomography( const CvMat* src_points,
|
||||
const CvMat* dst_points,
|
||||
CvMat* homography,
|
||||
int method CV_DEFAULT(0),
|
||||
double ransacReprojThreshold CV_DEFAULT(3),
|
||||
CvMat* mask CV_DEFAULT(0),
|
||||
int maxIters CV_DEFAULT(2000),
|
||||
double confidence CV_DEFAULT(0.995));
|
||||
|
||||
/* Computes RQ decomposition for 3x3 matrices */
|
||||
CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
||||
CvMat *matrixQx CV_DEFAULT(NULL),
|
||||
CvMat *matrixQy CV_DEFAULT(NULL),
|
||||
CvMat *matrixQz CV_DEFAULT(NULL),
|
||||
CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
|
||||
|
||||
/* Computes projection matrix decomposition */
|
||||
CVAPI(void) cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
|
||||
CvMat *rotMatr, CvMat *posVect,
|
||||
CvMat *rotMatrX CV_DEFAULT(NULL),
|
||||
CvMat *rotMatrY CV_DEFAULT(NULL),
|
||||
CvMat *rotMatrZ CV_DEFAULT(NULL),
|
||||
CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
|
||||
|
||||
/* Computes d(AB)/dA and d(AB)/dB */
|
||||
CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
|
||||
|
||||
/* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
|
||||
t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
|
||||
CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
|
||||
const CvMat* _rvec2, const CvMat* _tvec2,
|
||||
CvMat* _rvec3, CvMat* _tvec3,
|
||||
CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
|
||||
CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
|
||||
CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
|
||||
CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
|
||||
|
||||
/* Projects object points to the view plane using
|
||||
the specified extrinsic and intrinsic camera parameters */
|
||||
CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
|
||||
const CvMat* translation_vector, const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs, CvMat* image_points,
|
||||
CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
|
||||
CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
|
||||
CvMat* dpddist CV_DEFAULT(NULL),
|
||||
double aspect_ratio CV_DEFAULT(0));
|
||||
|
||||
/* Finds extrinsic camera parameters from
|
||||
a few known corresponding point pairs and intrinsic parameters */
|
||||
CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* camera_matrix,
|
||||
const CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vector,
|
||||
CvMat* translation_vector,
|
||||
int use_extrinsic_guess CV_DEFAULT(0) );
|
||||
|
||||
/* Computes initial estimate of the intrinsic camera parameters
|
||||
in case of planar calibration target (e.g. chessboard) */
|
||||
CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* npoints, CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
double aspect_ratio CV_DEFAULT(1.) );
|
||||
|
||||
#define CV_CALIB_CB_ADAPTIVE_THRESH 1
|
||||
#define CV_CALIB_CB_NORMALIZE_IMAGE 2
|
||||
#define CV_CALIB_CB_FILTER_QUADS 4
|
||||
#define CV_CALIB_CB_FAST_CHECK 8
|
||||
|
||||
// Performs a fast check if a chessboard is in the input image. This is a workaround to
|
||||
// a problem of cvFindChessboardCorners being slow on images with no chessboard
|
||||
// - src: input image
|
||||
// - size: chessboard size
|
||||
// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
|
||||
// 0 if there is no chessboard, -1 in case of error
|
||||
CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
|
||||
|
||||
/* Detects corners on a chessboard calibration pattern */
|
||||
CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int* corner_count CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE) );
|
||||
|
||||
/* Draws individual chessboard corners or the whole chessboard detected */
|
||||
CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
|
||||
CvPoint2D32f* corners,
|
||||
int count, int pattern_was_found );
|
||||
|
||||
#define CV_CALIB_USE_INTRINSIC_GUESS 1
|
||||
#define CV_CALIB_FIX_ASPECT_RATIO 2
|
||||
#define CV_CALIB_FIX_PRINCIPAL_POINT 4
|
||||
#define CV_CALIB_ZERO_TANGENT_DIST 8
|
||||
#define CV_CALIB_FIX_FOCAL_LENGTH 16
|
||||
#define CV_CALIB_FIX_K1 32
|
||||
#define CV_CALIB_FIX_K2 64
|
||||
#define CV_CALIB_FIX_K3 128
|
||||
#define CV_CALIB_FIX_K4 2048
|
||||
#define CV_CALIB_FIX_K5 4096
|
||||
#define CV_CALIB_FIX_K6 8192
|
||||
#define CV_CALIB_RATIONAL_MODEL 16384
|
||||
#define CV_CALIB_THIN_PRISM_MODEL 32768
|
||||
#define CV_CALIB_FIX_S1_S2_S3_S4 65536
|
||||
#define CV_CALIB_TILTED_MODEL 262144
|
||||
#define CV_CALIB_FIX_TAUX_TAUY 524288
|
||||
#define CV_CALIB_FIX_TANGENT_DIST 2097152
|
||||
|
||||
#define CV_CALIB_NINTRINSIC 18
|
||||
|
||||
/* Finds intrinsic and extrinsic camera parameters
|
||||
from a few views of known calibration pattern */
|
||||
CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
|
||||
const CvMat* image_points,
|
||||
const CvMat* point_counts,
|
||||
CvSize image_size,
|
||||
CvMat* camera_matrix,
|
||||
CvMat* distortion_coeffs,
|
||||
CvMat* rotation_vectors CV_DEFAULT(NULL),
|
||||
CvMat* translation_vectors CV_DEFAULT(NULL),
|
||||
int flags CV_DEFAULT(0),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
|
||||
|
||||
/* Computes various useful characteristics of the camera from the data computed by
|
||||
cvCalibrateCamera2 */
|
||||
CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
|
||||
CvSize image_size,
|
||||
double aperture_width CV_DEFAULT(0),
|
||||
double aperture_height CV_DEFAULT(0),
|
||||
double *fovx CV_DEFAULT(NULL),
|
||||
double *fovy CV_DEFAULT(NULL),
|
||||
double *focal_length CV_DEFAULT(NULL),
|
||||
CvPoint2D64f *principal_point CV_DEFAULT(NULL),
|
||||
double *pixel_aspect_ratio CV_DEFAULT(NULL));
|
||||
|
||||
#define CV_CALIB_FIX_INTRINSIC 256
|
||||
#define CV_CALIB_SAME_FOCAL_LENGTH 512
|
||||
|
||||
/* Computes the transformation from one camera coordinate system to another one
|
||||
from a few correspondent views of the same calibration target. Optionally, calibrates
|
||||
both cameras */
|
||||
CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
|
||||
const CvMat* image_points2, const CvMat* npoints,
|
||||
CvMat* camera_matrix1, CvMat* dist_coeffs1,
|
||||
CvMat* camera_matrix2, CvMat* dist_coeffs2,
|
||||
CvSize image_size, CvMat* R, CvMat* T,
|
||||
CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC),
|
||||
CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
|
||||
CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)) );
|
||||
|
||||
#define CV_CALIB_ZERO_DISPARITY 1024
|
||||
|
||||
/* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
|
||||
views parallel (=> to make all the epipolar lines horizontal or vertical) */
|
||||
CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
|
||||
const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
|
||||
CvSize image_size, const CvMat* R, const CvMat* T,
|
||||
CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
|
||||
CvMat* Q CV_DEFAULT(0),
|
||||
int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
|
||||
double alpha CV_DEFAULT(-1),
|
||||
CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
|
||||
CvRect* valid_pix_ROI1 CV_DEFAULT(0),
|
||||
CvRect* valid_pix_ROI2 CV_DEFAULT(0));
|
||||
|
||||
/* Computes rectification transformations for uncalibrated pair of images using a set
|
||||
of point correspondences */
|
||||
CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
|
||||
const CvMat* F, CvSize img_size,
|
||||
CvMat* H1, CvMat* H2,
|
||||
double threshold CV_DEFAULT(5));
|
||||
|
||||
|
||||
|
||||
/* stereo correspondence parameters and functions */
|
||||
|
||||
#define CV_STEREO_BM_NORMALIZED_RESPONSE 0
|
||||
#define CV_STEREO_BM_XSOBEL 1
|
||||
|
||||
/* Block matching algorithm structure */
|
||||
typedef struct CvStereoBMState
|
||||
{
|
||||
// pre-filtering (normalization of input images)
|
||||
int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
|
||||
int preFilterSize; // averaging window size: ~5x5..21x21
|
||||
int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
|
||||
|
||||
// correspondence using Sum of Absolute Difference (SAD)
|
||||
int SADWindowSize; // ~5x5..21x21
|
||||
int minDisparity; // minimum disparity (can be negative)
|
||||
int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
|
||||
|
||||
// post-filtering
|
||||
int textureThreshold; // the disparity is only computed for pixels
|
||||
// with textured enough neighborhood
|
||||
int uniquenessRatio; // accept the computed disparity d* only if
|
||||
// SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
|
||||
// for any d != d*+/-1 within the search range.
|
||||
int speckleWindowSize; // disparity variation window
|
||||
int speckleRange; // acceptable range of variation in window
|
||||
|
||||
int trySmallerWindows; // if 1, the results may be more accurate,
|
||||
// at the expense of slower processing
|
||||
CvRect roi1, roi2;
|
||||
int disp12MaxDiff;
|
||||
|
||||
// temporary buffers
|
||||
CvMat* preFilteredImg0;
|
||||
CvMat* preFilteredImg1;
|
||||
CvMat* slidingSumBuf;
|
||||
CvMat* cost;
|
||||
CvMat* disp;
|
||||
} CvStereoBMState;
|
||||
|
||||
#define CV_STEREO_BM_BASIC 0
|
||||
#define CV_STEREO_BM_FISH_EYE 1
|
||||
#define CV_STEREO_BM_NARROW 2
|
||||
|
||||
CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
|
||||
int numberOfDisparities CV_DEFAULT(0));
|
||||
|
||||
CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
|
||||
|
||||
CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
|
||||
CvArr* disparity, CvStereoBMState* state );
|
||||
|
||||
CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
|
||||
int numberOfDisparities, int SADWindowSize );
|
||||
|
||||
CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
|
||||
int minDisparity, int numberOfDisparities,
|
||||
int disp12MaxDiff CV_DEFAULT(1) );
|
||||
|
||||
/* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
|
||||
CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
|
||||
CvArr* _3dImage, const CvMat* Q,
|
||||
int handleMissingValues CV_DEFAULT(0) );
|
||||
|
||||
/** @} calib3d_c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CV_EXPORTS CvLevMarq
|
||||
{
|
||||
public:
|
||||
CvLevMarq();
|
||||
CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
|
||||
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
|
||||
bool completeSymmFlag=false );
|
||||
~CvLevMarq();
|
||||
void init( int nparams, int nerrs, CvTermCriteria criteria=
|
||||
cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
|
||||
bool completeSymmFlag=false );
|
||||
bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
|
||||
bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
|
||||
|
||||
void clear();
|
||||
void step();
|
||||
enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
|
||||
|
||||
cv::Ptr<CvMat> mask;
|
||||
cv::Ptr<CvMat> prevParam;
|
||||
cv::Ptr<CvMat> param;
|
||||
cv::Ptr<CvMat> J;
|
||||
cv::Ptr<CvMat> err;
|
||||
cv::Ptr<CvMat> JtJ;
|
||||
cv::Ptr<CvMat> JtJN;
|
||||
cv::Ptr<CvMat> JtErr;
|
||||
cv::Ptr<CvMat> JtJV;
|
||||
cv::Ptr<CvMat> JtJW;
|
||||
double prevErrNorm, errNorm;
|
||||
int lambdaLg10;
|
||||
CvTermCriteria criteria;
|
||||
int state;
|
||||
int iters;
|
||||
bool completeSymmFlag;
|
||||
int solveMethod;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* OPENCV_CALIB3D_C_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,678 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CORE_AFFINE3_HPP
|
||||
#define OPENCV_CORE_AFFINE3_HPP
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup core
|
||||
//! @{
|
||||
|
||||
/** @brief Affine transform
|
||||
*
|
||||
* It represents a 4x4 homogeneous transformation matrix \f$T\f$
|
||||
*
|
||||
* \f[T =
|
||||
* \begin{bmatrix}
|
||||
* R & t\\
|
||||
* 0 & 1\\
|
||||
* \end{bmatrix}
|
||||
* \f]
|
||||
*
|
||||
* where \f$R\f$ is a 3x3 rotation matrix and \f$t\f$ is a 3x1 translation vector.
|
||||
*
|
||||
* You can specify \f$R\f$ either by a 3x3 rotation matrix or by a 3x1 rotation vector,
|
||||
* which is converted to a 3x3 rotation matrix by the Rodrigues formula.
|
||||
*
|
||||
* To construct a matrix \f$T\f$ representing first rotation around the axis \f$r\f$ with rotation
|
||||
* angle \f$|r|\f$ in radian (right hand rule) and then translation by the vector \f$t\f$, you can use
|
||||
*
|
||||
* @code
|
||||
* cv::Vec3f r, t;
|
||||
* cv::Affine3f T(r, t);
|
||||
* @endcode
|
||||
*
|
||||
* If you already have the rotation matrix \f$R\f$, then you can use
|
||||
*
|
||||
* @code
|
||||
* cv::Matx33f R;
|
||||
* cv::Affine3f T(R, t);
|
||||
* @endcode
|
||||
*
|
||||
* To extract the rotation matrix \f$R\f$ from \f$T\f$, use
|
||||
*
|
||||
* @code
|
||||
* cv::Matx33f R = T.rotation();
|
||||
* @endcode
|
||||
*
|
||||
* To extract the translation vector \f$t\f$ from \f$T\f$, use
|
||||
*
|
||||
* @code
|
||||
* cv::Vec3f t = T.translation();
|
||||
* @endcode
|
||||
*
|
||||
* To extract the rotation vector \f$r\f$ from \f$T\f$, use
|
||||
*
|
||||
* @code
|
||||
* cv::Vec3f r = T.rvec();
|
||||
* @endcode
|
||||
*
|
||||
* Note that since the mapping from rotation vectors to rotation matrices
|
||||
* is many to one. The returned rotation vector is not necessarily the one
|
||||
* you used before to set the matrix.
|
||||
*
|
||||
* If you have two transformations \f$T = T_1 * T_2\f$, use
|
||||
*
|
||||
* @code
|
||||
* cv::Affine3f T, T1, T2;
|
||||
* T = T2.concatenate(T1);
|
||||
* @endcode
|
||||
*
|
||||
* To get the inverse transform of \f$T\f$, use
|
||||
*
|
||||
* @code
|
||||
* cv::Affine3f T, T_inv;
|
||||
* T_inv = T.inv();
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
template<typename T>
|
||||
class Affine3
|
||||
{
|
||||
public:
|
||||
typedef T float_type;
|
||||
typedef Matx<float_type, 3, 3> Mat3;
|
||||
typedef Matx<float_type, 4, 4> Mat4;
|
||||
typedef Vec<float_type, 3> Vec3;
|
||||
|
||||
//! Default constructor. It represents a 4x4 identity matrix.
|
||||
Affine3();
|
||||
|
||||
//! Augmented affine matrix
|
||||
Affine3(const Mat4& affine);
|
||||
|
||||
/**
|
||||
* The resulting 4x4 matrix is
|
||||
*
|
||||
* \f[
|
||||
* \begin{bmatrix}
|
||||
* R & t\\
|
||||
* 0 & 1\\
|
||||
* \end{bmatrix}
|
||||
* \f]
|
||||
*
|
||||
* @param R 3x3 rotation matrix.
|
||||
* @param t 3x1 translation vector.
|
||||
*/
|
||||
Affine3(const Mat3& R, const Vec3& t = Vec3::all(0));
|
||||
|
||||
/**
|
||||
* Rodrigues vector.
|
||||
*
|
||||
* The last row of the current matrix is set to [0,0,0,1].
|
||||
*
|
||||
* @param rvec 3x1 rotation vector. Its direction indicates the rotation axis and its length
|
||||
* indicates the rotation angle in radian (using right hand rule).
|
||||
* @param t 3x1 translation vector.
|
||||
*/
|
||||
Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0));
|
||||
|
||||
/**
|
||||
* Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix.
|
||||
*
|
||||
* The last row of the current matrix is set to [0,0,0,1] when data is not 4x4.
|
||||
*
|
||||
* @param data 1-channel matrix.
|
||||
* when it is 4x4, it is copied to the current matrix and t is not used.
|
||||
* When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used.
|
||||
* When it is 3x3, it is copied to the upper left 3x3 part of the current matrix.
|
||||
* When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used
|
||||
* to compute a 3x3 rotation matrix.
|
||||
* @param t 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4.
|
||||
*/
|
||||
explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//! From 16-element array
|
||||
explicit Affine3(const float_type* vals);
|
||||
|
||||
//! Create an 4x4 identity transform
|
||||
static Affine3 Identity();
|
||||
|
||||
/**
|
||||
* Rotation matrix.
|
||||
*
|
||||
* Copy the rotation matrix to the upper left 3x3 part of the current matrix.
|
||||
* The remaining elements of the current matrix are not changed.
|
||||
*
|
||||
* @param R 3x3 rotation matrix.
|
||||
*
|
||||
*/
|
||||
void rotation(const Mat3& R);
|
||||
|
||||
/**
|
||||
* Rodrigues vector.
|
||||
*
|
||||
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
|
||||
*
|
||||
* @param rvec 3x1 rotation vector. The direction indicates the rotation axis and
|
||||
* its length indicates the rotation angle in radian (using the right thumb convention).
|
||||
*/
|
||||
void rotation(const Vec3& rvec);
|
||||
|
||||
/**
|
||||
* Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix.
|
||||
*
|
||||
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
|
||||
*
|
||||
* @param data 1-channel matrix.
|
||||
* When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix.
|
||||
* When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula
|
||||
* is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix.
|
||||
*/
|
||||
void rotation(const Mat& data);
|
||||
|
||||
/**
|
||||
* Copy the 3x3 matrix L to the upper left part of the current matrix
|
||||
*
|
||||
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
|
||||
*
|
||||
* @param L 3x3 matrix.
|
||||
*/
|
||||
void linear(const Mat3& L);
|
||||
|
||||
/**
|
||||
* Copy t to the first three elements of the last column of the current matrix
|
||||
*
|
||||
* It sets the upper right 3x1 part of the matrix. The remaining part is unaffected.
|
||||
*
|
||||
* @param t 3x1 translation vector.
|
||||
*/
|
||||
void translation(const Vec3& t);
|
||||
|
||||
//! @return the upper left 3x3 part
|
||||
Mat3 rotation() const;
|
||||
|
||||
//! @return the upper left 3x3 part
|
||||
Mat3 linear() const;
|
||||
|
||||
//! @return the upper right 3x1 part
|
||||
Vec3 translation() const;
|
||||
|
||||
//! Rodrigues vector.
|
||||
//! @return a vector representing the upper left 3x3 rotation matrix of the current matrix.
|
||||
//! @warning Since the mapping between rotation vectors and rotation matrices is many to one,
|
||||
//! this function returns only one rotation vector that represents the current rotation matrix,
|
||||
//! which is not necessarily the same one set by `rotation(const Vec3& rvec)`.
|
||||
Vec3 rvec() const;
|
||||
|
||||
//! @return the inverse of the current matrix.
|
||||
Affine3 inv(int method = cv::DECOMP_SVD) const;
|
||||
|
||||
//! a.rotate(R) is equivalent to Affine(R, 0) * a;
|
||||
Affine3 rotate(const Mat3& R) const;
|
||||
|
||||
//! a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;
|
||||
Affine3 rotate(const Vec3& rvec) const;
|
||||
|
||||
//! a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
|
||||
Affine3 translate(const Vec3& t) const;
|
||||
|
||||
//! a.concatenate(affine) is equivalent to affine * a;
|
||||
Affine3 concatenate(const Affine3& affine) const;
|
||||
|
||||
template <typename Y> operator Affine3<Y>() const;
|
||||
|
||||
template <typename Y> Affine3<Y> cast() const;
|
||||
|
||||
Mat4 matrix;
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine);
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine);
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const;
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine>() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename T> static
|
||||
Affine3<T> operator*(const Affine3<T>& affine1, const Affine3<T>& affine2);
|
||||
|
||||
//! V is a 3-element vector with member fields x, y and z
|
||||
template<typename T, typename V> static
|
||||
V operator*(const Affine3<T>& affine, const V& vector);
|
||||
|
||||
typedef Affine3<float> Affine3f;
|
||||
typedef Affine3<double> Affine3d;
|
||||
|
||||
static Vec3f operator*(const Affine3f& affine, const Vec3f& vector);
|
||||
static Vec3d operator*(const Affine3d& affine, const Vec3d& vector);
|
||||
|
||||
template<typename _Tp> class DataType< Affine3<_Tp> >
|
||||
{
|
||||
public:
|
||||
typedef Affine3<_Tp> value_type;
|
||||
typedef Affine3<typename DataType<_Tp>::work_type> work_type;
|
||||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
channels = 16,
|
||||
fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
|
||||
#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
|
||||
,depth = DataType<channel_type>::depth
|
||||
,type = CV_MAKETYPE(depth, channels)
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
|
||||
namespace traits {
|
||||
template<typename _Tp>
|
||||
struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; };
|
||||
template<typename _Tp>
|
||||
struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; };
|
||||
} // namespace
|
||||
|
||||
//! @} core
|
||||
|
||||
}
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Implementation
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3()
|
||||
: matrix(Mat4::eye())
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat4& affine)
|
||||
: matrix(affine)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat3& R, const Vec3& t)
|
||||
{
|
||||
rotation(R);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Vec3& _rvec, const Vec3& t)
|
||||
{
|
||||
rotation(_rvec);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
||||
{
|
||||
CV_Assert(data.type() == cv::traits::Type<T>::value);
|
||||
CV_Assert(data.channels() == 1);
|
||||
|
||||
if (data.cols == 4 && data.rows == 4)
|
||||
{
|
||||
data.copyTo(matrix);
|
||||
return;
|
||||
}
|
||||
else if (data.cols == 4 && data.rows == 3)
|
||||
{
|
||||
rotation(data(Rect(0, 0, 3, 3)));
|
||||
translation(data(Rect(3, 0, 1, 3)));
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation(data);
|
||||
translation(t);
|
||||
}
|
||||
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const float_type* vals) : matrix(vals)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::Identity()
|
||||
{
|
||||
return Affine3<T>(cv::Affine3<T>::Mat4::eye());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Mat3& R)
|
||||
{
|
||||
linear(R);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Vec3& _rvec)
|
||||
{
|
||||
double theta = norm(_rvec);
|
||||
|
||||
if (theta < DBL_EPSILON)
|
||||
rotation(Mat3::eye());
|
||||
else
|
||||
{
|
||||
double c = std::cos(theta);
|
||||
double s = std::sin(theta);
|
||||
double c1 = 1. - c;
|
||||
double itheta = (theta != 0) ? 1./theta : 0.;
|
||||
|
||||
Point3_<T> r = _rvec*itheta;
|
||||
|
||||
Mat3 rrt( r.x*r.x, r.x*r.y, r.x*r.z, r.x*r.y, r.y*r.y, r.y*r.z, r.x*r.z, r.y*r.z, r.z*r.z );
|
||||
Mat3 r_x( 0, -r.z, r.y, r.z, 0, -r.x, -r.y, r.x, 0 );
|
||||
|
||||
// R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x]
|
||||
// where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0]
|
||||
Mat3 R = c*Mat3::eye() + c1*rrt + s*r_x;
|
||||
|
||||
rotation(R);
|
||||
}
|
||||
}
|
||||
|
||||
//Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix;
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const cv::Mat& data)
|
||||
{
|
||||
CV_Assert(data.type() == cv::traits::Type<T>::value);
|
||||
CV_Assert(data.channels() == 1);
|
||||
|
||||
if (data.cols == 3 && data.rows == 3)
|
||||
{
|
||||
Mat3 R;
|
||||
data.copyTo(R);
|
||||
rotation(R);
|
||||
}
|
||||
else if ((data.cols == 3 && data.rows == 1) || (data.cols == 1 && data.rows == 3))
|
||||
{
|
||||
Vec3 _rvec;
|
||||
data.reshape(1, 3).copyTo(_rvec);
|
||||
rotation(_rvec);
|
||||
}
|
||||
else
|
||||
CV_Error(Error::StsError, "Input matrix can only be 3x3, 1x3 or 3x1");
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::linear(const Mat3& L)
|
||||
{
|
||||
matrix.val[0] = L.val[0]; matrix.val[1] = L.val[1]; matrix.val[ 2] = L.val[2];
|
||||
matrix.val[4] = L.val[3]; matrix.val[5] = L.val[4]; matrix.val[ 6] = L.val[5];
|
||||
matrix.val[8] = L.val[6]; matrix.val[9] = L.val[7]; matrix.val[10] = L.val[8];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::translation(const Vec3& t)
|
||||
{
|
||||
matrix.val[3] = t[0]; matrix.val[7] = t[1]; matrix.val[11] = t[2];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::rotation() const
|
||||
{
|
||||
return linear();
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::linear() const
|
||||
{
|
||||
typename cv::Affine3<T>::Mat3 R;
|
||||
R.val[0] = matrix.val[0]; R.val[1] = matrix.val[1]; R.val[2] = matrix.val[ 2];
|
||||
R.val[3] = matrix.val[4]; R.val[4] = matrix.val[5]; R.val[5] = matrix.val[ 6];
|
||||
R.val[6] = matrix.val[8]; R.val[7] = matrix.val[9]; R.val[8] = matrix.val[10];
|
||||
return R;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::translation() const
|
||||
{
|
||||
return Vec3(matrix.val[3], matrix.val[7], matrix.val[11]);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::rvec() const
|
||||
{
|
||||
cv::Vec3d w;
|
||||
cv::Matx33d u, vt, R = rotation();
|
||||
cv::SVD::compute(R, w, u, vt, cv::SVD::FULL_UV + cv::SVD::MODIFY_A);
|
||||
R = u * vt;
|
||||
|
||||
double rx = R.val[7] - R.val[5];
|
||||
double ry = R.val[2] - R.val[6];
|
||||
double rz = R.val[3] - R.val[1];
|
||||
|
||||
double s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25);
|
||||
double c = (R.val[0] + R.val[4] + R.val[8] - 1) * 0.5;
|
||||
c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 : c;
|
||||
double theta = acos(c);
|
||||
|
||||
if( s < 1e-5 )
|
||||
{
|
||||
if( c > 0 )
|
||||
rx = ry = rz = 0;
|
||||
else
|
||||
{
|
||||
double t;
|
||||
t = (R.val[0] + 1) * 0.5;
|
||||
rx = std::sqrt(std::max(t, 0.0));
|
||||
t = (R.val[4] + 1) * 0.5;
|
||||
ry = std::sqrt(std::max(t, 0.0)) * (R.val[1] < 0 ? -1.0 : 1.0);
|
||||
t = (R.val[8] + 1) * 0.5;
|
||||
rz = std::sqrt(std::max(t, 0.0)) * (R.val[2] < 0 ? -1.0 : 1.0);
|
||||
|
||||
if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.val[5] > 0) != (ry*rz > 0) )
|
||||
rz = -rz;
|
||||
theta /= std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
rx *= theta;
|
||||
ry *= theta;
|
||||
rz *= theta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double vth = 1/(2*s);
|
||||
vth *= theta;
|
||||
rx *= vth; ry *= vth; rz *= vth;
|
||||
}
|
||||
|
||||
return cv::Vec3d(rx, ry, rz);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::inv(int method) const
|
||||
{
|
||||
return matrix.inv(method);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Mat3& R) const
|
||||
{
|
||||
Mat3 Lc = linear();
|
||||
Vec3 tc = translation();
|
||||
Mat4 result;
|
||||
result.val[12] = result.val[13] = result.val[14] = 0;
|
||||
result.val[15] = 1;
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
float_type value = 0;
|
||||
for(int k = 0; k < 3; ++k)
|
||||
value += R(j, k) * Lc(k, i);
|
||||
result(j, i) = value;
|
||||
}
|
||||
|
||||
result(j, 3) = R.row(j).dot(tc.t());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Vec3& _rvec) const
|
||||
{
|
||||
return rotate(Affine3f(_rvec).rotation());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::translate(const Vec3& t) const
|
||||
{
|
||||
Mat4 m = matrix;
|
||||
m.val[ 3] += t[0];
|
||||
m.val[ 7] += t[1];
|
||||
m.val[11] += t[2];
|
||||
return m;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::concatenate(const Affine3<T>& affine) const
|
||||
{
|
||||
return (*this).rotate(affine.rotation()).translate(affine.translation());
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<T>::operator Affine3<Y>() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<Y> cv::Affine3<T>::cast() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::operator*(const cv::Affine3<T>& affine1, const cv::Affine3<T>& affine2)
|
||||
{
|
||||
return affine2.concatenate(affine1);
|
||||
}
|
||||
|
||||
template<typename T, typename V> inline
|
||||
V cv::operator*(const cv::Affine3<T>& affine, const V& v)
|
||||
{
|
||||
const typename Affine3<T>::Mat4& m = affine.matrix;
|
||||
|
||||
V r;
|
||||
r.x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3];
|
||||
r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7];
|
||||
r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline
|
||||
cv::Vec3f cv::operator*(const cv::Affine3f& affine, const cv::Vec3f& v)
|
||||
{
|
||||
const cv::Matx44f& m = affine.matrix;
|
||||
cv::Vec3f r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline
|
||||
cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v)
|
||||
{
|
||||
const cv::Matx44d& m = affine.matrix;
|
||||
cv::Vec3d r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine)
|
||||
{
|
||||
cv::Mat(4, 4, cv::traits::Type<T>::value, affine.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine)
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> a = affine;
|
||||
cv::Mat(4, 4, cv::traits::Type<T>::value, a.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> r;
|
||||
cv::Mat hdr(4, 4, cv::traits::Type<T>::value, r.matrix().data());
|
||||
cv::Mat(matrix, false).copyTo(hdr);
|
||||
return r;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine>() const
|
||||
{
|
||||
return this->operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>();
|
||||
}
|
||||
|
||||
#endif /* defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H */
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* OPENCV_CORE_AFFINE3_HPP */
|
|
@ -0,0 +1,105 @@
|
|||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_CORE_ASYNC_HPP
|
||||
#define OPENCV_CORE_ASYNC_HPP
|
||||
|
||||
#include <opencv2/core/mat.hpp>
|
||||
|
||||
#ifdef CV_CXX11
|
||||
//#include <future>
|
||||
#include <chrono>
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
|
||||
/** @addtogroup core_async
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
/** @brief Returns result of asynchronous operations
|
||||
|
||||
Object has attached asynchronous state.
|
||||
Assignment operator doesn't clone asynchronous state (it is shared between all instances).
|
||||
|
||||
Result can be fetched via get() method only once.
|
||||
|
||||
*/
|
||||
class CV_EXPORTS_W AsyncArray
|
||||
{
|
||||
public:
|
||||
~AsyncArray() CV_NOEXCEPT;
|
||||
CV_WRAP AsyncArray() CV_NOEXCEPT;
|
||||
AsyncArray(const AsyncArray& o) CV_NOEXCEPT;
|
||||
AsyncArray& operator=(const AsyncArray& o) CV_NOEXCEPT;
|
||||
CV_WRAP void release() CV_NOEXCEPT;
|
||||
|
||||
/** Fetch the result.
|
||||
@param[out] dst destination array
|
||||
|
||||
Waits for result until container has valid result.
|
||||
Throws exception if exception was stored as a result.
|
||||
|
||||
Throws exception on invalid container state.
|
||||
|
||||
@note Result or stored exception can be fetched only once.
|
||||
*/
|
||||
CV_WRAP void get(OutputArray dst) const;
|
||||
|
||||
/** Retrieving the result with timeout
|
||||
@param[out] dst destination array
|
||||
@param[in] timeoutNs timeout in nanoseconds, -1 for infinite wait
|
||||
|
||||
@returns true if result is ready, false if the timeout has expired
|
||||
|
||||
@note Result or stored exception can be fetched only once.
|
||||
*/
|
||||
bool get(OutputArray dst, int64 timeoutNs) const;
|
||||
|
||||
CV_WRAP inline
|
||||
bool get(OutputArray dst, double timeoutNs) const { return get(dst, (int64)timeoutNs); }
|
||||
|
||||
bool wait_for(int64 timeoutNs) const;
|
||||
|
||||
CV_WRAP inline
|
||||
bool wait_for(double timeoutNs) const { return wait_for((int64)timeoutNs); }
|
||||
|
||||
CV_WRAP bool valid() const CV_NOEXCEPT;
|
||||
|
||||
#ifdef CV_CXX11
|
||||
inline AsyncArray(AsyncArray&& o) { p = o.p; o.p = NULL; }
|
||||
inline AsyncArray& operator=(AsyncArray&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; }
|
||||
|
||||
template<typename _Rep, typename _Period>
|
||||
inline bool get(OutputArray dst, const std::chrono::duration<_Rep, _Period>& timeout)
|
||||
{
|
||||
return get(dst, (int64)(std::chrono::nanoseconds(timeout).count()));
|
||||
}
|
||||
|
||||
template<typename _Rep, typename _Period>
|
||||
inline bool wait_for(const std::chrono::duration<_Rep, _Period>& timeout)
|
||||
{
|
||||
return wait_for((int64)(std::chrono::nanoseconds(timeout).count()));
|
||||
}
|
||||
|
||||
#if 0
|
||||
std::future<Mat> getFutureMat() const;
|
||||
std::future<UMat> getFutureUMat() const;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// PImpl
|
||||
struct Impl; friend struct Impl;
|
||||
inline void* _getImpl() const CV_NOEXCEPT { return p; }
|
||||
protected:
|
||||
Impl* p;
|
||||
};
|
||||
|
||||
|
||||
//! @}
|
||||
} // namespace
|
||||
#endif // OPENCV_CORE_ASYNC_HPP
|
|
@ -0,0 +1,722 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2014, Itseez Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CORE_BASE_HPP
|
||||
#define OPENCV_CORE_BASE_HPP
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error base.hpp header must be compiled as C++
|
||||
#endif
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <algorithm>
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
namespace Error {
|
||||
//! error codes
|
||||
enum Code {
|
||||
StsOk= 0, //!< everything is ok
|
||||
StsBackTrace= -1, //!< pseudo error for back trace
|
||||
StsError= -2, //!< unknown /unspecified error
|
||||
StsInternal= -3, //!< internal error (bad state)
|
||||
StsNoMem= -4, //!< insufficient memory
|
||||
StsBadArg= -5, //!< function arg/param is bad
|
||||
StsBadFunc= -6, //!< unsupported function
|
||||
StsNoConv= -7, //!< iteration didn't converge
|
||||
StsAutoTrace= -8, //!< tracing
|
||||
HeaderIsNull= -9, //!< image header is NULL
|
||||
BadImageSize= -10, //!< image size is invalid
|
||||
BadOffset= -11, //!< offset is invalid
|
||||
BadDataPtr= -12, //!<
|
||||
BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix.
|
||||
BadModelOrChSeq= -14, //!<
|
||||
BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices.
|
||||
BadNumChannel1U= -16, //!<
|
||||
BadDepth= -17, //!< input image depth is not supported by the function
|
||||
BadAlphaChannel= -18, //!<
|
||||
BadOrder= -19, //!< number of dimensions is out of range
|
||||
BadOrigin= -20, //!< incorrect input origin
|
||||
BadAlign= -21, //!< incorrect input align
|
||||
BadCallBack= -22, //!<
|
||||
BadTileSize= -23, //!<
|
||||
BadCOI= -24, //!< input COI is not supported
|
||||
BadROISize= -25, //!< incorrect input roi
|
||||
MaskIsTiled= -26, //!<
|
||||
StsNullPtr= -27, //!< null pointer
|
||||
StsVecLengthErr= -28, //!< incorrect vector length
|
||||
StsFilterStructContentErr= -29, //!< incorrect filter structure content
|
||||
StsKernelStructContentErr= -30, //!< incorrect transform kernel content
|
||||
StsFilterOffsetErr= -31, //!< incorrect filter offset value
|
||||
StsBadSize= -201, //!< the input/output structure size is incorrect
|
||||
StsDivByZero= -202, //!< division by zero
|
||||
StsInplaceNotSupported= -203, //!< in-place operation is not supported
|
||||
StsObjectNotFound= -204, //!< request can't be completed
|
||||
StsUnmatchedFormats= -205, //!< formats of input/output arrays differ
|
||||
StsBadFlag= -206, //!< flag is wrong or not supported
|
||||
StsBadPoint= -207, //!< bad CvPoint
|
||||
StsBadMask= -208, //!< bad format of mask (neither 8uC1 nor 8sC1)
|
||||
StsUnmatchedSizes= -209, //!< sizes of input/output structures do not match
|
||||
StsUnsupportedFormat= -210, //!< the data format/type is not supported by the function
|
||||
StsOutOfRange= -211, //!< some of parameters are out of range
|
||||
StsParseError= -212, //!< invalid syntax/structure of the parsed file
|
||||
StsNotImplemented= -213, //!< the requested function/feature is not implemented
|
||||
StsBadMemBlock= -214, //!< an allocated block has been corrupted
|
||||
StsAssert= -215, //!< assertion failed
|
||||
GpuNotSupported= -216, //!< no CUDA support
|
||||
GpuApiCallError= -217, //!< GPU API call error
|
||||
OpenGlNotSupported= -218, //!< no OpenGL support
|
||||
OpenGlApiCallError= -219, //!< OpenGL API call error
|
||||
OpenCLApiCallError= -220, //!< OpenCL API call error
|
||||
OpenCLDoubleNotSupported= -221,
|
||||
OpenCLInitError= -222, //!< OpenCL initialization error
|
||||
OpenCLNoAMDBlasFft= -223
|
||||
};
|
||||
} //Error
|
||||
|
||||
//! @} core_utils
|
||||
|
||||
//! @addtogroup core_array
|
||||
//! @{
|
||||
|
||||
//! matrix decomposition types
|
||||
enum DecompTypes {
|
||||
/** Gaussian elimination with the optimal pivot element chosen. */
|
||||
DECOMP_LU = 0,
|
||||
/** singular value decomposition (SVD) method; the system can be over-defined and/or the matrix
|
||||
src1 can be singular */
|
||||
DECOMP_SVD = 1,
|
||||
/** eigenvalue decomposition; the matrix src1 must be symmetrical */
|
||||
DECOMP_EIG = 2,
|
||||
/** Cholesky \f$LL^T\f$ factorization; the matrix src1 must be symmetrical and positively
|
||||
defined */
|
||||
DECOMP_CHOLESKY = 3,
|
||||
/** QR factorization; the system can be over-defined and/or the matrix src1 can be singular */
|
||||
DECOMP_QR = 4,
|
||||
/** while all the previous flags are mutually exclusive, this flag can be used together with
|
||||
any of the previous; it means that the normal equations
|
||||
\f$\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}\f$ are
|
||||
solved instead of the original system
|
||||
\f$\texttt{src1}\cdot\texttt{dst}=\texttt{src2}\f$ */
|
||||
DECOMP_NORMAL = 16
|
||||
};
|
||||
|
||||
/** norm types
|
||||
|
||||
src1 and src2 denote input arrays.
|
||||
*/
|
||||
|
||||
enum NormTypes {
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
|
||||
{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_INF = 1,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{\| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\)}
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) }
|
||||
\f]*/
|
||||
NORM_L1 = 2,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
|
||||
{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_L2 = 4,
|
||||
/**
|
||||
\f[
|
||||
norm = \forkthree
|
||||
{ \| \texttt{src1} \| _{L_2} ^{2} = \sum_I \texttt{src1}(I)^2} {if \(\texttt{normType} = \texttt{NORM_L2SQR}\)}
|
||||
{ \| \texttt{src1} - \texttt{src2} \| _{L_2} ^{2} = \sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2 }{if \(\texttt{normType} = \texttt{NORM_L2SQR}\) }
|
||||
{ \left(\frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}}\right)^2 }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2SQR}\) }
|
||||
\f]
|
||||
*/
|
||||
NORM_L2SQR = 5,
|
||||
/**
|
||||
In the case of one input array, calculates the Hamming distance of the array from zero,
|
||||
In the case of two input arrays, calculates the Hamming distance between the arrays.
|
||||
*/
|
||||
NORM_HAMMING = 6,
|
||||
/**
|
||||
Similar to NORM_HAMMING, but in the calculation, each two bits of the input sequence will
|
||||
be added and treated as a single bit to be used in the same calculation as NORM_HAMMING.
|
||||
*/
|
||||
NORM_HAMMING2 = 7,
|
||||
NORM_TYPE_MASK = 7, //!< bit-mask which can be used to separate norm type from norm flags
|
||||
NORM_RELATIVE = 8, //!< flag
|
||||
NORM_MINMAX = 32 //!< flag
|
||||
};
|
||||
|
||||
//! comparison types
|
||||
enum CmpTypes { CMP_EQ = 0, //!< src1 is equal to src2.
|
||||
CMP_GT = 1, //!< src1 is greater than src2.
|
||||
CMP_GE = 2, //!< src1 is greater than or equal to src2.
|
||||
CMP_LT = 3, //!< src1 is less than src2.
|
||||
CMP_LE = 4, //!< src1 is less than or equal to src2.
|
||||
CMP_NE = 5 //!< src1 is unequal to src2.
|
||||
};
|
||||
|
||||
//! generalized matrix multiplication flags
|
||||
enum GemmFlags { GEMM_1_T = 1, //!< transposes src1
|
||||
GEMM_2_T = 2, //!< transposes src2
|
||||
GEMM_3_T = 4 //!< transposes src3
|
||||
};
|
||||
|
||||
enum DftFlags {
|
||||
/** performs an inverse 1D or 2D transform instead of the default forward
|
||||
transform. */
|
||||
DFT_INVERSE = 1,
|
||||
/** scales the result: divide it by the number of array elements. Normally, it is
|
||||
combined with DFT_INVERSE. */
|
||||
DFT_SCALE = 2,
|
||||
/** performs a forward or inverse transform of every individual row of the input
|
||||
matrix; this flag enables you to transform multiple vectors simultaneously and can be used to
|
||||
decrease the overhead (which is sometimes several times larger than the processing itself) to
|
||||
perform 3D and higher-dimensional transformations and so forth.*/
|
||||
DFT_ROWS = 4,
|
||||
/** performs a forward transformation of 1D or 2D real array; the result,
|
||||
though being a complex array, has complex-conjugate symmetry (*CCS*, see the function
|
||||
description below for details), and such an array can be packed into a real array of the same
|
||||
size as input, which is the fastest option and which is what the function does by default;
|
||||
however, you may wish to get a full complex array (for simpler spectrum analysis, and so on) -
|
||||
pass the flag to enable the function to produce a full-size complex output array. */
|
||||
DFT_COMPLEX_OUTPUT = 16,
|
||||
/** performs an inverse transformation of a 1D or 2D complex array; the
|
||||
result is normally a complex array of the same size, however, if the input array has
|
||||
conjugate-complex symmetry (for example, it is a result of forward transformation with
|
||||
DFT_COMPLEX_OUTPUT flag), the output is a real array; while the function itself does not
|
||||
check whether the input is symmetrical or not, you can pass the flag and then the function
|
||||
will assume the symmetry and produce the real output array (note that when the input is packed
|
||||
into a real array and inverse transformation is executed, the function treats the input as a
|
||||
packed complex-conjugate symmetrical array, and the output will also be a real array). */
|
||||
DFT_REAL_OUTPUT = 32,
|
||||
/** specifies that input is complex input. If this flag is set, the input must have 2 channels.
|
||||
On the other hand, for backwards compatibility reason, if input has 2 channels, input is
|
||||
already considered complex. */
|
||||
DFT_COMPLEX_INPUT = 64,
|
||||
/** performs an inverse 1D or 2D transform instead of the default forward transform. */
|
||||
DCT_INVERSE = DFT_INVERSE,
|
||||
/** performs a forward or inverse transform of every individual row of the input
|
||||
matrix. This flag enables you to transform multiple vectors simultaneously and can be used to
|
||||
decrease the overhead (which is sometimes several times larger than the processing itself) to
|
||||
perform 3D and higher-dimensional transforms and so forth.*/
|
||||
DCT_ROWS = DFT_ROWS
|
||||
};
|
||||
|
||||
//! Various border types, image boundaries are denoted with `|`
|
||||
//! @see borderInterpolate, copyMakeBorder
|
||||
enum BorderTypes {
|
||||
BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
|
||||
BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
|
||||
BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
|
||||
BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
|
||||
BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
|
||||
BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
|
||||
|
||||
BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
|
||||
BORDER_ISOLATED = 16 //!< do not look outside of ROI
|
||||
};
|
||||
|
||||
//! @} core_array
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
/*! @brief Signals an error and raises the exception.
|
||||
|
||||
By default the function prints information about the error to stderr,
|
||||
then it either stops if setBreakOnError() had been called before or raises the exception.
|
||||
It is possible to alternate error processing by using redirectError().
|
||||
@param _code - error code (Error::Code)
|
||||
@param _err - error description
|
||||
@param _func - function name. Available only when the compiler supports getting it
|
||||
@param _file - source file name where the error has occurred
|
||||
@param _line - line number in the source file where the error has occurred
|
||||
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
|
||||
*/
|
||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||
|
||||
#ifdef __GNUC__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/** same as cv::error, but does not return */
|
||||
CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
|
||||
{
|
||||
error(_code, _err, _func, _file, _line);
|
||||
#ifdef __GNUC__
|
||||
# if !defined __clang__ && !defined __APPLE__
|
||||
// this suppresses this warning: "noreturn" function does return [enabled by default]
|
||||
__builtin_trap();
|
||||
// or use infinite loop: for (;;) {}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CV_STATIC_ANALYSIS
|
||||
|
||||
// In practice, some macro are not processed correctly (noreturn is not detected).
|
||||
// We need to use simplified definition for them.
|
||||
#define CV_Error(code, msg) do { (void)(code); (void)(msg); abort(); } while (0)
|
||||
#define CV_Error_(code, args) do { (void)(code); (void)(cv::format args); abort(); } while (0)
|
||||
#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)
|
||||
#define CV_ErrorNoReturn CV_Error
|
||||
#define CV_ErrorNoReturn_ CV_Error_
|
||||
|
||||
#else // CV_STATIC_ANALYSIS
|
||||
|
||||
/** @brief Call the error handler.
|
||||
|
||||
Currently, the error handler prints the error code and the error message to the standard
|
||||
error stream `stderr`. In the Debug configuration, it then provokes memory access violation, so that
|
||||
the execution stack and all the parameters can be analyzed by the debugger. In the Release
|
||||
configuration, the exception is thrown.
|
||||
|
||||
@param code one of Error::Code
|
||||
@param msg error message
|
||||
*/
|
||||
#define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** @brief Call the error handler.
|
||||
|
||||
This macro can be used to construct an error message on-fly to include some dynamic information,
|
||||
for example:
|
||||
@code
|
||||
// note the extra parentheses around the formatted text message
|
||||
CV_Error_(Error::StsOutOfRange,
|
||||
("the value at (%d, %d)=%g is out of range", badPt.x, badPt.y, badValue));
|
||||
@endcode
|
||||
@param code one of Error::Code
|
||||
@param args printf-like formatted error message in parentheses
|
||||
*/
|
||||
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** @brief Checks a condition at runtime and throws exception if it fails
|
||||
|
||||
The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
|
||||
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
|
||||
configurations while CV_DbgAssert is only retained in the Debug configuration.
|
||||
*/
|
||||
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
#ifdef __OPENCV_BUILD
|
||||
#undef CV_Error
|
||||
#define CV_Error CV__ErrorNoReturn
|
||||
#undef CV_Error_
|
||||
#define CV_Error_ CV__ErrorNoReturn_
|
||||
#undef CV_Assert
|
||||
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||
#else
|
||||
// backward compatibility
|
||||
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
||||
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
|
||||
#endif
|
||||
//! @endcond
|
||||
|
||||
#endif // CV_STATIC_ANALYSIS
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
#if defined OPENCV_FORCE_MULTIARG_ASSERT_CHECK && defined CV_STATIC_ANALYSIS
|
||||
#warning "OPENCV_FORCE_MULTIARG_ASSERT_CHECK can't be used with CV_STATIC_ANALYSIS"
|
||||
#undef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||
#endif
|
||||
|
||||
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||
#define CV_Assert_1( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
|
||||
#else
|
||||
#define CV_Assert_1 CV_Assert
|
||||
#endif
|
||||
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
|
||||
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
|
||||
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
|
||||
#define CV_Assert_5( expr1, expr2, expr3, expr4, expr5 ) CV_Assert_4(expr1, expr2, expr3, expr4); CV_Assert_1(expr5)
|
||||
#define CV_Assert_6( expr1, expr2, expr3, expr4, expr5, expr6 ) CV_Assert_5(expr1, expr2, expr3, expr4, expr5); CV_Assert_1(expr6)
|
||||
#define CV_Assert_7( expr1, expr2, expr3, expr4, expr5, expr6, expr7 ) CV_Assert_6(expr1, expr2, expr3, expr4, expr5, expr6 ); CV_Assert_1(expr7)
|
||||
#define CV_Assert_8( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ) CV_Assert_7(expr1, expr2, expr3, expr4, expr5, expr6, expr7 ); CV_Assert_1(expr8)
|
||||
#define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9)
|
||||
#define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10)
|
||||
|
||||
#define CV_Assert_N(...) do { __CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
|
||||
|
||||
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
|
||||
#undef CV_Assert
|
||||
#define CV_Assert CV_Assert_N
|
||||
#endif
|
||||
//! @endcond
|
||||
|
||||
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
|
||||
# define CV_DbgAssert(expr) CV_Assert(expr)
|
||||
#else
|
||||
/** replaced with CV_Assert(expr) in Debug configuration */
|
||||
# define CV_DbgAssert(expr)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor
|
||||
* bit count of A exclusive XOR'ed with B
|
||||
*/
|
||||
struct CV_EXPORTS Hamming
|
||||
{
|
||||
enum { normType = NORM_HAMMING };
|
||||
typedef unsigned char ValueType;
|
||||
typedef int ResultType;
|
||||
|
||||
/** this will count the bits in a ^ b
|
||||
*/
|
||||
ResultType operator()( const unsigned char* a, const unsigned char* b, int size ) const;
|
||||
};
|
||||
|
||||
typedef Hamming HammingLUT;
|
||||
|
||||
/////////////////////////////////// inline norms ////////////////////////////////////
|
||||
|
||||
template<typename _Tp> inline _Tp cv_abs(_Tp x) { return std::abs(x); }
|
||||
inline int cv_abs(uchar x) { return x; }
|
||||
inline int cv_abs(schar x) { return std::abs(x); }
|
||||
inline int cv_abs(ushort x) { return x; }
|
||||
inline int cv_abs(short x) { return std::abs(x); }
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normL2Sqr(const _Tp* a, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
int i=0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; i <= n - 4; i += 4 )
|
||||
{
|
||||
_AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3];
|
||||
s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
|
||||
}
|
||||
#endif
|
||||
for( ; i < n; i++ )
|
||||
{
|
||||
_AccTp v = a[i];
|
||||
s += v*v;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normL1(const _Tp* a, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
int i = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= n - 4; i += 4 )
|
||||
{
|
||||
s += (_AccTp)cv_abs(a[i]) + (_AccTp)cv_abs(a[i+1]) +
|
||||
(_AccTp)cv_abs(a[i+2]) + (_AccTp)cv_abs(a[i+3]);
|
||||
}
|
||||
#endif
|
||||
for( ; i < n; i++ )
|
||||
s += cv_abs(a[i]);
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normInf(const _Tp* a, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
for( int i = 0; i < n; i++ )
|
||||
s = std::max(s, (_AccTp)cv_abs(a[i]));
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
int i= 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= n - 4; i += 4 )
|
||||
{
|
||||
_AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
|
||||
s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
|
||||
}
|
||||
#endif
|
||||
for( ; i < n; i++ )
|
||||
{
|
||||
_AccTp v = _AccTp(a[i] - b[i]);
|
||||
s += v*v;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline float normL2Sqr(const float* a, const float* b, int n)
|
||||
{
|
||||
float s = 0.f;
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
float v = a[i] - b[i];
|
||||
s += v*v;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normL1(const _Tp* a, const _Tp* b, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
int i= 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= n - 4; i += 4 )
|
||||
{
|
||||
_AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]);
|
||||
s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3);
|
||||
}
|
||||
#endif
|
||||
for( ; i < n; i++ )
|
||||
{
|
||||
_AccTp v = _AccTp(a[i] - b[i]);
|
||||
s += std::abs(v);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
inline float normL1(const float* a, const float* b, int n)
|
||||
{
|
||||
float s = 0.f;
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
s += std::abs(a[i] - b[i]);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
inline int normL1(const uchar* a, const uchar* b, int n)
|
||||
{
|
||||
int s = 0;
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
s += std::abs(a[i] - b[i]);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _AccTp> static inline
|
||||
_AccTp normInf(const _Tp* a, const _Tp* b, int n)
|
||||
{
|
||||
_AccTp s = 0;
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
_AccTp v0 = a[i] - b[i];
|
||||
s = std::max(s, std::abs(v0));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/** @brief Computes the cube root of an argument.
|
||||
|
||||
The function cubeRoot computes \f$\sqrt[3]{\texttt{val}}\f$. Negative arguments are handled correctly.
|
||||
NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for
|
||||
single-precision data.
|
||||
@param val A function argument.
|
||||
*/
|
||||
CV_EXPORTS_W float cubeRoot(float val);
|
||||
|
||||
/** @overload
|
||||
|
||||
cubeRoot with argument of `double` type calls `std::cbrt(double)` (C++11) or falls back on `pow()` for C++98 compilation mode.
|
||||
*/
|
||||
static inline
|
||||
double cubeRoot(double val)
|
||||
{
|
||||
#ifdef CV_CXX11
|
||||
return std::cbrt(val);
|
||||
#else
|
||||
double v = pow(abs(val), 1/3.); // pow doesn't support negative inputs with fractional exponents
|
||||
return val >= 0 ? v : -v;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Calculates the angle of a 2D vector in degrees.
|
||||
|
||||
The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured
|
||||
in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees.
|
||||
@param x x-coordinate of the vector.
|
||||
@param y y-coordinate of the vector.
|
||||
*/
|
||||
CV_EXPORTS_W float fastAtan2(float y, float x);
|
||||
|
||||
/** proxy for hal::LU */
|
||||
CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n);
|
||||
/** proxy for hal::LU */
|
||||
CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n);
|
||||
/** proxy for hal::Cholesky */
|
||||
CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n);
|
||||
/** proxy for hal::Cholesky */
|
||||
CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n);
|
||||
|
||||
////////////////// forward declarations for important OpenCV types //////////////////
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
template<typename _Tp, int cn> class Vec;
|
||||
template<typename _Tp, int m, int n> class Matx;
|
||||
|
||||
template<typename _Tp> class Complex;
|
||||
template<typename _Tp> class Point_;
|
||||
template<typename _Tp> class Point3_;
|
||||
template<typename _Tp> class Size_;
|
||||
template<typename _Tp> class Rect_;
|
||||
template<typename _Tp> class Scalar_;
|
||||
|
||||
class CV_EXPORTS RotatedRect;
|
||||
class CV_EXPORTS Range;
|
||||
class CV_EXPORTS TermCriteria;
|
||||
class CV_EXPORTS KeyPoint;
|
||||
class CV_EXPORTS DMatch;
|
||||
class CV_EXPORTS RNG;
|
||||
|
||||
class CV_EXPORTS Mat;
|
||||
class CV_EXPORTS MatExpr;
|
||||
|
||||
class CV_EXPORTS UMat;
|
||||
|
||||
class CV_EXPORTS SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
template<typename _Tp> class Mat_;
|
||||
template<typename _Tp> class SparseMat_;
|
||||
|
||||
class CV_EXPORTS MatConstIterator;
|
||||
class CV_EXPORTS SparseMatIterator;
|
||||
class CV_EXPORTS SparseMatConstIterator;
|
||||
template<typename _Tp> class MatIterator_;
|
||||
template<typename _Tp> class MatConstIterator_;
|
||||
template<typename _Tp> class SparseMatIterator_;
|
||||
template<typename _Tp> class SparseMatConstIterator_;
|
||||
|
||||
namespace ogl
|
||||
{
|
||||
class CV_EXPORTS Buffer;
|
||||
class CV_EXPORTS Texture2D;
|
||||
class CV_EXPORTS Arrays;
|
||||
}
|
||||
|
||||
namespace cuda
|
||||
{
|
||||
class CV_EXPORTS GpuMat;
|
||||
class CV_EXPORTS HostMem;
|
||||
class CV_EXPORTS Stream;
|
||||
class CV_EXPORTS Event;
|
||||
}
|
||||
|
||||
namespace cudev
|
||||
{
|
||||
template <typename _Tp> class GpuMat_;
|
||||
}
|
||||
|
||||
namespace ipp
|
||||
{
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
CV_EXPORTS unsigned long long getIppFeatures();
|
||||
#else
|
||||
CV_EXPORTS int getIppFeatures();
|
||||
#endif
|
||||
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
|
||||
int line = 0);
|
||||
CV_EXPORTS int getIppStatus();
|
||||
CV_EXPORTS String getIppErrorLocation();
|
||||
CV_EXPORTS_W bool useIPP();
|
||||
CV_EXPORTS_W void setUseIPP(bool flag);
|
||||
CV_EXPORTS_W String getIppVersion();
|
||||
|
||||
// IPP Not-Exact mode. This function may force use of IPP then both IPP and OpenCV provide proper results
|
||||
// but have internal accuracy differences which have too much direct or indirect impact on accuracy tests.
|
||||
CV_EXPORTS_W bool useIPP_NotExact();
|
||||
CV_EXPORTS_W void setUseIPP_NotExact(bool flag);
|
||||
#if OPENCV_ABI_COMPATIBILITY < 400
|
||||
CV_EXPORTS_W bool useIPP_NE();
|
||||
CV_EXPORTS_W void setUseIPP_NE(bool flag);
|
||||
#endif
|
||||
|
||||
} // ipp
|
||||
|
||||
//! @endcond
|
||||
|
||||
//! @} core_utils
|
||||
|
||||
|
||||
|
||||
|
||||
} // cv
|
||||
|
||||
#include "opencv2/core/neon_utils.hpp"
|
||||
#include "opencv2/core/vsx_utils.hpp"
|
||||
#include "opencv2/core/check.hpp"
|
||||
|
||||
#endif //OPENCV_CORE_BASE_HPP
|
|
@ -0,0 +1,223 @@
|
|||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_CORE_BINDINGS_UTILS_HPP
|
||||
#define OPENCV_CORE_BINDINGS_UTILS_HPP
|
||||
|
||||
#include <opencv2/core/async.hpp>
|
||||
#include <opencv2/core/detail/async_promise.hpp>
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace cv { namespace utils {
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
CV_EXPORTS_W String dumpInputArray(InputArray argument);
|
||||
|
||||
CV_EXPORTS_W String dumpInputArrayOfArrays(InputArrayOfArrays argument);
|
||||
|
||||
CV_EXPORTS_W String dumpInputOutputArray(InputOutputArray argument);
|
||||
|
||||
CV_EXPORTS_W String dumpInputOutputArrayOfArrays(InputOutputArrayOfArrays argument);
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpBool(bool argument)
|
||||
{
|
||||
return (argument) ? String("Bool: True") : String("Bool: False");
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpInt(int argument)
|
||||
{
|
||||
return cv::format("Int: %d", argument);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpSizeT(size_t argument)
|
||||
{
|
||||
std::ostringstream oss("size_t: ", std::ios::ate);
|
||||
oss << argument;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpFloat(float argument)
|
||||
{
|
||||
return cv::format("Float: %.2f", argument);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpDouble(double argument)
|
||||
{
|
||||
return cv::format("Double: %.2f", argument);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpCString(const char* argument)
|
||||
{
|
||||
return cv::format("String: %s", argument);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpString(const String& argument)
|
||||
{
|
||||
return cv::format("String: %s", argument.c_str());
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(int value, const Point& point = Point(42, 24))
|
||||
{
|
||||
return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x,
|
||||
point.y);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(const Rect& rect)
|
||||
{
|
||||
return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRect(const Rect& argument)
|
||||
{
|
||||
return format("rect: (x=%d, y=%d, w=%d, h=%d)", argument.x, argument.y,
|
||||
argument.width, argument.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpTermCriteria(const TermCriteria& argument)
|
||||
{
|
||||
return format("term_criteria: (type=%d, max_count=%d, epsilon=%lf",
|
||||
argument.type, argument.maxCount, argument.epsilon);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRotatedRect(const RotatedRect& argument)
|
||||
{
|
||||
return format("rotated_rect: (c_x=%f, c_y=%f, w=%f, h=%f, a=%f)",
|
||||
argument.center.x, argument.center.y, argument.size.width,
|
||||
argument.size.height, argument.angle);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRange(const Range& argument)
|
||||
{
|
||||
if (argument == Range::all())
|
||||
{
|
||||
return "range: all";
|
||||
}
|
||||
else
|
||||
{
|
||||
return format("range: (s=%d, e=%d)", argument.start, argument.end);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testReservedKeywordConversion(int positional_argument, int lambda = 2, int from = 3)
|
||||
{
|
||||
return format("arg=%d, lambda=%d, from=%d", positional_argument, lambda, from);
|
||||
}
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfInt(const std::vector<int>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfDouble(const std::vector<double>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfRect(const std::vector<Rect>& vec);
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfRect(size_t len, CV_OUT std::vector<Rect>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(12345);
|
||||
Mat tmp(static_cast<int>(len), 1, CV_32SC4);
|
||||
rng.fill(tmp, RNG::UNIFORM, 10, 20);
|
||||
tmp.copyTo(vec);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfInt(size_t len, CV_OUT std::vector<int>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(554433);
|
||||
Mat tmp(static_cast<int>(len), 1, CV_32SC1);
|
||||
rng.fill(tmp, RNG::UNIFORM, -10, 10);
|
||||
tmp.copyTo(vec);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfMat(size_t len, int rows, int cols, int dtype, CV_OUT std::vector<Mat>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(65431);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
vec[i].create(rows, cols, dtype);
|
||||
rng.fill(vec[i], RNG::UNIFORM, 0, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void testRaiseGeneralException()
|
||||
{
|
||||
throw std::runtime_error("exception text");
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
AsyncArray testAsyncArray(InputArray argument)
|
||||
{
|
||||
AsyncPromise p;
|
||||
p.setValue(argument);
|
||||
return p.getArrayResult();
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
AsyncArray testAsyncException()
|
||||
{
|
||||
AsyncPromise p;
|
||||
try
|
||||
{
|
||||
CV_Error(Error::StsOk, "Test: Generated async error");
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
p.setException(e);
|
||||
}
|
||||
return p.getArrayResult();
|
||||
}
|
||||
|
||||
//! @} // core_utils
|
||||
} // namespace cv::utils
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_WRAP static inline
|
||||
int setLogLevel(int level)
|
||||
{
|
||||
// NB: Binding generators doesn't work with enums properly yet, so we define separate overload here
|
||||
return cv::utils::logging::setLogLevel((cv::utils::logging::LogLevel)level);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
int getLogLevel()
|
||||
{
|
||||
return cv::utils::logging::getLogLevel();
|
||||
}
|
||||
|
||||
//! @endcond IGNORED
|
||||
|
||||
} // namespaces cv / utils
|
||||
|
||||
#endif // OPENCV_CORE_BINDINGS_UTILS_HPP
|
|
@ -0,0 +1,40 @@
|
|||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
#ifndef OPENCV_CORE_BUFFER_POOL_HPP
|
||||
#define OPENCV_CORE_BUFFER_POOL_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4265)
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup core
|
||||
//! @{
|
||||
|
||||
class BufferPoolController
|
||||
{
|
||||
protected:
|
||||
~BufferPoolController() { }
|
||||
public:
|
||||
virtual size_t getReservedSize() const = 0;
|
||||
virtual size_t getMaxReservedSize() const = 0;
|
||||
virtual void setMaxReservedSize(size_t size) = 0;
|
||||
virtual void freeAllReservedBuffers() = 0;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_CORE_BUFFER_POOL_HPP
|
|
@ -0,0 +1,160 @@
|
|||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_CORE_CHECK_HPP
|
||||
#define OPENCV_CORE_CHECK_HPP
|
||||
|
||||
#include <opencv2/core/base.hpp>
|
||||
|
||||
namespace cv {
|
||||
|
||||
/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "<invalid depth>" */
|
||||
CV_EXPORTS const char* depthToString(int depth);
|
||||
|
||||
/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "<invalid type>" */
|
||||
CV_EXPORTS const String typeToString(int type);
|
||||
|
||||
|
||||
//! @cond IGNORED
|
||||
namespace detail {
|
||||
|
||||
/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */
|
||||
CV_EXPORTS const char* depthToString_(int depth);
|
||||
|
||||
/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */
|
||||
CV_EXPORTS const cv::String typeToString_(int type);
|
||||
|
||||
enum TestOp {
|
||||
TEST_CUSTOM = 0,
|
||||
TEST_EQ = 1,
|
||||
TEST_NE = 2,
|
||||
TEST_LE = 3,
|
||||
TEST_LT = 4,
|
||||
TEST_GE = 5,
|
||||
TEST_GT = 6,
|
||||
CV__LAST_TEST_OP
|
||||
};
|
||||
|
||||
struct CheckContext {
|
||||
const char* func;
|
||||
const char* file;
|
||||
int line;
|
||||
enum TestOp testOp;
|
||||
const char* message;
|
||||
const char* p1_str;
|
||||
const char* p2_str;
|
||||
};
|
||||
|
||||
#ifndef CV__CHECK_FILENAME
|
||||
# define CV__CHECK_FILENAME __FILE__
|
||||
#endif
|
||||
|
||||
#ifndef CV__CHECK_FUNCTION
|
||||
# if defined _MSC_VER
|
||||
# define CV__CHECK_FUNCTION __FUNCSIG__
|
||||
# elif defined __GNUC__
|
||||
# define CV__CHECK_FUNCTION __PRETTY_FUNCTION__
|
||||
# else
|
||||
# define CV__CHECK_FUNCTION "<unknown>"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CV__CHECK_LOCATION_VARNAME(id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_check_, id), __LINE__)
|
||||
#define CV__DEFINE_CHECK_CONTEXT(id, message, testOp, p1_str, p2_str) \
|
||||
static const cv::detail::CheckContext CV__CHECK_LOCATION_VARNAME(id) = \
|
||||
{ CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, "" message, "" p1_str, "" p2_str }
|
||||
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_<int> v1, const Size_<int> v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx);
|
||||
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_<int> v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_auto(const std::string& v1, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx);
|
||||
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx);
|
||||
|
||||
|
||||
#define CV__TEST_EQ(v1, v2) ((v1) == (v2))
|
||||
#define CV__TEST_NE(v1, v2) ((v1) != (v2))
|
||||
#define CV__TEST_LE(v1, v2) ((v1) <= (v2))
|
||||
#define CV__TEST_LT(v1, v2) ((v1) < (v2))
|
||||
#define CV__TEST_GE(v1, v2) ((v1) >= (v2))
|
||||
#define CV__TEST_GT(v1, v2) ((v1) > (v2))
|
||||
|
||||
#define CV__CHECK(id, op, type, v1, v2, v1_str, v2_str, msg_str) do { \
|
||||
if(CV__TEST_##op((v1), (v2))) ; else { \
|
||||
CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_ ## op, v1_str, v2_str); \
|
||||
cv::detail::check_failed_ ## type((v1), (v2), CV__CHECK_LOCATION_VARNAME(id)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CV__CHECK_CUSTOM_TEST(id, type, v, test_expr, v_str, test_expr_str, msg_str) do { \
|
||||
if(!!(test_expr)) ; else { \
|
||||
CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_CUSTOM, v_str, test_expr_str); \
|
||||
cv::detail::check_failed_ ## type((v), CV__CHECK_LOCATION_VARNAME(id)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
} // namespace
|
||||
//! @endcond
|
||||
|
||||
|
||||
/// Supported values of these types: int, float, double
|
||||
#define CV_CheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_CheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_CheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_CheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_CheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_CheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg)
|
||||
|
||||
/// Check with additional "decoding" of type values in error message
|
||||
#define CV_CheckTypeEQ(t1, t2, msg) CV__CHECK(_, EQ, MatType, t1, t2, #t1, #t2, msg)
|
||||
/// Check with additional "decoding" of depth values in error message
|
||||
#define CV_CheckDepthEQ(d1, d2, msg) CV__CHECK(_, EQ, MatDepth, d1, d2, #d1, #d2, msg)
|
||||
|
||||
#define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg)
|
||||
|
||||
/// Example: type == CV_8UC1 || type == CV_8UC3
|
||||
#define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg)
|
||||
|
||||
/// Example: depth == CV_32F || depth == CV_64F
|
||||
#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg)
|
||||
|
||||
/// Example: v == A || v == B
|
||||
#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
|
||||
|
||||
/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1")
|
||||
// TODO define pretty-printers
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define CV_DbgCheck(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
|
||||
#define CV_DbgCheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_DbgCheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_DbgCheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_DbgCheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_DbgCheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg)
|
||||
#define CV_DbgCheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg)
|
||||
#else
|
||||
#define CV_DbgCheck(v, test_expr, msg) do { } while (0)
|
||||
#define CV_DbgCheckEQ(v1, v2, msg) do { } while (0)
|
||||
#define CV_DbgCheckNE(v1, v2, msg) do { } while (0)
|
||||
#define CV_DbgCheckLE(v1, v2, msg) do { } while (0)
|
||||
#define CV_DbgCheckLT(v1, v2, msg) do { } while (0)
|
||||
#define CV_DbgCheckGE(v1, v2, msg) do { } while (0)
|
||||
#define CV_DbgCheckGT(v1, v2, msg) do { } while (0)
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // OPENCV_CORE_CHECK_HPP
|
|
@ -0,0 +1,48 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,631 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CORE_CUDAINL_HPP
|
||||
#define OPENCV_CORE_CUDAINL_HPP
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda {
|
||||
|
||||
//===================================================================================
|
||||
// GpuMat
|
||||
//===================================================================================
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(Allocator* allocator_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(int rows_, int cols_, int type_, Allocator* allocator_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{
|
||||
if (rows_ > 0 && cols_ > 0)
|
||||
create(rows_, cols_, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(Size size_, int type_, Allocator* allocator_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{
|
||||
if (size_.height > 0 && size_.width > 0)
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{
|
||||
if (rows_ > 0 && cols_ > 0)
|
||||
{
|
||||
create(rows_, cols_, type_);
|
||||
setTo(s_);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(Size size_, int type_, Scalar s_, Allocator* allocator_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{
|
||||
if (size_.height > 0 && size_.width > 0)
|
||||
{
|
||||
create(size_.height, size_.width, type_);
|
||||
setTo(s_);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(const GpuMat& m)
|
||||
: flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), allocator(m.allocator)
|
||||
{
|
||||
if (refcount)
|
||||
CV_XADD(refcount, 1);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::GpuMat(InputArray arr, Allocator* allocator_) :
|
||||
flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
|
||||
{
|
||||
upload(arr);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat::~GpuMat()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat& GpuMat::operator =(const GpuMat& m)
|
||||
{
|
||||
if (this != &m)
|
||||
{
|
||||
GpuMat temp(m);
|
||||
swap(temp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::create(Size size_, int type_)
|
||||
{
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::swap(GpuMat& b)
|
||||
{
|
||||
std::swap(flags, b.flags);
|
||||
std::swap(rows, b.rows);
|
||||
std::swap(cols, b.cols);
|
||||
std::swap(step, b.step);
|
||||
std::swap(data, b.data);
|
||||
std::swap(datastart, b.datastart);
|
||||
std::swap(dataend, b.dataend);
|
||||
std::swap(refcount, b.refcount);
|
||||
std::swap(allocator, b.allocator);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::clone() const
|
||||
{
|
||||
GpuMat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::copyTo(OutputArray dst, InputArray mask) const
|
||||
{
|
||||
copyTo(dst, mask, Stream::Null());
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat& GpuMat::setTo(Scalar s)
|
||||
{
|
||||
return setTo(s, Stream::Null());
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat& GpuMat::setTo(Scalar s, InputArray mask)
|
||||
{
|
||||
return setTo(s, mask, Stream::Null());
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::convertTo(OutputArray dst, int rtype) const
|
||||
{
|
||||
convertTo(dst, rtype, Stream::Null());
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const
|
||||
{
|
||||
convertTo(dst, rtype, alpha, beta, Stream::Null());
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const
|
||||
{
|
||||
convertTo(dst, rtype, alpha, 0.0, stream);
|
||||
}
|
||||
|
||||
inline
|
||||
void GpuMat::assignTo(GpuMat& m, int _type) const
|
||||
{
|
||||
if (_type < 0)
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
uchar* GpuMat::ptr(int y)
|
||||
{
|
||||
CV_DbgAssert( (unsigned)y < (unsigned)rows );
|
||||
return data + step * y;
|
||||
}
|
||||
|
||||
inline
|
||||
const uchar* GpuMat::ptr(int y) const
|
||||
{
|
||||
CV_DbgAssert( (unsigned)y < (unsigned)rows );
|
||||
return data + step * y;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp* GpuMat::ptr(int y)
|
||||
{
|
||||
return (_Tp*)ptr(y);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
const _Tp* GpuMat::ptr(int y) const
|
||||
{
|
||||
return (const _Tp*)ptr(y);
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
GpuMat::operator PtrStepSz<T>() const
|
||||
{
|
||||
return PtrStepSz<T>(rows, cols, (T*)data, step);
|
||||
}
|
||||
|
||||
template <class T> inline
|
||||
GpuMat::operator PtrStep<T>() const
|
||||
{
|
||||
return PtrStep<T>((T*)data, step);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::row(int y) const
|
||||
{
|
||||
return GpuMat(*this, Range(y, y+1), Range::all());
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::col(int x) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), Range(x, x+1));
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::rowRange(int startrow, int endrow) const
|
||||
{
|
||||
return GpuMat(*this, Range(startrow, endrow), Range::all());
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::rowRange(Range r) const
|
||||
{
|
||||
return GpuMat(*this, r, Range::all());
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::colRange(int startcol, int endcol) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), Range(startcol, endcol));
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::colRange(Range r) const
|
||||
{
|
||||
return GpuMat(*this, Range::all(), r);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::operator ()(Range rowRange_, Range colRange_) const
|
||||
{
|
||||
return GpuMat(*this, rowRange_, colRange_);
|
||||
}
|
||||
|
||||
inline
|
||||
GpuMat GpuMat::operator ()(Rect roi) const
|
||||
{
|
||||
return GpuMat(*this, roi);
|
||||
}
|
||||
|
||||
inline
|
||||
bool GpuMat::isContinuous() const
|
||||
{
|
||||
return (flags & Mat::CONTINUOUS_FLAG) != 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t GpuMat::elemSize() const
|
||||
{
|
||||
return CV_ELEM_SIZE(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t GpuMat::elemSize1() const
|
||||
{
|
||||
return CV_ELEM_SIZE1(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int GpuMat::type() const
|
||||
{
|
||||
return CV_MAT_TYPE(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int GpuMat::depth() const
|
||||
{
|
||||
return CV_MAT_DEPTH(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int GpuMat::channels() const
|
||||
{
|
||||
return CV_MAT_CN(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t GpuMat::step1() const
|
||||
{
|
||||
return step / elemSize1();
|
||||
}
|
||||
|
||||
inline
|
||||
Size GpuMat::size() const
|
||||
{
|
||||
return Size(cols, rows);
|
||||
}
|
||||
|
||||
inline
|
||||
bool GpuMat::empty() const
|
||||
{
|
||||
return data == 0;
|
||||
}
|
||||
|
||||
static inline
|
||||
GpuMat createContinuous(int rows, int cols, int type)
|
||||
{
|
||||
GpuMat m;
|
||||
createContinuous(rows, cols, type, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline
|
||||
void createContinuous(Size size, int type, OutputArray arr)
|
||||
{
|
||||
createContinuous(size.height, size.width, type, arr);
|
||||
}
|
||||
|
||||
static inline
|
||||
GpuMat createContinuous(Size size, int type)
|
||||
{
|
||||
GpuMat m;
|
||||
createContinuous(size, type, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline
|
||||
void ensureSizeIsEnough(Size size, int type, OutputArray arr)
|
||||
{
|
||||
ensureSizeIsEnough(size.height, size.width, type, arr);
|
||||
}
|
||||
|
||||
static inline
|
||||
void swap(GpuMat& a, GpuMat& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// HostMem
|
||||
//===================================================================================
|
||||
|
||||
inline
|
||||
HostMem::HostMem(AllocType alloc_type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem::HostMem(const HostMem& m)
|
||||
: flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), alloc_type(m.alloc_type)
|
||||
{
|
||||
if( refcount )
|
||||
CV_XADD(refcount, 1);
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem::HostMem(int rows_, int cols_, int type_, AllocType alloc_type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
|
||||
{
|
||||
if (rows_ > 0 && cols_ > 0)
|
||||
create(rows_, cols_, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem::HostMem(Size size_, int type_, AllocType alloc_type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
|
||||
{
|
||||
if (size_.height > 0 && size_.width > 0)
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem::HostMem(InputArray arr, AllocType alloc_type_)
|
||||
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
|
||||
{
|
||||
arr.getMat().copyTo(*this);
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem::~HostMem()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem& HostMem::operator =(const HostMem& m)
|
||||
{
|
||||
if (this != &m)
|
||||
{
|
||||
HostMem temp(m);
|
||||
swap(temp);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostMem::swap(HostMem& b)
|
||||
{
|
||||
std::swap(flags, b.flags);
|
||||
std::swap(rows, b.rows);
|
||||
std::swap(cols, b.cols);
|
||||
std::swap(step, b.step);
|
||||
std::swap(data, b.data);
|
||||
std::swap(datastart, b.datastart);
|
||||
std::swap(dataend, b.dataend);
|
||||
std::swap(refcount, b.refcount);
|
||||
std::swap(alloc_type, b.alloc_type);
|
||||
}
|
||||
|
||||
inline
|
||||
HostMem HostMem::clone() const
|
||||
{
|
||||
HostMem m(size(), type(), alloc_type);
|
||||
createMatHeader().copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostMem::create(Size size_, int type_)
|
||||
{
|
||||
create(size_.height, size_.width, type_);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat HostMem::createMatHeader() const
|
||||
{
|
||||
return Mat(size(), type(), data, step);
|
||||
}
|
||||
|
||||
inline
|
||||
bool HostMem::isContinuous() const
|
||||
{
|
||||
return (flags & Mat::CONTINUOUS_FLAG) != 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t HostMem::elemSize() const
|
||||
{
|
||||
return CV_ELEM_SIZE(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t HostMem::elemSize1() const
|
||||
{
|
||||
return CV_ELEM_SIZE1(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int HostMem::type() const
|
||||
{
|
||||
return CV_MAT_TYPE(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int HostMem::depth() const
|
||||
{
|
||||
return CV_MAT_DEPTH(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
int HostMem::channels() const
|
||||
{
|
||||
return CV_MAT_CN(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t HostMem::step1() const
|
||||
{
|
||||
return step / elemSize1();
|
||||
}
|
||||
|
||||
inline
|
||||
Size HostMem::size() const
|
||||
{
|
||||
return Size(cols, rows);
|
||||
}
|
||||
|
||||
inline
|
||||
bool HostMem::empty() const
|
||||
{
|
||||
return data == 0;
|
||||
}
|
||||
|
||||
static inline
|
||||
void swap(HostMem& a, HostMem& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Stream
|
||||
//===================================================================================
|
||||
|
||||
inline
|
||||
Stream::Stream(const Ptr<Impl>& impl)
|
||||
: impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Event
|
||||
//===================================================================================
|
||||
|
||||
inline
|
||||
Event::Event(const Ptr<Impl>& impl)
|
||||
: impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Initialization & Info
|
||||
//===================================================================================
|
||||
|
||||
inline
|
||||
bool TargetArchs::has(int major, int minor)
|
||||
{
|
||||
return hasPtx(major, minor) || hasBin(major, minor);
|
||||
}
|
||||
|
||||
inline
|
||||
bool TargetArchs::hasEqualOrGreater(int major, int minor)
|
||||
{
|
||||
return hasEqualOrGreaterPtx(major, minor) || hasEqualOrGreaterBin(major, minor);
|
||||
}
|
||||
|
||||
inline
|
||||
DeviceInfo::DeviceInfo()
|
||||
{
|
||||
device_id_ = getDevice();
|
||||
}
|
||||
|
||||
inline
|
||||
DeviceInfo::DeviceInfo(int device_id)
|
||||
{
|
||||
CV_Assert( device_id >= 0 && device_id < getCudaEnabledDeviceCount() );
|
||||
device_id_ = device_id;
|
||||
}
|
||||
|
||||
inline
|
||||
int DeviceInfo::deviceID() const
|
||||
{
|
||||
return device_id_;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t DeviceInfo::freeMemory() const
|
||||
{
|
||||
size_t _totalMemory = 0, _freeMemory = 0;
|
||||
queryMemory(_totalMemory, _freeMemory);
|
||||
return _freeMemory;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t DeviceInfo::totalMemory() const
|
||||
{
|
||||
size_t _totalMemory = 0, _freeMemory = 0;
|
||||
queryMemory(_totalMemory, _freeMemory);
|
||||
return _totalMemory;
|
||||
}
|
||||
|
||||
inline
|
||||
bool DeviceInfo::supports(FeatureSet feature_set) const
|
||||
{
|
||||
int version = majorVersion() * 10 + minorVersion();
|
||||
return version >= feature_set;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace cv { namespace cuda {
|
||||
|
||||
//===================================================================================
|
||||
// Mat
|
||||
//===================================================================================
|
||||
|
||||
namespace cv {
|
||||
|
||||
inline
|
||||
Mat::Mat(const cuda::GpuMat& m)
|
||||
: flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
m.download(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CORE_CUDAINL_HPP
|
|
@ -0,0 +1,211 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_DEVICE_BLOCK_HPP
|
||||
#define OPENCV_CUDA_DEVICE_BLOCK_HPP
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
struct Block
|
||||
{
|
||||
static __device__ __forceinline__ unsigned int id()
|
||||
{
|
||||
return blockIdx.x;
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ unsigned int stride()
|
||||
{
|
||||
return blockDim.x * blockDim.y * blockDim.z;
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ void sync()
|
||||
{
|
||||
__syncthreads();
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ int flattenedThreadId()
|
||||
{
|
||||
return threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
|
||||
}
|
||||
|
||||
template<typename It, typename T>
|
||||
static __device__ __forceinline__ void fill(It beg, It end, const T& value)
|
||||
{
|
||||
int STRIDE = stride();
|
||||
It t = beg + flattenedThreadId();
|
||||
|
||||
for(; t < end; t += STRIDE)
|
||||
*t = value;
|
||||
}
|
||||
|
||||
template<typename OutIt, typename T>
|
||||
static __device__ __forceinline__ void yota(OutIt beg, OutIt end, T value)
|
||||
{
|
||||
int STRIDE = stride();
|
||||
int tid = flattenedThreadId();
|
||||
value += tid;
|
||||
|
||||
for(OutIt t = beg + tid; t < end; t += STRIDE, value += STRIDE)
|
||||
*t = value;
|
||||
}
|
||||
|
||||
template<typename InIt, typename OutIt>
|
||||
static __device__ __forceinline__ void copy(InIt beg, InIt end, OutIt out)
|
||||
{
|
||||
int STRIDE = stride();
|
||||
InIt t = beg + flattenedThreadId();
|
||||
OutIt o = out + (t - beg);
|
||||
|
||||
for(; t < end; t += STRIDE, o += STRIDE)
|
||||
*o = *t;
|
||||
}
|
||||
|
||||
template<typename InIt, typename OutIt, class UnOp>
|
||||
static __device__ __forceinline__ void transform(InIt beg, InIt end, OutIt out, UnOp op)
|
||||
{
|
||||
int STRIDE = stride();
|
||||
InIt t = beg + flattenedThreadId();
|
||||
OutIt o = out + (t - beg);
|
||||
|
||||
for(; t < end; t += STRIDE, o += STRIDE)
|
||||
*o = op(*t);
|
||||
}
|
||||
|
||||
template<typename InIt1, typename InIt2, typename OutIt, class BinOp>
|
||||
static __device__ __forceinline__ void transform(InIt1 beg1, InIt1 end1, InIt2 beg2, OutIt out, BinOp op)
|
||||
{
|
||||
int STRIDE = stride();
|
||||
InIt1 t1 = beg1 + flattenedThreadId();
|
||||
InIt2 t2 = beg2 + flattenedThreadId();
|
||||
OutIt o = out + (t1 - beg1);
|
||||
|
||||
for(; t1 < end1; t1 += STRIDE, t2 += STRIDE, o += STRIDE)
|
||||
*o = op(*t1, *t2);
|
||||
}
|
||||
|
||||
template<int CTA_SIZE, typename T, class BinOp>
|
||||
static __device__ __forceinline__ void reduce(volatile T* buffer, BinOp op)
|
||||
{
|
||||
int tid = flattenedThreadId();
|
||||
T val = buffer[tid];
|
||||
|
||||
if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); }
|
||||
|
||||
if (tid < 32)
|
||||
{
|
||||
if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); }
|
||||
if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); }
|
||||
if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); }
|
||||
if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); }
|
||||
if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); }
|
||||
if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); }
|
||||
}
|
||||
}
|
||||
|
||||
template<int CTA_SIZE, typename T, class BinOp>
|
||||
static __device__ __forceinline__ T reduce(volatile T* buffer, T init, BinOp op)
|
||||
{
|
||||
int tid = flattenedThreadId();
|
||||
T val = buffer[tid] = init;
|
||||
__syncthreads();
|
||||
|
||||
if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); }
|
||||
if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); }
|
||||
|
||||
if (tid < 32)
|
||||
{
|
||||
if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); }
|
||||
if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); }
|
||||
if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); }
|
||||
if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); }
|
||||
if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); }
|
||||
if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); }
|
||||
}
|
||||
__syncthreads();
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
template <typename T, class BinOp>
|
||||
static __device__ __forceinline__ void reduce_n(T* data, unsigned int n, BinOp op)
|
||||
{
|
||||
int ftid = flattenedThreadId();
|
||||
int sft = stride();
|
||||
|
||||
if (sft < n)
|
||||
{
|
||||
for (unsigned int i = sft + ftid; i < n; i += sft)
|
||||
data[ftid] = op(data[ftid], data[i]);
|
||||
|
||||
__syncthreads();
|
||||
|
||||
n = sft;
|
||||
}
|
||||
|
||||
while (n > 1)
|
||||
{
|
||||
unsigned int half = n/2;
|
||||
|
||||
if (ftid < half)
|
||||
data[ftid] = op(data[ftid], data[n - ftid - 1]);
|
||||
|
||||
__syncthreads();
|
||||
|
||||
n = n - half;
|
||||
}
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif /* OPENCV_CUDA_DEVICE_BLOCK_HPP */
|
722
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/border_interpolate.hpp
vendored
Normal file
722
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/border_interpolate.hpp
vendored
Normal file
|
@ -0,0 +1,722 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_BORDER_INTERPOLATE_HPP
|
||||
#define OPENCV_CUDA_BORDER_INTERPOLATE_HPP
|
||||
|
||||
#include "saturate_cast.hpp"
|
||||
#include "vec_traits.hpp"
|
||||
#include "vec_math.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BrdConstant
|
||||
|
||||
template <typename D> struct BrdRowConstant
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdRowConstant(int width_, const D& val_ = VecTraits<D>::all(0)) : width(width_), val(val_) {}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int x, const T* data) const
|
||||
{
|
||||
return x >= 0 ? saturate_cast<D>(data[x]) : val;
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int x, const T* data) const
|
||||
{
|
||||
return x < width ? saturate_cast<D>(data[x]) : val;
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int x, const T* data) const
|
||||
{
|
||||
return (x >= 0 && x < width) ? saturate_cast<D>(data[x]) : val;
|
||||
}
|
||||
|
||||
int width;
|
||||
D val;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdColConstant
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdColConstant(int height_, const D& val_ = VecTraits<D>::all(0)) : height(height_), val(val_) {}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const
|
||||
{
|
||||
return y >= 0 ? saturate_cast<D>(*(const T*)((const char*)data + y * step)) : val;
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const
|
||||
{
|
||||
return y < height ? saturate_cast<D>(*(const T*)((const char*)data + y * step)) : val;
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, const T* data, size_t step) const
|
||||
{
|
||||
return (y >= 0 && y < height) ? saturate_cast<D>(*(const T*)((const char*)data + y * step)) : val;
|
||||
}
|
||||
|
||||
int height;
|
||||
D val;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdConstant
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BrdConstant(int height_, int width_, const D& val_ = VecTraits<D>::all(0)) : height(height_), width(width_), val(val_)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const
|
||||
{
|
||||
return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast<D>(((const T*)((const uchar*)data + y * step))[x]) : val;
|
||||
}
|
||||
|
||||
template <typename Ptr2D> __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const
|
||||
{
|
||||
return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast<D>(src(y, x)) : val;
|
||||
}
|
||||
|
||||
int height;
|
||||
int width;
|
||||
D val;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BrdReplicate
|
||||
|
||||
template <typename D> struct BrdRowReplicate
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdRowReplicate(int width) : last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdRowReplicate(int width, U) : last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return ::max(x, 0);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return ::min(x, last_col);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_low(idx_col_high(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_low(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_high(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col(x)]);
|
||||
}
|
||||
|
||||
int last_col;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdColReplicate
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdColReplicate(int height) : last_row(height - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdColReplicate(int height, U) : last_row(height - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return ::max(y, 0);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return ::min(y, last_row);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_low(idx_row_high(y));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const T*)((const char*)data + idx_row_low(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const T*)((const char*)data + idx_row_high(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const T*)((const char*)data + idx_row(y) * step));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdReplicate
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BrdReplicate(int height, int width) : last_row(height - 1), last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdReplicate(int height, int width, U) : last_row(height - 1), last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return ::max(y, 0);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return ::min(y, last_row);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_low(idx_row_high(y));
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return ::max(x, 0);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return ::min(x, last_col);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_low(idx_col_high(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]);
|
||||
}
|
||||
|
||||
template <typename Ptr2D> __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const
|
||||
{
|
||||
return saturate_cast<D>(src(idx_row(y), idx_col(x)));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
int last_col;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BrdReflect101
|
||||
|
||||
template <typename D> struct BrdRowReflect101
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdRowReflect101(int width) : last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdRowReflect101(int width, U) : last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return ::abs(x) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_low(idx_col_high(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_low(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_high(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col(x)]);
|
||||
}
|
||||
|
||||
int last_col;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdColReflect101
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdColReflect101(int height) : last_row(height - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdColReflect101(int height, U) : last_row(height - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return ::abs(y) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_low(idx_row_high(y));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_low(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_high(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row(y) * step));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdReflect101
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BrdReflect101(int height, int width) : last_row(height - 1), last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdReflect101(int height, int width, U) : last_row(height - 1), last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return ::abs(y) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_low(idx_row_high(y));
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return ::abs(x) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_low(idx_col_high(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]);
|
||||
}
|
||||
|
||||
template <typename Ptr2D> __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const
|
||||
{
|
||||
return saturate_cast<D>(src(idx_row(y), idx_col(x)));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
int last_col;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BrdReflect
|
||||
|
||||
template <typename D> struct BrdRowReflect
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdRowReflect(int width) : last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdRowReflect(int width, U) : last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return (::abs(x) - (x < 0)) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return ::abs(last_col - ::abs(last_col - x) + (x > last_col)) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_high(::abs(x) - (x < 0));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_low(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_high(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col(x)]);
|
||||
}
|
||||
|
||||
int last_col;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdColReflect
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdColReflect(int height) : last_row(height - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdColReflect(int height, U) : last_row(height - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return (::abs(y) - (y < 0)) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return ::abs(last_row - ::abs(last_row - y) + (y > last_row)) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_high(::abs(y) - (y < 0));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_low(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_high(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row(y) * step));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdReflect
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BrdReflect(int height, int width) : last_row(height - 1), last_col(width - 1) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdReflect(int height, int width, U) : last_row(height - 1), last_col(width - 1) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return (::abs(y) - (y < 0)) % (last_row + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return /*::abs*/(last_row - ::abs(last_row - y) + (y > last_row)) /*% (last_row + 1)*/;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_low(idx_row_high(y));
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return (::abs(x) - (x < 0)) % (last_col + 1);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return (last_col - ::abs(last_col - x) + (x > last_col));
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_low(idx_col_high(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]);
|
||||
}
|
||||
|
||||
template <typename Ptr2D> __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const
|
||||
{
|
||||
return saturate_cast<D>(src(idx_row(y), idx_col(x)));
|
||||
}
|
||||
|
||||
int last_row;
|
||||
int last_col;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BrdWrap
|
||||
|
||||
template <typename D> struct BrdRowWrap
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdRowWrap(int width_) : width(width_) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdRowWrap(int width_, U) : width(width_) {}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return (x >= 0) * x + (x < 0) * (x - ((x - width + 1) / width) * width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return (x < width) * x + (x >= width) * (x % width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_high(idx_col_low(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_low(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col_high(x)]);
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int x, const T* data) const
|
||||
{
|
||||
return saturate_cast<D>(data[idx_col(x)]);
|
||||
}
|
||||
|
||||
int width;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdColWrap
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ BrdColWrap(int height_) : height(height_) {}
|
||||
template <typename U> __host__ __device__ __forceinline__ BrdColWrap(int height_, U) : height(height_) {}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return (y >= 0) * y + (y < 0) * (y - ((y - height + 1) / height) * height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return (y < height) * y + (y >= height) * (y % height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_high(idx_row_low(y));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_low(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row_high(y) * step));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(*(const D*)((const char*)data + idx_row(y) * step));
|
||||
}
|
||||
|
||||
int height;
|
||||
};
|
||||
|
||||
template <typename D> struct BrdWrap
|
||||
{
|
||||
typedef D result_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BrdWrap(int height_, int width_) :
|
||||
height(height_), width(width_)
|
||||
{
|
||||
}
|
||||
template <typename U>
|
||||
__host__ __device__ __forceinline__ BrdWrap(int height_, int width_, U) :
|
||||
height(height_), width(width_)
|
||||
{
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return (y >= 0) ? y : (y - ((y - height + 1) / height) * height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return (y < height) ? y : (y % height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
{
|
||||
return idx_row_high(idx_row_low(y));
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return (x >= 0) ? x : (x - ((x - width + 1) / width) * width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return (x < width) ? x : (x % width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
{
|
||||
return idx_col_high(idx_col_low(x));
|
||||
}
|
||||
|
||||
template <typename T> __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const
|
||||
{
|
||||
return saturate_cast<D>(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]);
|
||||
}
|
||||
|
||||
template <typename Ptr2D> __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const
|
||||
{
|
||||
return saturate_cast<D>(src(idx_row(y), idx_col(x)));
|
||||
}
|
||||
|
||||
int height;
|
||||
int width;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BorderReader
|
||||
|
||||
template <typename Ptr2D, typename B> struct BorderReader
|
||||
{
|
||||
typedef typename B::result_type elem_type;
|
||||
typedef typename Ptr2D::index_type index_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BorderReader(const Ptr2D& ptr_, const B& b_) : ptr(ptr_), b(b_) {}
|
||||
|
||||
__device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const
|
||||
{
|
||||
return b.at(y, x, ptr);
|
||||
}
|
||||
|
||||
Ptr2D ptr;
|
||||
B b;
|
||||
};
|
||||
|
||||
// under win32 there is some bug with templated types that passed as kernel parameters
|
||||
// with this specialization all works fine
|
||||
template <typename Ptr2D, typename D> struct BorderReader< Ptr2D, BrdConstant<D> >
|
||||
{
|
||||
typedef typename BrdConstant<D>::result_type elem_type;
|
||||
typedef typename Ptr2D::index_type index_type;
|
||||
|
||||
__host__ __device__ __forceinline__ BorderReader(const Ptr2D& src_, const BrdConstant<D>& b) :
|
||||
src(src_), height(b.height), width(b.width), val(b.val)
|
||||
{
|
||||
}
|
||||
|
||||
__device__ __forceinline__ D operator ()(index_type y, index_type x) const
|
||||
{
|
||||
return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast<D>(src(y, x)) : val;
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
int height;
|
||||
int width;
|
||||
D val;
|
||||
};
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_BORDER_INTERPOLATE_HPP
|
|
@ -0,0 +1,309 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_COLOR_HPP
|
||||
#define OPENCV_CUDA_COLOR_HPP
|
||||
|
||||
#include "detail/color_detail.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
// All OPENCV_CUDA_IMPLEMENT_*_TRAITS(ColorSpace1_to_ColorSpace2, ...) macros implements
|
||||
// template <typename T> class ColorSpace1_to_ColorSpace2_traits
|
||||
// {
|
||||
// typedef ... functor_type;
|
||||
// static __host__ __device__ functor_type create_functor();
|
||||
// };
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgba, 4, 4, 2)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr555, 3, 0, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr565, 3, 0, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr555, 3, 2, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr565, 3, 2, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr555, 4, 0, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr565, 4, 0, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr555, 4, 2, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr565, 4, 2, 6)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgb, 3, 2, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgb, 3, 2, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgr, 3, 0, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgr, 3, 0, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgba, 4, 2, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgba, 4, 2, 6)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgra, 4, 0, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgra, 4, 0, 6)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgr, 3)
|
||||
OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgra, 4)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr555, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr565, 6)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr555_to_gray, 5)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr565_to_gray, 6)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgb_to_gray, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgr_to_gray, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgba_to_gray, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgra_to_gray, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv4, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv4, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv4, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv4, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgba, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgr, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgra, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb4, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb4, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb4, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb4, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgba, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgr, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgra, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz4, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz4, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz4, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz4, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgba, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgr, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgra, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv4, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv4, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv4, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv4, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgba, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgr, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgra, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls4, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls4, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls4, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls4, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgb, 3, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgba, 3, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgb, 4, 3, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgba, 4, 4, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgr, 3, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgra, 3, 4, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgr, 4, 3, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgra, 4, 4, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab, 3, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab, 4, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab4, 3, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab4, 4, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab, 3, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab, 4, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab4, 3, 4, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab4, 4, 4, true, 0)
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab, 3, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab, 4, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab4, 3, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab4, 4, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab, 3, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab, 4, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab4, 3, 4, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab4, 4, 4, false, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgb, 3, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgb, 4, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgba, 3, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgba, 4, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgr, 3, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgr, 4, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgra, 3, 4, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgra, 4, 4, true, 0)
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgb, 3, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgb, 4, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgba, 3, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgba, 4, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgr, 3, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgr, 4, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgra, 3, 4, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgra, 4, 4, false, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv, 3, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv, 4, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv4, 3, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv4, 4, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv, 3, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv, 4, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv4, 3, 4, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv4, 4, 4, true, 0)
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv, 3, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv, 4, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv4, 3, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv4, 4, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv, 3, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv, 4, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv4, 3, 4, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv4, 4, 4, false, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgb, 3, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgb, 4, 3, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgba, 3, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgba, 4, 4, true, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgr, 3, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgr, 4, 3, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgra, 3, 4, true, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgra, 4, 4, true, 0)
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgb, 3, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgb, 4, 3, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgba, 3, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgba, 4, 4, false, 2)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgr, 3, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgr, 4, 3, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgra, 3, 4, false, 0)
|
||||
OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgra, 4, 4, false, 0)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_COLOR_HPP
|
|
@ -0,0 +1,123 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_COMMON_HPP
|
||||
#define OPENCV_CUDA_COMMON_HPP
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include "opencv2/core/cuda_types.hpp"
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/base.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
#ifndef CV_PI_F
|
||||
#ifndef CV_PI
|
||||
#define CV_PI_F 3.14159265f
|
||||
#else
|
||||
#define CV_PI_F ((float)CV_PI)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace cv { namespace cuda {
|
||||
static inline void checkCudaError(cudaError_t err, const char* file, const int line, const char* func)
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::error(cv::Error::GpuApiCallError, cudaGetErrorString(err), func, file, line);
|
||||
}
|
||||
}}
|
||||
|
||||
#ifndef cudaSafeCall
|
||||
#define cudaSafeCall(expr) cv::cuda::checkCudaError(expr, __FILE__, __LINE__, CV_Func)
|
||||
#endif
|
||||
|
||||
namespace cv { namespace cuda
|
||||
{
|
||||
template <typename T> static inline bool isAligned(const T* ptr, size_t size)
|
||||
{
|
||||
return reinterpret_cast<size_t>(ptr) % size == 0;
|
||||
}
|
||||
|
||||
static inline bool isAligned(size_t step, size_t size)
|
||||
{
|
||||
return step % size == 0;
|
||||
}
|
||||
}}
|
||||
|
||||
namespace cv { namespace cuda
|
||||
{
|
||||
namespace device
|
||||
{
|
||||
__host__ __device__ __forceinline__ int divUp(int total, int grain)
|
||||
{
|
||||
return (total + grain - 1) / grain;
|
||||
}
|
||||
|
||||
template<class T> inline void bindTexture(const textureReference* tex, const PtrStepSz<T>& img)
|
||||
{
|
||||
cudaChannelFormatDesc desc = cudaCreateChannelDesc<T>();
|
||||
cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) );
|
||||
}
|
||||
|
||||
template<class T> inline void createTextureObjectPitch2D(cudaTextureObject_t* tex, PtrStepSz<T>& img, const cudaTextureDesc& texDesc)
|
||||
{
|
||||
cudaResourceDesc resDesc;
|
||||
memset(&resDesc, 0, sizeof(resDesc));
|
||||
resDesc.resType = cudaResourceTypePitch2D;
|
||||
resDesc.res.pitch2D.devPtr = static_cast<void*>(img.ptr());
|
||||
resDesc.res.pitch2D.height = img.rows;
|
||||
resDesc.res.pitch2D.width = img.cols;
|
||||
resDesc.res.pitch2D.pitchInBytes = img.step;
|
||||
resDesc.res.pitch2D.desc = cudaCreateChannelDesc<T>();
|
||||
|
||||
cudaSafeCall( cudaCreateTextureObject(tex, &resDesc, &texDesc, NULL) );
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_COMMON_HPP
|
|
@ -0,0 +1,113 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_DATAMOV_UTILS_HPP
|
||||
#define OPENCV_CUDA_DATAMOV_UTILS_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
#if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 200
|
||||
|
||||
// for Fermi memory space is detected automatically
|
||||
template <typename T> struct ForceGlob
|
||||
{
|
||||
__device__ __forceinline__ static void Load(const T* ptr, int offset, T& val) { val = ptr[offset]; }
|
||||
};
|
||||
|
||||
#else // __CUDA_ARCH__ >= 200
|
||||
|
||||
#if defined(_WIN64) || defined(__LP64__)
|
||||
// 64-bit register modifier for inlined asm
|
||||
#define OPENCV_CUDA_ASM_PTR "l"
|
||||
#else
|
||||
// 32-bit register modifier for inlined asm
|
||||
#define OPENCV_CUDA_ASM_PTR "r"
|
||||
#endif
|
||||
|
||||
template<class T> struct ForceGlob;
|
||||
|
||||
#define OPENCV_CUDA_DEFINE_FORCE_GLOB(base_type, ptx_type, reg_mod) \
|
||||
template <> struct ForceGlob<base_type> \
|
||||
{ \
|
||||
__device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \
|
||||
{ \
|
||||
asm("ld.global."#ptx_type" %0, [%1];" : "="#reg_mod(val) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define OPENCV_CUDA_DEFINE_FORCE_GLOB_B(base_type, ptx_type) \
|
||||
template <> struct ForceGlob<base_type> \
|
||||
{ \
|
||||
__device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \
|
||||
{ \
|
||||
asm("ld.global."#ptx_type" %0, [%1];" : "=r"(*reinterpret_cast<uint*>(&val)) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \
|
||||
} \
|
||||
};
|
||||
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB_B(uchar, u8)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB_B(schar, s8)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB_B(char, b8)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (ushort, u16, h)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (short, s16, h)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (uint, u32, r)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (int, s32, r)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (float, f32, f)
|
||||
OPENCV_CUDA_DEFINE_FORCE_GLOB (double, f64, d)
|
||||
|
||||
#undef OPENCV_CUDA_DEFINE_FORCE_GLOB
|
||||
#undef OPENCV_CUDA_DEFINE_FORCE_GLOB_B
|
||||
#undef OPENCV_CUDA_ASM_PTR
|
||||
|
||||
#endif // __CUDA_ARCH__ >= 200
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_DATAMOV_UTILS_HPP
|
1980
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/color_detail.hpp
vendored
Normal file
1980
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/color_detail.hpp
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,365 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_REDUCE_DETAIL_HPP
|
||||
#define OPENCV_CUDA_REDUCE_DETAIL_HPP
|
||||
|
||||
#include <thrust/tuple.h>
|
||||
#include "../warp.hpp"
|
||||
#include "../warp_shuffle.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
namespace reduce_detail
|
||||
{
|
||||
template <typename T> struct GetType;
|
||||
template <typename T> struct GetType<T*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T> struct GetType<volatile T*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T> struct GetType<T&>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <unsigned int I, unsigned int N>
|
||||
struct For
|
||||
{
|
||||
template <class PointerTuple, class ValTuple>
|
||||
static __device__ void loadToSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid)
|
||||
{
|
||||
thrust::get<I>(smem)[tid] = thrust::get<I>(val);
|
||||
|
||||
For<I + 1, N>::loadToSmem(smem, val, tid);
|
||||
}
|
||||
template <class PointerTuple, class ValTuple>
|
||||
static __device__ void loadFromSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid)
|
||||
{
|
||||
thrust::get<I>(val) = thrust::get<I>(smem)[tid];
|
||||
|
||||
For<I + 1, N>::loadFromSmem(smem, val, tid);
|
||||
}
|
||||
|
||||
template <class PointerTuple, class ValTuple, class OpTuple>
|
||||
static __device__ void merge(const PointerTuple& smem, const ValTuple& val, unsigned int tid, unsigned int delta, const OpTuple& op)
|
||||
{
|
||||
typename GetType<typename thrust::tuple_element<I, PointerTuple>::type>::type reg = thrust::get<I>(smem)[tid + delta];
|
||||
thrust::get<I>(smem)[tid] = thrust::get<I>(val) = thrust::get<I>(op)(thrust::get<I>(val), reg);
|
||||
|
||||
For<I + 1, N>::merge(smem, val, tid, delta, op);
|
||||
}
|
||||
template <class ValTuple, class OpTuple>
|
||||
static __device__ void mergeShfl(const ValTuple& val, unsigned int delta, unsigned int width, const OpTuple& op)
|
||||
{
|
||||
typename GetType<typename thrust::tuple_element<I, ValTuple>::type>::type reg = shfl_down(thrust::get<I>(val), delta, width);
|
||||
thrust::get<I>(val) = thrust::get<I>(op)(thrust::get<I>(val), reg);
|
||||
|
||||
For<I + 1, N>::mergeShfl(val, delta, width, op);
|
||||
}
|
||||
};
|
||||
template <unsigned int N>
|
||||
struct For<N, N>
|
||||
{
|
||||
template <class PointerTuple, class ValTuple>
|
||||
static __device__ void loadToSmem(const PointerTuple&, const ValTuple&, unsigned int)
|
||||
{
|
||||
}
|
||||
template <class PointerTuple, class ValTuple>
|
||||
static __device__ void loadFromSmem(const PointerTuple&, const ValTuple&, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
template <class PointerTuple, class ValTuple, class OpTuple>
|
||||
static __device__ void merge(const PointerTuple&, const ValTuple&, unsigned int, unsigned int, const OpTuple&)
|
||||
{
|
||||
}
|
||||
template <class ValTuple, class OpTuple>
|
||||
static __device__ void mergeShfl(const ValTuple&, unsigned int, unsigned int, const OpTuple&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
__device__ __forceinline__ void loadToSmem(volatile T* smem, T& val, unsigned int tid)
|
||||
{
|
||||
smem[tid] = val;
|
||||
}
|
||||
template <typename T>
|
||||
__device__ __forceinline__ void loadFromSmem(volatile T* smem, T& val, unsigned int tid)
|
||||
{
|
||||
val = smem[tid];
|
||||
}
|
||||
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9,
|
||||
typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7, typename R8, typename R9>
|
||||
__device__ __forceinline__ void loadToSmem(const thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9>& smem,
|
||||
const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>& val,
|
||||
unsigned int tid)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9> >::value>::loadToSmem(smem, val, tid);
|
||||
}
|
||||
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9,
|
||||
typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7, typename R8, typename R9>
|
||||
__device__ __forceinline__ void loadFromSmem(const thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9>& smem,
|
||||
const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>& val,
|
||||
unsigned int tid)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9> >::value>::loadFromSmem(smem, val, tid);
|
||||
}
|
||||
|
||||
template <typename T, class Op>
|
||||
__device__ __forceinline__ void merge(volatile T* smem, T& val, unsigned int tid, unsigned int delta, const Op& op)
|
||||
{
|
||||
T reg = smem[tid + delta];
|
||||
smem[tid] = val = op(val, reg);
|
||||
}
|
||||
template <typename T, class Op>
|
||||
__device__ __forceinline__ void mergeShfl(T& val, unsigned int delta, unsigned int width, const Op& op)
|
||||
{
|
||||
T reg = shfl_down(val, delta, width);
|
||||
val = op(val, reg);
|
||||
}
|
||||
template <typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9,
|
||||
typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7, typename R8, typename R9,
|
||||
class Op0, class Op1, class Op2, class Op3, class Op4, class Op5, class Op6, class Op7, class Op8, class Op9>
|
||||
__device__ __forceinline__ void merge(const thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9>& smem,
|
||||
const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>& val,
|
||||
unsigned int tid,
|
||||
unsigned int delta,
|
||||
const thrust::tuple<Op0, Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8, Op9>& op)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9> >::value>::merge(smem, val, tid, delta, op);
|
||||
}
|
||||
template <typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, typename R6, typename R7, typename R8, typename R9,
|
||||
class Op0, class Op1, class Op2, class Op3, class Op4, class Op5, class Op6, class Op7, class Op8, class Op9>
|
||||
__device__ __forceinline__ void mergeShfl(const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>& val,
|
||||
unsigned int delta,
|
||||
unsigned int width,
|
||||
const thrust::tuple<Op0, Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8, Op9>& op)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9> >::value>::mergeShfl(val, delta, width, op);
|
||||
}
|
||||
|
||||
template <unsigned int N> struct Generic
|
||||
{
|
||||
template <typename Pointer, typename Reference, class Op>
|
||||
static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op)
|
||||
{
|
||||
loadToSmem(smem, val, tid);
|
||||
if (N >= 32)
|
||||
__syncthreads();
|
||||
|
||||
if (N >= 2048)
|
||||
{
|
||||
if (tid < 1024)
|
||||
merge(smem, val, tid, 1024, op);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 1024)
|
||||
{
|
||||
if (tid < 512)
|
||||
merge(smem, val, tid, 512, op);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 512)
|
||||
{
|
||||
if (tid < 256)
|
||||
merge(smem, val, tid, 256, op);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 256)
|
||||
{
|
||||
if (tid < 128)
|
||||
merge(smem, val, tid, 128, op);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 128)
|
||||
{
|
||||
if (tid < 64)
|
||||
merge(smem, val, tid, 64, op);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 64)
|
||||
{
|
||||
if (tid < 32)
|
||||
merge(smem, val, tid, 32, op);
|
||||
}
|
||||
|
||||
if (tid < 16)
|
||||
{
|
||||
merge(smem, val, tid, 16, op);
|
||||
merge(smem, val, tid, 8, op);
|
||||
merge(smem, val, tid, 4, op);
|
||||
merge(smem, val, tid, 2, op);
|
||||
merge(smem, val, tid, 1, op);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int I, typename Pointer, typename Reference, class Op>
|
||||
struct Unroll
|
||||
{
|
||||
static __device__ void loopShfl(Reference val, Op op, unsigned int N)
|
||||
{
|
||||
mergeShfl(val, I, N, op);
|
||||
Unroll<I / 2, Pointer, Reference, Op>::loopShfl(val, op, N);
|
||||
}
|
||||
static __device__ void loop(Pointer smem, Reference val, unsigned int tid, Op op)
|
||||
{
|
||||
merge(smem, val, tid, I, op);
|
||||
Unroll<I / 2, Pointer, Reference, Op>::loop(smem, val, tid, op);
|
||||
}
|
||||
};
|
||||
template <typename Pointer, typename Reference, class Op>
|
||||
struct Unroll<0, Pointer, Reference, Op>
|
||||
{
|
||||
static __device__ void loopShfl(Reference, Op, unsigned int)
|
||||
{
|
||||
}
|
||||
static __device__ void loop(Pointer, Reference, unsigned int, Op)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N> struct WarpOptimized
|
||||
{
|
||||
template <typename Pointer, typename Reference, class Op>
|
||||
static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op)
|
||||
{
|
||||
#if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300
|
||||
CV_UNUSED(smem);
|
||||
CV_UNUSED(tid);
|
||||
|
||||
Unroll<N / 2, Pointer, Reference, Op>::loopShfl(val, op, N);
|
||||
#else
|
||||
loadToSmem(smem, val, tid);
|
||||
|
||||
if (tid < N / 2)
|
||||
Unroll<N / 2, Pointer, Reference, Op>::loop(smem, val, tid, op);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N> struct GenericOptimized32
|
||||
{
|
||||
enum { M = N / 32 };
|
||||
|
||||
template <typename Pointer, typename Reference, class Op>
|
||||
static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op)
|
||||
{
|
||||
const unsigned int laneId = Warp::laneId();
|
||||
|
||||
#if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300
|
||||
Unroll<16, Pointer, Reference, Op>::loopShfl(val, op, warpSize);
|
||||
|
||||
if (laneId == 0)
|
||||
loadToSmem(smem, val, tid / 32);
|
||||
#else
|
||||
loadToSmem(smem, val, tid);
|
||||
|
||||
if (laneId < 16)
|
||||
Unroll<16, Pointer, Reference, Op>::loop(smem, val, tid, op);
|
||||
|
||||
__syncthreads();
|
||||
|
||||
if (laneId == 0)
|
||||
loadToSmem(smem, val, tid / 32);
|
||||
#endif
|
||||
|
||||
__syncthreads();
|
||||
|
||||
loadFromSmem(smem, val, tid);
|
||||
|
||||
if (tid < 32)
|
||||
{
|
||||
#if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300
|
||||
Unroll<M / 2, Pointer, Reference, Op>::loopShfl(val, op, M);
|
||||
#else
|
||||
Unroll<M / 2, Pointer, Reference, Op>::loop(smem, val, tid, op);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <bool val, class T1, class T2> struct StaticIf;
|
||||
template <class T1, class T2> struct StaticIf<true, T1, T2>
|
||||
{
|
||||
typedef T1 type;
|
||||
};
|
||||
template <class T1, class T2> struct StaticIf<false, T1, T2>
|
||||
{
|
||||
typedef T2 type;
|
||||
};
|
||||
|
||||
template <unsigned int N> struct IsPowerOf2
|
||||
{
|
||||
enum { value = ((N != 0) && !(N & (N - 1))) };
|
||||
};
|
||||
|
||||
template <unsigned int N> struct Dispatcher
|
||||
{
|
||||
typedef typename StaticIf<
|
||||
(N <= 32) && IsPowerOf2<N>::value,
|
||||
WarpOptimized<N>,
|
||||
typename StaticIf<
|
||||
(N <= 1024) && IsPowerOf2<N>::value,
|
||||
GenericOptimized32<N>,
|
||||
Generic<N>
|
||||
>::type
|
||||
>::type reductor;
|
||||
};
|
||||
}
|
||||
}}}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_REDUCE_DETAIL_HPP
|
502
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/reduce_key_val.hpp
vendored
Normal file
502
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/reduce_key_val.hpp
vendored
Normal file
|
@ -0,0 +1,502 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP
|
||||
#define OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP
|
||||
|
||||
#include <thrust/tuple.h>
|
||||
#include "../warp.hpp"
|
||||
#include "../warp_shuffle.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
namespace reduce_key_val_detail
|
||||
{
|
||||
template <typename T> struct GetType;
|
||||
template <typename T> struct GetType<T*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T> struct GetType<volatile T*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T> struct GetType<T&>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <unsigned int I, unsigned int N>
|
||||
struct For
|
||||
{
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void loadToSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid)
|
||||
{
|
||||
thrust::get<I>(smem)[tid] = thrust::get<I>(data);
|
||||
|
||||
For<I + 1, N>::loadToSmem(smem, data, tid);
|
||||
}
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void loadFromSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid)
|
||||
{
|
||||
thrust::get<I>(data) = thrust::get<I>(smem)[tid];
|
||||
|
||||
For<I + 1, N>::loadFromSmem(smem, data, tid);
|
||||
}
|
||||
|
||||
template <class ReferenceTuple>
|
||||
static __device__ void copyShfl(const ReferenceTuple& val, unsigned int delta, int width)
|
||||
{
|
||||
thrust::get<I>(val) = shfl_down(thrust::get<I>(val), delta, width);
|
||||
|
||||
For<I + 1, N>::copyShfl(val, delta, width);
|
||||
}
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void copy(const PointerTuple& svals, const ReferenceTuple& val, unsigned int tid, unsigned int delta)
|
||||
{
|
||||
thrust::get<I>(svals)[tid] = thrust::get<I>(val) = thrust::get<I>(svals)[tid + delta];
|
||||
|
||||
For<I + 1, N>::copy(svals, val, tid, delta);
|
||||
}
|
||||
|
||||
template <class KeyReferenceTuple, class ValReferenceTuple, class CmpTuple>
|
||||
static __device__ void mergeShfl(const KeyReferenceTuple& key, const ValReferenceTuple& val, const CmpTuple& cmp, unsigned int delta, int width)
|
||||
{
|
||||
typename GetType<typename thrust::tuple_element<I, KeyReferenceTuple>::type>::type reg = shfl_down(thrust::get<I>(key), delta, width);
|
||||
|
||||
if (thrust::get<I>(cmp)(reg, thrust::get<I>(key)))
|
||||
{
|
||||
thrust::get<I>(key) = reg;
|
||||
thrust::get<I>(val) = shfl_down(thrust::get<I>(val), delta, width);
|
||||
}
|
||||
|
||||
For<I + 1, N>::mergeShfl(key, val, cmp, delta, width);
|
||||
}
|
||||
template <class KeyPointerTuple, class KeyReferenceTuple, class ValPointerTuple, class ValReferenceTuple, class CmpTuple>
|
||||
static __device__ void merge(const KeyPointerTuple& skeys, const KeyReferenceTuple& key,
|
||||
const ValPointerTuple& svals, const ValReferenceTuple& val,
|
||||
const CmpTuple& cmp,
|
||||
unsigned int tid, unsigned int delta)
|
||||
{
|
||||
typename GetType<typename thrust::tuple_element<I, KeyPointerTuple>::type>::type reg = thrust::get<I>(skeys)[tid + delta];
|
||||
|
||||
if (thrust::get<I>(cmp)(reg, thrust::get<I>(key)))
|
||||
{
|
||||
thrust::get<I>(skeys)[tid] = thrust::get<I>(key) = reg;
|
||||
thrust::get<I>(svals)[tid] = thrust::get<I>(val) = thrust::get<I>(svals)[tid + delta];
|
||||
}
|
||||
|
||||
For<I + 1, N>::merge(skeys, key, svals, val, cmp, tid, delta);
|
||||
}
|
||||
};
|
||||
template <unsigned int N>
|
||||
struct For<N, N>
|
||||
{
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void loadToSmem(const PointerTuple&, const ReferenceTuple&, unsigned int)
|
||||
{
|
||||
}
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void loadFromSmem(const PointerTuple&, const ReferenceTuple&, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
template <class ReferenceTuple>
|
||||
static __device__ void copyShfl(const ReferenceTuple&, unsigned int, int)
|
||||
{
|
||||
}
|
||||
template <class PointerTuple, class ReferenceTuple>
|
||||
static __device__ void copy(const PointerTuple&, const ReferenceTuple&, unsigned int, unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
template <class KeyReferenceTuple, class ValReferenceTuple, class CmpTuple>
|
||||
static __device__ void mergeShfl(const KeyReferenceTuple&, const ValReferenceTuple&, const CmpTuple&, unsigned int, int)
|
||||
{
|
||||
}
|
||||
template <class KeyPointerTuple, class KeyReferenceTuple, class ValPointerTuple, class ValReferenceTuple, class CmpTuple>
|
||||
static __device__ void merge(const KeyPointerTuple&, const KeyReferenceTuple&,
|
||||
const ValPointerTuple&, const ValReferenceTuple&,
|
||||
const CmpTuple&,
|
||||
unsigned int, unsigned int)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// loadToSmem
|
||||
|
||||
template <typename T>
|
||||
__device__ __forceinline__ void loadToSmem(volatile T* smem, T& data, unsigned int tid)
|
||||
{
|
||||
smem[tid] = data;
|
||||
}
|
||||
template <typename T>
|
||||
__device__ __forceinline__ void loadFromSmem(volatile T* smem, T& data, unsigned int tid)
|
||||
{
|
||||
data = smem[tid];
|
||||
}
|
||||
template <typename VP0, typename VP1, typename VP2, typename VP3, typename VP4, typename VP5, typename VP6, typename VP7, typename VP8, typename VP9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9>
|
||||
__device__ __forceinline__ void loadToSmem(const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& smem,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& data,
|
||||
unsigned int tid)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9> >::value>::loadToSmem(smem, data, tid);
|
||||
}
|
||||
template <typename VP0, typename VP1, typename VP2, typename VP3, typename VP4, typename VP5, typename VP6, typename VP7, typename VP8, typename VP9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9>
|
||||
__device__ __forceinline__ void loadFromSmem(const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& smem,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& data,
|
||||
unsigned int tid)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9> >::value>::loadFromSmem(smem, data, tid);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// copyVals
|
||||
|
||||
template <typename V>
|
||||
__device__ __forceinline__ void copyValsShfl(V& val, unsigned int delta, int width)
|
||||
{
|
||||
val = shfl_down(val, delta, width);
|
||||
}
|
||||
template <typename V>
|
||||
__device__ __forceinline__ void copyVals(volatile V* svals, V& val, unsigned int tid, unsigned int delta)
|
||||
{
|
||||
svals[tid] = val = svals[tid + delta];
|
||||
}
|
||||
template <typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9>
|
||||
__device__ __forceinline__ void copyValsShfl(const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
unsigned int delta,
|
||||
int width)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9> >::value>::copyShfl(val, delta, width);
|
||||
}
|
||||
template <typename VP0, typename VP1, typename VP2, typename VP3, typename VP4, typename VP5, typename VP6, typename VP7, typename VP8, typename VP9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9>
|
||||
__device__ __forceinline__ void copyVals(const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& svals,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
unsigned int tid, unsigned int delta)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9> >::value>::copy(svals, val, tid, delta);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// merge
|
||||
|
||||
template <typename K, typename V, class Cmp>
|
||||
__device__ __forceinline__ void mergeShfl(K& key, V& val, const Cmp& cmp, unsigned int delta, int width)
|
||||
{
|
||||
K reg = shfl_down(key, delta, width);
|
||||
|
||||
if (cmp(reg, key))
|
||||
{
|
||||
key = reg;
|
||||
copyValsShfl(val, delta, width);
|
||||
}
|
||||
}
|
||||
template <typename K, typename V, class Cmp>
|
||||
__device__ __forceinline__ void merge(volatile K* skeys, K& key, volatile V* svals, V& val, const Cmp& cmp, unsigned int tid, unsigned int delta)
|
||||
{
|
||||
K reg = skeys[tid + delta];
|
||||
|
||||
if (cmp(reg, key))
|
||||
{
|
||||
skeys[tid] = key = reg;
|
||||
copyVals(svals, val, tid, delta);
|
||||
}
|
||||
}
|
||||
template <typename K,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9,
|
||||
class Cmp>
|
||||
__device__ __forceinline__ void mergeShfl(K& key,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
const Cmp& cmp,
|
||||
unsigned int delta, int width)
|
||||
{
|
||||
K reg = shfl_down(key, delta, width);
|
||||
|
||||
if (cmp(reg, key))
|
||||
{
|
||||
key = reg;
|
||||
copyValsShfl(val, delta, width);
|
||||
}
|
||||
}
|
||||
template <typename K,
|
||||
typename VP0, typename VP1, typename VP2, typename VP3, typename VP4, typename VP5, typename VP6, typename VP7, typename VP8, typename VP9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9,
|
||||
class Cmp>
|
||||
__device__ __forceinline__ void merge(volatile K* skeys, K& key,
|
||||
const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& svals,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
const Cmp& cmp, unsigned int tid, unsigned int delta)
|
||||
{
|
||||
K reg = skeys[tid + delta];
|
||||
|
||||
if (cmp(reg, key))
|
||||
{
|
||||
skeys[tid] = key = reg;
|
||||
copyVals(svals, val, tid, delta);
|
||||
}
|
||||
}
|
||||
template <typename KR0, typename KR1, typename KR2, typename KR3, typename KR4, typename KR5, typename KR6, typename KR7, typename KR8, typename KR9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9,
|
||||
class Cmp0, class Cmp1, class Cmp2, class Cmp3, class Cmp4, class Cmp5, class Cmp6, class Cmp7, class Cmp8, class Cmp9>
|
||||
__device__ __forceinline__ void mergeShfl(const thrust::tuple<KR0, KR1, KR2, KR3, KR4, KR5, KR6, KR7, KR8, KR9>& key,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
const thrust::tuple<Cmp0, Cmp1, Cmp2, Cmp3, Cmp4, Cmp5, Cmp6, Cmp7, Cmp8, Cmp9>& cmp,
|
||||
unsigned int delta, int width)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<KR0, KR1, KR2, KR3, KR4, KR5, KR6, KR7, KR8, KR9> >::value>::mergeShfl(key, val, cmp, delta, width);
|
||||
}
|
||||
template <typename KP0, typename KP1, typename KP2, typename KP3, typename KP4, typename KP5, typename KP6, typename KP7, typename KP8, typename KP9,
|
||||
typename KR0, typename KR1, typename KR2, typename KR3, typename KR4, typename KR5, typename KR6, typename KR7, typename KR8, typename KR9,
|
||||
typename VP0, typename VP1, typename VP2, typename VP3, typename VP4, typename VP5, typename VP6, typename VP7, typename VP8, typename VP9,
|
||||
typename VR0, typename VR1, typename VR2, typename VR3, typename VR4, typename VR5, typename VR6, typename VR7, typename VR8, typename VR9,
|
||||
class Cmp0, class Cmp1, class Cmp2, class Cmp3, class Cmp4, class Cmp5, class Cmp6, class Cmp7, class Cmp8, class Cmp9>
|
||||
__device__ __forceinline__ void merge(const thrust::tuple<KP0, KP1, KP2, KP3, KP4, KP5, KP6, KP7, KP8, KP9>& skeys,
|
||||
const thrust::tuple<KR0, KR1, KR2, KR3, KR4, KR5, KR6, KR7, KR8, KR9>& key,
|
||||
const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& svals,
|
||||
const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
|
||||
const thrust::tuple<Cmp0, Cmp1, Cmp2, Cmp3, Cmp4, Cmp5, Cmp6, Cmp7, Cmp8, Cmp9>& cmp,
|
||||
unsigned int tid, unsigned int delta)
|
||||
{
|
||||
For<0, thrust::tuple_size<thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9> >::value>::merge(skeys, key, svals, val, cmp, tid, delta);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Generic
|
||||
|
||||
template <unsigned int N> struct Generic
|
||||
{
|
||||
template <class KP, class KR, class VP, class VR, class Cmp>
|
||||
static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp)
|
||||
{
|
||||
loadToSmem(skeys, key, tid);
|
||||
loadValsToSmem(svals, val, tid);
|
||||
if (N >= 32)
|
||||
__syncthreads();
|
||||
|
||||
if (N >= 2048)
|
||||
{
|
||||
if (tid < 1024)
|
||||
merge(skeys, key, svals, val, cmp, tid, 1024);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 1024)
|
||||
{
|
||||
if (tid < 512)
|
||||
merge(skeys, key, svals, val, cmp, tid, 512);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 512)
|
||||
{
|
||||
if (tid < 256)
|
||||
merge(skeys, key, svals, val, cmp, tid, 256);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 256)
|
||||
{
|
||||
if (tid < 128)
|
||||
merge(skeys, key, svals, val, cmp, tid, 128);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 128)
|
||||
{
|
||||
if (tid < 64)
|
||||
merge(skeys, key, svals, val, cmp, tid, 64);
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
if (N >= 64)
|
||||
{
|
||||
if (tid < 32)
|
||||
merge(skeys, key, svals, val, cmp, tid, 32);
|
||||
}
|
||||
|
||||
if (tid < 16)
|
||||
{
|
||||
merge(skeys, key, svals, val, cmp, tid, 16);
|
||||
merge(skeys, key, svals, val, cmp, tid, 8);
|
||||
merge(skeys, key, svals, val, cmp, tid, 4);
|
||||
merge(skeys, key, svals, val, cmp, tid, 2);
|
||||
merge(skeys, key, svals, val, cmp, tid, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int I, class KP, class KR, class VP, class VR, class Cmp>
|
||||
struct Unroll
|
||||
{
|
||||
static __device__ void loopShfl(KR key, VR val, Cmp cmp, unsigned int N)
|
||||
{
|
||||
mergeShfl(key, val, cmp, I, N);
|
||||
Unroll<I / 2, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, N);
|
||||
}
|
||||
static __device__ void loop(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp)
|
||||
{
|
||||
merge(skeys, key, svals, val, cmp, tid, I);
|
||||
Unroll<I / 2, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp);
|
||||
}
|
||||
};
|
||||
template <class KP, class KR, class VP, class VR, class Cmp>
|
||||
struct Unroll<0, KP, KR, VP, VR, Cmp>
|
||||
{
|
||||
static __device__ void loopShfl(KR, VR, Cmp, unsigned int)
|
||||
{
|
||||
}
|
||||
static __device__ void loop(KP, KR, VP, VR, unsigned int, Cmp)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N> struct WarpOptimized
|
||||
{
|
||||
template <class KP, class KR, class VP, class VR, class Cmp>
|
||||
static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp)
|
||||
{
|
||||
#if 0 // __CUDA_ARCH__ >= 300
|
||||
CV_UNUSED(skeys);
|
||||
CV_UNUSED(svals);
|
||||
CV_UNUSED(tid);
|
||||
|
||||
Unroll<N / 2, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, N);
|
||||
#else
|
||||
loadToSmem(skeys, key, tid);
|
||||
loadToSmem(svals, val, tid);
|
||||
|
||||
if (tid < N / 2)
|
||||
Unroll<N / 2, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int N> struct GenericOptimized32
|
||||
{
|
||||
enum { M = N / 32 };
|
||||
|
||||
template <class KP, class KR, class VP, class VR, class Cmp>
|
||||
static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp)
|
||||
{
|
||||
const unsigned int laneId = Warp::laneId();
|
||||
|
||||
#if 0 // __CUDA_ARCH__ >= 300
|
||||
Unroll<16, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, warpSize);
|
||||
|
||||
if (laneId == 0)
|
||||
{
|
||||
loadToSmem(skeys, key, tid / 32);
|
||||
loadToSmem(svals, val, tid / 32);
|
||||
}
|
||||
#else
|
||||
loadToSmem(skeys, key, tid);
|
||||
loadToSmem(svals, val, tid);
|
||||
|
||||
if (laneId < 16)
|
||||
Unroll<16, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp);
|
||||
|
||||
__syncthreads();
|
||||
|
||||
if (laneId == 0)
|
||||
{
|
||||
loadToSmem(skeys, key, tid / 32);
|
||||
loadToSmem(svals, val, tid / 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
__syncthreads();
|
||||
|
||||
loadFromSmem(skeys, key, tid);
|
||||
|
||||
if (tid < 32)
|
||||
{
|
||||
#if 0 // __CUDA_ARCH__ >= 300
|
||||
loadFromSmem(svals, val, tid);
|
||||
|
||||
Unroll<M / 2, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, M);
|
||||
#else
|
||||
Unroll<M / 2, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <bool val, class T1, class T2> struct StaticIf;
|
||||
template <class T1, class T2> struct StaticIf<true, T1, T2>
|
||||
{
|
||||
typedef T1 type;
|
||||
};
|
||||
template <class T1, class T2> struct StaticIf<false, T1, T2>
|
||||
{
|
||||
typedef T2 type;
|
||||
};
|
||||
|
||||
template <unsigned int N> struct IsPowerOf2
|
||||
{
|
||||
enum { value = ((N != 0) && !(N & (N - 1))) };
|
||||
};
|
||||
|
||||
template <unsigned int N> struct Dispatcher
|
||||
{
|
||||
typedef typename StaticIf<
|
||||
(N <= 32) && IsPowerOf2<N>::value,
|
||||
WarpOptimized<N>,
|
||||
typename StaticIf<
|
||||
(N <= 1024) && IsPowerOf2<N>::value,
|
||||
GenericOptimized32<N>,
|
||||
Generic<N>
|
||||
>::type
|
||||
>::type reductor;
|
||||
};
|
||||
}
|
||||
}}}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP
|
392
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/transform_detail.hpp
vendored
Normal file
392
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/transform_detail.hpp
vendored
Normal file
|
@ -0,0 +1,392 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_TRANSFORM_DETAIL_HPP
|
||||
#define OPENCV_CUDA_TRANSFORM_DETAIL_HPP
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../vec_traits.hpp"
|
||||
#include "../functional.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
namespace transform_detail
|
||||
{
|
||||
//! Read Write Traits
|
||||
|
||||
template <typename T, typename D, int shift> struct UnaryReadWriteTraits
|
||||
{
|
||||
typedef typename TypeVec<T, shift>::vec_type read_type;
|
||||
typedef typename TypeVec<D, shift>::vec_type write_type;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename D, int shift> struct BinaryReadWriteTraits
|
||||
{
|
||||
typedef typename TypeVec<T1, shift>::vec_type read_type1;
|
||||
typedef typename TypeVec<T2, shift>::vec_type read_type2;
|
||||
typedef typename TypeVec<D, shift>::vec_type write_type;
|
||||
};
|
||||
|
||||
//! Transform kernels
|
||||
|
||||
template <int shift> struct OpUnroller;
|
||||
template <> struct OpUnroller<1>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src.x);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src1.x, src2.x);
|
||||
}
|
||||
};
|
||||
template <> struct OpUnroller<2>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src.y);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src1.x, src2.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src1.y, src2.y);
|
||||
}
|
||||
};
|
||||
template <> struct OpUnroller<3>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src.y);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.z = op(src.z);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src1.x, src2.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src1.y, src2.y);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.z = op(src1.z, src2.z);
|
||||
}
|
||||
};
|
||||
template <> struct OpUnroller<4>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src.y);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.z = op(src.z);
|
||||
if (mask(y, x_shifted + 3))
|
||||
dst.w = op(src.w);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.x = op(src1.x, src2.x);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.y = op(src1.y, src2.y);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.z = op(src1.z, src2.z);
|
||||
if (mask(y, x_shifted + 3))
|
||||
dst.w = op(src1.w, src2.w);
|
||||
}
|
||||
};
|
||||
template <> struct OpUnroller<8>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.a0 = op(src.a0);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.a1 = op(src.a1);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.a2 = op(src.a2);
|
||||
if (mask(y, x_shifted + 3))
|
||||
dst.a3 = op(src.a3);
|
||||
if (mask(y, x_shifted + 4))
|
||||
dst.a4 = op(src.a4);
|
||||
if (mask(y, x_shifted + 5))
|
||||
dst.a5 = op(src.a5);
|
||||
if (mask(y, x_shifted + 6))
|
||||
dst.a6 = op(src.a6);
|
||||
if (mask(y, x_shifted + 7))
|
||||
dst.a7 = op(src.a7);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y)
|
||||
{
|
||||
if (mask(y, x_shifted))
|
||||
dst.a0 = op(src1.a0, src2.a0);
|
||||
if (mask(y, x_shifted + 1))
|
||||
dst.a1 = op(src1.a1, src2.a1);
|
||||
if (mask(y, x_shifted + 2))
|
||||
dst.a2 = op(src1.a2, src2.a2);
|
||||
if (mask(y, x_shifted + 3))
|
||||
dst.a3 = op(src1.a3, src2.a3);
|
||||
if (mask(y, x_shifted + 4))
|
||||
dst.a4 = op(src1.a4, src2.a4);
|
||||
if (mask(y, x_shifted + 5))
|
||||
dst.a5 = op(src1.a5, src2.a5);
|
||||
if (mask(y, x_shifted + 6))
|
||||
dst.a6 = op(src1.a6, src2.a6);
|
||||
if (mask(y, x_shifted + 7))
|
||||
dst.a7 = op(src1.a7, src2.a7);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static __global__ void transformSmart(const PtrStepSz<T> src_, PtrStep<D> dst_, const Mask mask, const UnOp op)
|
||||
{
|
||||
typedef TransformFunctorTraits<UnOp> ft;
|
||||
typedef typename UnaryReadWriteTraits<T, D, ft::smart_shift>::read_type read_type;
|
||||
typedef typename UnaryReadWriteTraits<T, D, ft::smart_shift>::write_type write_type;
|
||||
|
||||
const int x = threadIdx.x + blockIdx.x * blockDim.x;
|
||||
const int y = threadIdx.y + blockIdx.y * blockDim.y;
|
||||
const int x_shifted = x * ft::smart_shift;
|
||||
|
||||
if (y < src_.rows)
|
||||
{
|
||||
const T* src = src_.ptr(y);
|
||||
D* dst = dst_.ptr(y);
|
||||
|
||||
if (x_shifted + ft::smart_shift - 1 < src_.cols)
|
||||
{
|
||||
const read_type src_n_el = ((const read_type*)src)[x];
|
||||
OpUnroller<ft::smart_shift>::unroll(src_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int real_x = x_shifted; real_x < src_.cols; ++real_x)
|
||||
{
|
||||
if (mask(y, real_x))
|
||||
dst[real_x] = op(src[real_x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
__global__ static void transformSimple(const PtrStepSz<T> src, PtrStep<D> dst, const Mask mask, const UnOp op)
|
||||
{
|
||||
const int x = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
const int y = blockDim.y * blockIdx.y + threadIdx.y;
|
||||
|
||||
if (x < src.cols && y < src.rows && mask(y, x))
|
||||
{
|
||||
dst.ptr(y)[x] = op(src.ptr(y)[x]);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __global__ void transformSmart(const PtrStepSz<T1> src1_, const PtrStep<T2> src2_, PtrStep<D> dst_,
|
||||
const Mask mask, const BinOp op)
|
||||
{
|
||||
typedef TransformFunctorTraits<BinOp> ft;
|
||||
typedef typename BinaryReadWriteTraits<T1, T2, D, ft::smart_shift>::read_type1 read_type1;
|
||||
typedef typename BinaryReadWriteTraits<T1, T2, D, ft::smart_shift>::read_type2 read_type2;
|
||||
typedef typename BinaryReadWriteTraits<T1, T2, D, ft::smart_shift>::write_type write_type;
|
||||
|
||||
const int x = threadIdx.x + blockIdx.x * blockDim.x;
|
||||
const int y = threadIdx.y + blockIdx.y * blockDim.y;
|
||||
const int x_shifted = x * ft::smart_shift;
|
||||
|
||||
if (y < src1_.rows)
|
||||
{
|
||||
const T1* src1 = src1_.ptr(y);
|
||||
const T2* src2 = src2_.ptr(y);
|
||||
D* dst = dst_.ptr(y);
|
||||
|
||||
if (x_shifted + ft::smart_shift - 1 < src1_.cols)
|
||||
{
|
||||
const read_type1 src1_n_el = ((const read_type1*)src1)[x];
|
||||
const read_type2 src2_n_el = ((const read_type2*)src2)[x];
|
||||
|
||||
OpUnroller<ft::smart_shift>::unroll(src1_n_el, src2_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int real_x = x_shifted; real_x < src1_.cols; ++real_x)
|
||||
{
|
||||
if (mask(y, real_x))
|
||||
dst[real_x] = op(src1[real_x], src2[real_x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static __global__ void transformSimple(const PtrStepSz<T1> src1, const PtrStep<T2> src2, PtrStep<D> dst,
|
||||
const Mask mask, const BinOp op)
|
||||
{
|
||||
const int x = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
const int y = blockDim.y * blockIdx.y + threadIdx.y;
|
||||
|
||||
if (x < src1.cols && y < src1.rows && mask(y, x))
|
||||
{
|
||||
const T1 src1_data = src1.ptr(y)[x];
|
||||
const T2 src2_data = src2.ptr(y)[x];
|
||||
dst.ptr(y)[x] = op(src1_data, src2_data);
|
||||
}
|
||||
}
|
||||
|
||||
template <bool UseSmart> struct TransformDispatcher;
|
||||
template<> struct TransformDispatcher<false>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static void call(PtrStepSz<T> src, PtrStepSz<D> dst, UnOp op, Mask mask, cudaStream_t stream)
|
||||
{
|
||||
typedef TransformFunctorTraits<UnOp> ft;
|
||||
|
||||
const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1);
|
||||
const dim3 grid(divUp(src.cols, threads.x), divUp(src.rows, threads.y), 1);
|
||||
|
||||
transformSimple<T, D><<<grid, threads, 0, stream>>>(src, dst, mask, op);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static void call(PtrStepSz<T1> src1, PtrStepSz<T2> src2, PtrStepSz<D> dst, BinOp op, Mask mask, cudaStream_t stream)
|
||||
{
|
||||
typedef TransformFunctorTraits<BinOp> ft;
|
||||
|
||||
const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1);
|
||||
const dim3 grid(divUp(src1.cols, threads.x), divUp(src1.rows, threads.y), 1);
|
||||
|
||||
transformSimple<T1, T2, D><<<grid, threads, 0, stream>>>(src1, src2, dst, mask, op);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
};
|
||||
template<> struct TransformDispatcher<true>
|
||||
{
|
||||
template <typename T, typename D, typename UnOp, typename Mask>
|
||||
static void call(PtrStepSz<T> src, PtrStepSz<D> dst, UnOp op, Mask mask, cudaStream_t stream)
|
||||
{
|
||||
typedef TransformFunctorTraits<UnOp> ft;
|
||||
|
||||
CV_StaticAssert(ft::smart_shift != 1, "");
|
||||
|
||||
if (!isAligned(src.data, ft::smart_shift * sizeof(T)) || !isAligned(src.step, ft::smart_shift * sizeof(T)) ||
|
||||
!isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D)))
|
||||
{
|
||||
TransformDispatcher<false>::call(src, dst, op, mask, stream);
|
||||
return;
|
||||
}
|
||||
|
||||
const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1);
|
||||
const dim3 grid(divUp(src.cols, threads.x * ft::smart_shift), divUp(src.rows, threads.y), 1);
|
||||
|
||||
transformSmart<T, D><<<grid, threads, 0, stream>>>(src, dst, mask, op);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
|
||||
static void call(PtrStepSz<T1> src1, PtrStepSz<T2> src2, PtrStepSz<D> dst, BinOp op, Mask mask, cudaStream_t stream)
|
||||
{
|
||||
typedef TransformFunctorTraits<BinOp> ft;
|
||||
|
||||
CV_StaticAssert(ft::smart_shift != 1, "");
|
||||
|
||||
if (!isAligned(src1.data, ft::smart_shift * sizeof(T1)) || !isAligned(src1.step, ft::smart_shift * sizeof(T1)) ||
|
||||
!isAligned(src2.data, ft::smart_shift * sizeof(T2)) || !isAligned(src2.step, ft::smart_shift * sizeof(T2)) ||
|
||||
!isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D)))
|
||||
{
|
||||
TransformDispatcher<false>::call(src1, src2, dst, op, mask, stream);
|
||||
return;
|
||||
}
|
||||
|
||||
const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1);
|
||||
const dim3 grid(divUp(src1.cols, threads.x * ft::smart_shift), divUp(src1.rows, threads.y), 1);
|
||||
|
||||
transformSmart<T1, T2, D><<<grid, threads, 0, stream>>>(src1, src2, dst, mask, op);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
};
|
||||
} // namespace transform_detail
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_TRANSFORM_DETAIL_HPP
|
191
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/type_traits_detail.hpp
vendored
Normal file
191
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/type_traits_detail.hpp
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP
|
||||
#define OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../vec_traits.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
namespace type_traits_detail
|
||||
{
|
||||
template <bool, typename T1, typename T2> struct Select { typedef T1 type; };
|
||||
template <typename T1, typename T2> struct Select<false, T1, T2> { typedef T2 type; };
|
||||
|
||||
template <typename T> struct IsSignedIntergral { enum {value = 0}; };
|
||||
template <> struct IsSignedIntergral<schar> { enum {value = 1}; };
|
||||
template <> struct IsSignedIntergral<char1> { enum {value = 1}; };
|
||||
template <> struct IsSignedIntergral<short> { enum {value = 1}; };
|
||||
template <> struct IsSignedIntergral<short1> { enum {value = 1}; };
|
||||
template <> struct IsSignedIntergral<int> { enum {value = 1}; };
|
||||
template <> struct IsSignedIntergral<int1> { enum {value = 1}; };
|
||||
|
||||
template <typename T> struct IsUnsignedIntegral { enum {value = 0}; };
|
||||
template <> struct IsUnsignedIntegral<uchar> { enum {value = 1}; };
|
||||
template <> struct IsUnsignedIntegral<uchar1> { enum {value = 1}; };
|
||||
template <> struct IsUnsignedIntegral<ushort> { enum {value = 1}; };
|
||||
template <> struct IsUnsignedIntegral<ushort1> { enum {value = 1}; };
|
||||
template <> struct IsUnsignedIntegral<uint> { enum {value = 1}; };
|
||||
template <> struct IsUnsignedIntegral<uint1> { enum {value = 1}; };
|
||||
|
||||
template <typename T> struct IsIntegral { enum {value = IsSignedIntergral<T>::value || IsUnsignedIntegral<T>::value}; };
|
||||
template <> struct IsIntegral<char> { enum {value = 1}; };
|
||||
template <> struct IsIntegral<bool> { enum {value = 1}; };
|
||||
|
||||
template <typename T> struct IsFloat { enum {value = 0}; };
|
||||
template <> struct IsFloat<float> { enum {value = 1}; };
|
||||
template <> struct IsFloat<double> { enum {value = 1}; };
|
||||
|
||||
template <typename T> struct IsVec { enum {value = 0}; };
|
||||
template <> struct IsVec<uchar1> { enum {value = 1}; };
|
||||
template <> struct IsVec<uchar2> { enum {value = 1}; };
|
||||
template <> struct IsVec<uchar3> { enum {value = 1}; };
|
||||
template <> struct IsVec<uchar4> { enum {value = 1}; };
|
||||
template <> struct IsVec<uchar8> { enum {value = 1}; };
|
||||
template <> struct IsVec<char1> { enum {value = 1}; };
|
||||
template <> struct IsVec<char2> { enum {value = 1}; };
|
||||
template <> struct IsVec<char3> { enum {value = 1}; };
|
||||
template <> struct IsVec<char4> { enum {value = 1}; };
|
||||
template <> struct IsVec<char8> { enum {value = 1}; };
|
||||
template <> struct IsVec<ushort1> { enum {value = 1}; };
|
||||
template <> struct IsVec<ushort2> { enum {value = 1}; };
|
||||
template <> struct IsVec<ushort3> { enum {value = 1}; };
|
||||
template <> struct IsVec<ushort4> { enum {value = 1}; };
|
||||
template <> struct IsVec<ushort8> { enum {value = 1}; };
|
||||
template <> struct IsVec<short1> { enum {value = 1}; };
|
||||
template <> struct IsVec<short2> { enum {value = 1}; };
|
||||
template <> struct IsVec<short3> { enum {value = 1}; };
|
||||
template <> struct IsVec<short4> { enum {value = 1}; };
|
||||
template <> struct IsVec<short8> { enum {value = 1}; };
|
||||
template <> struct IsVec<uint1> { enum {value = 1}; };
|
||||
template <> struct IsVec<uint2> { enum {value = 1}; };
|
||||
template <> struct IsVec<uint3> { enum {value = 1}; };
|
||||
template <> struct IsVec<uint4> { enum {value = 1}; };
|
||||
template <> struct IsVec<uint8> { enum {value = 1}; };
|
||||
template <> struct IsVec<int1> { enum {value = 1}; };
|
||||
template <> struct IsVec<int2> { enum {value = 1}; };
|
||||
template <> struct IsVec<int3> { enum {value = 1}; };
|
||||
template <> struct IsVec<int4> { enum {value = 1}; };
|
||||
template <> struct IsVec<int8> { enum {value = 1}; };
|
||||
template <> struct IsVec<float1> { enum {value = 1}; };
|
||||
template <> struct IsVec<float2> { enum {value = 1}; };
|
||||
template <> struct IsVec<float3> { enum {value = 1}; };
|
||||
template <> struct IsVec<float4> { enum {value = 1}; };
|
||||
template <> struct IsVec<float8> { enum {value = 1}; };
|
||||
template <> struct IsVec<double1> { enum {value = 1}; };
|
||||
template <> struct IsVec<double2> { enum {value = 1}; };
|
||||
template <> struct IsVec<double3> { enum {value = 1}; };
|
||||
template <> struct IsVec<double4> { enum {value = 1}; };
|
||||
template <> struct IsVec<double8> { enum {value = 1}; };
|
||||
|
||||
template <class U> struct AddParameterType { typedef const U& type; };
|
||||
template <class U> struct AddParameterType<U&> { typedef U& type; };
|
||||
template <> struct AddParameterType<void> { typedef void type; };
|
||||
|
||||
template <class U> struct ReferenceTraits
|
||||
{
|
||||
enum { value = false };
|
||||
typedef U type;
|
||||
};
|
||||
template <class U> struct ReferenceTraits<U&>
|
||||
{
|
||||
enum { value = true };
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template <class U> struct PointerTraits
|
||||
{
|
||||
enum { value = false };
|
||||
typedef void type;
|
||||
};
|
||||
template <class U> struct PointerTraits<U*>
|
||||
{
|
||||
enum { value = true };
|
||||
typedef U type;
|
||||
};
|
||||
template <class U> struct PointerTraits<U*&>
|
||||
{
|
||||
enum { value = true };
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template <class U> struct UnConst
|
||||
{
|
||||
typedef U type;
|
||||
enum { value = 0 };
|
||||
};
|
||||
template <class U> struct UnConst<const U>
|
||||
{
|
||||
typedef U type;
|
||||
enum { value = 1 };
|
||||
};
|
||||
template <class U> struct UnConst<const U&>
|
||||
{
|
||||
typedef U& type;
|
||||
enum { value = 1 };
|
||||
};
|
||||
|
||||
template <class U> struct UnVolatile
|
||||
{
|
||||
typedef U type;
|
||||
enum { value = 0 };
|
||||
};
|
||||
template <class U> struct UnVolatile<volatile U>
|
||||
{
|
||||
typedef U type;
|
||||
enum { value = 1 };
|
||||
};
|
||||
template <class U> struct UnVolatile<volatile U&>
|
||||
{
|
||||
typedef U& type;
|
||||
enum { value = 1 };
|
||||
};
|
||||
} // namespace type_traits_detail
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP
|
121
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/vec_distance_detail.hpp
vendored
Normal file
121
third_party/opencv/uos/sw_64/include/opencv2/core/cuda/detail/vec_distance_detail.hpp
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP
|
||||
#define OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP
|
||||
|
||||
#include "../datamov_utils.hpp"
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
namespace vec_distance_detail
|
||||
{
|
||||
template <int THREAD_DIM, int N> struct UnrollVecDiffCached
|
||||
{
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ void calcCheck(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int ind)
|
||||
{
|
||||
if (ind < len)
|
||||
{
|
||||
T1 val1 = *vecCached++;
|
||||
|
||||
T2 val2;
|
||||
ForceGlob<T2>::Load(vecGlob, ind, val2);
|
||||
|
||||
dist.reduceIter(val1, val2);
|
||||
|
||||
UnrollVecDiffCached<THREAD_DIM, N - 1>::calcCheck(vecCached, vecGlob, len, dist, ind + THREAD_DIM);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ void calcWithoutCheck(const T1* vecCached, const T2* vecGlob, Dist& dist)
|
||||
{
|
||||
T1 val1 = *vecCached++;
|
||||
|
||||
T2 val2;
|
||||
ForceGlob<T2>::Load(vecGlob, 0, val2);
|
||||
vecGlob += THREAD_DIM;
|
||||
|
||||
dist.reduceIter(val1, val2);
|
||||
|
||||
UnrollVecDiffCached<THREAD_DIM, N - 1>::calcWithoutCheck(vecCached, vecGlob, dist);
|
||||
}
|
||||
};
|
||||
template <int THREAD_DIM> struct UnrollVecDiffCached<THREAD_DIM, 0>
|
||||
{
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ __forceinline__ void calcCheck(const T1*, const T2*, int, Dist&, int)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ __forceinline__ void calcWithoutCheck(const T1*, const T2*, Dist&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <int THREAD_DIM, int MAX_LEN, bool LEN_EQ_MAX_LEN> struct VecDiffCachedCalculator;
|
||||
template <int THREAD_DIM, int MAX_LEN> struct VecDiffCachedCalculator<THREAD_DIM, MAX_LEN, false>
|
||||
{
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid)
|
||||
{
|
||||
UnrollVecDiffCached<THREAD_DIM, MAX_LEN / THREAD_DIM>::calcCheck(vecCached, vecGlob, len, dist, tid);
|
||||
}
|
||||
};
|
||||
template <int THREAD_DIM, int MAX_LEN> struct VecDiffCachedCalculator<THREAD_DIM, MAX_LEN, true>
|
||||
{
|
||||
template <typename Dist, typename T1, typename T2>
|
||||
static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid)
|
||||
{
|
||||
UnrollVecDiffCached<THREAD_DIM, MAX_LEN / THREAD_DIM>::calcWithoutCheck(vecCached, vecGlob + tid, dist);
|
||||
}
|
||||
};
|
||||
} // namespace vec_distance_detail
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP
|
|
@ -0,0 +1,88 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_DYNAMIC_SMEM_HPP
|
||||
#define OPENCV_CUDA_DYNAMIC_SMEM_HPP
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
template<class T> struct DynamicSharedMem
|
||||
{
|
||||
__device__ __forceinline__ operator T*()
|
||||
{
|
||||
extern __shared__ int __smem[];
|
||||
return (T*)__smem;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ operator const T*() const
|
||||
{
|
||||
extern __shared__ int __smem[];
|
||||
return (T*)__smem;
|
||||
}
|
||||
};
|
||||
|
||||
// specialize for double to avoid unaligned memory access compile errors
|
||||
template<> struct DynamicSharedMem<double>
|
||||
{
|
||||
__device__ __forceinline__ operator double*()
|
||||
{
|
||||
extern __shared__ double __smem_d[];
|
||||
return (double*)__smem_d;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ operator const double*() const
|
||||
{
|
||||
extern __shared__ double __smem_d[];
|
||||
return (double*)__smem_d;
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_DYNAMIC_SMEM_HPP
|
|
@ -0,0 +1,269 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_EMULATION_HPP_
|
||||
#define OPENCV_CUDA_EMULATION_HPP_
|
||||
|
||||
#include "common.hpp"
|
||||
#include "warp_reduce.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
struct Emulation
|
||||
{
|
||||
|
||||
static __device__ __forceinline__ int syncthreadsOr(int pred)
|
||||
{
|
||||
#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
|
||||
// just campilation stab
|
||||
return 0;
|
||||
#else
|
||||
return __syncthreads_or(pred);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<int CTA_SIZE>
|
||||
static __forceinline__ __device__ int Ballot(int predicate)
|
||||
{
|
||||
#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200)
|
||||
return __ballot(predicate);
|
||||
#else
|
||||
__shared__ volatile int cta_buffer[CTA_SIZE];
|
||||
|
||||
int tid = threadIdx.x;
|
||||
cta_buffer[tid] = predicate ? (1 << (tid & 31)) : 0;
|
||||
return warp_reduce(cta_buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct smem
|
||||
{
|
||||
enum { TAG_MASK = (1U << ( (sizeof(unsigned int) << 3) - 5U)) - 1U };
|
||||
|
||||
template<typename T>
|
||||
static __device__ __forceinline__ T atomicInc(T* address, T val)
|
||||
{
|
||||
#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120)
|
||||
T count;
|
||||
unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U);
|
||||
do
|
||||
{
|
||||
count = *address & TAG_MASK;
|
||||
count = tag | (count + 1);
|
||||
*address = count;
|
||||
} while (*address != count);
|
||||
|
||||
return (count & TAG_MASK) - 1;
|
||||
#else
|
||||
return ::atomicInc(address, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static __device__ __forceinline__ T atomicAdd(T* address, T val)
|
||||
{
|
||||
#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120)
|
||||
T count;
|
||||
unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U);
|
||||
do
|
||||
{
|
||||
count = *address & TAG_MASK;
|
||||
count = tag | (count + val);
|
||||
*address = count;
|
||||
} while (*address != count);
|
||||
|
||||
return (count & TAG_MASK) - val;
|
||||
#else
|
||||
return ::atomicAdd(address, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static __device__ __forceinline__ T atomicMin(T* address, T val)
|
||||
{
|
||||
#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120)
|
||||
T count = ::min(*address, val);
|
||||
do
|
||||
{
|
||||
*address = count;
|
||||
} while (*address > count);
|
||||
|
||||
return count;
|
||||
#else
|
||||
return ::atomicMin(address, val);
|
||||
#endif
|
||||
}
|
||||
}; // struct cmem
|
||||
|
||||
struct glob
|
||||
{
|
||||
static __device__ __forceinline__ int atomicAdd(int* address, int val)
|
||||
{
|
||||
return ::atomicAdd(address, val);
|
||||
}
|
||||
static __device__ __forceinline__ unsigned int atomicAdd(unsigned int* address, unsigned int val)
|
||||
{
|
||||
return ::atomicAdd(address, val);
|
||||
}
|
||||
static __device__ __forceinline__ float atomicAdd(float* address, float val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 200
|
||||
return ::atomicAdd(address, val);
|
||||
#else
|
||||
int* address_as_i = (int*) address;
|
||||
int old = *address_as_i, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_i, assumed,
|
||||
__float_as_int(val + __int_as_float(assumed)));
|
||||
} while (assumed != old);
|
||||
return __int_as_float(old);
|
||||
#endif
|
||||
}
|
||||
static __device__ __forceinline__ double atomicAdd(double* address, double val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 130
|
||||
unsigned long long int* address_as_ull = (unsigned long long int*) address;
|
||||
unsigned long long int old = *address_as_ull, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_ull, assumed,
|
||||
__double_as_longlong(val + __longlong_as_double(assumed)));
|
||||
} while (assumed != old);
|
||||
return __longlong_as_double(old);
|
||||
#else
|
||||
CV_UNUSED(address);
|
||||
CV_UNUSED(val);
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ int atomicMin(int* address, int val)
|
||||
{
|
||||
return ::atomicMin(address, val);
|
||||
}
|
||||
static __device__ __forceinline__ float atomicMin(float* address, float val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 120
|
||||
int* address_as_i = (int*) address;
|
||||
int old = *address_as_i, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_i, assumed,
|
||||
__float_as_int(::fminf(val, __int_as_float(assumed))));
|
||||
} while (assumed != old);
|
||||
return __int_as_float(old);
|
||||
#else
|
||||
CV_UNUSED(address);
|
||||
CV_UNUSED(val);
|
||||
return 0.0f;
|
||||
#endif
|
||||
}
|
||||
static __device__ __forceinline__ double atomicMin(double* address, double val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 130
|
||||
unsigned long long int* address_as_ull = (unsigned long long int*) address;
|
||||
unsigned long long int old = *address_as_ull, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_ull, assumed,
|
||||
__double_as_longlong(::fmin(val, __longlong_as_double(assumed))));
|
||||
} while (assumed != old);
|
||||
return __longlong_as_double(old);
|
||||
#else
|
||||
CV_UNUSED(address);
|
||||
CV_UNUSED(val);
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ int atomicMax(int* address, int val)
|
||||
{
|
||||
return ::atomicMax(address, val);
|
||||
}
|
||||
static __device__ __forceinline__ float atomicMax(float* address, float val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 120
|
||||
int* address_as_i = (int*) address;
|
||||
int old = *address_as_i, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_i, assumed,
|
||||
__float_as_int(::fmaxf(val, __int_as_float(assumed))));
|
||||
} while (assumed != old);
|
||||
return __int_as_float(old);
|
||||
#else
|
||||
CV_UNUSED(address);
|
||||
CV_UNUSED(val);
|
||||
return 0.0f;
|
||||
#endif
|
||||
}
|
||||
static __device__ __forceinline__ double atomicMax(double* address, double val)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 130
|
||||
unsigned long long int* address_as_ull = (unsigned long long int*) address;
|
||||
unsigned long long int old = *address_as_ull, assumed;
|
||||
do {
|
||||
assumed = old;
|
||||
old = ::atomicCAS(address_as_ull, assumed,
|
||||
__double_as_longlong(::fmax(val, __longlong_as_double(assumed))));
|
||||
} while (assumed != old);
|
||||
return __longlong_as_double(old);
|
||||
#else
|
||||
CV_UNUSED(address);
|
||||
CV_UNUSED(val);
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}; //struct Emulation
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif /* OPENCV_CUDA_EMULATION_HPP_ */
|
|
@ -0,0 +1,286 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_FILTERS_HPP
|
||||
#define OPENCV_CUDA_FILTERS_HPP
|
||||
|
||||
#include "saturate_cast.hpp"
|
||||
#include "vec_traits.hpp"
|
||||
#include "vec_math.hpp"
|
||||
#include "type_traits.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
template <typename Ptr2D> struct PointFilter
|
||||
{
|
||||
typedef typename Ptr2D::elem_type elem_type;
|
||||
typedef float index_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ PointFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f)
|
||||
: src(src_)
|
||||
{
|
||||
CV_UNUSED(fx);
|
||||
CV_UNUSED(fy);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ elem_type operator ()(float y, float x) const
|
||||
{
|
||||
return src(__float2int_rz(y), __float2int_rz(x));
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
};
|
||||
|
||||
template <typename Ptr2D> struct LinearFilter
|
||||
{
|
||||
typedef typename Ptr2D::elem_type elem_type;
|
||||
typedef float index_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ LinearFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f)
|
||||
: src(src_)
|
||||
{
|
||||
CV_UNUSED(fx);
|
||||
CV_UNUSED(fy);
|
||||
}
|
||||
__device__ __forceinline__ elem_type operator ()(float y, float x) const
|
||||
{
|
||||
typedef typename TypeVec<float, VecTraits<elem_type>::cn>::vec_type work_type;
|
||||
|
||||
work_type out = VecTraits<work_type>::all(0);
|
||||
|
||||
const int x1 = __float2int_rd(x);
|
||||
const int y1 = __float2int_rd(y);
|
||||
const int x2 = x1 + 1;
|
||||
const int y2 = y1 + 1;
|
||||
|
||||
elem_type src_reg = src(y1, x1);
|
||||
out = out + src_reg * ((x2 - x) * (y2 - y));
|
||||
|
||||
src_reg = src(y1, x2);
|
||||
out = out + src_reg * ((x - x1) * (y2 - y));
|
||||
|
||||
src_reg = src(y2, x1);
|
||||
out = out + src_reg * ((x2 - x) * (y - y1));
|
||||
|
||||
src_reg = src(y2, x2);
|
||||
out = out + src_reg * ((x - x1) * (y - y1));
|
||||
|
||||
return saturate_cast<elem_type>(out);
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
};
|
||||
|
||||
template <typename Ptr2D> struct CubicFilter
|
||||
{
|
||||
typedef typename Ptr2D::elem_type elem_type;
|
||||
typedef float index_type;
|
||||
typedef typename TypeVec<float, VecTraits<elem_type>::cn>::vec_type work_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ CubicFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f)
|
||||
: src(src_)
|
||||
{
|
||||
CV_UNUSED(fx);
|
||||
CV_UNUSED(fy);
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ float bicubicCoeff(float x_)
|
||||
{
|
||||
float x = fabsf(x_);
|
||||
if (x <= 1.0f)
|
||||
{
|
||||
return x * x * (1.5f * x - 2.5f) + 1.0f;
|
||||
}
|
||||
else if (x < 2.0f)
|
||||
{
|
||||
return x * (x * (-0.5f * x + 2.5f) - 4.0f) + 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
__device__ elem_type operator ()(float y, float x) const
|
||||
{
|
||||
const float xmin = ::ceilf(x - 2.0f);
|
||||
const float xmax = ::floorf(x + 2.0f);
|
||||
|
||||
const float ymin = ::ceilf(y - 2.0f);
|
||||
const float ymax = ::floorf(y + 2.0f);
|
||||
|
||||
work_type sum = VecTraits<work_type>::all(0);
|
||||
float wsum = 0.0f;
|
||||
|
||||
for (float cy = ymin; cy <= ymax; cy += 1.0f)
|
||||
{
|
||||
for (float cx = xmin; cx <= xmax; cx += 1.0f)
|
||||
{
|
||||
const float w = bicubicCoeff(x - cx) * bicubicCoeff(y - cy);
|
||||
sum = sum + w * src(__float2int_rd(cy), __float2int_rd(cx));
|
||||
wsum += w;
|
||||
}
|
||||
}
|
||||
|
||||
work_type res = (!wsum)? VecTraits<work_type>::all(0) : sum / wsum;
|
||||
|
||||
return saturate_cast<elem_type>(res);
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
};
|
||||
// for integer scaling
|
||||
template <typename Ptr2D> struct IntegerAreaFilter
|
||||
{
|
||||
typedef typename Ptr2D::elem_type elem_type;
|
||||
typedef float index_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ IntegerAreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_)
|
||||
: src(src_), scale_x(scale_x_), scale_y(scale_y_), scale(1.f / (scale_x * scale_y)) {}
|
||||
|
||||
__device__ __forceinline__ elem_type operator ()(float y, float x) const
|
||||
{
|
||||
float fsx1 = x * scale_x;
|
||||
float fsx2 = fsx1 + scale_x;
|
||||
|
||||
int sx1 = __float2int_ru(fsx1);
|
||||
int sx2 = __float2int_rd(fsx2);
|
||||
|
||||
float fsy1 = y * scale_y;
|
||||
float fsy2 = fsy1 + scale_y;
|
||||
|
||||
int sy1 = __float2int_ru(fsy1);
|
||||
int sy2 = __float2int_rd(fsy2);
|
||||
|
||||
typedef typename TypeVec<float, VecTraits<elem_type>::cn>::vec_type work_type;
|
||||
work_type out = VecTraits<work_type>::all(0.f);
|
||||
|
||||
for(int dy = sy1; dy < sy2; ++dy)
|
||||
for(int dx = sx1; dx < sx2; ++dx)
|
||||
{
|
||||
out = out + src(dy, dx) * scale;
|
||||
}
|
||||
|
||||
return saturate_cast<elem_type>(out);
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
float scale_x, scale_y ,scale;
|
||||
};
|
||||
|
||||
template <typename Ptr2D> struct AreaFilter
|
||||
{
|
||||
typedef typename Ptr2D::elem_type elem_type;
|
||||
typedef float index_type;
|
||||
|
||||
explicit __host__ __device__ __forceinline__ AreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_)
|
||||
: src(src_), scale_x(scale_x_), scale_y(scale_y_){}
|
||||
|
||||
__device__ __forceinline__ elem_type operator ()(float y, float x) const
|
||||
{
|
||||
float fsx1 = x * scale_x;
|
||||
float fsx2 = fsx1 + scale_x;
|
||||
|
||||
int sx1 = __float2int_ru(fsx1);
|
||||
int sx2 = __float2int_rd(fsx2);
|
||||
|
||||
float fsy1 = y * scale_y;
|
||||
float fsy2 = fsy1 + scale_y;
|
||||
|
||||
int sy1 = __float2int_ru(fsy1);
|
||||
int sy2 = __float2int_rd(fsy2);
|
||||
|
||||
float scale = 1.f / (fminf(scale_x, src.width - fsx1) * fminf(scale_y, src.height - fsy1));
|
||||
|
||||
typedef typename TypeVec<float, VecTraits<elem_type>::cn>::vec_type work_type;
|
||||
work_type out = VecTraits<work_type>::all(0.f);
|
||||
|
||||
for (int dy = sy1; dy < sy2; ++dy)
|
||||
{
|
||||
for (int dx = sx1; dx < sx2; ++dx)
|
||||
out = out + src(dy, dx) * scale;
|
||||
|
||||
if (sx1 > fsx1)
|
||||
out = out + src(dy, (sx1 -1) ) * ((sx1 - fsx1) * scale);
|
||||
|
||||
if (sx2 < fsx2)
|
||||
out = out + src(dy, sx2) * ((fsx2 -sx2) * scale);
|
||||
}
|
||||
|
||||
if (sy1 > fsy1)
|
||||
for (int dx = sx1; dx < sx2; ++dx)
|
||||
out = out + src( (sy1 - 1) , dx) * ((sy1 -fsy1) * scale);
|
||||
|
||||
if (sy2 < fsy2)
|
||||
for (int dx = sx1; dx < sx2; ++dx)
|
||||
out = out + src(sy2, dx) * ((fsy2 -sy2) * scale);
|
||||
|
||||
if ((sy1 > fsy1) && (sx1 > fsx1))
|
||||
out = out + src( (sy1 - 1) , (sx1 - 1)) * ((sy1 -fsy1) * (sx1 -fsx1) * scale);
|
||||
|
||||
if ((sy1 > fsy1) && (sx2 < fsx2))
|
||||
out = out + src( (sy1 - 1) , sx2) * ((sy1 -fsy1) * (fsx2 -sx2) * scale);
|
||||
|
||||
if ((sy2 < fsy2) && (sx2 < fsx2))
|
||||
out = out + src(sy2, sx2) * ((fsy2 -sy2) * (fsx2 -sx2) * scale);
|
||||
|
||||
if ((sy2 < fsy2) && (sx1 > fsx1))
|
||||
out = out + src(sy2, (sx1 - 1)) * ((fsy2 -sy2) * (sx1 -fsx1) * scale);
|
||||
|
||||
return saturate_cast<elem_type>(out);
|
||||
}
|
||||
|
||||
Ptr2D src;
|
||||
float scale_x, scale_y;
|
||||
int width, haight;
|
||||
};
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_FILTERS_HPP
|
|
@ -0,0 +1,79 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP
|
||||
#define OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
template<class Func>
|
||||
void printFuncAttrib(Func& func)
|
||||
{
|
||||
|
||||
cudaFuncAttributes attrs;
|
||||
cudaFuncGetAttributes(&attrs, func);
|
||||
|
||||
printf("=== Function stats ===\n");
|
||||
printf("Name: \n");
|
||||
printf("sharedSizeBytes = %d\n", attrs.sharedSizeBytes);
|
||||
printf("constSizeBytes = %d\n", attrs.constSizeBytes);
|
||||
printf("localSizeBytes = %d\n", attrs.localSizeBytes);
|
||||
printf("maxThreadsPerBlock = %d\n", attrs.maxThreadsPerBlock);
|
||||
printf("numRegs = %d\n", attrs.numRegs);
|
||||
printf("ptxVersion = %d\n", attrs.ptxVersion);
|
||||
printf("binaryVersion = %d\n", attrs.binaryVersion);
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif /* OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP */
|
|
@ -0,0 +1,810 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_FUNCTIONAL_HPP
|
||||
#define OPENCV_CUDA_FUNCTIONAL_HPP
|
||||
|
||||
#include <functional>
|
||||
#include "saturate_cast.hpp"
|
||||
#include "vec_traits.hpp"
|
||||
#include "type_traits.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
// Function Objects
|
||||
#ifdef CV_CXX11
|
||||
template<typename Argument, typename Result> struct unary_function
|
||||
{
|
||||
typedef Argument argument_type;
|
||||
typedef Result result_type;
|
||||
};
|
||||
template<typename Argument1, typename Argument2, typename Result> struct binary_function
|
||||
{
|
||||
typedef Argument1 first_argument_type;
|
||||
typedef Argument2 second_argument_type;
|
||||
typedef Result result_type;
|
||||
};
|
||||
#else
|
||||
template<typename Argument, typename Result> struct unary_function : public std::unary_function<Argument, Result> {};
|
||||
template<typename Argument1, typename Argument2, typename Result> struct binary_function : public std::binary_function<Argument1, Argument2, Result> {};
|
||||
#endif
|
||||
|
||||
// Arithmetic Operations
|
||||
template <typename T> struct plus : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ plus() {}
|
||||
__host__ __device__ __forceinline__ plus(const plus&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct minus : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ minus() {}
|
||||
__host__ __device__ __forceinline__ minus(const minus&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct multiplies : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ multiplies() {}
|
||||
__host__ __device__ __forceinline__ multiplies(const multiplies&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct divides : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ divides() {}
|
||||
__host__ __device__ __forceinline__ divides(const divides&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct modulus : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a % b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ modulus() {}
|
||||
__host__ __device__ __forceinline__ modulus(const modulus&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct negate : unary_function<T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a) const
|
||||
{
|
||||
return -a;
|
||||
}
|
||||
__host__ __device__ __forceinline__ negate() {}
|
||||
__host__ __device__ __forceinline__ negate(const negate&) {}
|
||||
};
|
||||
|
||||
// Comparison Operations
|
||||
template <typename T> struct equal_to : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ equal_to() {}
|
||||
__host__ __device__ __forceinline__ equal_to(const equal_to&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct not_equal_to : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a != b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ not_equal_to() {}
|
||||
__host__ __device__ __forceinline__ not_equal_to(const not_equal_to&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct greater : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ greater() {}
|
||||
__host__ __device__ __forceinline__ greater(const greater&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct less : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ less() {}
|
||||
__host__ __device__ __forceinline__ less(const less&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct greater_equal : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a >= b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ greater_equal() {}
|
||||
__host__ __device__ __forceinline__ greater_equal(const greater_equal&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct less_equal : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a <= b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ less_equal() {}
|
||||
__host__ __device__ __forceinline__ less_equal(const less_equal&) {}
|
||||
};
|
||||
|
||||
// Logical Operations
|
||||
template <typename T> struct logical_and : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a && b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ logical_and() {}
|
||||
__host__ __device__ __forceinline__ logical_and(const logical_and&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct logical_or : binary_function<T, T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a || b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ logical_or() {}
|
||||
__host__ __device__ __forceinline__ logical_or(const logical_or&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct logical_not : unary_function<T, bool>
|
||||
{
|
||||
__device__ __forceinline__ bool operator ()(typename TypeTraits<T>::ParameterType a) const
|
||||
{
|
||||
return !a;
|
||||
}
|
||||
__host__ __device__ __forceinline__ logical_not() {}
|
||||
__host__ __device__ __forceinline__ logical_not(const logical_not&) {}
|
||||
};
|
||||
|
||||
// Bitwise Operations
|
||||
template <typename T> struct bit_and : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a & b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ bit_and() {}
|
||||
__host__ __device__ __forceinline__ bit_and(const bit_and&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct bit_or : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a | b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ bit_or() {}
|
||||
__host__ __device__ __forceinline__ bit_or(const bit_or&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct bit_xor : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType a,
|
||||
typename TypeTraits<T>::ParameterType b) const
|
||||
{
|
||||
return a ^ b;
|
||||
}
|
||||
__host__ __device__ __forceinline__ bit_xor() {}
|
||||
__host__ __device__ __forceinline__ bit_xor(const bit_xor&) {}
|
||||
};
|
||||
|
||||
template <typename T> struct bit_not : unary_function<T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType v) const
|
||||
{
|
||||
return ~v;
|
||||
}
|
||||
__host__ __device__ __forceinline__ bit_not() {}
|
||||
__host__ __device__ __forceinline__ bit_not(const bit_not&) {}
|
||||
};
|
||||
|
||||
// Generalized Identity Operations
|
||||
template <typename T> struct identity : unary_function<T, T>
|
||||
{
|
||||
__device__ __forceinline__ typename TypeTraits<T>::ParameterType operator()(typename TypeTraits<T>::ParameterType x) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
__host__ __device__ __forceinline__ identity() {}
|
||||
__host__ __device__ __forceinline__ identity(const identity&) {}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct project1st : binary_function<T1, T2, T1>
|
||||
{
|
||||
__device__ __forceinline__ typename TypeTraits<T1>::ParameterType operator()(typename TypeTraits<T1>::ParameterType lhs, typename TypeTraits<T2>::ParameterType rhs) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
__host__ __device__ __forceinline__ project1st() {}
|
||||
__host__ __device__ __forceinline__ project1st(const project1st&) {}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct project2nd : binary_function<T1, T2, T2>
|
||||
{
|
||||
__device__ __forceinline__ typename TypeTraits<T2>::ParameterType operator()(typename TypeTraits<T1>::ParameterType lhs, typename TypeTraits<T2>::ParameterType rhs) const
|
||||
{
|
||||
return rhs;
|
||||
}
|
||||
__host__ __device__ __forceinline__ project2nd() {}
|
||||
__host__ __device__ __forceinline__ project2nd(const project2nd&) {}
|
||||
};
|
||||
|
||||
// Min/Max Operations
|
||||
|
||||
#define OPENCV_CUDA_IMPLEMENT_MINMAX(name, type, op) \
|
||||
template <> struct name<type> : binary_function<type, type, type> \
|
||||
{ \
|
||||
__device__ __forceinline__ type operator()(type lhs, type rhs) const {return op(lhs, rhs);} \
|
||||
__host__ __device__ __forceinline__ name() {}\
|
||||
__host__ __device__ __forceinline__ name(const name&) {}\
|
||||
};
|
||||
|
||||
template <typename T> struct maximum : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType lhs, typename TypeTraits<T>::ParameterType rhs) const
|
||||
{
|
||||
return max(lhs, rhs);
|
||||
}
|
||||
__host__ __device__ __forceinline__ maximum() {}
|
||||
__host__ __device__ __forceinline__ maximum(const maximum&) {}
|
||||
};
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uchar, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, schar, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, char, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, ushort, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, short, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, int, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uint, ::max)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, float, ::fmax)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, double, ::fmax)
|
||||
|
||||
template <typename T> struct minimum : binary_function<T, T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType lhs, typename TypeTraits<T>::ParameterType rhs) const
|
||||
{
|
||||
return min(lhs, rhs);
|
||||
}
|
||||
__host__ __device__ __forceinline__ minimum() {}
|
||||
__host__ __device__ __forceinline__ minimum(const minimum&) {}
|
||||
};
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uchar, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, schar, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, char, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, ushort, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, short, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, int, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uint, ::min)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, float, ::fmin)
|
||||
OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, double, ::fmin)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_MINMAX
|
||||
|
||||
// Math functions
|
||||
|
||||
template <typename T> struct abs_func : unary_function<T, T>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType x) const
|
||||
{
|
||||
return abs(x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<unsigned char> : unary_function<unsigned char, unsigned char>
|
||||
{
|
||||
__device__ __forceinline__ unsigned char operator ()(unsigned char x) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<signed char> : unary_function<signed char, signed char>
|
||||
{
|
||||
__device__ __forceinline__ signed char operator ()(signed char x) const
|
||||
{
|
||||
return ::abs((int)x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<char> : unary_function<char, char>
|
||||
{
|
||||
__device__ __forceinline__ char operator ()(char x) const
|
||||
{
|
||||
return ::abs((int)x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<unsigned short> : unary_function<unsigned short, unsigned short>
|
||||
{
|
||||
__device__ __forceinline__ unsigned short operator ()(unsigned short x) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<short> : unary_function<short, short>
|
||||
{
|
||||
__device__ __forceinline__ short operator ()(short x) const
|
||||
{
|
||||
return ::abs((int)x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<unsigned int> : unary_function<unsigned int, unsigned int>
|
||||
{
|
||||
__device__ __forceinline__ unsigned int operator ()(unsigned int x) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<int> : unary_function<int, int>
|
||||
{
|
||||
__device__ __forceinline__ int operator ()(int x) const
|
||||
{
|
||||
return ::abs(x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<float> : unary_function<float, float>
|
||||
{
|
||||
__device__ __forceinline__ float operator ()(float x) const
|
||||
{
|
||||
return ::fabsf(x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
template <> struct abs_func<double> : unary_function<double, double>
|
||||
{
|
||||
__device__ __forceinline__ double operator ()(double x) const
|
||||
{
|
||||
return ::fabs(x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ abs_func() {}
|
||||
__host__ __device__ __forceinline__ abs_func(const abs_func&) {}
|
||||
};
|
||||
|
||||
#define OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(name, func) \
|
||||
template <typename T> struct name ## _func : unary_function<T, float> \
|
||||
{ \
|
||||
__device__ __forceinline__ float operator ()(typename TypeTraits<T>::ParameterType v) const \
|
||||
{ \
|
||||
return func ## f(v); \
|
||||
} \
|
||||
__host__ __device__ __forceinline__ name ## _func() {} \
|
||||
__host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
|
||||
}; \
|
||||
template <> struct name ## _func<double> : unary_function<double, double> \
|
||||
{ \
|
||||
__device__ __forceinline__ double operator ()(double v) const \
|
||||
{ \
|
||||
return func(v); \
|
||||
} \
|
||||
__host__ __device__ __forceinline__ name ## _func() {} \
|
||||
__host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
|
||||
};
|
||||
|
||||
#define OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(name, func) \
|
||||
template <typename T> struct name ## _func : binary_function<T, T, float> \
|
||||
{ \
|
||||
__device__ __forceinline__ float operator ()(typename TypeTraits<T>::ParameterType v1, typename TypeTraits<T>::ParameterType v2) const \
|
||||
{ \
|
||||
return func ## f(v1, v2); \
|
||||
} \
|
||||
__host__ __device__ __forceinline__ name ## _func() {} \
|
||||
__host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
|
||||
}; \
|
||||
template <> struct name ## _func<double> : binary_function<double, double, double> \
|
||||
{ \
|
||||
__device__ __forceinline__ double operator ()(double v1, double v2) const \
|
||||
{ \
|
||||
return func(v1, v2); \
|
||||
} \
|
||||
__host__ __device__ __forceinline__ name ## _func() {} \
|
||||
__host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \
|
||||
};
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sqrt, ::sqrt)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp, ::exp)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp2, ::exp2)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp10, ::exp10)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log, ::log)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log2, ::log2)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log10, ::log10)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sin, ::sin)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cos, ::cos)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tan, ::tan)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asin, ::asin)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acos, ::acos)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atan, ::atan)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sinh, ::sinh)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cosh, ::cosh)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tanh, ::tanh)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asinh, ::asinh)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acosh, ::acosh)
|
||||
OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atanh, ::atanh)
|
||||
|
||||
OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(hypot, ::hypot)
|
||||
OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(atan2, ::atan2)
|
||||
OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(pow, ::pow)
|
||||
|
||||
#undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR
|
||||
#undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR_NO_DOUBLE
|
||||
#undef OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR
|
||||
|
||||
template<typename T> struct hypot_sqr_func : binary_function<T, T, float>
|
||||
{
|
||||
__device__ __forceinline__ T operator ()(typename TypeTraits<T>::ParameterType src1, typename TypeTraits<T>::ParameterType src2) const
|
||||
{
|
||||
return src1 * src1 + src2 * src2;
|
||||
}
|
||||
__host__ __device__ __forceinline__ hypot_sqr_func() {}
|
||||
__host__ __device__ __forceinline__ hypot_sqr_func(const hypot_sqr_func&) {}
|
||||
};
|
||||
|
||||
// Saturate Cast Functor
|
||||
template <typename T, typename D> struct saturate_cast_func : unary_function<T, D>
|
||||
{
|
||||
__device__ __forceinline__ D operator ()(typename TypeTraits<T>::ParameterType v) const
|
||||
{
|
||||
return saturate_cast<D>(v);
|
||||
}
|
||||
__host__ __device__ __forceinline__ saturate_cast_func() {}
|
||||
__host__ __device__ __forceinline__ saturate_cast_func(const saturate_cast_func&) {}
|
||||
};
|
||||
|
||||
// Threshold Functors
|
||||
template <typename T> struct thresh_binary_func : unary_function<T, T>
|
||||
{
|
||||
__host__ __device__ __forceinline__ thresh_binary_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {}
|
||||
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return (src > thresh) * maxVal;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ thresh_binary_func() {}
|
||||
__host__ __device__ __forceinline__ thresh_binary_func(const thresh_binary_func& other)
|
||||
: thresh(other.thresh), maxVal(other.maxVal) {}
|
||||
|
||||
T thresh;
|
||||
T maxVal;
|
||||
};
|
||||
|
||||
template <typename T> struct thresh_binary_inv_func : unary_function<T, T>
|
||||
{
|
||||
__host__ __device__ __forceinline__ thresh_binary_inv_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {}
|
||||
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return (src <= thresh) * maxVal;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ thresh_binary_inv_func() {}
|
||||
__host__ __device__ __forceinline__ thresh_binary_inv_func(const thresh_binary_inv_func& other)
|
||||
: thresh(other.thresh), maxVal(other.maxVal) {}
|
||||
|
||||
T thresh;
|
||||
T maxVal;
|
||||
};
|
||||
|
||||
template <typename T> struct thresh_trunc_func : unary_function<T, T>
|
||||
{
|
||||
explicit __host__ __device__ __forceinline__ thresh_trunc_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
|
||||
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return minimum<T>()(src, thresh);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ thresh_trunc_func() {}
|
||||
__host__ __device__ __forceinline__ thresh_trunc_func(const thresh_trunc_func& other)
|
||||
: thresh(other.thresh) {}
|
||||
|
||||
T thresh;
|
||||
};
|
||||
|
||||
template <typename T> struct thresh_to_zero_func : unary_function<T, T>
|
||||
{
|
||||
explicit __host__ __device__ __forceinline__ thresh_to_zero_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
|
||||
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return (src > thresh) * src;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ thresh_to_zero_func() {}
|
||||
__host__ __device__ __forceinline__ thresh_to_zero_func(const thresh_to_zero_func& other)
|
||||
: thresh(other.thresh) {}
|
||||
|
||||
T thresh;
|
||||
};
|
||||
|
||||
template <typename T> struct thresh_to_zero_inv_func : unary_function<T, T>
|
||||
{
|
||||
explicit __host__ __device__ __forceinline__ thresh_to_zero_inv_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);}
|
||||
|
||||
__device__ __forceinline__ T operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return (src <= thresh) * src;
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ thresh_to_zero_inv_func() {}
|
||||
__host__ __device__ __forceinline__ thresh_to_zero_inv_func(const thresh_to_zero_inv_func& other)
|
||||
: thresh(other.thresh) {}
|
||||
|
||||
T thresh;
|
||||
};
|
||||
|
||||
// Function Object Adaptors
|
||||
template <typename Predicate> struct unary_negate : unary_function<typename Predicate::argument_type, bool>
|
||||
{
|
||||
explicit __host__ __device__ __forceinline__ unary_negate(const Predicate& p) : pred(p) {}
|
||||
|
||||
__device__ __forceinline__ bool operator()(typename TypeTraits<typename Predicate::argument_type>::ParameterType x) const
|
||||
{
|
||||
return !pred(x);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ unary_negate() {}
|
||||
__host__ __device__ __forceinline__ unary_negate(const unary_negate& other) : pred(other.pred) {}
|
||||
|
||||
Predicate pred;
|
||||
};
|
||||
|
||||
template <typename Predicate> __host__ __device__ __forceinline__ unary_negate<Predicate> not1(const Predicate& pred)
|
||||
{
|
||||
return unary_negate<Predicate>(pred);
|
||||
}
|
||||
|
||||
template <typename Predicate> struct binary_negate : binary_function<typename Predicate::first_argument_type, typename Predicate::second_argument_type, bool>
|
||||
{
|
||||
explicit __host__ __device__ __forceinline__ binary_negate(const Predicate& p) : pred(p) {}
|
||||
|
||||
__device__ __forceinline__ bool operator()(typename TypeTraits<typename Predicate::first_argument_type>::ParameterType x,
|
||||
typename TypeTraits<typename Predicate::second_argument_type>::ParameterType y) const
|
||||
{
|
||||
return !pred(x,y);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ binary_negate() {}
|
||||
__host__ __device__ __forceinline__ binary_negate(const binary_negate& other) : pred(other.pred) {}
|
||||
|
||||
Predicate pred;
|
||||
};
|
||||
|
||||
template <typename BinaryPredicate> __host__ __device__ __forceinline__ binary_negate<BinaryPredicate> not2(const BinaryPredicate& pred)
|
||||
{
|
||||
return binary_negate<BinaryPredicate>(pred);
|
||||
}
|
||||
|
||||
template <typename Op> struct binder1st : unary_function<typename Op::second_argument_type, typename Op::result_type>
|
||||
{
|
||||
__host__ __device__ __forceinline__ binder1st(const Op& op_, const typename Op::first_argument_type& arg1_) : op(op_), arg1(arg1_) {}
|
||||
|
||||
__device__ __forceinline__ typename Op::result_type operator ()(typename TypeTraits<typename Op::second_argument_type>::ParameterType a) const
|
||||
{
|
||||
return op(arg1, a);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ binder1st() {}
|
||||
__host__ __device__ __forceinline__ binder1st(const binder1st& other) : op(other.op), arg1(other.arg1) {}
|
||||
|
||||
Op op;
|
||||
typename Op::first_argument_type arg1;
|
||||
};
|
||||
|
||||
template <typename Op, typename T> __host__ __device__ __forceinline__ binder1st<Op> bind1st(const Op& op, const T& x)
|
||||
{
|
||||
return binder1st<Op>(op, typename Op::first_argument_type(x));
|
||||
}
|
||||
|
||||
template <typename Op> struct binder2nd : unary_function<typename Op::first_argument_type, typename Op::result_type>
|
||||
{
|
||||
__host__ __device__ __forceinline__ binder2nd(const Op& op_, const typename Op::second_argument_type& arg2_) : op(op_), arg2(arg2_) {}
|
||||
|
||||
__forceinline__ __device__ typename Op::result_type operator ()(typename TypeTraits<typename Op::first_argument_type>::ParameterType a) const
|
||||
{
|
||||
return op(a, arg2);
|
||||
}
|
||||
|
||||
__host__ __device__ __forceinline__ binder2nd() {}
|
||||
__host__ __device__ __forceinline__ binder2nd(const binder2nd& other) : op(other.op), arg2(other.arg2) {}
|
||||
|
||||
Op op;
|
||||
typename Op::second_argument_type arg2;
|
||||
};
|
||||
|
||||
template <typename Op, typename T> __host__ __device__ __forceinline__ binder2nd<Op> bind2nd(const Op& op, const T& x)
|
||||
{
|
||||
return binder2nd<Op>(op, typename Op::second_argument_type(x));
|
||||
}
|
||||
|
||||
// Functor Traits
|
||||
template <typename F> struct IsUnaryFunction
|
||||
{
|
||||
typedef char Yes;
|
||||
struct No {Yes a[2];};
|
||||
|
||||
template <typename T, typename D> static Yes check(unary_function<T, D>);
|
||||
static No check(...);
|
||||
|
||||
static F makeF();
|
||||
|
||||
enum { value = (sizeof(check(makeF())) == sizeof(Yes)) };
|
||||
};
|
||||
|
||||
template <typename F> struct IsBinaryFunction
|
||||
{
|
||||
typedef char Yes;
|
||||
struct No {Yes a[2];};
|
||||
|
||||
template <typename T1, typename T2, typename D> static Yes check(binary_function<T1, T2, D>);
|
||||
static No check(...);
|
||||
|
||||
static F makeF();
|
||||
|
||||
enum { value = (sizeof(check(makeF())) == sizeof(Yes)) };
|
||||
};
|
||||
|
||||
namespace functional_detail
|
||||
{
|
||||
template <size_t src_elem_size, size_t dst_elem_size> struct UnOpShift { enum { shift = 1 }; };
|
||||
template <size_t src_elem_size> struct UnOpShift<src_elem_size, 1> { enum { shift = 4 }; };
|
||||
template <size_t src_elem_size> struct UnOpShift<src_elem_size, 2> { enum { shift = 2 }; };
|
||||
|
||||
template <typename T, typename D> struct DefaultUnaryShift
|
||||
{
|
||||
enum { shift = UnOpShift<sizeof(T), sizeof(D)>::shift };
|
||||
};
|
||||
|
||||
template <size_t src_elem_size1, size_t src_elem_size2, size_t dst_elem_size> struct BinOpShift { enum { shift = 1 }; };
|
||||
template <size_t src_elem_size1, size_t src_elem_size2> struct BinOpShift<src_elem_size1, src_elem_size2, 1> { enum { shift = 4 }; };
|
||||
template <size_t src_elem_size1, size_t src_elem_size2> struct BinOpShift<src_elem_size1, src_elem_size2, 2> { enum { shift = 2 }; };
|
||||
|
||||
template <typename T1, typename T2, typename D> struct DefaultBinaryShift
|
||||
{
|
||||
enum { shift = BinOpShift<sizeof(T1), sizeof(T2), sizeof(D)>::shift };
|
||||
};
|
||||
|
||||
template <typename Func, bool unary = IsUnaryFunction<Func>::value> struct ShiftDispatcher;
|
||||
template <typename Func> struct ShiftDispatcher<Func, true>
|
||||
{
|
||||
enum { shift = DefaultUnaryShift<typename Func::argument_type, typename Func::result_type>::shift };
|
||||
};
|
||||
template <typename Func> struct ShiftDispatcher<Func, false>
|
||||
{
|
||||
enum { shift = DefaultBinaryShift<typename Func::first_argument_type, typename Func::second_argument_type, typename Func::result_type>::shift };
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Func> struct DefaultTransformShift
|
||||
{
|
||||
enum { shift = functional_detail::ShiftDispatcher<Func>::shift };
|
||||
};
|
||||
|
||||
template <typename Func> struct DefaultTransformFunctorTraits
|
||||
{
|
||||
enum { simple_block_dim_x = 16 };
|
||||
enum { simple_block_dim_y = 16 };
|
||||
|
||||
enum { smart_block_dim_x = 16 };
|
||||
enum { smart_block_dim_y = 16 };
|
||||
enum { smart_shift = DefaultTransformShift<Func>::shift };
|
||||
};
|
||||
|
||||
template <typename Func> struct TransformFunctorTraits : DefaultTransformFunctorTraits<Func> {};
|
||||
|
||||
#define OPENCV_CUDA_TRANSFORM_FUNCTOR_TRAITS(type) \
|
||||
template <> struct TransformFunctorTraits< type > : DefaultTransformFunctorTraits< type >
|
||||
}}} // namespace cv { namespace cuda { namespace cudev
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_FUNCTIONAL_HPP
|
|
@ -0,0 +1,128 @@
|
|||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_CUDA_LIMITS_HPP
|
||||
#define OPENCV_CUDA_LIMITS_HPP
|
||||
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include "common.hpp"
|
||||
|
||||
/** @file
|
||||
* @deprecated Use @ref cudev instead.
|
||||
*/
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv { namespace cuda { namespace device
|
||||
{
|
||||
template <class T> struct numeric_limits;
|
||||
|
||||
template <> struct numeric_limits<bool>
|
||||
{
|
||||
__device__ __forceinline__ static bool min() { return false; }
|
||||
__device__ __forceinline__ static bool max() { return true; }
|
||||
static const bool is_signed = false;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<signed char>
|
||||
{
|
||||
__device__ __forceinline__ static signed char min() { return SCHAR_MIN; }
|
||||
__device__ __forceinline__ static signed char max() { return SCHAR_MAX; }
|
||||
static const bool is_signed = true;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<unsigned char>
|
||||
{
|
||||
__device__ __forceinline__ static unsigned char min() { return 0; }
|
||||
__device__ __forceinline__ static unsigned char max() { return UCHAR_MAX; }
|
||||
static const bool is_signed = false;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<short>
|
||||
{
|
||||
__device__ __forceinline__ static short min() { return SHRT_MIN; }
|
||||
__device__ __forceinline__ static short max() { return SHRT_MAX; }
|
||||
static const bool is_signed = true;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<unsigned short>
|
||||
{
|
||||
__device__ __forceinline__ static unsigned short min() { return 0; }
|
||||
__device__ __forceinline__ static unsigned short max() { return USHRT_MAX; }
|
||||
static const bool is_signed = false;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<int>
|
||||
{
|
||||
__device__ __forceinline__ static int min() { return INT_MIN; }
|
||||
__device__ __forceinline__ static int max() { return INT_MAX; }
|
||||
static const bool is_signed = true;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<unsigned int>
|
||||
{
|
||||
__device__ __forceinline__ static unsigned int min() { return 0; }
|
||||
__device__ __forceinline__ static unsigned int max() { return UINT_MAX; }
|
||||
static const bool is_signed = false;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<float>
|
||||
{
|
||||
__device__ __forceinline__ static float min() { return FLT_MIN; }
|
||||
__device__ __forceinline__ static float max() { return FLT_MAX; }
|
||||
__device__ __forceinline__ static float epsilon() { return FLT_EPSILON; }
|
||||
static const bool is_signed = true;
|
||||
};
|
||||
|
||||
template <> struct numeric_limits<double>
|
||||
{
|
||||
__device__ __forceinline__ static double min() { return DBL_MIN; }
|
||||
__device__ __forceinline__ static double max() { return DBL_MAX; }
|
||||
__device__ __forceinline__ static double epsilon() { return DBL_EPSILON; }
|
||||
static const bool is_signed = true;
|
||||
};
|
||||
}}} // namespace cv { namespace cuda { namespace cudev {
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CUDA_LIMITS_HPP
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue