summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralejandro-colomar <colomar.6.4.3@gmail.com>2019-08-15 13:15:44 +0200
committeralejandro-colomar <colomar.6.4.3@gmail.com>2019-08-15 13:15:44 +0200
commit96d72f3d04ee22e71f0f3c28ee7a07d2a127bf28 (patch)
treee6bdb3fa59dd6aa47cda52b04cf06a655dfb04fa
parentb1553ef2f78b261193df81a4f12aef428cfcc720 (diff)
Remove OCR module
-rw-r--r--bin/Makefile1
-rw-r--r--inc/vision-artificial/image/ocr.h64
-rw-r--r--inc/vision-artificial/image/ocr.hpp66
-rw-r--r--src/image/iface.cpp1
-rw-r--r--src/image/ocr.c146
-rw-r--r--tmp/image/Makefile16
6 files changed, 0 insertions, 294 deletions
diff --git a/bin/Makefile b/bin/Makefile
index 91612cf..43d53ff 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -8,7 +8,6 @@ OBJS = \
$(TMP_DIR)/image/calib3d.o \
$(TMP_DIR)/image/cv.o \
$(TMP_DIR)/image/iface.o \
- $(TMP_DIR)/image/ocr.o \
$(TMP_DIR)/image/orb.o \
$(TMP_DIR)/image/zbar.o \
$(TMP_DIR)/menu/iface.o \
diff --git a/inc/vision-artificial/image/ocr.h b/inc/vision-artificial/image/ocr.h
deleted file mode 100644
index adf30b9..0000000
--- a/inc/vision-artificial/image/ocr.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2018 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#ifndef VA_IMAGE_OCR_H
-#define VA_IMAGE_OCR_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
-enum Img_OCR_Action {
- IMG_OCR_ACT_FOO = 0x000000u,
-
- IMG_OCR_ACT_OCR = 0x001000u,
- IMG_OCR_ACT_READ
-};
-
-
-/******************************************************************************
- ******* structs / unions *****************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* extern functions *****************************************************
- ******************************************************************************/
-void img_ocr_act (int action, const void *data);
-
-
-/******************************************************************************
- ******* static inline functions (prototypes) *********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* static inline functions (definitions) ********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#endif /* vision-artificial/image/ocr.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/inc/vision-artificial/image/ocr.hpp b/inc/vision-artificial/image/ocr.hpp
deleted file mode 100644
index 7984152..0000000
--- a/inc/vision-artificial/image/ocr.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2018 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#ifndef VA_IMG_OCR_HPP
-#define VA_IMG_OCR_HPP
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
-enum Img_OCR_Action {
- IMG_OCR_ACT_FOO = 0x000000u,
-
- IMG_OCR_ACT_OCR = 0x001000u,
- IMG_OCR_ACT_READ
-};
-
-
-/******************************************************************************
- ******* structs / unions *****************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* extern functions *****************************************************
- ******************************************************************************/
-extern "C" {
-void img_ocr_act (int action, const void *data);
-}
-
-
-/******************************************************************************
- ******* static inline functions (prototypes) *********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* static inline functions (definitions) ********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#endif /* vision-artificial/image/ocr.hpp */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/src/image/iface.cpp b/src/image/iface.cpp
index 067fb67..834f035 100644
--- a/src/image/iface.cpp
+++ b/src/image/iface.cpp
@@ -31,7 +31,6 @@
#include "vision-artificial/image/calib3d.hpp"
#include "vision-artificial/image/cv.hpp"
-#include "vision-artificial/image/ocr.hpp"
#include "vision-artificial/image/orb.hpp"
#include "vision-artificial/image/zbar.hpp"
#include "vision-artificial/save/save.hpp"
diff --git a/src/image/ocr.c b/src/image/ocr.c
deleted file mode 100644
index f2fa918..0000000
--- a/src/image/ocr.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2018 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-#include "vision-artificial/image/ocr.h"
-
-#include <limits.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#include <tesseract/capi.h>
-
-#include "libalx/base/errno/error.h"
-#include "libalx/base/compiler/size.h"
-
-#include "vision-artificial/share/share.h"
-#include "vision-artificial/image/iface.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* structs / unions *****************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* static functions (prototypes) ****************************************
- ******************************************************************************/
-static void img_ocr_read (const void *data);
-
-
-/******************************************************************************
- ******* global functions *****************************************************
- ******************************************************************************/
-void img_ocr_act (int action, const void *data)
-{
-
- switch (action) {
- case IMG_OCR_ACT_READ:
- img_ocr_read(data);
- break;
- }
-}
-
-
-/******************************************************************************
- ******* static functions (definitions) ***************************************
- ******************************************************************************/
-static void img_ocr_read (const void *data)
-{
- const struct Img_Iface_Data_Read *data_cast;
- struct TessBaseAPI *handle_ocr;
- int lang;
- char lang_str[FILENAME_MAX];
- int conf;
- char conf_str[FILENAME_MAX];
- char *txt;
-
- /* Data */
- data_cast = (const struct Img_Iface_Data_Read *)data;
-
- /* Language */
- lang = data_cast->lang;
- switch (lang) {
- case IMG_IFACE_OCR_LANG_ENG:
- sprintf(lang_str, "eng");
- break;
- case IMG_IFACE_OCR_LANG_SPA:
- sprintf(lang_str, "spa");
- break;
- case IMG_IFACE_OCR_LANG_CAT:
- sprintf(lang_str, "cat");
- break;
- case IMG_IFACE_OCR_LANG_DIGITS:
- sprintf(lang_str, "digits");
- break;
- case IMG_IFACE_OCR_LANG_DIGITS_COMMA:
- sprintf(lang_str, "digits_comma");
- break;
- }
-
- /* Config file */
- conf = data_cast->conf;
- switch (conf) {
- case IMG_IFACE_OCR_CONF_PRICE:
- if (snprintf(conf_str, sizeof(conf_str), "%s/%s", SHARE_DIR,
- "price") >= SSIZEOF(conf_str)) {
- alx_perror(conf_str);
- conf = IMG_IFACE_OCR_CONF_NONE;
- }
- break;
- }
-
- /* init OCR */
- handle_ocr = TessBaseAPICreate();
-#if defined(OEM_LSTM_ONLY)
- TessBaseAPIInit2(handle_ocr, NULL, lang_str, OEM_LSTM_ONLY);
-#else
- TessBaseAPIInit2(handle_ocr, NULL, lang_str, OEM_DEFAULT);
-#endif
-/* TessBaseAPIInit2(handle_ocr, NULL, lang_str, OEM_TESSERACT_LSTM_COMBINED);*/
-
- /* Configure OCR (whitelist chars) */
- if (conf)
- TessBaseAPIReadConfigFile(handle_ocr, conf_str);
-
- /* scan image for text */
- TessBaseAPISetImage(handle_ocr, data_cast->img.data,
- data_cast->img.width, data_cast->img.height,
- data_cast->img.B_per_pix,
- data_cast->img.B_per_line);
- TessBaseAPIRecognize(handle_ocr, NULL);
- txt = TessBaseAPIGetUTF8Text(handle_ocr);
-
- /* Copy text to global variable */
- snprintf(img_ocr_text, OCR_TEXT_MAX, "%s", txt);
-
- /* cleanup */
- TessDeleteText(txt);
- TessBaseAPIEnd(handle_ocr);
- TessBaseAPIDelete(handle_ocr);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/tmp/image/Makefile b/tmp/image/Makefile
index 21d9be7..91566f6 100644
--- a/tmp/image/Makefile
+++ b/tmp/image/Makefile
@@ -16,7 +16,6 @@ OBJ = \
calib3d.o \
cv.o \
iface.o \
- ocr.o \
orb.o \
zbar.o
@@ -36,7 +35,6 @@ IFACE_INC = \
$(INC_DIR)/vision-artificial/image/iface.hpp \
$(INC_DIR)/vision-artificial/image/calib3d.hpp \
$(INC_DIR)/vision-artificial/image/cv.hpp \
- $(INC_DIR)/vision-artificial/image/ocr.hpp \
$(INC_DIR)/vision-artificial/image/orb.hpp \
$(INC_DIR)/vision-artificial/image/zbar.hpp \
$(INC_DIR)/vision-artificial/save/save.hpp \
@@ -44,13 +42,6 @@ IFACE_INC = \
IFACE_SRC = \
$(SRC_DIR)/image/iface.cpp
-OCR_INC = \
- $(INC_DIR)/vision-artificial/image/ocr.h \
- $(INC_DIR)/vision-artificial/image/iface.h \
- $(INC_DIR)/vision-artificial/share/share.h
-OCR_SRC = \
- $(SRC_DIR)/image/ocr.c
-
ORB_INC = \
$(INC_DIR)/vision-artificial/image/orb.hpp
ORB_SRC = \
@@ -91,13 +82,6 @@ iface.o: iface.s
@echo " AS vision-artificial/image/$@"
$(Q)$(AS) $< -o $@
-ocr.s: $(OCR_SRC) $(OCR_INC)
- @echo " CC vision-artificial/image/$@"
- $(Q)$(CC) $(CFLAGS) -I $(INC_DIR) -S $< -o $@
-ocr.o: ocr.s
- @echo " AS vision-artificial/image/$@"
- $(Q)$(AS) $< -o $@
-
orb.s: $(ORB_SRC) $(ORB_INC)
@echo " CXX vision-artificial/image/$@"
$(Q)$(CXX) $(CXXFLAGS) -I $(INC_DIR) -S $< -o $@