2018-01-17 14:00:57 -08:00
|
|
|
#include "ocr_driver.h"
|
|
|
|
|
|
|
|
static const ocr_driver_t *ocr_backends[] = {
|
|
|
|
#ifdef HAVE_TESSERACT
|
|
|
|
&ocr_tesseract,
|
|
|
|
#endif
|
|
|
|
&ocr_null,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const ocr_driver_t *current_ocr_backend = NULL;
|
2018-01-24 18:35:14 -08:00
|
|
|
static void *ocr_data = NULL;
|
2018-01-17 14:00:57 -08:00
|
|
|
|
|
|
|
bool ocr_driver_init(void)
|
|
|
|
{
|
|
|
|
/*TODO: find name of active driver*/
|
|
|
|
|
2018-01-24 18:35:14 -08:00
|
|
|
ocr_data = NULL;
|
2018-01-17 14:00:57 -08:00
|
|
|
if (current_ocr_backend)
|
2018-01-24 18:35:14 -08:00
|
|
|
ocr_data = (*current_ocr_backend->init)();
|
|
|
|
return ocr_data != NULL;
|
2018-01-17 14:00:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ocr_driver_free(void)
|
|
|
|
{
|
2018-01-24 18:35:14 -08:00
|
|
|
if (current_ocr_backend && ocr_data)
|
|
|
|
(*current_ocr_backend->free)(ocr_data);
|
2018-01-17 14:00:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
char* ocr_driver_get_text(struct ocr_image_info image)
|
|
|
|
{
|
|
|
|
char* image_string = NULL;
|
2018-01-24 18:35:14 -08:00
|
|
|
if (current_ocr_backend && ocr_data)
|
|
|
|
image_string = (*current_ocr_backend->get_text)(ocr_data, image);
|
2018-01-17 14:00:57 -08:00
|
|
|
return image_string;
|
|
|
|
}
|