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

Function detection_cb

tracking/apps/tracker_object_node.cpp:214–526  ·  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

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

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
to_object_name_MsgMethod · 0.80
getFrameIdMethod · 0.80
getSourceMethod · 0.80
whatMethod · 0.80
readMatrixFromFileFunction · 0.70

Tested by

no test coverage detected