NVIDIA DeepStream SDK API Reference

9.2 Release
sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "nvds_eval_gt_loader.h"
21 #include "nvds_eval_ap.h"
22 
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <set>
27 #include <utility>
28 #include <cstdint>
29 
33 struct ClassAccum
34 {
35  std::vector<std::pair<float,float>> preds; /* (conf, best_iou) per prediction */
36  uint32_t total_gt = 0; /* GT boxes of this class seen this epoch */
37 };
38 
45 struct ModelAccum
46 {
47  std::string model_version;
48  std::map<std::string, ClassAccum> per_class; /* class_label -> ClassAccum */
49  uint32_t frame_count = 0; /* frames processed for this (role, model) */
50  uint32_t frames_with_gt = 0; /* frames where GT was non-empty (GT available) */
51 };
52 
57 struct ModelKey
58 {
59  std::string role; /* "Primary" | "Shadow" */
60  std::string model_name; /* logical model name */
61 
62  bool operator< (const ModelKey &o) const {
63  if (role != o.role) return role < o.role;
64  return model_name < o.model_name;
65  }
66  bool operator== (const ModelKey &o) const {
67  return role == o.role && model_name == o.model_name;
68  }
69 };
70 
78 {
79 public:
87  void add_frame (const std::string &role,
88  const std::string &model_name,
89  const std::string &model_version,
90  const std::vector<std::string> &preds_label,
91  const std::vector<float> &preds_conf,
92  const std::vector<float> &preds_x1,
93  const std::vector<float> &preds_y1,
94  const std::vector<float> &preds_x2,
95  const std::vector<float> &preds_y2,
96  const std::vector<GTBox> &gt_boxes);
97 
98  void reset ();
99 
100  const std::map<ModelKey, ModelAccum> &models () const { return models_; }
101  uint32_t total_frames () const { return total_frames_; }
102 
103 private:
104  std::map<ModelKey, ModelAccum> models_; /* (role, model_name) -> accum */
105  uint32_t total_frames_ = 0;
106 };
ModelKey::model_name
std::string model_name
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:60
ModelKey::role
std::string role
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:59
ModelAccum::per_class
std::map< std::string, ClassAccum > per_class
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:48
ModelKey
ModelKey: compound key for the accumulator map.
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:57
ClassAccum
ClassAccum: per-(role, model_name, class_label) accumulator over one epoch.
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:33
ModelKey::operator==
bool operator==(const ModelKey &o) const
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:66
EvalAccumulator::add_frame
void add_frame(const std::string &role, const std::string &model_name, const std::string &model_version, const std::vector< std::string > &preds_label, const std::vector< float > &preds_conf, const std::vector< float > &preds_x1, const std::vector< float > &preds_y1, const std::vector< float > &preds_x2, const std::vector< float > &preds_y2, const std::vector< GTBox > &gt_boxes)
add_frame: record one frame's predictions vs GT.
EvalAccumulator::reset
void reset()
ClassAccum::total_gt
uint32_t total_gt
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:36
nvds_eval_ap.h
ClassAccum::preds
std::vector< std::pair< float, float > > preds
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:35
ModelKey::operator<
bool operator<(const ModelKey &o) const
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:62
ModelAccum::frames_with_gt
uint32_t frames_with_gt
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:50
ModelAccum::frame_count
uint32_t frame_count
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:49
ModelAccum::model_version
std::string model_version
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:47
EvalAccumulator::models
const std::map< ModelKey, ModelAccum > & models() const
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:100
nvds_eval_gt_loader.h
EvalAccumulator::total_frames
uint32_t total_frames() const
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:101
EvalAccumulator
EvalAccumulator: per-epoch accumulator across all (role, model) pairs.
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:77
ModelAccum
ModelAccum: accumulator for one (role, model_name) pair over an epoch.
Definition: sources/gst-plugins/gst-nvinfereval/nvds_eval_accumulator.h:45