add SingleObjectTracker position xyz output
This commit is contained in:
@@ -758,6 +758,19 @@ int SingleObjectTrackerBase::getTarget()
|
||||
{
|
||||
return this->_target;
|
||||
}
|
||||
//增加跟踪目标位置输出
|
||||
double SingleObjectTrackerBase::getObjectWs()
|
||||
{
|
||||
return this->_object_ws;
|
||||
}
|
||||
double SingleObjectTrackerBase::getObjectHs()
|
||||
{
|
||||
return this->_object_hs;
|
||||
}
|
||||
int SingleObjectTrackerBase::useWidthOrHeight()
|
||||
{
|
||||
return this->_use_width_or_height;
|
||||
}
|
||||
|
||||
void SingleObjectTrackerBase::warmUp()
|
||||
{
|
||||
@@ -803,6 +816,22 @@ void SingleObjectTrackerBase::track(cv::Mat img_, TargetsInFrame& tgts_)
|
||||
tgt.setBox(rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, img_.cols, img_.rows);
|
||||
tgt.setTrackID(1);
|
||||
tgt.setLOS(tgt.cx, tgt.cy, this->camera_matrix, img_.cols, img_.rows);
|
||||
int ow = int(round(rect.width));
|
||||
int oh = int(round(rect.height));
|
||||
if (this->_use_width_or_height == 0)
|
||||
{
|
||||
double z = this->camera_matrix.at<double>(0, 0) * this->_object_ws / ow;
|
||||
double x = tan(tgt.los_ax / SV_RAD2DEG) * z;
|
||||
double y = tan(tgt.los_ay / SV_RAD2DEG) * z;
|
||||
tgt.setPosition(x, y, z);
|
||||
}
|
||||
else if (this->_use_width_or_height == 1)
|
||||
{
|
||||
double z = this->camera_matrix.at<double>(1, 1) * this->_object_hs / oh;
|
||||
double x = tan(tgt.los_ax / SV_RAD2DEG) * z;
|
||||
double y = tan(tgt.los_ay / SV_RAD2DEG) * z;
|
||||
tgt.setPosition(x, y, z);
|
||||
}
|
||||
tgts_.targets.push_back(tgt);
|
||||
}
|
||||
|
||||
@@ -840,6 +869,18 @@ void SingleObjectTrackerBase::_load()
|
||||
else if ("target" == std::string(i->key)) {
|
||||
this->_target = i->value.toNumber();
|
||||
}
|
||||
else if ("useWidthOrHeight" == std::string(i->key))
|
||||
{
|
||||
this->_use_width_or_height = i->value.toNumber();
|
||||
}
|
||||
else if ("sigleobjectW" == std::string(i->key))
|
||||
{
|
||||
this->_object_ws = i->value.toNumber();
|
||||
}
|
||||
else if ("sigleobjectH" == std::string(i->key))
|
||||
{
|
||||
this->_object_hs = i->value.toNumber();
|
||||
}
|
||||
}
|
||||
|
||||
setupImpl();
|
||||
|
||||
Reference in New Issue
Block a user