Skip to content

Commit ed0c45d

Browse files
fix(bytetrack): fix cppcheck warnings (#7576)
* fix unreadVariable Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> * fix variableScope Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> * fix unusedVariable Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> * fix constParameterPointer Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> * fix unreadVariable Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> * style(pre-commit): autofix --------- Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5bead38 commit ed0c45d

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

perception/bytetrack/lib/src/lapjv.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ int_t _carr_dense(
181181

182182
/** Find columns with minimum d[j] and put them on the SCAN list.
183183
*/
184-
uint_t _find_dense(const uint_t n, uint_t lo, cost_t * d, int_t * cols, [[maybe_unused]] int_t * y)
184+
uint_t _find_dense(
185+
const uint_t n, uint_t lo, const cost_t * d, int_t * cols, [[maybe_unused]] int_t * y)
185186
{
186187
uint_t hi = lo + 1;
187188
cost_t mind = d[cols[lo]];
@@ -203,7 +204,7 @@ uint_t _find_dense(const uint_t n, uint_t lo, cost_t * d, int_t * cols, [[maybe_
203204
// and try to decrease d of the TODO columns using the SCAN column.
204205
int_t _scan_dense(
205206
const uint_t n, cost_t * cost[], uint_t * plo, uint_t * phi, cost_t * d, int_t * cols,
206-
int_t * pred, int_t * y, cost_t * v)
207+
int_t * pred, const int_t * y, const cost_t * v)
207208
{
208209
uint_t lo = *plo;
209210
uint_t hi = *phi;

perception/bytetrack/lib/src/strack.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ void STrack::activate(int frame_id)
112112
this->track_id = this->next_id();
113113
this->unique_id = boost::uuids::random_generator()();
114114

115-
std::vector<float> _tlwh_tmp(4);
116-
_tlwh_tmp[0] = this->original_tlwh[0];
117-
_tlwh_tmp[1] = this->original_tlwh[1];
118-
_tlwh_tmp[2] = this->original_tlwh[2];
119-
_tlwh_tmp[3] = this->original_tlwh[3];
120-
std::vector<float> xyah = tlwh_to_xyah(_tlwh_tmp);
121115
// init kf
122116
init_kalman_filter();
123117
// reflect state
@@ -132,7 +126,6 @@ void STrack::activate(int frame_id)
132126

133127
void STrack::re_activate(STrack & new_track, int frame_id, bool new_id)
134128
{
135-
std::vector<float> xyah = tlwh_to_xyah(new_track.tlwh);
136129
// TODO(me): write kf update
137130
Eigen::MatrixXd measurement = Eigen::MatrixXd::Zero(_kf_parameters.dim_z, 1);
138131
measurement << new_track.tlwh[0], new_track.tlwh[1], new_track.tlwh[2], new_track.tlwh[3];
@@ -156,8 +149,6 @@ void STrack::update(STrack & new_track, int frame_id)
156149
this->frame_id = frame_id;
157150
this->tracklet_len++;
158151

159-
std::vector<float> xyah = tlwh_to_xyah(new_track.tlwh);
160-
161152
// update
162153
// TODO(me): write update
163154
Eigen::MatrixXd measurement = Eigen::MatrixXd::Zero(_kf_parameters.dim_z, 1);

perception/bytetrack/lib/src/utils.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ std::vector<std::vector<float>> ByteTracker::ious(
190190

191191
// bbox_ious
192192
for (size_t k = 0; k < btlbrs.size(); k++) {
193-
std::vector<float> ious_tmp;
194193
float box_area = (btlbrs[k][2] - btlbrs[k][0] + 1) * (btlbrs[k][3] - btlbrs[k][1] + 1);
195194
for (size_t n = 0; n < atlbrs.size(); n++) {
196195
float iw = std::min(atlbrs[n][2], btlbrs[k][2]) - std::max(atlbrs[n][0], btlbrs[k][0]) + 1;
@@ -277,8 +276,6 @@ double ByteTracker::lapjv(
277276
std::vector<std::vector<float>> cost_c;
278277
cost_c.assign(cost.begin(), cost.end());
279278

280-
std::vector<std::vector<float>> cost_c_extended;
281-
282279
int n_rows = cost.size();
283280
int n_cols = cost[0].size();
284281
rowsol.resize(n_rows);
@@ -296,6 +293,8 @@ double ByteTracker::lapjv(
296293
}
297294

298295
if (extend_cost || cost_limit < LONG_MAX) {
296+
std::vector<std::vector<float>> cost_c_extended;
297+
299298
n = n_rows + n_cols;
300299
cost_c_extended.resize(n);
301300
for (size_t i = 0; i < cost_c_extended.size(); i++) cost_c_extended[i].resize(n);

perception/bytetrack/src/bytetrack_visualizer_node.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ void ByteTrackVisualizerNode::callback(
128128
}
129129

130130
std::vector<cv::Rect> bboxes;
131-
for (auto & feat_obj : rect_msg->feature_objects) {
131+
for (const auto & feat_obj : rect_msg->feature_objects) {
132132
auto roi_msg = feat_obj.feature.roi;
133133
cv::Rect rect(roi_msg.x_offset, roi_msg.y_offset, roi_msg.width, roi_msg.height);
134134
bboxes.push_back(rect);
135135
}
136136

137137
std::vector<boost::uuids::uuid> uuids;
138-
for (auto & dynamic_obj : uuid_msg->objects) {
138+
for (const auto & dynamic_obj : uuid_msg->objects) {
139139
auto uuid_msg = dynamic_obj.id.uuid;
140140
boost::uuids::uuid uuid_raw;
141141
std::copy(uuid_msg.begin(), uuid_msg.end(), uuid_raw.begin());

0 commit comments

Comments
 (0)