I would like to implement near real-time OCR on the camera feed of my flutter app. To do this I would like to access the camera data in a speedy manner. As far as I can tell I have two options, and have hit roadblocks with both:
Take a screenshot of the
CameraPreview
by putting aRepaintBoundary
around it and creating aRenderRepaintBoundary
, and callingboundary.toImage()
. The problem with this method is that the .toImage method only seems to capture the painted widgets in the boundary and not the data from the camera preview. Simmilar to the issue described here: https://github.com/flutter/flutter/issues/17687Capture an image with
controller.takePicture(filePath)
from Camera 0.2.1, similar to the example docs. The problem here is that it takes super long before the image becomes available (2-3 seconds). I guess that this is because the file is saved to the disc on capture and then needs to be read from the file again.
Is there any way that one can directly access the picture information after capture, to do things like pre-process and OCR?
For "near real-time OCR", you need
CameraController#startImageStream
example code
This functionality was merged to https://github.com/flutter/plugins but it was not well documented.
Ref: