node-native-win-utils 1.4.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +29 -82
  2. package/binding.gyp +2 -0
  3. package/dist/dirnameLocal.cjs +4 -0
  4. package/dist/dirnameLocal.d.cts +1 -0
  5. package/dist/dirnameLocal.d.mts +1 -0
  6. package/dist/dirnameLocal.mjs +2 -0
  7. package/dist/{index.js → index.cjs} +83 -16
  8. package/dist/{index.d.ts → index.d.cts} +68 -17
  9. package/dist/index.d.mts +230 -0
  10. package/dist/index.mjs +212 -0
  11. package/dist/keyCodes.d.mts +101 -0
  12. package/dist/keyCodes.mjs +201 -0
  13. package/node22.json +16 -0
  14. package/package.json +19 -9
  15. package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
  16. package/src/cpp/keyboard.cpp +141 -140
  17. package/src/cpp/main.cpp +9 -3
  18. package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
  19. package/src/dirnameLocal.mts +3 -0
  20. package/src/index.mts +455 -0
  21. package/src/keyCodes.mts +203 -0
  22. package/dllCopy.js +0 -14
  23. package/include/opencv2/core/affine.hpp +0 -678
  24. package/include/opencv2/core/async.hpp +0 -105
  25. package/include/opencv2/core/base.hpp +0 -664
  26. package/include/opencv2/core/bindings_utils.hpp +0 -325
  27. package/include/opencv2/core/bufferpool.hpp +0 -40
  28. package/include/opencv2/core/check.hpp +0 -170
  29. package/include/opencv2/core/core.hpp +0 -48
  30. package/include/opencv2/core/core_c.h +0 -3128
  31. package/include/opencv2/core/cuda/block.hpp +0 -211
  32. package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
  33. package/include/opencv2/core/cuda/color.hpp +0 -309
  34. package/include/opencv2/core/cuda/common.hpp +0 -131
  35. package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
  36. package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
  37. package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
  38. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
  39. package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
  40. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
  41. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
  42. package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
  43. package/include/opencv2/core/cuda/emulation.hpp +0 -269
  44. package/include/opencv2/core/cuda/filters.hpp +0 -293
  45. package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
  46. package/include/opencv2/core/cuda/functional.hpp +0 -805
  47. package/include/opencv2/core/cuda/limits.hpp +0 -128
  48. package/include/opencv2/core/cuda/reduce.hpp +0 -209
  49. package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
  50. package/include/opencv2/core/cuda/scan.hpp +0 -258
  51. package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
  52. package/include/opencv2/core/cuda/transform.hpp +0 -75
  53. package/include/opencv2/core/cuda/type_traits.hpp +0 -90
  54. package/include/opencv2/core/cuda/utility.hpp +0 -230
  55. package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
  56. package/include/opencv2/core/cuda/vec_math.hpp +0 -923
  57. package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
  58. package/include/opencv2/core/cuda/warp.hpp +0 -139
  59. package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
  60. package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
  61. package/include/opencv2/core/cuda.hpp +0 -1279
  62. package/include/opencv2/core/cuda.inl.hpp +0 -763
  63. package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
  64. package/include/opencv2/core/cuda_types.hpp +0 -144
  65. package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
  66. package/include/opencv2/core/cv_cpu_helper.h +0 -550
  67. package/include/opencv2/core/cvdef.h +0 -973
  68. package/include/opencv2/core/cvstd.hpp +0 -190
  69. package/include/opencv2/core/cvstd.inl.hpp +0 -197
  70. package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
  71. package/include/opencv2/core/detail/async_promise.hpp +0 -71
  72. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
  73. package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
  74. package/include/opencv2/core/directx.hpp +0 -184
  75. package/include/opencv2/core/dualquaternion.hpp +0 -979
  76. package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
  77. package/include/opencv2/core/eigen.hpp +0 -402
  78. package/include/opencv2/core/fast_math.hpp +0 -433
  79. package/include/opencv2/core/hal/hal.hpp +0 -256
  80. package/include/opencv2/core/hal/interface.h +0 -190
  81. package/include/opencv2/core/hal/intrin.hpp +0 -939
  82. package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
  83. package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
  84. package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
  85. package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
  86. package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
  87. package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
  88. package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
  89. package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
  90. package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
  91. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
  92. package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
  93. package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
  94. package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
  95. package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
  96. package/include/opencv2/core/hal/msa_macros.h +0 -1558
  97. package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
  98. package/include/opencv2/core/llapi/llapi.h +0 -102
  99. package/include/opencv2/core/mat.hpp +0 -3775
  100. package/include/opencv2/core/mat.inl.hpp +0 -3422
  101. package/include/opencv2/core/matx.hpp +0 -1536
  102. package/include/opencv2/core/neon_utils.hpp +0 -128
  103. package/include/opencv2/core/ocl.hpp +0 -917
  104. package/include/opencv2/core/ocl_genbase.hpp +0 -69
  105. package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
  106. package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
  107. package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
  108. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
  109. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
  110. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
  111. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
  112. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
  113. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
  114. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
  115. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
  116. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
  117. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
  118. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
  119. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
  120. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
  121. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
  122. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
  123. package/include/opencv2/core/opengl.hpp +0 -733
  124. package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
  125. package/include/opencv2/core/operations.hpp +0 -610
  126. package/include/opencv2/core/optim.hpp +0 -302
  127. package/include/opencv2/core/ovx.hpp +0 -28
  128. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
  129. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
  130. package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
  131. package/include/opencv2/core/persistence.hpp +0 -1350
  132. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
  133. package/include/opencv2/core/private.cuda.hpp +0 -169
  134. package/include/opencv2/core/private.hpp +0 -896
  135. package/include/opencv2/core/quaternion.hpp +0 -1696
  136. package/include/opencv2/core/quaternion.inl.hpp +0 -1063
  137. package/include/opencv2/core/saturate.hpp +0 -180
  138. package/include/opencv2/core/simd_intrinsics.hpp +0 -87
  139. package/include/opencv2/core/softfloat.hpp +0 -514
  140. package/include/opencv2/core/sse_utils.hpp +0 -652
  141. package/include/opencv2/core/traits.hpp +0 -417
  142. package/include/opencv2/core/types.hpp +0 -2457
  143. package/include/opencv2/core/types_c.h +0 -2126
  144. package/include/opencv2/core/utility.hpp +0 -1229
  145. package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
  146. package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
  147. package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
  148. package/include/opencv2/core/utils/configuration.private.hpp +0 -22
  149. package/include/opencv2/core/utils/filesystem.hpp +0 -82
  150. package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
  151. package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
  152. package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
  153. package/include/opencv2/core/utils/instrumentation.hpp +0 -125
  154. package/include/opencv2/core/utils/lock.private.hpp +0 -119
  155. package/include/opencv2/core/utils/logger.defines.hpp +0 -42
  156. package/include/opencv2/core/utils/logger.hpp +0 -218
  157. package/include/opencv2/core/utils/logtag.hpp +0 -28
  158. package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
  159. package/include/opencv2/core/utils/tls.hpp +0 -235
  160. package/include/opencv2/core/utils/trace.hpp +0 -252
  161. package/include/opencv2/core/utils/trace.private.hpp +0 -421
  162. package/include/opencv2/core/va_intel.hpp +0 -75
  163. package/include/opencv2/core/version.hpp +0 -26
  164. package/include/opencv2/core/vsx_utils.hpp +0 -1047
  165. package/include/opencv2/core.hpp +0 -3365
  166. package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
  167. package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
  168. package/include/opencv2/imgcodecs/ios.h +0 -59
  169. package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
  170. package/include/opencv2/imgcodecs/macosx.h +0 -20
  171. package/include/opencv2/imgcodecs.hpp +0 -407
  172. package/include/opencv2/imgproc/bindings.hpp +0 -34
  173. package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
  174. package/include/opencv2/imgproc/hal/hal.hpp +0 -246
  175. package/include/opencv2/imgproc/hal/interface.h +0 -46
  176. package/include/opencv2/imgproc/imgproc.hpp +0 -48
  177. package/include/opencv2/imgproc/imgproc_c.h +0 -1177
  178. package/include/opencv2/imgproc/segmentation.hpp +0 -141
  179. package/include/opencv2/imgproc/types_c.h +0 -659
  180. package/include/opencv2/imgproc.hpp +0 -5035
  181. package/include/opencv2/opencv_modules.hpp +0 -17
  182. package/include/tesseract/baseapi.h +0 -820
  183. package/include/tesseract/capi.h +0 -485
  184. package/include/tesseract/export.h +0 -37
  185. package/include/tesseract/ltrresultiterator.h +0 -235
  186. package/include/tesseract/ocrclass.h +0 -158
  187. package/include/tesseract/osdetect.h +0 -139
  188. package/include/tesseract/pageiterator.h +0 -364
  189. package/include/tesseract/publictypes.h +0 -281
  190. package/include/tesseract/renderer.h +0 -334
  191. package/include/tesseract/resultiterator.h +0 -250
  192. package/include/tesseract/tesseract.h +0 -40
  193. package/include/tesseract/unichar.h +0 -174
  194. package/include/tesseract/version.h +0 -34
  195. package/include/tesseract/version.h.in +0 -34
  196. package/libs/libjpeg-turbo.lib +0 -0
  197. package/libs/libpng.lib +0 -0
  198. package/libs/opencv_core470.lib +0 -0
  199. package/libs/opencv_imgcodecs470.lib +0 -0
  200. package/libs/opencv_imgproc470.lib +0 -0
  201. package/libs/tesseract.lib +0 -0
  202. package/libs/zlib.lib +0 -0
  203. /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
  204. /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
