車輛乘載人數分析指南

代表「人流分析」模型資訊卡的圖示。

人車流量分析模型可讓您根據在影片影格中新增的特定輸入內容,計算人物或車輛數量。與人車偵測工具模型相比,人流分析模型提供進階功能。這些功能包括活動區計數、越線計數和停留偵測。

  • 使用者可透過活動區,計算特定自訂區域內的人車數量。
  • 越線偵測功能可計算物件越過特定線條的方向。
  • 停留時間偵測功能以活動區為基礎,可偵測物體是否在區域內停留至少一段時間。

模型會接受影片串流做為輸入內容,並輸出通訊協定緩衝區,其中包含每個影格中偵測到的人數和車輛數。模型會以每秒 6 影格的速度執行。

用途:智慧城市交通數據分析

下列影片示範如何使用 Gemini Enterprise Agent Platform Vision 建立、建構及部署人流分析應用程式。

這個應用程式使用的模型,會計算在使用者於Google Cloud 控制台指定的路口,有多少車輛越線。此外,應用程式會使用人物模糊處理模型,保護影片動態消息來源中出現的任何人物身分。

應用程式會將分析後的資料傳送至 Gemini Enterprise Agent Platform Vision 的 Media Warehouse 進行媒體儲存,並傳送至 BigQuery,將結構化資料儲存在資料表中。您可以根據模型中的條件 (例如車輛或人數),在倉儲中搜尋儲存的資料。BigQuery 中的資料表資料可讓您查詢資料,取得分析資訊。

模型輸出

「Person Vehicle Detection」(人物車輛偵測) 會顯示目前處理的影格中偵測到的人數和車輛數。計數類型取決於使用者提供的註解輸入內容。輸出內容也包含原始偵測和追蹤結果。以下是處理器輸出的通訊協定緩衝區定義。輸出串流的頻率固定為每秒影格數:每秒三個影格。

// The prediction result proto for Person/Vehicle Detection.
message OccupancyCountingPredictionResult {

 // Current timestamp.
 google.protobuf.Timestamp current_time = 1;

 // The entity info for annotations from the processor.
 message Entity {
   // Label id.
   int64 label_id = 1;
   // Human readable string of the label.
   string label_string = 2;
 }

 // Identified box contains location and the entity of the object.
 message IdentifiedBox {
   // An unique id for this box.
   int64 box_id = 1;
   // Bounding Box in the normalized coordinates.
   message NormalizedBoundingBox {
     // Min in x coordinate.
     float xmin = 1;
     // Min in y coordinate.
     float ymin = 2;
     // Width of the bounding box.
     float width = 3;
     // Height of the bounding box.
     float height = 4;
   }

   // Bounding Box in the normalized coordinates.
   NormalizedBoundingBox normalized_bounding_box = 2;

   // Confidence score associated with this box.
   float score = 3;

   // Entity of this box.
   Entity entity = 4;

   // A unique id to identify a track. It must be consistent across frames.
   // It only exists if tracking is enabled.
   int64 track_id = 5;
 }

 // A list of identified boxes.
 repeated IdentifiedBox identified_boxes = 2;

 // The statistics info for annotations from the processor.
 message Stats {
   // The object info and count for annotations from the processor.
   message ObjectCount {
     // Entity of this object.
     Entity entity = 1;
     // Count of the object.
     int32 count = 2;
   }

   // Counts of the full frame.
   repeated ObjectCount full_frame_count = 1;

   // Message for Crossing line count.
   message CrossingLineCount {
     // Line annotation from the user.
     StreamAnnotation annotation = 1;
     // The direction that follows the right hand rule.
     repeated ObjectCount positive_direction_counts = 2;
     // The direction that is opposite to the right hand rule.
     repeated ObjectCount negative_direction_counts = 3;
   }

   // Crossing line counts.
   repeated CrossingLineCount crossing_line_counts = 2;

   // Message for the active zone count.
   message ActiveZoneCount {
     // Active zone annotation from the user.
     StreamAnnotation annotation = 1;
     // Counts in the zone.
     repeated ObjectCount counts = 2;
   }

   // Active zone counts.
   repeated ActiveZoneCount active_zone_counts = 3;
 }

 // Detection statistics.
 Stats stats = 3;

 // The track info for annotations from the processor.
 message TrackInfo {
   // A unique id to identify a track. It must be consistent across frames.
   string track_id = 1;
   // Start timestamp of this track.
   google.protobuf.Timestamp start_time = 2;
 }

 // The dwell time info for annotations from the processor.
 message DwellTimeInfo {
   // A unique id to identify a track. It must be consistent across frames.
   string track_id = 1;
   // The unique id for the zone in which the object is dwelling/waiting.
   string zone_id = 2;
   // The beginning time when a dwelling object has been identified in a zone.
   google.protobuf.Timestamp dwell_start_time = 3;
   // The end time when a dwelling object has exited in a zone.
   google.protobuf.Timestamp dwell_end_time = 4;
 }

 // Track related information. All the tracks that are live at this timestamp.
 // It only exists if tracking is enabled.
 repeated TrackInfo track_info = 4;

 // Dwell time related information. All the tracks that are live in a given
 // zone with a start and end dwell time timestamp
 repeated DwellTimeInfo dwell_time_info = 5;
}

最佳做法和限制

  • 避免使用不尋常的攝影機視角 (例如由上而下的視角),因為這會導致人物和車輛看起來與標準或常見視角不同。異常視角可能會大幅影響偵測品質。
  • 確保人物和車輛完全或大部分可見。如果物體部分被其他物體遮擋,偵測品質可能會受到影響。
  • 人車偵測工具可偵測的物件大小有下限。這個大小約為相機檢視畫面大小的 2%。請確認目標人物和車輛與攝影機的距離不會太遠。這些主要物件的可視大小必須夠大。
  • 感興趣的區域必須有適當的光線。
  • 確認影片來源相機鏡頭乾淨清潔。
  • 確保實體 (人和車除外) 不會遮擋攝影機的任何視野。
  • 下列因素可能會降低模型效能。取得資料時,請考量下列因素:
    • 光線不佳。
    • 擁擠程度和物件遮蔽。
    • 不常見或較少見的觀點。
    • 小型物件大小。