Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Hardcoded path in TessBaseAPITest.java #208

Closed
Robyer opened this issue May 15, 2017 · 4 comments
Closed

Hardcoded path in TessBaseAPITest.java #208

Robyer opened this issue May 15, 2017 · 4 comments

Comments

@Robyer
Copy link
Contributor

Robyer commented May 15, 2017

TessBaseAPITest.java uses hardcoded path "/sdcard/tesseract/" instead of Environment.getExternalStorageDirectory() (or similar) as Lint warns. Why is the warning supressed? In current state everyone have to hardcode their own path when they want to run tests.

See https://github.com/rmtheis/tess-two/blob/master/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java#L50-L51

EDIT: Furthermore, this path is not consistent with your readme for end users, see:

Pre-requisites

Android 2.3 or higher
A v3.04 trained data file for a language. Data files must be copied to the Android device in a subdirectory named tessdata.

But tests currently uses <sdcard>/tesseract/tessdata instead of <sdcard>/tessdata as readme suggests. It would be good to use same path in tests.

@rmtheis
Copy link
Owner

rmtheis commented May 16, 2017

Hmm--true. Currently it's set up this way so that preparetests.sh (or preparetests.cmd) can be run from the command line to install the training data into a known/standard location and clean up files before running the tests. If Environment.getExternalStorageDirectory() were used instead, then the install location wouldn't be known prior to runtime and the setup scripts wouldn't be usable as-is.

Do you have a suggestion for how to remove the hard-coded path in a way that also makes it easy to set up a device for testing?

@Robyer
Copy link
Contributor Author

Robyer commented May 16, 2017

Oh, I see... I googled a bit and found a possible solution: https://android.stackexchange.com/a/14109/199338

