MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / detection_cb

Function detection_cb

tracking/apps/tracker_node.cpp:212–515  ·  view source on GitHub ↗

* \brief Read the DetectionArray message and use the detections for creating/updating/deleting tracks * * \param[in] msg the DetectionArray message. */

Source from the content-addressed store, hash-verified

210 * \param[in] msg the DetectionArray message.
211 */
212void
213detection_cb(const opt_msgs::DetectionArray::ConstPtr& msg)
214{
215 // Read message header information:
216 std::string frame_id = msg->header.frame_id;
217 ros::Time frame_time = msg->header.stamp;
218
219 std::string frame_id_tmp = frame_id;
220 int pos = frame_id_tmp.find("_rgb_optical_frame");
221 if (pos != std::string::npos)
222 frame_id_tmp.replace(pos, std::string("_rgb_optical_frame").size(), "");
223 pos = frame_id_tmp.find("_depth_optical_frame");
224 if (pos != std::string::npos)
225 frame_id_tmp.replace(pos, std::string("_depth_optical_frame").size(), "");
226 last_received_detection_[frame_id_tmp] = frame_time;
227
228 // Compute delay of detection message, if any:
229 double time_delay = 0.0;
230 if (frame_time > latest_time)
231 {
232 latest_time = frame_time;
233 time_delay = 0.0;
234 }
235 else
236 {
237 time_delay = (latest_time - frame_time).toSec();
238 }
239
240 tf::StampedTransform transform;
241 tf::StampedTransform inverse_transform;
242 // cv_bridge::CvImage::Ptr cvPtr;
243
244 try
245 {
246 // Read transforms between camera frame and world frame:
247 if (!extrinsic_calibration)
248 {
249 static tf::TransformBroadcaster world_to_camera_tf_publisher;
250// world_to_camera_tf_publisher.sendTransform(tf::StampedTransform(camera_frame_to_world_transform, ros::Time::now(), world_frame_id, frame_id));
251 world_to_camera_tf_publisher.sendTransform(tf::StampedTransform(world_to_camera_frame_transform, ros::Time::now(), frame_id, world_frame_id));
252 }
253 //Calculate direct and inverse transforms between camera and world frame:
254 tf_listener->lookupTransform(world_frame_id, frame_id, ros::Time(0), transform);
255 tf_listener->lookupTransform(frame_id, world_frame_id, ros::Time(0), inverse_transform);
256 // cvPtr = cv_bridge::toCvCopy(msg->image, sensor_msgs::image_encodings::BGR8);
257
258 // Read camera intrinsic parameters:
259 Eigen::Matrix3d intrinsic_matrix;
260 for(int i = 0; i < 3; i++)
261 for(int j = 0; j < 3; j++)
262 intrinsic_matrix(i, j) = msg->intrinsic_matrix[i * 3 + j];
263
264 // Add a new DetectionSource or update an existing one:
265 if(detection_sources_map.find(frame_id) == detection_sources_map.end())
266 {
267 detection_sources_map[frame_id] = new open_ptrack::detection::DetectionSource(cv::Mat(0, 0, CV_8UC3),
268 transform, inverse_transform, intrinsic_matrix, frame_time, frame_id);
269 }

Callers

nothing calls this directly

Calls 15

MatClass · 0.85
DetectionClass · 0.85
getDurationMethod · 0.80
closeMethod · 0.80
getWorldCentroidMethod · 0.80
setWorldCentroidMethod · 0.80
publishMethod · 0.80
getAssociationResultMethod · 0.80
getFrameIdMethod · 0.80
getSourceMethod · 0.80
whatMethod · 0.80
readMatrixFromFileFunction · 0.70

Tested by

no test coverage detected