fritz 使用手册_Fritz对象检测指南:使用机器学习在Android中构建宠物监控应用

fritz 使用手册

by Eric Hsiao

萧敬轩

Fritz对象检测指南:使用机器学习在Android中构建宠物监控应用 (A guide to Object Detection with Fritz: Build a pet monitoring app in Android with machine learning)

Whether it is detecting plant damage for farmers, tracking vehicles on the road, or monitoring your pets — the applications for object detection are endless. With the rise of mobile frameworks like TensorFlow Lite and Core ML, more and more mobile apps leverage the power of machine learning to create features that leave us in awe.

无论是为农民发现植物受损 ,在路上追踪车辆还是监视宠物-用于物体检测的应用层出不穷。 随着TensorFlow LiteCore ML等移动框架的兴起越来越多的移动应用利用机器学习的力量来创建令我们敬畏的功能。

那么对象检测到底是什么呢? (So what exactly is object detection?)

In plain English, object detection identifies and locates specific items in an image or live video with a bounding box.

用简单的英语来说,物体检测可以识别和定位带有边框的图像或实时视频中的特定项目。

But creating features powered by machine learning isn’t easy. Many engineering teams cannot justify the time and resources. You need the right in-house expertise to collect data, train a model, and iterate on the performance and accuracy. Understandably, with pressure from product teams to deliver value quickly for end-users, potential features are tossed aside in a backlog abyss.

但是创建由机器学习支持的功能并不容易。 许多工程团队无法证明时间和资源的合理性。 您需要合适的内部专家来收集数据,训练模型并迭代性能和准确性。 可以理解的是,在产品团队的压力下,他们需要Swift为最终用户交付价值,潜在的功能被积压的深渊抛弃了。

In this post, I’ll show you how any Android developer can use real-time object detection to create an app that detects and recognizes pets — all in less than 30 minutes. To do this, I’ll use the Fritz SDK (full disclosure, I work at Fritz) which makes it easier to leverage machine learning capabilities without any prior experience.

在这篇文章中,我将向您展示任何Android开发人员如何使用实时对象检测来创建可检测和识别宠物的应用程序-只需不到30分钟即可完成。 为此,我将使用Fritz SDK (完整的披露内容,我在Fritz工作),这使得在没有任何先验经验的情况下更容易利用机器学习功能。

入门 (Getting started)

To start using the Fritz SDK, we’ll go through adding the necessary dependencies in a sample app that we’ve created.

要开始使用Fritz SDK,我们将在我们创建的示例应用程序中添加必要的依赖项。

1.首先,创建一个Fritz帐户 (1. First, create a Fritz account)

Sign up here and follow the get started directions.

在这里注册并按照入门指南进行操作 。

2.克隆示例相机应用 (2. Clone the sample camera app)

Set up a skeleton app that includes a video feed and camera code. In this tutorial, we won’t go depth into the Camera 2 API, but if you have any questions, please leave a comment.

设置一个包含视频供稿和摄像机代码的骨架应用程序。 在本教程中,我们不会深入研究Camera 2 API ,但是如果您有任何疑问,请发表评论。

git clone https://github.com/fritzlabs/camera-sample-app

3.在webapp中注册Android应用 (3. Register the Android app in the webapp)

You need to register your app with Fritz in order to use ML-features. When you’re adding the app to Fritz, use the same applicationId (ai.fritz.camera) as the app/build.gradle.

您需要向Fritz注册应用才能使用ML功能。 将应用程序添加到Fritz时,请使用与app / build.gradle相同的applicationId(ai.fritz.camera)

Make sure you note the API Key for Step 5. If you need to access it again, you can go to Project Settings > Your App (Pet Monitor)> Show API Key (in the options menu).

确保注意步骤5的API密钥。如果需要再次访问它,则可以转到“项目设置”>“您的应用程序(宠物监控器)”>“显示API密钥”(在选项菜单中)。

4.app / build.gradle中添加FritzCore +依赖 (4. Add FritzCore + dependencies in app/build.gradle)

Make sure to add the Fritz repository. This will allow you to download the necessary dependencies:

确保添加Fritz存储库。 这将允许您下载必要的依赖项:

In the dependencies section, add these 2 libraries:

在“依赖关系”部分中,添加以下两个库:

dependencies {    implementation "ai.fritz:core:2.0.0"    implementation "ai.fritz:vision-object:2.0.0"}

5.配置SDK (5. Configure the SDK)

