Android : How to capture text from camera without

2019-07-13 18:02发布

问题:

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:

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.



回答2:

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.



标签: android ocr