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

Commit

Permalink
Improve data path used for testing. Closes #208.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtheis committed May 18, 2017
1 parent cc75026 commit fa9c178
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
29 changes: 15 additions & 14 deletions preparetests.cmd
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
for /f %%i in ('adb shell echo $EXTERNAL_STORAGE') do set DIR=%%i

git clone https://github.com/tesseract-ocr/tessdata.git

adb shell rm /sdcard/testAddPageToDocument.pdf
adb shell rm /sdcard/testCreate.pdf
adb shell rm %DIR%/testAddPageToDocument.pdf
adb shell rm %DIR%/testCreate.pdf

adb uninstall com.googlecode.tesseract.android.test

adb shell mkdir /sdcard/tesseract
adb shell mkdir /sdcard/tesseract/tessdata
adb shell mkdir %DIR%/tessdata

adb push -p tessdata/eng.cube.bigrams /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.fold /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.lm /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.nn /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.params /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.size /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.word-freq /sdcard/tesseract/tessdata
adb push -p tessdata/eng.tesseract_cube.nn /sdcard/tesseract/tessdata
adb push -p tessdata/eng.traineddata /sdcard/tesseract/tessdata
adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf /sdcard/tesseract/tessdata
adb push -p tessdata/eng.cube.bigrams %DIR%/tessdata
adb push -p tessdata/eng.cube.fold %DIR%/tessdata
adb push -p tessdata/eng.cube.lm %DIR%/tessdata
adb push -p tessdata/eng.cube.nn %DIR%/tessdata
adb push -p tessdata/eng.cube.params %DIR%/tessdata
adb push -p tessdata/eng.cube.size %DIR%/tessdata
adb push -p tessdata/eng.cube.word-freq %DIR%/tessdata
adb push -p tessdata/eng.tesseract_cube.nn %DIR%/tessdata
adb push -p tessdata/eng.traineddata %DIR%/tessdata
adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf %DIR%/tessdata
15 changes: 8 additions & 7 deletions preparetests.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
#!/bin/sh

DIR="`adb shell echo \\$EXTERNAL_STORAGE`"

git clone https://github.com/tesseract-ocr/tessdata.git

adb shell rm /sdcard/testAddPageToDocument.pdf
adb shell rm /sdcard/testCreate.pdf
adb shell rm $DIR/testAddPageToDocument.pdf
adb shell rm $DIR/testCreate.pdf

adb uninstall com.googlecode.tesseract.android.test

adb shell mkdir /sdcard/tesseract
adb shell mkdir /sdcard/tesseract/tessdata
adb shell mkdir $DIR/tessdata

for f in tessdata/eng.*; do
TRAINEDDATA_FILENAME="/sdcard/tesseract/tessdata/`basename $f`"
TRAINEDDATA_FILENAME="$DIR/tessdata/`basename $f`"

if [ `adb shell "if [ -f $TRAINEDDATA_FILENAME ]; then echo 1; fi"` ]; then
echo "$TRAINEDDATA_FILENAME already present on device"
continue
fi

echo "Copying $f to device...";
adb push -p $f /sdcard/tesseract/tessdata
adb push -p $f $DIR/tessdata
done

adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf /sdcard/tesseract/tessdata
adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf $DIR/tessdata

# adb shell am instrument -w com.googlecode.tesseract.android.test/android.test.InstrumentationTestRunner
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.os.AsyncTask;
import android.os.Environment;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.Html;
import android.util.Pair;
Expand All @@ -47,10 +48,9 @@
import java.util.concurrent.Semaphore;

public class TessBaseAPITest extends TestCase {
@SuppressLint("SdCardPath")
static final String TESSBASE_PATH = "/sdcard/tesseract/";
static final String TESSBASE_PATH = Environment.getExternalStorageDirectory().toString();
static final String DEFAULT_LANGUAGE = "eng";
private static final String TESSDATA_PATH = TESSBASE_PATH + "tessdata/";
private static final String TESSDATA_PATH = TESSBASE_PATH + "/tessdata/";
private static final String[] EXPECTED_CUBE_DATA_FILES_ENG = {
"eng.cube.bigrams",
"eng.cube.fold",
Expand Down

0 comments on commit fa9c178

Please sign in to comment.