Сначала я импортировал [b]Tess-Two[/b] из github: https://github.com/rmtheis/tess-two< /p>
И связал его с моим проектом https://github.com/GautamGupta/Simple-Android-OCR
Приложение компилируется и работает нормально. Но после нажатия на изображение, когда я нажимаю «Сохранить», оно вылетает.
Вот исходный основной вид деятельности:
[code]public class SimpleAndroidOCRActivity extends Activity { public static final String PACKAGE_NAME = "com.datumdroid.android.ocr.simple"; public static final String DATA_PATH = Environment .getExternalStorageDirectory().toString() + "/SimpleAndroidOCR/";
// You should have the trained data file in assets folder // You can get them at: // http://code.google.com/p/tesseract-ocr/downloads/list public static final String lang = "eng";
private static final String TAG = "SimpleAndroidOCR.java";
for (String path : paths) { File dir = new File(path); if (!dir.exists()) { if (!dir.mkdirs()) { Log.v(TAG, "ERROR: Creation of directory " + path + " on sdcard failed"); return; } else { Log.v(TAG, "Created directory " + path + " on sdcard"); } } }
// lang.traineddata file with the app (in assets folder) // You can get them at: // http://code.google.com/p/tesseract-ocr/downloads/list // This area needs work and optimization if (!(new File(DATA_PATH + "tessdata/" + lang + ".traineddata")).exists()) { try { AssetManager assetManager = getAssets(); InputStream in = assetManager.open("tessdata/" + lang + ".traineddata"); //GZIPInputStream gin = new GZIPInputStream(in); OutputStream out = new FileOutputStream(DATA_PATH + "tessdata/" + lang + ".traineddata");
// Transfer bytes from in to out byte[] buf = new byte[1024]; int len; //while ((lenf = gin.read(buff)) > 0) { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); //gin.close(); out.close();
Log.v(TAG, "Copied " + lang + " traineddata"); } catch (IOException e) { Log.e(TAG, "Was unable to copy " + lang + " traineddata " + e.toString()); } }
public class ButtonClickHandler implements View.OnClickListener { public void onClick(View view) { Log.v(TAG, "Starting Camera app"); startCameraActivity(); } }
TessBaseAPI baseApi = new TessBaseAPI(); baseApi.setDebug(true); baseApi.init(DATA_PATH, lang); baseApi.setImage(bitmap);
String recognizedText = baseApi.getUTF8Text();
baseApi.end();
// You now have the text in recognizedText var, you can do anything with it. // We will display a stripped out trimmed alpha-numeric version of it (if lang is eng) // so that garbage doesn't make it to the display.
Я пытаюсь запустить POC для извлечения текста из файла изображения с использованием tesseract-ocr в файле Code FastApi Python, установленном в DigitalOcean Farm Linux, и я Получите ошибку, в то время как запуск того же кода в моей местной среде Mac...
Я пытаюсь запустить POC для извлечения текста из файла изображения с использованием tesseract-ocr в файле Code FastApi Python, установленном в DigitalOcean Farm Linux, и я Получите ошибку, в то время как запуск того же кода в моей местной среде Mac...
Я работаю над проектом, где мне нужно обнаружить объекты в документе PDF.
После обнаружения объектов мне нужно прочитать текст в этом месте, поскольку он будет использоваться в качестве имени объекта. />
Мне удалось обнаружить объекты, я...