Merge pull request #1806 from stweil/training

training: Add new flag --workspace_dir to tesstraining_utils.sh
This commit is contained in:
Egor Pugin 2018-07-26 20:05:34 +03:00 committed by GitHub
commit 51c1950129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,8 +18,10 @@
if [ "$(uname)" == "Darwin" ];then if [ "$(uname)" == "Darwin" ];then
FONTS_DIR="/Library/Fonts/" FONTS_DIR="/Library/Fonts/"
FONT_CONFIG_CACHE=$(mktemp -d -t font_tmp.XXXXXXXXXX)
else else
FONTS_DIR="/usr/share/fonts/" FONTS_DIR="/usr/share/fonts/"
FONT_CONFIG_CACHE=$(mktemp -d --tmpdir font_tmp.XXXXXXXXXX)
fi fi
OUTPUT_DIR="/tmp/tesstrain/tessdata" OUTPUT_DIR="/tmp/tesstrain/tessdata"
OVERWRITE=0 OVERWRITE=0
@ -148,6 +150,13 @@ parse_flags() {
--wordlist) --wordlist)
parse_value "WORDLIST_FILE" ${ARGV[$j]} parse_value "WORDLIST_FILE" ${ARGV[$j]}
i=$j ;; i=$j ;;
--workspace_dir)
rmdir "$FONT_CONFIG_CACHE"
rmdir "$WORKSPACE_DIR"
parse_value "WORKSPACE_DIR" ${ARGV[$j]}
FONT_CONFIG_CACHE=$WORKSPACE_DIR/fc-cache
mkdir -p $FONT_CONFIG_CACHE
i=$j ;;
*) *)
err_exit "Unrecognized argument ${ARGV[$i]}" ;; err_exit "Unrecognized argument ${ARGV[$i]}" ;;
esac esac
@ -192,11 +201,7 @@ parse_flags() {
# Function initializes font config with a unique font cache dir. # Function initializes font config with a unique font cache dir.
initialize_fontconfig() { initialize_fontconfig() {
if [[ "$OSTYPE" == "darwin"* ]]; then export FONT_CONFIG_CACHE
export FONT_CONFIG_CACHE=$(mktemp -d -t font_tmp.XXXXXXXXXX)
else
export FONT_CONFIG_CACHE=$(mktemp -d --tmpdir font_tmp.XXXXXXXXXX)
fi
local sample_path=${FONT_CONFIG_CACHE}/sample_text.txt local sample_path=${FONT_CONFIG_CACHE}/sample_text.txt
echo "Text" >${sample_path} echo "Text" >${sample_path}
run_command text2image --fonts_dir=${FONTS_DIR} \ run_command text2image --fonts_dir=${FONTS_DIR} \