xStr = "fused_object"; yStr = "sensor_object";改为接收到的目标类型
时间: 2024-04-25 07:26:26 浏览: 86
您可以将代码中的字符串变量`xStr`和`yStr`改为接收到的目标类型。具体来说,可以将这两个字符串变量作为函数的参数,然后在调用函数时传入目标类型。修改后的代码可能如下所示:
```C++
float TrackObjectDistance::ComputeCameraCamera(const SensorObjectConstPtr& fused_object,
const SensorObjectPtr& sensor_object,
int range,
const std::string& xStr,
const std::string& yStr) {
double center_distance =
(sensor_object->GetBaseObject()->center -
fused_object->GetBaseObject()->center)
.head(2)
.norm();
if (center_distance > s_camera2camera_association_center_dist_threshold_) {
ADEBUG << "center distance exceed camera2camera tight threshold: "
<< "center_dist@" << center_distance << ", "
<< "tight_threh@"
<< s_camera2camera_association_center_dist_threshold_;
return (std::numeric_limits<float>::max)();
}
float distance = ComputePolygonDistance(fused_object, sensor_object, range);
AINFO << "Compute " << xStr << "-" << yStr << " distance: " << distance;
return distance;
}
```
在这个修改后的代码中,`xStr`和`yStr`分别表示两个目标的类型,它们被作为函数的参数传递,并在输出日志中使用。这样,您在调用函数时可以根据需要传入相应的目标类型,从而实现更加灵活的调用。
阅读全文