Call Fritz.configure in the Application or MainActivity onCreate lifecycle method with the API key you got in Step 3.

使用在步骤3中获得的API密钥,在ApplicationMainActivity onCreate生命周期方法中调用Fritz.configure

With that, you’re ready to use object detection in your app.

这样,您就可以在应用程序中使用对象检测了。

在实时视频中检测猫狗 (Detecting dogs & cats on live video)

Now let’s get to the fun stuff. We’ll jump into the MainActivity and use the object detection predictor on each frame passed in on the video stream.

现在让我们来看看有趣的东西。 我们将跳入MainActivity,并在视频流上传递的每个帧上使用对象检测预测值。

1.获取FritzVisionObjectPredictor的实例 (1. Get an instance of FritzVisionObjectPredictor)

The predictor takes in a FritzVisionImage and returns a list of FritzVisionObjects detected.

预测器接收FritzVisionImage并返回检测到的FritzVisionObjects列表。

2.将每一帧转换为FritzVisionImage对象 (2. Convert each frame to a FritzVisionImage object)

Use either fromBitmap or fromMediaImage static methods to create an object from a Bitmap or media.Image object. For the sample app, use fromMediaImage, which also takes in the rotation applied on the image from the camera.

使用fromBitmapfromMediaImage静态方法从Bitmapmedia.Image对象创建对象。 对于示例应用程序,请使用fromMediaImage 这也吸收了应用在相机图像上的旋转。

The rotation depends on the device rotation and the camera orientation sensor. The cameraId identifies the active camera being used on the device (front, back, etc.), and you can get the rotation angle with the following helper method.

旋转取决于设备旋转和相机方向传感器。 cameraId标识设备上正在使用的活动摄像机(正面,背面等),您可以使用以下辅助方法获取旋转角度。

int rotation = FritzVisionOrientation.getImageRotationFromCamera(this, cameraId);

Finally, create a FritzVisionImage object with the Image and rotation value.

最后,使用Image和rotation值创建一个FritzVisionImage对象。

3.运行预测 (3. Run prediction)

Pass the image into the predictor to detect different objects in the image.

将图像传递到预测变量中以检测图像中的不同对象。

4.过滤结果并显示边界框 (4. Filter the result and display bounding boxes)

Each FritzVisionObject comes with a label, a confidence score, and a bounding box that shows where it’s located on the original image. In this case, we only care about pets (specifically cats and dogs), so we can filter out the other items.

每个FritzVisionObject都有一个标签,一个置信度分数和一个边界框,用于显示其在原始图像上的位置。 在这种情况下,我们只关心宠物(特别是猫和狗),因此我们可以过滤掉其他物品。

Finally, display the bounding boxes around your pets. FritzVisionObject has a convenient method called drawOnCanvas which makes it easy to display the detected objects.

最后,显示宠物周围的边界框。 FritzVisionObject有一个称为drawOnCanvas的便捷方法,可轻松显示检测到的对象。

Here’s the complete code after the render callback:

这是渲染回调之后的完整代码:

Notice the scale factor on the boxes. This is because the media.Image object we used to create the FritzVisionImage object is the same size as the preview viewport. In the camera sample app, it’s 1280 x 960. The bounding boxes will have coordinates associated with the preview size. Since we want to show this on the full screen, we need to scale the result to the phone’s viewport.

注意包装盒上的比例因子。 这是因为我们用来创建FritzVisionImage对象media.Image对象是大小预览视窗相同。 在相机示例应用中,尺寸为1280 x960。边界框将具有与预览尺寸相关联的坐标。 由于我们要在全屏上显示此内容,因此需要将结果缩放到手机的视口。

Here’s the final result:

这是最终结果:

For the finished code, take a look at the GitHub repo.

有关完成的代码,请查看GitHub repo 。

为什么这很有用 (Why this is useful)

With the machine learning feature behind this basic app, there are ton of different features you can create (both practical and goofy):

有了这个基本应用程序背后的机器学习功能,您可以创建许多不同的功能(实用的和愚蠢的):

  • Alert the owners with a text message if the dog walker hasn’t returned.

    如果walk狗没有回来,请通过短信提醒主人。
  • Record a message telling your dog to “Sit down!” when they’re running around the room with no one around. I bet you could capture funny photos of your dog in this moment, too.

    记录一条消息,告诉您的狗“坐下!” 当他们在房间里跑来跑去时,没人在附近。 我敢打赌,您也可以在这一刻捕捉狗的有趣照片。
  • Show the user a message when a cat / dog is detected (take a look at the completed code for an example)

    在检测到猫/狗时向用户显示一条消息(以完整代码为例)
  • Sound an alarm when the camera detects cats (I’m allergic).

    相机检测到猫时发出警报声(我过敏)。

