ByteTrack的卡尔曼滤波使用什么样的边框坐标信息

ByteTrack的卡尔曼滤波使用什么样的边框坐标信息

flyfish

如果想直接看结果,可以直接看文章末尾。
8维的状态空间,前4维表边框坐标信息,那么这个边框坐标信息是什么样子的
边框又叫边界框、bounding box。通常是目标检测中一个矩形框包含了目标在哪里的信息。
整个分析过程都在STrack类和BYTETracker类中
首先看一个坐标的赋值

在 std::vector BYTETracker::update(const  std::vector& objects)成员函数中

std::vector tlbr_;
tlbr_.resize(4);
tlbr_[0] = objects[i].box.x;
tlbr_[1] = objects[i].box.y;
tlbr_[2] = objects[i].box.x + objects[i].box.width;
tlbr_[3] = objects[i].box.y + objects[i].box.height;
float score = objects[i].score;
STrack strack(STrack::tlbr_to_tlwh(tlbr_), score);

tlbr_在构建的使用的坐标信息是

0 left
1 top
2 right
3 bottom
std::vector STrack::tlbr_to_tlwh( std::vector &tlbr)
{
	tlbr[2] -= tlbr[0];
	tlbr[3] -= tlbr[1];
	return tlbr;
}

STrack在构建的使用的坐标信息

0 left  
1 top
2 width
3 height

STrack的构造函数

STrack::STrack( std::vector tlwh_, float score)
{
	_tlwh.resize(4);
	_tlwh.assign(tlwh_.begin(), tlwh_.end());

	is_activated = false;
	track_id = 0;
	state = TrackState::New;
	
	tlwh.resize(4);
	tlbr.resize(4);

	static_tlwh();
	static_tlbr();
	frame_id = 0;
	tracklet_len = 0;
	this->score = score;
	start_frame = 0;
}

构造函数调用了
static_tlwh();
static_tlbr();

void STrack::static_tlwh()
{
    if (this->state == TrackState::New)
    {
        tlwh[0] = _tlwh[0];
        tlwh[1] = _tlwh[1];
        tlwh[2] = _tlwh[2];
        tlwh[3] = _tlwh[3];
        return;
    }
    
    tlwh[0] = mean[0];
    tlwh[1] = mean[1];
    tlwh[2] = mean[2];
    tlwh[3] = mean[3];
    
    tlwh[2] *= tlwh[3];
    tlwh[0] -= tlwh[2] / 2;
    tlwh[1] -= tlwh[3] / 2;
}

void STrack::static_tlbr()
{
    tlbr.clear();
    tlbr.assign(tlwh.begin(), tlwh.end());
    tlbr[2] += tlbr[0];
    tlbr[3] += tlbr[1];
}

STrack类有两个成员变量

std::vector tlwh;
std::vector tlbr;

边框坐标信息1

tlbr
0 left
1 top
2 right
3 bottom

边框坐标信息2

tlwh
0 left  
1 top
2 width
3 height

卡尔曼滤波使用的边框坐标信息

void STrack::activate(byte_kalman::KalmanFilter &kalman_filter, int frame_id)
{
    this->kalman_filter = kalman_filter;
    this->track_id = this->next_id();
    
    std::vector _tlwh_tmp(4);
    _tlwh_tmp[0] = this->_tlwh[0];
    _tlwh_tmp[1] = this->_tlwh[1];
    _tlwh_tmp[2] = this->_tlwh[2];
    _tlwh_tmp[3] = this->_tlwh[3];
    std::vector xyah = tlwh_to_xyah(_tlwh_tmp);
    DETECTBOX xyah_box;
    xyah_box[0] = xyah[0];
    xyah_box[1] = xyah[1];
    xyah_box[2] = xyah[2];
    xyah_box[3] = xyah[3];
    auto mc = this->kalman_filter.initiate(xyah_box);
    this->mean = mc.first;
    this->covariance = mc.second;
    
    static_tlwh();
    static_tlbr();
    
    this->tracklet_len = 0;
    this->state = TrackState::Tracked;
    if (frame_id == 1)
    {
        this->is_activated = true;
    }
    //this->is_activated = true;
    this->frame_id = frame_id;
    this->start_frame = frame_id;
}

最终定位到STrack类的tlwh_to_xyah函数

std::vector STrack::tlwh_to_xyah( std::vector tlwh_tmp)
{
    std::vector tlwh_output = tlwh_tmp;
    tlwh_output[0] += tlwh_output[2] / 2;
    tlwh_output[1] += tlwh_output[3] / 2;
    tlwh_output[2] /= tlwh_output[3];
    return tlwh_output;
}

通过该成员函数得知ByteTrack的卡尔曼滤波使用的边框坐标信息是

0 边框中心点 center_x
1 边框中心点 center_y
2 边框的宽高比 或者说 纵横比、width/height
3 边框的高度

总结

tlbr 边框坐标信息1

0 left
1 top
2 right
3 bottom

tlwh 边框坐标信息2

0 left  
1 top
2 width
3 height

xyah 边框坐标信息3

即卡尔曼滤波使用的边框坐标信息

0 边框中心点 center_x
1 边框中心点 center_y
2 边框的宽高比 或者说 纵横比、width/height
3 边框的高度

你可能感兴趣的:(多目标跟踪,ByteTrack,卡尔曼滤波,多目标跟踪)