| 134 | |
| 135 | |
| 136 | void peopleTracksCallback(const opt_msgs::TrackArray::ConstPtr& association_message) |
| 137 | { |
| 138 | Jzon::Array tracks; |
| 139 | if (association_message->tracks.size() != 0){ |
| 140 | facetracksflag = 1; |
| 141 | } |
| 142 | |
| 143 | if (facetracksflag==0){ |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | |
| 148 | Jzon::Object root, header, stamp; |
| 149 | |
| 150 | /// Add header (84 characters): |
| 151 | header.Add("seq", int(association_message->header.seq)); |
| 152 | stamp.Add("sec", int(association_message->header.stamp.sec)); |
| 153 | stamp.Add("nsec", int(association_message->header.stamp.nsec)); |
| 154 | header.Add("stamp", stamp); |
| 155 | std::string camera_name = association_message->header.frame_id; |
| 156 | if (strcmp(camera_name.substr(0,1).c_str(), "/") == 0) // Remove bar at the beginning |
| 157 | { |
| 158 | camera_name = camera_name.substr(1, camera_name.size() - 1); |
| 159 | } |
| 160 | header.Add("frame_id", camera_name); |
| 161 | root.Add("header", header); |
| 162 | |
| 163 | /// Add tracks array: |
| 164 | // >50 characters for every track |
| 165 | for (unsigned int i = 0; i < association_message->tracks.size(); i++) |
| 166 | { |
| 167 | Jzon::Object current_track; |
| 168 | current_track.Add("id", association_message->tracks[i].id); |
| 169 | current_track.Add("x", association_message->tracks[i].x); |
| 170 | current_track.Add("y", association_message->tracks[i].y); |
| 171 | current_track.Add("height", association_message->tracks[i].height); |
| 172 | current_track.Add("age", association_message->tracks[i].age); |
| 173 | current_track.Add("confidence", association_message->tracks[i].confidence); |
| 174 | current_track.Add("stable_id", association_message->tracks[i].stable_id); |
| 175 | |
| 176 | if (namePairs.count(association_message->tracks[i].stable_id)) { |
| 177 | current_track.Add("face_name", namePairs.at(association_message->tracks[i].stable_id)); |
| 178 | } |
| 179 | |
| 180 | tracks.Add(current_track); |
| 181 | } |
| 182 | root.Add("people_tracks", tracks); |
| 183 | |
| 184 | /// Convert JSON object to string: |
| 185 | Jzon::Format message_format = Jzon::StandardFormat; |
| 186 | message_format.indentSize = json_indent_size; |
| 187 | message_format.newline = json_newline; |
| 188 | message_format.spacing = json_spacing; |
| 189 | message_format.useTabs = json_use_tabs; |
| 190 | Jzon::Writer writer(root, message_format); |
| 191 | writer.Write(); |
| 192 | std::string json_string = writer.GetResult(); |
| 193 | // std::cout << "String sent: " << json_string << std::endl; |
nothing calls this directly
no test coverage detected