Of course, not many people have a spare Android tablet / phone that they can use as an expensive pet monitoring camera, but this is just a simple example among many different possibilities for how you might create an app with object detection using Fritz. I can’t wait to see what all the creative developers of the world build using object detection.

当然,没有多少人有备用的Android平板电脑/手机可以用作昂贵的宠物监控摄像头,但这只是您使用Fritz创建带有对象检测的应用程序的许多不同可能性中的一个简单示例。 我迫不及待地想看看世界上所有的创意开发人员都使用对象检测构建了什么。

Got an idea? Leave a comment!

有想法吗? 发表评论!

I’m a lead developer at Fritz specializing in mobile machine learning. If you’re looking to create features powered by AI/ML, we offer prebuilt APIs (image segmentation, image labeling, style transfer) and custom model support.

我是Fritz的首席开发人员,专门研究移动机器学习。 如果您要创建由AI / ML提供支持的功能,我们提供预构建的API( 图像分割 , 图像标签 , 样式转换 )和自定义模型支持。

翻译自: https://www.freecodecamp.org/news/a-guide-to-object-detection-with-fritz-build-a-pet-monitoring-app-in-android-with-machine-learning-a8ed500978e5/

fritz 使用手册

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/392757.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ajax无刷新评论的思路,ajax学习——ajax版无刷新评论(数据库)

//Comment.htm无刷新评论type"text/javascript">//加载评论$(function() {$.post("GetComment.ashx",function(data, status) {if (status ! "success") {$("#ulComment").append($("加载数据失败"));return;}var lines …

Numpy 新手教程(2)

翻译自官方文档Tentative NumPy Tutorial,有删节。 基本操作 主要的算术运算符都能够应用于数组类型,结果为相应元素之间的运,返回值为一个新的数组。 >>> a array( [20,30,40,50] ) >>> b arange( 4 ) >>> b a…

bl小说里面有个机器人管家_机器人也有攀登者,登顶珠峰的机器人来了!独造机器人管家...

机器人也有攀登者,登顶珠峰的机器人来了!2019年,是一个具有特殊纪念意义的年份!为庆祝祖国70华诞,各行各业纷纷献礼。9月30日,由吴京、章子怡、张译、井柏然、胡歌等知名演员主演的年度冒险电影——《攀登者》,将隆重上…

python 找出监听的端口号对号显示

刚好做运维平台,领导也有个要求是实时的查看,任意一台主机的端口开启状态,实际上我已经做了脚本发邮件每天diff的功能,但是为了方便展示还是写了这个脚本: 脚本内容: 123456789101112131415161718192021222…

2018年最新税收分类编码_2018年新编码器调查:31,000人告诉我们他们如何学习编码和获得开发人员工作

2018年最新税收分类编码More than 31,000 people responded to our 2018 New Coder Survey, granting researchers an unprecedented glimpse into how adults are learning to code.超过31,000人对我们的2018年《新编码器调查》做出了回应,使研究人员对成年人如何学…

彩虹系统怎么弄服务器,用云服务器彩虹挂机

用云服务器彩虹挂机 内容精选换一换当云服务器网络异常、防火墙未放行本地远程桌面端口、云服务器CPU负载过高等场景均可能导致云服务器无法正常登录。当您的云服务器无法远程登录时,我们建议您首先检查是否可以通过控制台远程登录。再参考排查思路检查登录异常的原…

leetcode 463. 岛屿的周长