@@ -1,334 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // File: renderer.h
3
- // Description: Rendering interface to inject into TessBaseAPI
4
- //
5
- // (C) Copyright 2011, Google Inc.
6
- // Licensed under the Apache License, Version 2.0 (the "License");
7
- // you may not use this file except in compliance with the License.
8
- // You may obtain a copy of the License at
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
-
16
- #ifndef TESSERACT_API_RENDERER_H_
17
- #define TESSERACT_API_RENDERER_H_
18
-
19
- #include "export.h"
20
-
21
- // To avoid collision with other typenames include the ABSOLUTE MINIMUM
22
- // complexity of includes here. Use forward declarations wherever possible
23
- // and hide includes of complex types in baseapi.cpp.
24
- #include <cstdint>
25
- #include <string> // for std::string
26
- #include <vector> // for std::vector
27
-
28
- struct Pix;
29
-
30
- namespace tesseract {
31
-
32
- class TessBaseAPI;
33
-
34
- /**
35
- * Interface for rendering tesseract results into a document, such as text,
36
- * HOCR or pdf. This class is abstract. Specific classes handle individual
37
- * formats. This interface is then used to inject the renderer class into
38
- * tesseract when processing images.
39
- *
40
- * For simplicity implementing this with tesseract version 3.01,
41
- * the renderer contains document state that is cleared from document
42
- * to document just as the TessBaseAPI is. This way the base API can just
43
- * delegate its rendering functionality to injected renderers, and the
44
- * renderers can manage the associated state needed for the specific formats
45
- * in addition to the heuristics for producing it.
46
- */
47
- class TESS_API TessResultRenderer {
48
- public:
49
- virtual ~TessResultRenderer();
50
-
51
- // Takes ownership of pointer so must be new'd instance.
52
- // Renderers aren't ordered, but appends the sequences of next parameter
53
- // and existing next(). The renderers should be unique across both lists.
54
- void insert(TessResultRenderer *next);
55
-
56
- // Returns the next renderer or nullptr.
57
- TessResultRenderer *next() {
58
- return next_;
59
- }
60
-
61
- /**
62
- * Starts a new document with the given title.
63
- * This clears the contents of the output data.
64
- * Title should use UTF-8 encoding.
65
- */
66
- bool BeginDocument(const char *title);
67
-
68
- /**
69
- * Adds the recognized text from the source image to the current document.
70
- * Invalid if BeginDocument not yet called.
71
- *
72
- * Note that this API is a bit weird but is designed to fit into the
73
- * current TessBaseAPI implementation where the api has lots of state
74
- * information that we might want to add in.
75
- */
76
- bool AddImage(TessBaseAPI *api);
77
-
78
- /**
79
- * Finishes the document and finalizes the output data
80
- * Invalid if BeginDocument not yet called.
81
- */
82
- bool EndDocument();
83
-
84
- const char *file_extension() const {
85
- return file_extension_;
86
- }
87
- const char *title() const {
88
- return title_.c_str();
89
- }
90
-
91
- // Is everything fine? Otherwise something went wrong.
92
- bool happy() const {
93
- return happy_;
94
- }
95
-
96
- /**
97
- * Returns the index of the last image given to AddImage
98
- * (i.e. images are incremented whether the image succeeded or not)
99
- *
100
- * This is always defined. It means either the number of the
101
- * current image, the last image ended, or in the completed document
102
- * depending on when in the document lifecycle you are looking at it.
103
- * Will return -1 if a document was never started.
104
- */
105
- int imagenum() const {
106
- return imagenum_;
107
- }
108
-
109
- protected:
110
- /**
111
- * Called by concrete classes.
112
- *
113
- * outputbase is the name of the output file excluding
114
- * extension. For example, "/path/to/chocolate-chip-cookie-recipe"
115
- *
116
- * extension indicates the file extension to be used for output
117
- * files. For example "pdf" will produce a .pdf file, and "hocr"
118
- * will produce .hocr files.
119
- */
120
- TessResultRenderer(const char *outputbase, const char *extension);
121
-
122
- // Hook for specialized handling in BeginDocument()
123
- virtual bool BeginDocumentHandler();
124
-
125
- // This must be overridden to render the OCR'd results
126
- virtual bool AddImageHandler(TessBaseAPI *api) = 0;
127
-
128
- // Hook for specialized handling in EndDocument()
129
- virtual bool EndDocumentHandler();
130
-
131
- // Renderers can call this to append '\0' terminated strings into
132
- // the output string returned by GetOutput.
133
- // This method will grow the output buffer if needed.
134
- void AppendString(const char *s);
135
-
136
- // Renderers can call this to append binary byte sequences into
137
- // the output string returned by GetOutput. Note that s is not necessarily
138
- // '\0' terminated (and can contain '\0' within it).
139
- // This method will grow the output buffer if needed.
140
- void AppendData(const char *s, int len);
141
-
142
- template <typename T>
143
- auto AppendData(T &&d) {
144
- AppendData(d.data(), d.size());
145
- return d.size();
146
- }
147
-
148
- private:
149
- TessResultRenderer *next_; // Can link multiple renderers together
150
- FILE *fout_; // output file pointer
151
- const char *file_extension_; // standard extension for generated output
152
- std::string title_; // title of document being rendered
153
- int imagenum_; // index of last image added
154
- bool happy_; // I get grumpy when the disk fills up, etc.
155
- };
156
-
157
- /**
158
- * Renders tesseract output into a plain UTF-8 text string
159
- */
160
- class TESS_API TessTextRenderer : public TessResultRenderer {
161
- public:
162
- explicit TessTextRenderer(const char *outputbase);
163
-
164
- protected:
165
- bool AddImageHandler(TessBaseAPI *api) override;
166
- };
167
-
168
- /**
169
- * Renders tesseract output into an hocr text string
170
- */
171
- class TESS_API TessHOcrRenderer : public TessResultRenderer {
172
- public:
173
- explicit TessHOcrRenderer(const char *outputbase, bool font_info);
174
- explicit TessHOcrRenderer(const char *outputbase);
175
-
176
- protected:
177
- bool BeginDocumentHandler() override;
178
- bool AddImageHandler(TessBaseAPI *api) override;
179
- bool EndDocumentHandler() override;
180
-
181
- private:
182
- bool font_info_; // whether to print font information
183
- };
184
-
185
- /**
186
- * Renders tesseract output into an alto text string
187
- */
188
- class TESS_API TessAltoRenderer : public TessResultRenderer {
189
- public:
190
- explicit TessAltoRenderer(const char *outputbase);
191
-
192
- protected:
193
- bool BeginDocumentHandler() override;
194
- bool AddImageHandler(TessBaseAPI *api) override;
195
- bool EndDocumentHandler() override;
196
-
197
- private:
198
- bool begin_document;
199
- };
200
-
201
- /**
202
- * Renders Tesseract output into a PAGE XML text string
203
- */
204
- class TESS_API TessPAGERenderer : public TessResultRenderer {
205
- public:
206
- explicit TessPAGERenderer(const char *outputbase);
207
-
208
- protected:
209
- bool BeginDocumentHandler() override;
210
- bool AddImageHandler(TessBaseAPI *api) override;
211
- bool EndDocumentHandler() override;
212
-
213
- private:
214
- bool begin_document;
215
- };
216
-
217
-
218
- /**
219
- * Renders Tesseract output into a TSV string
220
- */
221
- class TESS_API TessTsvRenderer : public TessResultRenderer {
222
- public:
223
- explicit TessTsvRenderer(const char *outputbase, bool font_info);
224
- explicit TessTsvRenderer(const char *outputbase);
225
-
226
- protected:
227
- bool BeginDocumentHandler() override;
228
- bool AddImageHandler(TessBaseAPI *api) override;
229
- bool EndDocumentHandler() override;
230
-
231
- private:
232
- bool font_info_; // whether to print font information
233
- };
234
-
235
- /**
236
- * Renders tesseract output into searchable PDF
237
- */
238
- class TESS_API TessPDFRenderer : public TessResultRenderer {
239
- public:
240
- // datadir is the location of the TESSDATA. We need it because
241
- // we load a custom PDF font from this location.
242
- TessPDFRenderer(const char *outputbase, const char *datadir,
243
- bool textonly = false);
244
-
245
- protected:
246
- bool BeginDocumentHandler() override;
247
- bool AddImageHandler(TessBaseAPI *api) override;
248
- bool EndDocumentHandler() override;
249
-
250
- private:
251
- // We don't want to have every image in memory at once,
252
- // so we store some metadata as we go along producing
253
- // PDFs one page at a time. At the end, that metadata is
254
- // used to make everything that isn't easily handled in a
255
- // streaming fashion.
256
- long int obj_; // counter for PDF objects
257
- std::vector<uint64_t> offsets_; // offset of every PDF object in bytes
258
- std::vector<long int> pages_; // object number for every /Page object
259
- std::string datadir_; // where to find the custom font
260
- bool textonly_; // skip images if set
261
- // Bookkeeping only. DIY = Do It Yourself.
262
- void AppendPDFObjectDIY(size_t objectsize);
263
- // Bookkeeping + emit data.
264
- void AppendPDFObject(const char *data);
265
- // Create the /Contents object for an entire page.
266
- char *GetPDFTextObjects(TessBaseAPI *api, double width, double height);
267
- // Turn an image into a PDF object. Only transcode if we have to.
268
- static bool imageToPDFObj(Pix *pix, const char *filename, long int objnum,
269
- char **pdf_object, long int *pdf_object_size,
270
- int jpg_quality);
271
- };
272
-
273
- /**
274
- * Renders tesseract output into a plain UTF-8 text string
275
- */
276
- class TESS_API TessUnlvRenderer : public TessResultRenderer {
277
- public:
278
- explicit TessUnlvRenderer(const char *outputbase);
279
-
280
- protected:
281
- bool AddImageHandler(TessBaseAPI *api) override;
282
- };
283
-
284
- /**
285
- * Renders tesseract output into a plain UTF-8 text string for LSTMBox
286
- */
287
- class TESS_API TessLSTMBoxRenderer : public TessResultRenderer {
288
- public:
289
- explicit TessLSTMBoxRenderer(const char *outputbase);
290
-
291
- protected:
292
- bool AddImageHandler(TessBaseAPI *api) override;
293
- };
294
-
295
- /**
296
- * Renders tesseract output into a plain UTF-8 text string
297
- */
298
- class TESS_API TessBoxTextRenderer : public TessResultRenderer {
299
- public:
300
- explicit TessBoxTextRenderer(const char *outputbase);
301
-
302
- protected:
303
- bool AddImageHandler(TessBaseAPI *api) override;
304
- };
305
-
306
- /**
307
- * Renders tesseract output into a plain UTF-8 text string in WordStr format
308
- */
309
- class TESS_API TessWordStrBoxRenderer : public TessResultRenderer {
310
- public:
311
- explicit TessWordStrBoxRenderer(const char *outputbase);
312
-
313
- protected:
314
- bool AddImageHandler(TessBaseAPI *api) override;
315
- };
316
-
317
- #ifndef DISABLED_LEGACY_ENGINE
318
-
319
- /**
320
- * Renders tesseract output into an osd text string
321
- */
322
- class TESS_API TessOsdRenderer : public TessResultRenderer {
323
- public:
324
- explicit TessOsdRenderer(const char *outputbase);
325
-
326
- protected:
327
- bool AddImageHandler(TessBaseAPI *api) override;
328
- };
329
-
330
- #endif // ndef DISABLED_LEGACY_ENGINE
331
-
332
- } // namespace tesseract.
333
-
334
- #endif // TESSERACT_API_RENDERER_H_
@@ -1,250 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // File: resultiterator.h
3
- // Description: Iterator for tesseract results that is capable of
4
- // iterating in proper reading order over Bi Directional
5
- // (e.g. mixed Hebrew and English) text.
6
- // Author: David Eger
7
- //
8
- // (C) Copyright 2011, Google Inc.
9
- // Licensed under the Apache License, Version 2.0 (the "License");
10
- // you may not use this file except in compliance with the License.
11
- // You may obtain a copy of the License at
12
- // http://www.apache.org/licenses/LICENSE-2.0
13
- // Unless required by applicable law or agreed to in writing, software
14
- // distributed under the License is distributed on an "AS IS" BASIS,
15
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- // See the License for the specific language governing permissions and
17
- // limitations under the License.
18
-
19
- #ifndef TESSERACT_CCMAIN_RESULT_ITERATOR_H_
20
- #define TESSERACT_CCMAIN_RESULT_ITERATOR_H_
21
-
22
- #include "export.h" // for TESS_API, TESS_LOCAL
23
- #include "ltrresultiterator.h" // for LTRResultIterator
24
- #include "publictypes.h" // for PageIteratorLevel
25
- #include "unichar.h" // for StrongScriptDirection
26
-
27
- #include <set> // for std::pair
28
- #include <vector> // for std::vector
29
-
30
- namespace tesseract {
31
-
32
- class TESS_API ResultIterator : public LTRResultIterator {
33
- public:
34
- static ResultIterator *StartOfParagraph(const LTRResultIterator &resit);
35
-
36
- /**
37
- * ResultIterator is copy constructible!
38
- * The default copy constructor works just fine for us.
39
- */
40
- ~ResultIterator() override = default;
41
-
42
- // ============= Moving around within the page ============.
43
- /**
44
- * Moves the iterator to point to the start of the page to begin
45
- * an iteration.
46
- */
47
- void Begin() override;
48
-
49
- /**
50
- * Moves to the start of the next object at the given level in the
51
- * page hierarchy in the appropriate reading order and returns false if
52
- * the end of the page was reached.
53
- * NOTE that RIL_SYMBOL will skip non-text blocks, but all other
54
- * PageIteratorLevel level values will visit each non-text block once.
55
- * Think of non text blocks as containing a single para, with a single line,
56
- * with a single imaginary word.
57
- * Calls to Next with different levels may be freely intermixed.
58
- * This function iterates words in right-to-left scripts correctly, if
59
- * the appropriate language has been loaded into Tesseract.
60
- */
61
- bool Next(PageIteratorLevel level) override;
62
-
63
- /**
64
- * IsAtBeginningOf() returns whether we're at the logical beginning of the
65
- * given level. (as opposed to ResultIterator's left-to-right top-to-bottom
66
- * order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
67
- * For a full description, see pageiterator.h
68
- */
69
- bool IsAtBeginningOf(PageIteratorLevel level) const override;
70
-
71
- /**
72
- * Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
73
- * For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
74
- * point at the last word in a paragraph. See PageIterator for full comment.
75
- */
76
- bool IsAtFinalElement(PageIteratorLevel level,
77
- PageIteratorLevel element) const override;
78
-
79
- // ============= Functions that refer to words only ============.
80
- // Returns the number of blanks before the current word.
81
- int BlanksBeforeWord() const;
82
-
83
- // ============= Accessing data ==============.
84
-
85
- /**
86
- * Returns the null terminated UTF-8 encoded text string for the current
87
- * object at the given level. Use delete [] to free after use.
88
- */
89
- virtual char *GetUTF8Text(PageIteratorLevel level) const;
90
-
91
- /**
92
- * Returns the LSTM choices for every LSTM timestep for the current word.
93
- */
94
- virtual std::vector<std::vector<std::vector<std::pair<const char *, float>>>>
95
- *GetRawLSTMTimesteps() const;
96
- virtual std::vector<std::vector<std::pair<const char *, float>>>
97
- *GetBestLSTMSymbolChoices() const;
98
-
99
- /**
100
- * Return whether the current paragraph's dominant reading direction
101
- * is left-to-right (as opposed to right-to-left).
102
- */
103
- bool ParagraphIsLtr() const;
104
-
105
- // ============= Exposed only for testing =============.
106
-
107
- /**
108
- * Yields the reading order as a sequence of indices and (optional)
109
- * meta-marks for a set of words (given left-to-right).
110
- * The meta marks are passed as negative values:
111
- * kMinorRunStart Start of minor direction text.
112
- * kMinorRunEnd End of minor direction text.
113
- * kComplexWord The next indexed word contains both left-to-right and
114
- * right-to-left characters and was treated as neutral.
115
- *
116
- * For example, suppose we have five words in a text line,
117
- * indexed [0,1,2,3,4] from the leftmost side of the text line.
118
- * The following are all believable reading_orders:
119
- *
120
- * Left-to-Right (in ltr paragraph):
121
- * { 0, 1, 2, 3, 4 }
122
- * Left-to-Right (in rtl paragraph):
123
- * { kMinorRunStart, 0, 1, 2, 3, 4, kMinorRunEnd }
124
- * Right-to-Left (in rtl paragraph):
125
- * { 4, 3, 2, 1, 0 }
126
- * Left-to-Right except for an RTL phrase in words 2, 3 in an ltr paragraph:
127
- * { 0, 1, kMinorRunStart, 3, 2, kMinorRunEnd, 4 }
128
- */
129
- static void CalculateTextlineOrder(
130
- bool paragraph_is_ltr,
131
- const std::vector<StrongScriptDirection> &word_dirs,
132
- std::vector<int> *reading_order);
133
-
134
- static const int kMinorRunStart;
135
- static const int kMinorRunEnd;
136
- static const int kComplexWord;
137
-
138
- protected:
139
- /**
140
- * We presume the data associated with the given iterator will outlive us.
141
- * NB: This is private because it does something that is non-obvious:
142
- * it resets to the beginning of the paragraph instead of staying wherever
143
- * resit might have pointed.
144
- */
145
- explicit ResultIterator(const LTRResultIterator &resit);
146
-
147
- private:
148
- /**
149
- * Calculates the current paragraph's dominant writing direction.
150
- * Typically, members should use current_paragraph_ltr_ instead.
151
- */
152
- bool CurrentParagraphIsLtr() const;
153
-
154
- /**
155
- * Returns word indices as measured from resit->RestartRow() = index 0
156
- * for the reading order of words within a textline given an iterator
157
- * into the middle of the text line.
158
- * In addition to non-negative word indices, the following negative values
159
- * may be inserted:
160
- * kMinorRunStart Start of minor direction text.
161
- * kMinorRunEnd End of minor direction text.
162
- * kComplexWord The previous word contains both left-to-right and
163
- * right-to-left characters and was treated as neutral.
164
- */
165
- void CalculateTextlineOrder(bool paragraph_is_ltr,
166
- const LTRResultIterator &resit,
167
- std::vector<int> *indices) const;
168
- /** Same as above, but the caller's ssd gets filled in if ssd != nullptr. */
169
- void CalculateTextlineOrder(bool paragraph_is_ltr,
170
- const LTRResultIterator &resit,
171
- std::vector<StrongScriptDirection> *ssd,
172
- std::vector<int> *indices) const;
173
-
174
- /**
175
- * What is the index of the current word in a strict left-to-right reading
176
- * of the row?
177
- */
178
- int LTRWordIndex() const;
179
-
180
- /**
181
- * Given an iterator pointing at a word, returns the logical reading order
182
- * of blob indices for the word.
183
- */
184
- void CalculateBlobOrder(std::vector<int> *blob_indices) const;
185
-
186
- /** Precondition: current_paragraph_is_ltr_ is set. */
187
- void MoveToLogicalStartOfTextline();
188
-
189
- /**
190
- * Precondition: current_paragraph_is_ltr_ and in_minor_direction_
191
- * are set.
192
- */
193
- void MoveToLogicalStartOfWord();
194
-
195
- /** Are we pointing at the final (reading order) symbol of the word? */
196
- bool IsAtFinalSymbolOfWord() const;
197
-
198
- /** Are we pointing at the first (reading order) symbol of the word? */
199
- bool IsAtFirstSymbolOfWord() const;
200
-
201
- /**
202
- * Append any extra marks that should be appended to this word when printed.
203
- * Mostly, these are Unicode BiDi control characters.
204
- */
205
- void AppendSuffixMarks(std::string *text) const;
206
-
207
- /** Appends the current word in reading order to the given buffer.*/
208
- void AppendUTF8WordText(std::string *text) const;
209
-
210
- /**
211
- * Appends the text of the current text line, *assuming this iterator is
212
- * positioned at the beginning of the text line* This function
213
- * updates the iterator to point to the first position past the text line.
214
- * Each textline is terminated in a single newline character.
215
- * If the textline ends a paragraph, it gets a second terminal newline.
216
- */
217
- void IterateAndAppendUTF8TextlineText(std::string *text);
218
-
219
- /**
220
- * Appends the text of the current paragraph in reading order
221
- * to the given buffer.
222
- * Each textline is terminated in a single newline character, and the
223
- * paragraph gets an extra newline at the end.
224
- */
225
- void AppendUTF8ParagraphText(std::string *text) const;
226
-
227
- /** Returns whether the bidi_debug flag is set to at least min_level. */
228
- bool BidiDebug(int min_level) const;
229
-
230
- bool current_paragraph_is_ltr_;
231
-
232
- /**
233
- * Is the currently pointed-at character at the beginning of
234
- * a minor-direction run?
235
- */
236
- bool at_beginning_of_minor_run_;
237
-
238
- /** Is the currently pointed-at character in a minor-direction sequence? */
239
- bool in_minor_direction_;
240
-
241
- /**
242
- * Should detected inter-word spaces be preserved, or "compressed" to a single
243
- * space character (default behavior).
244
- */
245
- bool preserve_interword_spaces_;
246
- };
247
-
248
- } // namespace tesseract.
249
-
250
- #endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H_
@@ -1,40 +0,0 @@
1
- // The following ifdef block is the standard way of creating macros which make STATICTESSERACT_APIing
2
- // from a DLL simpler. All files within this DLL are compiled with the STATICTESSERACT_STATICTESSERACT_APIS
3
- // symbol defined on the command line. This symbol should not be defined on any project
4
- // that uses this DLL. This way any other project whose source files include this file see
5
- // STATICTESSERACT_API functions as being imported from a DLL, whereas this DLL sees symbols
6
- // defined with this macro as being STATICTESSERACT_APIed.
7
- #ifdef STATICTESSERACT_EXPORTS
8
- #define STATICTESSERACT_API __declspec(dllexport)
9
- #else
10
- #define STATICTESSERACT_API __declspec(dllimport)
11
- #endif
12
- #include <tesseract/baseapi.h>
13
- #include <tesseract/capi.h>
14
-
15
-
16
- extern "C"
17
- {
18
- STATICTESSERACT_API tesseract::TessBaseAPI* Tesseract_Create();
19
- STATICTESSERACT_API void Tesseract_Delete(tesseract::TessBaseAPI*& tesseract_ptr);
20
- STATICTESSERACT_API int Tesseract_Init(tesseract::TessBaseAPI* tesseract_ptr, const char* datapath, const char* language);
21
- STATICTESSERACT_API void Tesseract_End(tesseract::TessBaseAPI*& tesseract_ptr);
22
- STATICTESSERACT_API void Tesseract_SetPageSegMode(tesseract::TessBaseAPI* tesseract_ptr, int mode);
23
- STATICTESSERACT_API int Tesseract_GetPageSegMode(tesseract::TessBaseAPI* tesseract_ptr);
24
- STATICTESSERACT_API float Tesseract_MeanTextConf(tesseract::TessBaseAPI* tesseract_ptr);
25
- STATICTESSERACT_API void Tesseract_SetImage(tesseract::TessBaseAPI* tesseract_ptr, const unsigned char* imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line);
26
- STATICTESSERACT_API const char* Tesseract_GetUTF8Text(tesseract::TessBaseAPI* tesseract_ptr, int* len);
27
- STATICTESSERACT_API void Tesseract_FreeUTF8Text(char*& utf8_text_ptr);
28
- STATICTESSERACT_API bool Tesseract_SetVariable(tesseract::TessBaseAPI* tesseract_ptr, const char* name, const char* value);
29
- STATICTESSERACT_API void Tesseract_Clear(tesseract::TessBaseAPI* tesseract_ptr);
30
- STATICTESSERACT_API int Tesseract_GetBlockCount(tesseract::TessBaseAPI* tesseract_ptr);
31
- STATICTESSERACT_API int Tesseract_GetLineCount(tesseract::TessBaseAPI* tesseract_ptr);
32
- STATICTESSERACT_API int Tesseract_GetWordCount(tesseract::TessBaseAPI* tesseract_ptr);
33
- STATICTESSERACT_API int Tesseract_GetCharacterCount(tesseract::TessBaseAPI* tesseract_ptr);
34
- STATICTESSERACT_API void Tesseract_GetBlockMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char*& text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
35
- STATICTESSERACT_API void Tesseract_GetLineMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char*& text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
36
- STATICTESSERACT_API void Tesseract_GetWordMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char*& text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
37
- STATICTESSERACT_API void Tesseract_GetCharacterMatch(tesseract::TessBaseAPI* tesseract_ptr, int index, char*& text, int* len, float* confidence, int* x1, int* y1, int* x2, int* y2);
38
-
39
- }
40
-