偵測及追蹤物件
bookmark_border
bookmark
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
主要功能
- 快速偵測及追蹤物件
偵測物件並在圖片中取得物件的位置。跨連續圖片的影格追蹤物件。
- 最佳化裝置端模型
物件偵測和追蹤模型已針對行動裝置進行最佳化,即使是在低階裝置上也能使用即時應用程式。
- 醒目物件偵測
自動判斷圖片中最醒目的物件。
- 粗略分類
將物件分為廣泛類別,可用來濾除不感興趣的物件。支援的類別如下:居家用品、時尚商品、食物、植物和地點。
- 使用自訂模型分類
使用自訂圖片分類模型識別或篩選特定物件類別。排除圖片的背景,自訂模型成效更佳
搜尋結果範例
追蹤不同圖片中最顯眼的物件
以下範例顯示三個連續影格的追蹤資料,且使用 ML Kit 提供的預設粗略分類分類器。
 |
追蹤 ID |
0 |
範圍 |
(95、45)、(496、45)、(496、240)、(95、240) |
類別 |
位置 |
分類信心 |
0.9296875 |
|
 |
追蹤 ID |
0 |
範圍 |
(84、46)、(478、46)、(478、247)、(84、247) |
類別 |
位置 |
分類信心 |
0.8710938 |
|
 |
追蹤 ID |
0 |
範圍 |
(53、45)、(519、45)、(519、240)、(53、240) |
類別 |
位置 |
分類信心 |
0.8828125 |
|
相片:Christian Ferrer [CC BY-SA 4.0]
靜態圖片中的多個物件
以下範例顯示使用 ML Kit 提供的預設粗略分類器,在圖片中偵測到的四個物件資料。