给定一个包含 0 和 1 的二维网格地图,其中 1 表示陆地 0 表示水域。 网格中的格子水平和垂直方向相连(对角线方向不相连)。整个网格被水完全包围,但其中恰好有一个岛屿(或者说,一个或多个表示陆地的格子相…

欧拉路HDU3018

欧拉路,欧拉回路,讲的实际上就是一笔画的问题。 给定n个点,m条边,如果能一笔把所有边都连上就是欧拉路,如果起点和终点是同一点,就是欧拉回路。 欧拉路的特征:对于无向图,如果所有点…

NeuCF源码中用到的模块(函数)

论文:《Neural Collaborative Filtering》源码中用到的模块(函数) from keras.layers import Embedding, Input, Dense, merge, Reshape, Merge, Flatten (1)Input():用于实例化 Ker…

awt jtable 多线程加载图片_Java项目实战之天天酷跑(三):缓冲加载游戏界面

前文,我们完成了开始游戏界面的搭建。本文将实现缓冲加载界面的搭建。并搭建与前面俩界面间的桥梁。实现输入正确用户名密码后,进入开始游戏界面,点击开始游戏按钮后,进入缓冲加载界面的功能。界面示意图:具体要求&…

When Cyber Security Meets Machine Learning 机器学习 安全分析 对于安全领域的总结很有用 看未来演进方向...

链接:http://ucys.ugr.es/jnic2016/docs/MachineLearning_LiorRokachJNIC2016.pdf https://people.eecs.berkeley.edu/~adj/publications/paper-files/SecML-MLJ2010.pdf 一些关键点: 算了,不总结了。 本文转自张昺华-sky博客园博客&#xff…

如何使用TypeScript和Webpack Hot Module Replacement构建Apollo GraphQL服务器

by Derek Fong由德里克方(Derek Fong) 如何使用TypeScript和Webpack Hot Module Replacement构建Apollo GraphQL服务器 (How to build an Apollo GraphQL server with TypeScript and Webpack Hot Module Replacement) Let’s build an Apollo GraphQL Server with TypeScript…

本地修改指向服务器,本地修改指向服务器

本地修改指向服务器 内容精选换一换已获取服务器管理员帐号与密码。打开CMD运行窗口,输入gpedit.msc,打开本地组策略编辑器。打开组策略在指定RD会话主机服务器的授权模式下拉列表中选择按用户。设置允许RD最大连接数位999999。设置结束已断开连接的会话…

JUnit的使用

JUnit的作用(是一个第三方的组件,eclipse带了JUnit) 一个工具,用于单元测试,Java Unit 单元单元:一个类或是一个方法2. 在eclipse中的使用 操作步骤:在工程名上点右键-> Build Path -> add Libraries –> JUnit 测试方法…

乘法运算

无符号mul和有符号imul,在编译的过程中,先尝试将乘法转换成加法 或使用移位指令等周期转移较短的指令,如果都没有才用乘法指令 int main(int argc,char *argv) {int nVarOne argc;int nVarTwo argc;// 变量乘常量 (非2的幂)printf("nV…

leetcode 381. O(1) 时间插入、删除和获取随机元素 - 允许重复

设计一个支持在平均 时间复杂度 O(1) 下, 执行以下操作的数据结构。 注意: 允许出现重复元素。 insert(val):向集合中插入元素 val。 remove(val):当 val 存在时,从集合中移除一个 val。 getRandom:从现有集合中随机…

MAYA建模桌面一角_maya怎么建模逼真的学生书桌书桌桌面?

今天我们就来看看使用maya建模学生书桌的方法,这是实例教程,请看下文详细介绍。NURBS曲线的基础知识:NURBS曲面是由网状的曲线组合而成,在maya中可以使用creat菜单下的CV Curve Tool(CV曲线工具)EP Curve Tool(EP曲线工具)来创建曲…

expect 批量修改服务器用户密码

每个技术人员离职,留下的人 就要修改他的服务器账号密码,很麻烦,故写次脚本偷懒 change.sh 如下 12345678910#!/bin/bashfor i in awk {print $1} account.txt dojawk -v l"$i" {if(l$1)print $2} account.txt aawk -v l"$i&q…

虚拟机安装服务器2008,VMware Workstation 虚拟机安装64位windows 2008 R2 系统

偶看现在使用的电脑是 惠普 康柏 Elite 8300 MT Mini Tower,操作系统 Windows 7 旗舰版 64位基本硬件展示处理器 英特尔 第三代酷睿 i5-3470 3.20GHz 四核主板 惠普 3397内存 8 GB ( 记忆科技 DDR3 1600MHz / 镁光 DDR3 1600MHz )主硬盘 西数 WDC WD5000AAKX-60U6A…

黑客入门之单机游戏外挂

转载于: http://www.cnblogs.com/huipengbo/p/6887170.html 一.本文以植物大战僵尸外挂的编写为例,介绍单机游戏外挂的编写和使用过程。 1.启动单机游戏如:植物大战僵尸如下图 2.想明白我们写外挂的目的:让我们有充足的阳光数量来使用&#x…