[英]Rectangular box to scan/analyze on the camera preview with Flutter Google-ml-kit Text Recognition
There's an example app using on-device Text Recognition of Google ML Kit: https://github.com/bharat-biradar/Google-Ml-Kit-plugin/tree/master/example有一个使用 Google ML Kit 的设备上文本识别的示例应用程序: https://github.com/bharat-biradar/Google-Ml-Kit-plugin/tree/master/example
I'm using the "text recognition" part of that example app in my app and it works good.我在我的应用程序中使用了该示例应用程序的“文本识别”部分,它运行良好。 The only thing I need to do but can't do is that I want to show a rectangular box on the camera preview and only want to recognize texts inside this box.我唯一需要做但不能做的是我想在相机预览上显示一个矩形框,并且只想识别这个框内的文本。 Other parts of the preview should be ignored.应忽略预览的其他部分。 Otherwise, all the text in the preview would be recognized which is bad for my use case.否则,将识别预览中的所有文本,这对我的用例不利。
It's easy to show a rectangular box on the camera preview but I don't know how to only analyze the part in that rectangular box instead of the whole preview.在相机预览上显示一个矩形框很容易,但我不知道如何只分析该矩形框中的部分而不是整个预览。 Any help please?请问有什么帮助吗?
There are two ideas you can consider:您可以考虑两个想法:
(1) Crop your camera preview down to only the rectangular box and feed that cropped image to the ML Kit API. (1) 将您的相机预览裁剪为仅矩形框,并将裁剪后的图像提供给 ML Kit API。 (2) ML Kit's Text Recognition API returns a bounding box on Android (and frame
on iOS ). (2) ML Kit 的文本识别 API 在Android (和iOS上的frame
)上返回一个边界框。 You can use that to determine if any of the text recognition results falls into or overlaps with your rectangular box.您可以使用它来确定是否有任何文本识别结果落入或与您的矩形框重叠。 Depending on your use case and the input image, this approach may not be ideal since it can return text recognition result for text not entirely inside your rectangle.根据您的用例和输入图像,这种方法可能并不理想,因为它可以为不完全位于矩形内的文本返回文本识别结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.