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.pswp.cn/news/392757.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392757.shtml
英文地址,請注明出處:http://en.pswp.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…