本文整理汇总了Java中com.googlecode.tesseract.android.TessBaseAPI.setVariable方法的典型用法代码示例。如果您正苦于以下问题:Java TessBaseAPI.setVariable方法的具体用法?Java TessBaseAPI.setVariable怎么用?Java TessBaseAPI.setVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.tesseract.android.TessBaseAPI
的用法示例。
在下文中一共展示了TessBaseAPI.setVariable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectText
import com.googlecode.tesseract.android.TessBaseAPI; //导入方法依赖的package包/类
public String detectText(Bitmap bitmap) {
Log.d(TAG, "Initialization of TessBaseApi");
TessDataManager.initTessTrainedData(context);
TessBaseAPI tessBaseAPI = new TessBaseAPI();
String path = TessDataManager.getTesseractFolder();
Log.d(TAG, "Tess folder: " + path);
tessBaseAPI.setDebug(true);
tessBaseAPI.init(path, "eng");
// 白名单
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
// 黑名单
tessBaseAPI.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "[email protected]#$%^&*()_+=-[]}{;:'\"\\|~`,./<>?");
tessBaseAPI.setPageSegMode(TessBaseAPI.PageSegMode.PSM_AUTO_OSD);
Log.d(TAG, "Ended initialization of TessEngine");
Log.d(TAG, "Running inspection on bitmap");
tessBaseAPI.setImage(bitmap);
String inspection = tessBaseAPI.getHOCRText(0);
Log.d(TAG, "Confidence values: " + tessBaseAPI.meanConfidence());
tessBaseAPI.end();
System.gc();
return Tools.getTelNum(inspection);
}
示例2: doInBackground
import com.googlecode.tesseract.android.TessBaseAPI; //导入方法依赖的package包/类
@Override
protected String doInBackground(String... params) {
runOnUiThread(new Runnable() {
@Override
public void run() {
ProgressWheel pBar = (ProgressWheel) findViewById(R.id.progressBar);
pBar.setVisibility(View.VISIBLE);
pBar.spin();
pBar.setText("Fetching...");
}
});
// Sets Up Tesseract for text recognition.
baseApi = new TessBaseAPI();
baseApi.init(Environment.getExternalStorageDirectory() + "/tesseract/", "eng");
//baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
baseApi.setVariable("load_system_dawg","F");
baseApi.setVariable("load_freq_dawg","F");
baseApi.setPageSegMode(TessBaseAPI.PageSegMode.PSM_AUTO_OSD);
for (String key : card.getPatternMap().keySet()) {
if(card.getPatternMap().get(key).getResource().matches("[t][e][x][t].*")) fetchTextNew(card.getPattern(key).getResource());
}
baseApi.end();
return "sucess";
}
示例3: init
import com.googlecode.tesseract.android.TessBaseAPI; //导入方法依赖的package包/类
/**
* Initializes the OCR helper and readies it for use.
*
* @param dataPath Path the OCR data files.
* @return Bitmap with replaced colors
*/
public static synchronized OcrHelper init(@NonNull String dataPath,
@NonNull PokeInfoCalculator pokeInfoCalculator,
@NonNull GoIVSettings settings) {
if (instance == null) {
tesseract = new TessBaseAPI();
tesseract.init(dataPath, "eng");
tesseract.setPageSegMode(TessBaseAPI.PageSegMode.PSM_SINGLE_LINE);
tesseract.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/♀♂");
nidoFemale = pokeInfoCalculator.get(28).name;
nidoMale = pokeInfoCalculator.get(31).name;
nidoUngendered = nidoFemale.replace("♀", "").toLowerCase();
ocrCache = new LruCache<>(200);
appraisalCache = new LruCache<>(200);
candyWordFirst = isCandyWordFirst();
instance = new OcrHelper();
}
isPokeSpamEnabled = settings.isPokeSpamEnabled();
Map<String, String> appraisalMap = settings.loadAppraisalCache();
for (Map.Entry<String, String> entry : appraisalMap.entrySet()) {
appraisalCache.put(entry.getKey(), entry.getValue());
}
return instance;
}
示例4: digitRecognition
import com.googlecode.tesseract.android.TessBaseAPI; //导入方法依赖的package包/类
private String digitRecognition(Bitmap bitmap) {
TessBaseAPI tess = new TessBaseAPI();
tess.init(DATA_PATH, lang);
tess.setVariable("tessedit_char_whitelist", "0123456789");
tess.setImage(bitmap);
String stopNumber = tess.getUTF8Text();
tess.end();
return stopNumber;
}
示例5: populateMap
import com.googlecode.tesseract.android.TessBaseAPI; //导入方法依赖的package包/类
protected void populateMap(Bitmap bmp) throws ExecutionException, InterruptedException
{
Log.i("info", String.format("Image size: %d x %d", bmp.getWidth(), bmp.getHeight()));
// Attempt to initialize the API.
final TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(sTessBasePath.get(), DEFAULT_LANGUAGE);
baseApi.setPageSegMode(TessBaseAPI.PageSegMode.PSM_SINGLE_BLOCK);
baseApi.setImage(bmp);
Pixa allLinesPixa = baseApi.getTextlines();
Log.i("info", String.format("allLinesPixa.size() == %d", allLinesPixa.size()));
baseApi.setPageSegMode(PageSegMode.PSM_SINGLE_LINE);
Rect boxRect = allLinesPixa.getBoxRect(1);
baseApi.setRectangle(boxRect);
mStatsMap.put(mAgentStr, baseApi.getUTF8Text().replaceFirst(" .*$", ""));
Log.i("info", "Recognized Agent Name: " + mStatsMap.get(mAgentStr));
boolean varStatus = baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "0123456789,");
baseApi.setRectangle(allLinesPixa.getBoxRect(3));
mStatsMap.put(mApStr, baseApi.getUTF8Text().split("\\s")[0]);
varStatus = baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "");
Log.i("info", "AP: " + mStatsMap.get(mApStr));
for (Rect curRect : allLinesPixa.getBoxRects())
{
baseApi.setRectangle(curRect);
String text = baseApi.getUTF8Text();
for (Pair<String, Integer> statNamePair : mStatNames)
{
if (text.startsWith(statNamePair.first))
{
varStatus = baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "0123456789,M");
baseApi.setRectangle(curRect);
String[] splitStatString = baseApi.getUTF8Text().split("\\s");
int pos = statNamePair.second < 0 ? splitStatString.length+statNamePair.second : statNamePair.second;
mStatsMap.put(statNamePair.first, splitStatString[pos]);
varStatus = baseApi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "");
break;
}
}
}
baseApi.end();
}