I need some advices for my future project. I'm developing OCR project for some ID documents and for this i have already integrated card.io and tess-two and overrided this sources for my project. But my main purpose is about camera. I use Camera1 which is already implemented in card.io source. But when it comes to google developers, they strongly recommend Camera2. When i try to read my documents, i get some problems about focusing, blurred parts and etc. Most part of my algorithms are in Native side. If anyone have already experienced with these technologies, what could you recommend? If i integrate my codes from camera1 to camera2, can i get better results? Thanks for reading my big question ;)
I won't describe you how to use Camera2 API, you should read and try it by your self.
General approach:
implement OnImageAvailableListener interface in your camera manager class
public final class CameraManager implements ImageReader.OnImageAvailableListener {
@Override
public synchronized void onImageAvailable(ImageReader reader) {
Image image = reader.acquireLatestImage();
if (image != null) {
analyzeFrame(image);
}
}
create ImageReader and initialize before Camera opened
private ImageReader imageReader;
private void initialize() {
//I'm using YUV_420_888 for streaming
//you may use any supported format from:
//https://developer.android.com/reference/android/graphics/ImageFormat.html
imageReader = ImageReader.newInstance(PREVIEW_WIDTH, PREVIEW_HEIGHT, ImageFormat.YUV_420_888, 1);
imageReader.setOnImageAvailableListener(this, null);
}
add surface of your imageReader
to CaptureRequest.Builder after camera opened
Surface imageSurface = imageReader.getSurface();
//...
previewRequestBuilder.addTarget(imageSurface);
handle each frame in analyzeFrame
method
private void analyzeFrame(Image image) {
//...<-- image processing
image.close();
}
Which Camera api you use?
If i integrate my codes from camera1 to camera2, can i get better results?
short answer is No, you'll get the same frames to deal with
If anyone have already experienced with these technologies, what could you recommend?
I'd recommend you to use tess-two, pay attention on OcrRecognizeAsyncTask