每幀屬性
有些攝影機會在傳輸過程中描述每一幀:序列號、擷取時間戳、頻道名稱。Neat 可以將選定的這些值傳遞到解碼過程中,並將它們傳回對應的 Sample,即該值所屬的幀。
Sample::attributes 是一個簡單的字串到字串的映射。Neat 會複製它,並將其與其幀關聯,然後在重新使用目標緩衝區時清除它。它永遠不會解析、合併或重新解釋任何值。鍵和值必須是有效的 UTF-8,並且不能包含嵌入的 NULL 位元組,因為 GStreamer 字串表示形式無法保留它們。
保證內容
選定的多部分內容標頭將始終與其解碼後的幀關聯,透過預設的
HttpMjpegDecodedInput路徑、佇列/分支以及核心樣本到 GStreamer 的具體邊界。
這是本次發布的全部保證。任何超出此範圍的內容都列在 不支援的路徑 下,並且 Neat 會導致圖的建構失敗,而不是靜默地丟棄屬性。
啟用擷取
預設情況下,擷取功能已關閉。指定您想要使用的標頭會啟用它。
#include "nodes/groups/HttpMjpegDecodedInput.h"
simaai::neat::nodes::groups::HttpMjpegDecodedInputOptions opt;
opt.url = "http://camera.local/stream";
opt.header_capture.headers = {"Image-Index", "Image-Time"};
auto source = simaai::neat::nodes::groups::HttpMjpegDecodedInput(opt);
重新閱讀它們:
simaai::neat::Sample sample;
if (run.pull(1000, sample) == simaai::neat::PullStatus::Ok) {
const auto it = sample.attributes.find("image-index");
if (it != sample.attributes.end()) {
// it->second is the value this frame was sent with.
}
}
在 Python 中,相同的表面概念如下,其中 attributes 是一個動態映射——項目指派會到達底層的 Sample,而指派一個字典會取代其內容:
import pyneat
opt = pyneat.HttpMjpegDecodedInputOptions()
opt.url = "http://camera.local/stream"
opt.header_capture.headers = ["Image-Index", "Image-Time"]
source = pyneat.groups.http_mjpeg_decoded_input(opt)
# ... later, on a pulled sample:
index = sample.attributes.get("image-index")
sample.attributes["image-index"] = "42" # reaches the Sample
sample.attributes = {"image-time": "..."} # replaces the whole map
標頭規則
已設定的清單是一個允許清單。一個空的清單會完全停用擷取功能,並保持現有的拓撲結構和行為不變。
| 規則 | 行為 |
|---|---|
| 大小寫 | 已設定的名稱和輸出的鍵會正規化為 ASCII 小寫;匹配時不區分大小寫。以小寫鍵讀取屬性。 |
| 允許清單中的重複項 | 在正規化後合併。 |
| 標頭在單個部分中重複 | 最後一個值優先。 |
| 標頭在某個部分中不存在 | 鍵會被省略。它永遠不會從先前的框架繼承。 |
| 標頭存在但為空 | 保留為一個空字串。 |
| 空白字元 |