let objectDetector = ObjectDetector.objectDetector(
options: options)
浏览选项类型的 ML Kit 文档,我在这里使用的都是非常常用的。
EnableClassification
不仅为你提供边界框,还提供 ML Kit 对物体的分类。基本模型(你在此处使用的)仅识
别5种非常通用的物体类型,例如“时尚商品”或“食品”,因此请合理地管理你的期
望!
EnableMultipleObjects
选项在设置后,将允许你检测多个物体,如图 6-6 所示,
其中检测了三个物体(一只鸟和两朵花)并绘制了边界框。
最后,你把图像传递给物体检测器,让它推断出它在图像中发现的物体的标签和边界
框。这是一个异步函数,因此你需要指定在推理完成时回调的函数。 ML Kit 将返回一
个
detectedObjects
列表和一个错误对象,因此你可以简单地将它们传递给你接下来要
创建的函数:
objectDetector.process(visionImage)
{ detectedObjects, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.