961 {
962 int motion_size = static_cast<int>(motion_buffer->size());
963 if (debug_level_ >= 2) {
964 AINFO <<
" motion_size: " << motion_size;
965 }
966 if (motion_size <= 0) {
967 ADEBUG <<
" motion_size: " << motion_size;
968 return false;
969 }
970
971
972
973
974 if (debug_level_ >= 2) {
975 AINFO <<
"object_trackjectories_.size(): " << object_trackjectories_.size();
976 }
977 for (auto obj : *objects) {
978 int cur_id = obj->track_id;
979 if (debug_level_ >= 2) {
980 AINFO <<
"target ID: " << cur_id;
981 }
982
983
984
985
986
987 if (object_trackjectories_[cur_id].empty()) {
988 object_trackjectories_[cur_id].set_capacity(kDropsHistorySize);
989 }
990
991 object_id_skip_count_[cur_id] = 0;
992
993 auto pos = world2camera * obj->center;
994 float center_x = static_cast<float>(pos(2));
995 float center_y = static_cast<float>(-pos(0));
996
997 object_trackjectories_[cur_id].push_back(
998 std::make_pair(center_x, center_y));
999
1000 if (debug_level_ >= 2) {
1001 AINFO <<
"object_trackjectories_[" << cur_id
1002 << " ].size(): " << object_trackjectories_[cur_id].size();
1003 }
1004
1005 Eigen::Matrix4f accum_motion_buffer =
1006 motion_buffer->at(motion_size - 1).motion;
1007
1008 for (std::size_t it = object_trackjectories_[cur_id].size() - 1, count = 0;
1009 it > 0; it--) {
1010 if (count >= kDropsHistorySize || count > motion_buffer->size()) {
1011 break;
1012 }
1013 if (static_cast<int>(it) + 1 > motion_size) {
1014 continue;
1015 }
1016 Eigen::VectorXf pt =
1017 Eigen::VectorXf::Zero((*motion_buffer)[0].motion.cols());
1018 pt(0) = object_trackjectories_[cur_id][it].first;
1019 pt(1) = object_trackjectories_[cur_id][it].second;
1020 pt(2) = 0.0f;
1021 pt(3) = 1.0f;
1022
1023 Eigen::Vector3d transformed_pt;
1024 accum_motion_buffer *= motion_buffer->at(motion_size - it - 1).motion;
1025 TranformPoint(pt, accum_motion_buffer, &transformed_pt);
1026
1027
1028 if (debug_level_ >= 3) {
1029 AINFO <<
"(*motion_buffer)[" << motion_size - it - 1 <<
"].motion:";
1030 AINFO << motion_buffer->at(motion_size - it - 1).motion;
1031 AINFO <<
"accum_motion_buffer[" << motion_size - it - 1 <<
"] =";
1032 AINFO << accum_motion_buffer;
1033 AINFO <<
"target[" << obj->track_id <<
"][" << it <<
"]: ("
1034 << transformed_pt(0) << ", " << transformed_pt(1) << ")";
1035 }
1036 obj->drops[count] = transformed_pt;
1037 obj->drop_num = count++;
1038 }
1039 }
1040
1041
1042
1043 for (const auto &each_object : object_trackjectories_) {
1044 int obj_id = each_object.first;
1045 bool b_found_id = false;
1046 for (auto obj : *objects) {
1047 int cur_id = obj->track_id;
1048 if (obj_id == cur_id) {
1049 b_found_id = true;
1050 break;
1051 }
1052 }
1053
1054 if (!b_found_id && object_trackjectories_[obj_id].size() > 0) {
1055
1056 object_id_skip_count_[obj_id]++;
1057 if (debug_level_ >= 2) {
1058 AINFO <<
"object_id_skip_count_[" << obj_id
1059 << " ]: " << object_id_skip_count_[obj_id];
1060 }
1061 if (object_id_skip_count_[obj_id] >= kMaxAllowedSkipObject) {
1062 if (debug_level_ >= 2) {
1063 AINFO <<
"Removed obsolete object " << obj_id;
1064 }
1065 object_trackjectories_.erase(obj_id);
1066 object_id_skip_count_.erase(obj_id);
1067 }
1068 }
1069 }
1070 if (debug_level_ >= 2) {
1071 for (auto obj : *objects) {
1072 int cur_id = obj->track_id;
1073 AINFO <<
"obj->track_id: " << cur_id;
1074 AINFO <<
"obj->drop_num: " << obj->drop_num;
1075 }
1076 }
1077 return true;
1078}