0
갤러리에서 사진을 가져 와서 오랫동안 viewImage에 저장하고 텍스트로 변경하려고 시도합니다. 오랜 시간 동안로드되고 응답하지 않습니다. 작은 크기의 jpg 파일로 시도하면 변환. 내가 솔루션과 함께 제공하고이미지에서 텍스트로의 변환을 위해 tess-two를 사용하고 있습니다.
`public void processImage(View view){
String OCRresult = null;
mTess.setImage(photo);
OCRresult = mTess.getUTF8Text();
TextView OCRTextView = (TextView) findViewById(R.id.OCRTextView);
OCRTextView.setText(OCRresult);
}
private void checkFile(File dir) {
if (!dir.exists()&& dir.mkdirs()){
copyFiles();
}
if(dir.exists()) {
String datafilepath = datapath+ "/tessdata/eng.traineddata";
File datafile = new File(datafilepath);
if (!datafile.exists()) {
copyFiles();
}
}
}
private void copyFiles() {
try {
String filepath = datapath + "/tessdata/eng.traineddata";
AssetManager assetManager = getAssets();
InputStream instream = assetManager.open("tessdata/eng.traineddata");
OutputStream outstream = new FileOutputStream(filepath);
byte[] buffer = new byte[1024];
int read;
while ((read = instream.read(buffer)) != -1) {
outstream.write(buffer, 0, read);
}
outstream.flush();
outstream.close();
instream.close();
File file = new File(filepath);
if (!file.exists()) {
throw new FileNotFoundException();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}`