| 67 | std::string buffer; |
| 68 | |
| 69 | std::string |
| 70 | toJsonPoseMsg( |
| 71 | const std_msgs::Header& pr_header_msg, |
| 72 | const std::string& frame_id, |
| 73 | const opt_msgs::SkeletonTrack& t, |
| 74 | const opt_msgs::StandardSkeletonTrack& st_t, |
| 75 | const opt_msgs::PoseRecognition& pr) { |
| 76 | |
| 77 | // /// Create JSON-formatted message: |
| 78 | Jzon::Object root, header, stamp; |
| 79 | Jzon::Array tracks; |
| 80 | |
| 81 | // /// Add header (84 characters): |
| 82 | header.Add("seq", int(pr_header_msg.seq)); |
| 83 | stamp.Add("sec", int(pr_header_msg.stamp.sec)); |
| 84 | stamp.Add("nsec", int(pr_header_msg.stamp.nsec)); |
| 85 | header.Add("stamp", stamp); |
| 86 | |
| 87 | std::string camera_name = frame_id; |
| 88 | if (strcmp(camera_name.substr(0,1).c_str(), "/") == 0) // Remove bar at the beginning |
| 89 | { |
| 90 | camera_name = camera_name.substr(1, camera_name.size() - 1); |
| 91 | } |
| 92 | |
| 93 | header.Add("frame_id", camera_name); |
| 94 | root.Add("header", header); |
| 95 | |
| 96 | // persons |
| 97 | // for (unsigned int i = 0; i < skel_track_msg->tracks.size(); i++) |
| 98 | // { |
| 99 | Jzon::Object current_track; |
| 100 | current_track.Add("id", t.id); |
| 101 | current_track.Add("height", t.height); |
| 102 | if(std::isnan(st_t.orientation)) |
| 103 | current_track.Add("orientation", std::string("NaN")); |
| 104 | else |
| 105 | current_track.Add("orientation", st_t.orientation); |
| 106 | current_track.Add("age", t.age); |
| 107 | current_track.Add("predicted_pose_name", |
| 108 | pr.best_prediction_result.pose_name); |
| 109 | current_track.Add("predicted_pose_id", |
| 110 | pr.best_prediction_result.pose_id); |
| 111 | current_track.Add("prediction_score", |
| 112 | pr.best_prediction_result.score); |
| 113 | // poses |
| 114 | Jzon::Array poses; |
| 115 | for (size_t p_id = 0, p_end = pr.gallery_poses.size(); p_id != p_end; |
| 116 | ++p_id) |
| 117 | { |
| 118 | Jzon::Object pose; |
| 119 | const opt_msgs::PosePredictionResult& ppr = pr.gallery_poses[p_id]; |
| 120 | pose.Add("pose_name", ppr.pose_name); |
| 121 | pose.Add("pose_id", ppr.pose_id); |
| 122 | if(std::isnan(ppr.score)) |
| 123 | pose.Add("prediction_score", std::string("nan")); |
| 124 | else |
| 125 | pose.Add("prediction_score", ppr.score); |
| 126 | poses.Add(pose); |
no test coverage detected