MCPcopy Create free account
hub / github.com/creatale/node-dv / Init

Method Init

deps/tesseract/api/baseapi.cpp:274–334  ·  view source on GitHub ↗

* The datapath must be the name of the data directory (no ending /) or * some other file in which the data directory resides (for instance argv[0].) * The language is (usually) an ISO 639-3 string or NULL will default to eng. * If numeric_mode is true, then only digits and Roman numerals will * be returned. * @return: 0 on success and -1 on initialization failure. */

Source from the content-addressed store, hash-verified

272 * @return: 0 on success and -1 on initialization failure.
273 */
274int TessBaseAPI::Init(const char* datapath, const char* language,
275 OcrEngineMode oem, char **configs, int configs_size,
276 const GenericVector<STRING> *vars_vec,
277 const GenericVector<STRING> *vars_values,
278 bool set_only_non_debug_params) {
279 PERF_COUNT_START("TessBaseAPI::Init")
280 // Default language is "eng".
281 if (language == NULL) language = "eng";
282 // If the datapath, OcrEngineMode or the language have changed - start again.
283 // Note that the language_ field stores the last requested language that was
284 // initialized successfully, while tesseract_->lang stores the language
285 // actually used. They differ only if the requested language was NULL, in
286 // which case tesseract_->lang is set to the Tesseract default ("eng").
287 if (tesseract_ != NULL &&
288 (datapath_ == NULL || language_ == NULL ||
289 *datapath_ != datapath || last_oem_requested_ != oem ||
290 (*language_ != language && tesseract_->lang != language))) {
291 delete tesseract_;
292 tesseract_ = NULL;
293 }
294 // PERF_COUNT_SUB("delete tesseract_")
295#ifdef USE_OPENCL
296 OpenclDevice od;
297 od.InitEnv();
298#endif
299 PERF_COUNT_SUB("OD::InitEnv()")
300 bool reset_classifier = true;
301 if (tesseract_ == NULL) {
302 reset_classifier = false;
303 tesseract_ = new Tesseract;
304 if (tesseract_->init_tesseract(
305 datapath, output_file_ != NULL ? output_file_->string() : NULL,
306 language, oem, configs, configs_size, vars_vec, vars_values,
307 set_only_non_debug_params) != 0) {
308 return -1;
309 }
310 }
311 PERF_COUNT_SUB("update tesseract_")
312 // Update datapath and language requested for the last valid initialization.
313 if (datapath_ == NULL)
314 datapath_ = new STRING(datapath);
315 else
316 *datapath_ = datapath;
317 if ((strcmp(datapath_->string(), "") == 0) &&
318 (strcmp(tesseract_->datadir.string(), "") != 0))
319 *datapath_ = tesseract_->datadir;
320
321 if (language_ == NULL)
322 language_ = new STRING(language);
323 else
324 *language_ = language;
325 last_oem_requested_ = oem;
326 // PERF_COUNT_SUB("update last_oem_requested_")
327 // For same language and datapath, just reset the adaptive classifier.
328 if (reset_classifier) {
329 tesseract_->ResetAdaptiveClassifier();
330 PERF_COUNT_SUB("tesseract_->ResetAdaptiveClassifier()")
331 }

Callers 8

TesseractMethod · 0.45
LoadFromFpMethod · 0.45
TessBaseAPIInit4Function · 0.45
TessBaseAPIInit1Function · 0.45
TessBaseAPIInit2Function · 0.45
TessBaseAPIInit3Function · 0.45
mainFunction · 0.45
LoadMethod · 0.45

Calls 4

InitEnvMethod · 0.80
init_tesseractMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected