22 #include "buffer_probe.hpp"
24 #define UNTRACKED_OBJECT_ID 0xFFFFFFFFFFFFFFFF
26 #define NVDS_OBJ_VISIBILITY 20
27 #define NVDS_OBJ_IMAGE_FOOT_LOCATION 21
28 #define NVDS_TRACKER_PAST_FRAME_META 15
31 class NvDsKittiDump:
public BufferProbe::IBatchMetadataOperator {
34 char bbox_file[1024] = {0};
35 FILE *bbox_params_dump_file = NULL;
37 for (data.
initiateIterator(frame_itr); !frame_itr->done(); frame_itr->next()) {
38 uint stream_id = (*frame_itr)->padIndex();
39 snprintf(bbox_file,
sizeof(bbox_file) - 1,
"%s/%03u_%06lu.txt",
40 output_dir.c_str(), stream_id,
41 (ulong)(*frame_itr)->frameNum());
42 bbox_params_dump_file = fopen(bbox_file,
"w");
43 if (!bbox_params_dump_file)
continue;
48 for (frame_meta.
initiateIterator(obj_itr); !obj_itr->done(); obj_itr->next()) {
57 fprintf(bbox_params_dump_file,
58 "%s 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
59 object_meta.
label().c_str(), left, top, right, bottom, confidence);
61 fprintf(bbox_params_dump_file,
62 "%s %lu 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
63 object_meta.
label().c_str(), object_meta.
objectId(), left, top, right, bottom,
67 fclose(bbox_params_dump_file);
72 char bbox_file[1024] = {0};
73 FILE *bbox_params_dump_file = NULL;
75 for (data.
initiateIterator(frame_itr); !frame_itr->done(); frame_itr->next()) {
76 uint stream_id = (*frame_itr)->padIndex();
77 snprintf(bbox_file,
sizeof(bbox_file) - 1,
"%s/%03u_%06lu.txt",
78 output_dir.c_str(), stream_id,
79 (ulong)(*frame_itr)->frameNum());
80 bbox_params_dump_file = fopen(bbox_file,
"w");
81 if (!bbox_params_dump_file)
continue;
86 for (frame_meta.
initiateIterator(obj_itr); !obj_itr->done(); obj_itr->next()) {
89 uint64_t
id = object_meta.
objectId();
90 bool write_proj_info =
false;
91 float visibility = -1.0, x_img_foot = -1.0, y_img_foot = -1.0;
101 write_proj_info =
true;
104 object_meta.
iterate([&x_img_foot, &y_img_foot, &write_proj_info](
const UserMetadata& user_meta) {
108 write_proj_info =
true;
114 fprintf (bbox_params_dump_file,
115 "%s %lu 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f %f %f %f\n",
116 object_meta.
label().c_str(),
id, left, top, right, bottom, confidence, visibility, x_img_foot, y_img_foot);
120 fprintf (bbox_params_dump_file,
121 "%s %lu 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
122 object_meta.
label().c_str(),
id, left, top, right, bottom, confidence);
125 fclose(bbox_params_dump_file);
134 if (!pPastFrameObjBatch) {
138 for (uint si = 0; si < pPastFrameObjBatch->
numFilled; si++) {
140 uint stream_id = (uint) (objStream->
streamID);
141 for (uint li = 0; li < objStream->
numFilled; li++) {
143 for (uint oi = 0; oi < objList->
numObj; oi++) {
146 char bbox_file[1024] = { 0 };
147 snprintf(bbox_file,
sizeof(bbox_file) - 1,
"%s/%03u_%06lu.txt",
148 output_dir.c_str(), stream_id, (ulong)obj->
frameNum);
157 FILE *bbox_params_dump_file = fopen(bbox_file,
"a");
158 if (!bbox_params_dump_file) {
162 fprintf(bbox_params_dump_file,
163 "%s %lu 0.0 0 0.0 %f %f %f %f 0.0 0.0 0.0 0.0 0.0 0.0 0.0 %f\n",
166 fclose(bbox_params_dump_file);
175 std::string output_dir =
"/tmp/kitti/";
178 bool tracker_kitti_output =
false;
179 probe.
getProperty(
"tracker-kitti-output", tracker_kitti_output);
181 if (tracker_kitti_output) {