diff --git a/all_test.go b/all_test.go index 6263edf..d8ce498 100644 --- a/all_test.go +++ b/all_test.go @@ -321,16 +321,6 @@ func TestClient_HTML(t *testing.T) { }) } -func TestClient_DetectOrientationScript(t *testing.T) { - client := NewClient() - defer client.Close() - client.SetImage("./test/data/004-rotated-text.png") - deg, _, script_name, _, err := client.DetectOrientationScript() - Expect(t, err).ToBe(nil) - Expect(t, deg).ToBe(180) - Expect(t, script_name).ToBe("Latin") -} - func TestGetAvailableLangs(t *testing.T) { t.Skip("TODO") // langs, err := GetAvailableLanguages() diff --git a/client.go b/client.go index dd902be..8e8c27f 100644 --- a/client.go +++ b/client.go @@ -312,34 +312,6 @@ func (client *Client) init() error { return nil } -// Initialize tesseract::TessBaseAPI for OSD (Orientation and Script Detection) -func (client *Client) initOsd() error { - var tessdataPrefix *C.char - if client.TessdataPrefix != "" { - tessdataPrefix = C.CString(client.TessdataPrefix) - } - defer C.free(unsafe.Pointer(tessdataPrefix)) - - res := C.Init(client.api, tessdataPrefix, C.CString("osd"), nil, nil) - if res != 0 { - return fmt.Errorf("failed to initialize TessBaseAPI with code %d", res) - } - - if err := client.setVariablesToInitializedAPI(); err != nil { - return err - } - - if client.pixImage == nil { - return fmt.Errorf("PixImage is not set, use SetImage or SetImageFromBytes before DetectOrientationScript") - } - - C.SetPixImage(client.api, client.pixImage) - - client.shouldInit = true - - return nil -} - // This method flag the current instance to be initialized again on the next call to a function that // requires a gosseract API initialized: when user change the config file or the languages // the instance needs to init a new gosseract api @@ -347,7 +319,7 @@ func (client *Client) flagForInit() { client.shouldInit = true } -// This method sets all the specified variables to TessBaseAPI structure. +// This method sets all the sspecified variables to TessBaseAPI structure. // Because `api->SetVariable` must be called after `api->Init()`, // gosseract.Client.SetVariable cannot call `api->SetVariable` directly. // See https://zdenop.github.io/tesseract-doc/classtesseract_1_1_tess_base_a_p_i.html#a2e09259c558c6d8e0f7e523cbaf5adf5 @@ -404,25 +376,6 @@ func (client *Client) HOCRText() (out string, err error) { return } -func (client *Client) DetectOrientationScript() (int, float32, string, float32, error) { - if err := client.initOsd(); err != nil { - return 0, 0, "", 0, err - } - var ( - orient_deg C.int - orient_conf C.float - script_name *C.char - script_conf C.float - ) - defer C.free(unsafe.Pointer(script_name)) - C.DetectOrientationScript(client.api, &orient_deg, &orient_conf, &script_name, &script_conf) - if script_name == nil { - return int(orient_deg), float32(orient_conf), "", float32(script_conf), fmt.Errorf("script name is null") - } - - return int(orient_deg), float32(orient_conf), C.GoString(script_name), float32(script_conf), nil -} - // BoundingBox contains the position, confidence and UTF8 text of the recognized word type BoundingBox struct { Box image.Rectangle diff --git a/tessbridge.cpp b/tessbridge.cpp index cef7f00..c37378b 100644 --- a/tessbridge.cpp +++ b/tessbridge.cpp @@ -105,11 +105,6 @@ char* HOCRText(TessBaseAPI a) { return api->GetHOCRText(0); } -void DetectOrientationScript(TessBaseAPI a, int* orient_deg, float* orient_conf, const char** script_name, float* script_conf) { - tesseract::TessBaseAPI* api = (tesseract::TessBaseAPI*)a; - api->DetectOrientationScript(orient_deg, orient_conf, script_name, script_conf); -} - bounding_boxes* GetBoundingBoxesVerbose(TessBaseAPI a) { using namespace tesseract; tesseract::TessBaseAPI* api = (tesseract::TessBaseAPI*)a; diff --git a/tessbridge.h b/tessbridge.h index a06e6ce..161c08a 100644 --- a/tessbridge.h +++ b/tessbridge.h @@ -31,7 +31,6 @@ void SetPageSegMode(TessBaseAPI, int); int GetPageSegMode(TessBaseAPI); char* UTF8Text(TessBaseAPI); char* HOCRText(TessBaseAPI); -void DetectOrientationScript(TessBaseAPI, int*, float*, const char**, float*); const char* Version(TessBaseAPI); const char* GetDataPath(); diff --git a/test/data/004-rotated-text.png b/test/data/004-rotated-text.png deleted file mode 100644 index b3a4908..0000000 Binary files a/test/data/004-rotated-text.png and /dev/null differ diff --git a/test/runtimes/alpine.Dockerfile b/test/runtimes/alpine.Dockerfile index 013219b..39a4473 100644 --- a/test/runtimes/alpine.Dockerfile +++ b/test/runtimes/alpine.Dockerfile @@ -7,7 +7,7 @@ RUN apk add \ musl-dev \ go \ tesseract-ocr-dev -RUN apk add tesseract-ocr-data-osd tesseract-ocr-data-eng +RUN apk add tesseract-ocr-data-eng ENV GOPATH=/root/go