AI 驅動文件
您想了解什麼?
裁剪 ROI 端點(僅分類)
概覽
該 cropped_roi 端點提供對在裝置上執行的 Haystack 中由 分類結果 生成的 裁剪後的 ROI(ROIs) 的訪問。
僅限分類
Haystack 目前不支援分割結果。此端點僅適用於分類型別結果。如需以程式設計方式處理分割器輸出,請改用標準的 inspection results API。
基準 URL 格式為:
http://{device-ip}/edge/haystack/cropped_roi/{classification_result_id}
工作原理
當相機完成一個 classification capture 時,Node-RED 流會透過將裝置 IP 與 classification result ID 配對,動態構造裁剪後的 ROI 影象的 URL:
const imageUrl = `http://${baseUrl}/edge/haystack/cropped_roi/${result.id}`;
每個 URL 提供一個對應於單個 classification ROI 的裁剪影象,通常表示一次單獨的檢查。
Node-RED Flow Summary
ROI_Crop 流執行以下操作:
-
提取裝置 IP 地址
- 解析
image_url欄位以找到 IP(例如192.168.0.101) - 全域性儲存以便重複使用
- 解析
-
查詢最新捕獲資料
-
向裝置的 PostgREST API 傳送 GET 請求:
http://{device-ip}/postgrest/captures?select=...
&order=id.desc&limit=1 -
檢索最近的捕獲以及所有 classification_result 條目
-
-
僅篩選 Classification Results
-
跳過 segmentation 或 alignment 結果
-
遍歷每個 classification_result:
classificationResults.forEach(result => {
const roiName = result.roi_result?.inspection_region?.name || `ROI_${result.id}`;
const imageUrl = `http://${baseUrl}/edge/haystack/cropped_roi/${result.id}`;
imageMap[roiName] = imageUrl;
});
-
-
輸出裁剪 ROI 的 URL
- 將所有 ROI 影象連結儲存到全域性
imageMap - 返回最新裁剪 ROI 影象的 URL 列表
- 將所有 ROI 影象連結儲存到全域性

示例用法
獲取裁剪 ROI 影象
curl http://192.168.0.101/edge/haystack/cropped_roi/42 -o roi_42.jpg
在網頁介面中的使用
<img src="http://192.168.0.101/edge/haystack/cropped_roi/42" alt="Cropped ROI 42">
輸出示例
{
"ROI_1": "http://192.168.0.101/edge/haystack/cropped_roi/1",
"ROI_2": "http://192.168.0.101/edge/haystack/cropped_roi/2"
}
引數
| 引數 | 型別 | 描述 |
|---|---|---|
device-ip | string | 攝像機的 IP 地址(例如 192.168.0.101) |
整合流程
- 透過
/postgrest/captures獲取最新的捕獲後設資料。 - 標識可用的
classification_resultID。 - 為每個結果構建裁剪 ROI 的 URL。
- 顯示或下載這些影象以用於分析、訓練資料或 QA 檢查。
下載 Node-RED Flow
- ROI Crop Flow (JSON) - 用於提取裁剪 ROI 影象的完整 Node-RED flow
- 將此 flow 直接匯入 Node-RED 以訪問裁剪的 classification ROIs
- 可用於 OV20i 與 OV80i 系統