物件 0 |
範圍 |
(1、97)、(332、97)、(332、332)、(1、332) |
類別 |
FASHION_GOOD |
分類信心 |
0.95703125 |
Object 1 |
範圍 |
(186、80)、(337、80)、(337、226)、(186、226) |
類別 |
FASHION_GOOD |
分類信心 |
0.84375 |
Object 2 |
範圍 |
(296、80)、(472、80)、(472、388)、(296、388) |
類別 |
FASHION_GOOD |
分類信心 |
0.94921875 |
Object 3 |
範圍 |
(439、83)、(615、83)、(615、306)、(439、306) |
類別 |
FASHION_GOOD |
分類信心 |
0.9375 |
使用自訂 TensorFlow Lite 模型
預設粗細分類器是專為五個類別所設計,可提供偵測到的物件相關有限資訊。您可能需要使用更專業的分類器模型,以便更詳細地涵蓋更小的概念領域;例如,用於區分不同花朵或食品類型的模型。
這個 API 支援多種來源的自訂圖片分類模型,可讓您根據特定用途調整圖片內容。詳情請參閱「使用 ML Kit 自訂模型」一文。您可以將自訂模型與您的應用程式組合在一起,或是使用 Firebase 機器學習的模型部署服務從雲端動態下載。
iOS
Android
如有需要,物件偵測和追蹤功能會使用雙線性圖片縮放和延展功能,調整輸入圖片大小和顯示比例,使其符合基礎模型的要求。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eML Kit's on-device API enables detection and tracking of objects within images or live camera feeds, working efficiently even on lower-end mobile devices.\u003c/p\u003e\n"],["\u003cp\u003eIt offers optional object classification using a built-in coarse classifier or your own custom TensorFlow Lite model for more specialized categorization.\u003c/p\u003e\n"],["\u003cp\u003eThe API can identify the most prominent object in an image and track it across frames, making it suitable for visual search applications.\u003c/p\u003e\n"],["\u003cp\u003eCustom models can be integrated to classify objects into specific categories, enhancing the functionality for tailored use cases.\u003c/p\u003e\n"],["\u003cp\u003eInput images are automatically preprocessed to fit model requirements, using bilinear scaling and stretching if necessary.\u003c/p\u003e\n"]]],["ML Kit's API enables on-device object detection and tracking in images or live feeds, optionally classifying them. It features fast detection, an optimized model for mobile, and prominent object identification. Objects can be classified into broad categories or with custom models. The API supports custom image classification models, including ones dynamically downloaded. Detected objects are tracked across frames, and the system adjusts input image size and aspect ratio as needed.\n"],null,["With ML Kit's on-device object detection and tracking API, you can detect\nand track objects in an image or live camera feed.\n\nOptionally, you can classify detected objects, either by using the coarse\nclassifier built into the API, or using your own custom image classification\nmodel. See [Using a custom TensorFlow Lite model](#custom-tflite) for more\ninformation.\n\nBecause object detection and tracking happens on the device, it works well as\nthe front end of the visual search pipeline. After you detect and filter\nobjects, you can pass them to a cloud backend, such as\n[Cloud Vision Product Search](https://cloud.google.com/vision/product-search/docs/).\n\n[iOS](/ml-kit/vision/object-detection/ios)\n[Android](/ml-kit/vision/object-detection/android)\n\nKey capabilities\n\n- **Fast object detection and tracking** Detect objects and get their locations in the image. Track objects across successive image frames.\n- **Optimized on-device model** The object detection and tracking model is optimized for mobile devices and intended for use in real-time applications, even on lower-end devices.\n- **Prominent object detection** Automatically determine the most prominent object in an image.\n- **Coarse classification** Classify objects into broad categories, which you can use to filter out objects you're not interested in. The following categories are supported: home goods, fashion goods, food, plants, and places.\n- **Classification with a custom model** Use your own custom image classification model to identify or filter specific object categories. Make your custom model perform better by leaving out background of the image.\n\nExample results\n\nTracking the most prominent object across images\n\nThe example below shows the tracking data from three successive frames with the\ndefault coarse classifier provided by ML Kit.\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | |---------------------------|--------------------------------------------| | Tracking ID | 0 | | Bounds | (95, 45), (496, 45), (496, 240), (95, 240) | | Category | PLACE | | Classification confidence | 0.9296875 | |\n| | |---------------------------|--------------------------------------------| | Tracking ID | 0 | | Bounds | (84, 46), (478, 46), (478, 247), (84, 247) | | Category | PLACE | | Classification confidence | 0.8710938 | |\n| | |---------------------------|--------------------------------------------| | Tracking ID | 0 | | Bounds | (53, 45), (519, 45), (519, 240), (53, 240) | | Category | PLACE | | Classification confidence | 0.8828125 | |\n\nPhoto: Christian Ferrer \\[CC BY-SA 4.0\\]\n\nMultiple objects in a static image\n\nThe example below shows the data for the four objects detected in the image with\nthe default coarse classifier provided by ML Kit.\n\n| Object 0 ||\n|---------------------------|----------------------------------------------|\n| Bounds | (1, 97), (332, 97), (332, 332), (1, 332) |\n| Category | FASHION_GOOD |\n| Classification confidence | 0.95703125 |\n| Bounds | (186, 80), (337, 80), (337, 226), (186, 226) |\n| Category | FASHION_GOOD |\n| Classification confidence | 0.84375 |\n| Bounds | (296, 80), (472, 80), (472, 388), (296, 388) |\n| Category | FASHION_GOOD |\n| Classification confidence | 0.94921875 |\n| Bounds | (439, 83), (615, 83), (615, 306), (439, 306) |\n| Category | FASHION_GOOD |\n| Classification confidence | 0.9375 |\n\nUsing a custom TensorFlow Lite model\n\nThe default coarse classifier is built for five categories, providing limited\ninformation about the detected objects. You might need a more specialized\nclassifier model that covers a narrower domain of concepts in more detail;\nfor example, a model to distinguish between species of flowers or types of\nfood.\n\nThis API lets you tailor to a particular use case by by supporting custom image\nclassification models from a wide range of sources. Please refer to\n[Custom models with ML Kit](/ml-kit/custom-models) to learn more. Custom models\ncan be bundled with your app or dynamically downloaded from the cloud using\nFirebase Machine Learning's Model deployment service.\n\n[iOS](/ml-kit/vision/object-detection/custom-models/ios)\n[Android](/ml-kit/vision/object-detection/custom-models/android)\n\nInput image preprocessing\n\nIf needed, object detection and tracking uses bilinear image scaling and\nstretching to adjust the input image size and aspect ratio so that they fit the\nrequirements of the underlying model."]]