This is a B4A + B4i solution. It recognizes text in images based on Google ML Kit. Dependencies: - B4i (local Mac only): https://www.b4x.com/b4i/files/MLKit.zip Don't miss: - B4i dependencies + #PlistExtra (for MediaChooser) in Main module. - B4i bundle files under Files\Special. The...
Image source: https://en.wikipedia.org/wiki/Selfie#/media/File:TWC_Hokitika_Gorge_•_Stewart_Nimmo_•_MRD_1.jpg A B4A + B4i selfie segmentation feature based on Google ML Kit: https://developers.google.com/ml-kit/vision/selfie-segmentation The result is a mask image. In the example it is...
www.b4x.com
In the ImageToMLImage function, “alloc” is used to reserve memory space to create an MLKitVisionImage from the transferred bitmap. This memory space is not released again afterwards. This code crashes when a large number of images are processed or when very large images are used.
When using the function on iOS, it would be better to ensure that the caller has a reference to the generated MLImage so that it can be explicitly released after processing. For example:
B4X:
Dim imgML As NativeObject
imgML = ImageToMLImage(bmp).As(NativeObject)
recognizer.RunMethod("processImage:completion:", Array(imgML, Me.as(NativeObject).RunMethod("createBlock", Null)))
Wait For Process_Result(Success As Boolean, MLKText As Object)
imgML.RunMethod("release", Null)
imgML = Null