Android : How to capture text from camera without taking picture?

寵の児 提交于 2019-12-23 12:34:10

问题


I want to capture texts and numbers that showing with camera without taking picture using tess-two(in android and eclipse). I dont want to save image file.

something like this (it is capturing live on camera):

I have used tess-two , but i have to take picture first and then capture text. (using link : https://stackoverflow.com/questions/19533273/best-ocr-optical-character-recognition-example-in-android)

and I have used this (https://www.codeproject.com/Articles/840623/Android-Character-Recognition) to create behaviour like picture I have uploaded but it should take picture too.

so how can I achieve that?Is it possible?


回答1:


You can get the bitmap of the thumbnail easily as given in the android documentation here but from your question it seems like you will need the full size picture bitmap, so to get the full size bitmap you have to point the camera to some file where the capture picture can be stored.

To get the full size bitmap try this

private String imagePath = "";

private void startCamera() {
    // create a collision-resistant file name
    String fileUniqueName= new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = fileUniqueName + ".jpg";

    File storageDir = Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_PICTURES);
    imagePath = storageDir.getAbsolutePath() + "/" + imageFileName;
    File file = new File(imagePath);
    Uri outputFileUri = Uri.fromFile(file);

    Intent cameraIntent = new     Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);               
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(cameraIntent, 1);
}

Handle the captured image

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        File tempFile = new  File(imagePath);
        if(tempFile.exists()){        
            Bitmap requiredBitmap = BitmapFactory.decodeFile(tempFile.getAbsolutePath());
        }
    }
}

This captured image will not be shown in the gallery.




回答2:


Alternatively, you can use free SDK that does OCR without taking any picture: ABBYY Real-time Recognition SDK. It does all the work for manitulating video stream for you.

Disclaimer: I work for ABBYY.



来源:https://stackoverflow.com/questions/41735254/android-how-to-capture-text-from-camera-without-taking-picture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!