Turn android opencv camera prepair for OCR - android

I am going to create an android app which can capture the document paper to do OCR by using opencv camera. I am looking for the best way to turn opencv camera to get OCR optimize images (focus on document text, make text clearer) before OCR process.
I know there are some pre-processing image methods before OCR, but I want to get OCR optimize input sources before process them, for example, by using CvCameraViewListener2 to process frame.
Is there any suggestion to do this?

Related

Regarding opening camera in Android Things for OpenCV

I am trying to develop a camera app which captures image and process it using OpenCV in Kotlin language. I am trying to develop it for Android Things Odroid N2+ board.
For now, I am struggling with the camera2 API.
I have a question. For image processing using OpenCV, can we use the camera2 API or does OpenCV provide separate library/tools for camera capturing and processing image for Android ?
Having no experience in OpenCV library I have heard that VideoCapture class is used in python for this purpose.
The processing part involves first capturing a reference image and then comparing other images with the reference image.
How can I go about camera capture issue for image processing ?

Rapid text recognition from Android or iOS video camera

Are any of the current text capture APIs (e.g. Google's Text API) fast enough to capture text from a phone's video feed, and draw a box that stays on the text even as the camera moves?
I don't need fast enough to do full OCR per-frame (though that would be amazing!). I'm just looking for fast enough to recognize blocks of text and keep the bounding box displayed in sync with the live image.
There are two major options for good results. They are both C++ but there are wrappers. I've personally played with OpenCV for face recognition and the results were promising. Below links with small tutorials and demos.
OpenCV
Tessaract by Google
Firebase
onDeviceTextRecognizer is simple and working for me.

Tesseract getutf8text performance

I have been working with an app that uses the Tesseract API in order to support OCR. This is done by using a Surfaceview which shows the camera output (Camera2 API) and a ImageReader instance which is used to get the images from the camera. The camera is setup to be of the type setRepeatingRequest so new images are available very frequent. When I make a call to the getutf8text() method to get the readable text in images it makes the preview of the camera which is showed on the Surfaceview lag.
Are there any settings in the Tesseract API which can be set so it speeds up the getutf8text() method call or anything else I can do in order to get the preview Surfaceview to not lag?
Any help or guidance is appreciated!
Most of the things that you can do to speed up performance occur separately from the Tesseract API itself:
Run the OCR on a separate, non-UI thread
Grab a new image to start OCR on after OCR has finished on the last image. Try capture instead of setRepeatingRequest.
Downsample the image before OCR, so that it's smaller
Experiment with different Tesseract page segmentation modes to see what's the fastest on your data
Re-train the Tesseract trained data file to use fewer characters and a smaller dictionary, depending on what your app is used for
Modify Tesseract to perform only recognition pass #1
Don't forget to consider OpenCV or other approaches altogether
You didn't say what Tesseract API settings you're using now, and you didn't describe what your app does in a general sense, so it's hard to tell you where to start, but these points should get you started.
There are a few other things which you can try.
Init tesseract with OEM_TESSERACT_ONLY
Instead of using full-blown training data, use a faster alternative from https://github.com/tesseract-ocr/tessdata_fast.
Move the recognition to the computation thread.

Number and text detection possible with opencv android while video capture?

Is it possible to detect numbers or text while capturing video in android using opencv or any other best image& video processing api's
Yes, you can. OpenCV 3.0.0 includes a text detection tool which is based in Extremal Region detection and classification. You can use this in a video stream. Notice that this is detection, and the results can be used as the input of any OCR (as Tesseract). But remember:
Image -> Text Detection -> Preprocessing (binarization,etc) -> OCR -> Recognized Text
Hope that it helps!
You will need a capable OCR engine which will try to detect characters by any number of means. Tesseract is a good open source engine which will try to 'parse' your image for characters by masking.
However, there are several steps or approaches you need to take before you feed your OCR engine(Tesseract) your image. In order to ensure more accurate results, you need to 'clean' your image using binarization along with a number of other conventional methods such as 'canny' edge detection. This is where 'OpenCV' can help.
Also, you should isolate/detect characters in images. This can be done with powerful algorithms such as the Stroke Width Transform
Regarding detection on a video stream in android, you can run your captured frames through the cleansing and OCR engine as they are recieved through:
onPreviewFrame(byte[] data, Camera camera)
Also, check out this app which allows OCR in 'continuous preview' mode.
Hope this helps

Why on Android, OpenCV camera is faster than the Android Camera when capturing video

In a project on Android, I'm trying to capture the video and process it in realtime (like a Kinect). I tried with two method: using OpenCV keep calling mCamera.grab() and capture.retrieve(mRgba,Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); or the Android's Camera by keep capturing image.
I feel that the OpenCV camera's ability to capture image faster than the Android one. But why?
OpenCV uses a hack to get low level access to the Android camera. It allows to avoid several data copyings and transitions between native and managed layers.

Categories

Resources