So adb shell echo $EXTERNAL_STORAGE in preparetests.cmd (on Windows it works without escaping), and for linux perhaps adb shell echo \$EXTERNAL_STORAGE (but I didn't test this). This will give us in my case /sdcard string.

Then in Java we can use System.getenv("EXTERNAL_STORAGE") which will give us the same value /sdcard. Note when using Environment.getExternalStorageDirectory().getAbsolutePath() I will get /storage/emulated/0 in my case (Samsung Galaxy S7),but I believe it points to the same directory in filesystem as I tried using both in TessBaseAPITest and both worked.

So this works:
static final String TESSBASE_PATH = System.getenv("EXTERNAL_STORAGE") + "/";

@rmtheis
Copy link
Owner

rmtheis commented May 18, 2017

I just re-read your second comment and I see that your suggestion differs a little from the change I just pushed. Let me know if that change doesn't work for you.

@Robyer
Copy link
Contributor Author

Robyer commented May 18, 2017

It works 👍

rmtheis added a commit that referenced this issue Aug 12, 2018
commit f465360
Author: Robert Theis <[email protected]>
Date:   Fri Apr 20 07:24:09 2018 -0700

    Edit change log

commit 6aa9dc7
Author: Robert Theis <[email protected]>
Date:   Fri Apr 20 07:17:42 2018 -0700

    Edit change log

commit ce13d6f
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 20:56:55 2018 -0700

    Update change log

commit 35d3569
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 20:13:58 2018 -0700

    Set version to 9.0.0

commit 3b7e544
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 20:00:01 2018 -0700

    Fix 64-bit issues. Closes #197.

commit 229906e
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 19:01:38 2018 -0700

    Fix null check

commit 6509ff4
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 18:38:45 2018 -0700

    Add missing includes

commit 4a4bc77
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 17:51:19 2018 -0700

    Update dependency versions

commit 0766501
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 17:41:17 2018 -0700

    Mute libjpeg build warning

commit 5c0b8e3
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 17:17:49 2018 -0700

    Update documentation

commit e2bea65
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 16:44:51 2018 -0700

    Catch Arabic/Hindi init misconfigurations. Closes #240.

commit b0f3c2c
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 13:40:38 2018 -0700

    Edit ABI targets

commit 4661d8e
Author: Robert Theis <[email protected]>
Date:   Thu Apr 19 12:45:51 2018 -0700

    Minor edit to Gradle config

commit 3436f01
Merge: 14fa90a a5fac7d
Author: Robert Theis <[email protected]>
Date:   Wed Jan 17 17:12:42 2018 -0800

    Merge pull request #233 from mauriciotogneri/master

    Updated repositories. Changed compile to implementation.

commit a5fac7d
Author: mtogneri <[email protected]>
Date:   Sat Jan 6 17:57:13 2018 +0100

    Updated repositories. Changed compile to implementation.

commit 14fa90a
Merge: d85ef2d ce84fcd
Author: Robert Theis <[email protected]>
Date:   Thu Dec 28 20:28:25 2017 -0800

    Merge pull request #231 from mauriciotogneri/master

    Updated version of SDK, build tools and support libraries

commit ce84fcd
Author: Mauricio Togneri <[email protected]>
Date:   Fri Dec 15 10:19:15 2017 +0100

    Updated version of SDK, build tools and support libraries

commit d85ef2d
Author: Robert Theis <[email protected]>
Date:   Thu Sep 7 21:46:50 2017 -0700

    Add support annotations

commit 52be81e
Author: Robert Theis <[email protected]>
Date:   Sat Aug 12 20:10:17 2017 -0700

    Update change log

commit d5849be
Author: Robert Theis <[email protected]>
Date:   Sat Aug 12 19:17:18 2017 -0700

    Set version to 8.0.0

commit 688d487
Author: Robert Theis <[email protected]>
Date:   Sat Aug 12 19:17:04 2017 -0700

    Don't build 64-bit ABIs by default

commit ab9b9a3
Author: Robert Theis <[email protected]>
Date:   Sat Jul 22 14:32:20 2017 -0700

    Update readme

commit 5a1e4e2
Author: Robert Theis <[email protected]>
Date:   Wed Jun 28 07:22:16 2017 -0700

    Update Github issue template

commit b57e6af
Merge: 1632130 2dc4ac4
Author: Robert Theis <[email protected]>
Date:   Fri Jun 16 06:37:05 2017 -0700

    Merge pull request #217 from ivankolev/master

    clone tag 3.04.00 from tessdata

commit 2dc4ac4
Author: ivankolev <[email protected]>
Date:   Thu Jun 15 21:06:06 2017 -0400

    clone tag 3.04.00 from tessdata, as master now contains traineddata files for tesseract 4, notably it does not contain eng.cube.* files

commit 1632130
Merge: dafeb3c d727e0c
Author: Robert Theis <[email protected]>
Date:   Wed Jun 14 07:53:18 2017 -0700

    Merge pull request #216 from ivankolev/master

    See issue #215

commit d727e0c
Merge: b4066f1 dafeb3c
Author: ivankolev <[email protected]>
Date:   Tue Jun 13 18:19:09 2017 -0400

    Merge remote-tracking branch 'original-origin/master'

commit dafeb3c
Author: Robert Theis <[email protected]>
Date:   Mon Jun 12 21:25:03 2017 -0700

    Update .gitignore

commit 0bb3eb5
Author: Robert Theis <[email protected]>
Date:   Mon Jun 12 21:23:54 2017 -0700

    Update Gradle plugin

commit a00479b
Author: Robert Theis <[email protected]>
Date:   Mon Jun 12 20:47:15 2017 -0700

    Update change log

commit 686a681
Author: Robert Theis <[email protected]>
Date:   Mon Jun 12 20:09:03 2017 -0700

    Set version to 7.0.0

commit b4066f1
Author: ivankolev <[email protected]>
Date:   Mon Jun 12 18:20:48 2017 -0400

    add header files explicitly so "gradlew assemble" could finish successfully

commit fa9c178
Author: Robert Theis <[email protected]>
Date:   Wed May 17 19:59:07 2017 -0700

    Improve data path used for testing. Closes #208.

commit cc75026
Merge: aa4933b 65a5987
Author: Robert Theis <[email protected]>
Date:   Mon May 15 22:32:02 2017 -0400

    Merge pull request #209 from Robyer/fixPageSegMode

    Add missing PageSegMode constant

commit 65a5987
Author: Robert Pösel <[email protected]>
Date:   Mon May 15 12:59:10 2017 +0200

    Remove PSM_COUNT constant

    It is useless to have this in Java API.

commit 4c75483
Author: Robert Pösel <[email protected]>
Date:   Mon May 15 12:50:57 2017 +0200

    Add missing PSM_RAW_LINE mode

    It was added in Tesseract v3.04

commit aa4933b
Author: Robert Theis <[email protected]>
Date:   Sun May 14 13:19:33 2017 -0700

    Minor update to Javadoc for ResultIterator

commit ba06c7e
Merge: 43c52fe bfe2bcf
Author: Robert Theis <[email protected]>
Date:   Sun May 14 15:52:54 2017 -0400

    Merge pull request #206 from Robyer/improveResultIterator

    Improve ResultIterator

commit 43c52fe
Author: Robert Theis <[email protected]>
Date:   Sun May 14 12:05:54 2017 -0700

    Update test to check BeginDocument return value

commit 615586c
Merge: 98995d4 00d093d
Author: Robert Theis <[email protected]>
Date:   Sun May 14 15:04:33 2017 -0400

    Merge pull request #207 from Robyer/fixBeginDocument

    Fix return value of BeginDocument (fixes #103)

commit 98995d4
Merge: 3bda8b1 939b96e
Author: Robert Theis <[email protected]>
Date:   Sun May 14 14:11:32 2017 -0400

    Merge pull request #205 from Robyer/updateGradlePlugin

    Update gradle plugin

commit 00d093d
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 04:52:56 2017 +0200

    Fix return value of BeginDocument (fixes #103)

    pdfRenderer->BeginDocument return true on success so the condition was wrongly inverted. This commit fixes that and uses a bit cleaner code.

commit bfe2bcf
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 03:59:49 2017 +0200

    Fix typo in nativeDelete method

commit 56203ad
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 04:39:52 2017 +0200

    ResultIterator: Add IsAtBeginningOf and IsAtFinalElement methods

commit 506d004
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 03:35:19 2017 +0200

    Fix static native method parameter

commit bdd2fe7
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 03:06:03 2017 +0200

    Fix size of string holding symbol and confidence

    We're printing "%s|%.2f" which could end up in "%s|100.00" so it's "strlen(utfText) + 7".

commit af9fc83
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 03:01:17 2017 +0200

    ResultIterator can't return choices with custom level (closes #119)

    ChoicesIterator always return only list of alternatives of symbol, it doesn't let us specify different PageIteratorLevel here. So this commit removes the method parameter and renames the whole method to make more sense.

commit 939b96e
Author: Robert Pösel <[email protected]>
Date:   Thu May 11 02:51:57 2017 +0200

    Update gradle plugin

commit 3bda8b1
Merge: 3debecf 7792a02
Author: Robert Theis <[email protected]>
Date:   Thu Apr 27 07:12:34 2017 -0700

    Merge pull request #202 from Robyer/fixJavadocs

    Fix javadocs errors and warnings

commit 7792a02
Author: Robert Pösel <[email protected]>
Date:   Thu Apr 27 08:27:01 2017 +0200

    Fix javadocs errors and warnings
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants