簡體   English   中英

具有相同存儲類型的向量之間的函數不匹配

[英]Function mismatch between vectors with identical stored types

我已經定義了一個名為"Create2DBBox"的模板函數,僅用於從點雲矢量創建邊界框,實現細節不太重要。

我想使用模板PointT類型來接受不同的Point類型,例如PointXYZ或`PointXYZI',問題是當我定義如下函數時:

template<typename PointT>
std::vector<BBox2D> Create2DBBox(const std::shared_ptr<std::vector<pcl::PointCloud<PointT>, Eigen::aligned_allocator<pcl::PointCloud<PointT> >>> cloudVecIn, const Eigen::MatrixXf& projectMatrix, const cv::Size& imageSize)
{
  std::vector<BBox2D> bbox_vec_res;
  for(int i = 0; i < cloudVecIn->size(); ++i) {
    BBox2D bbox((*cloudVecIn)[i], projectMatrix, imageSize);
    bbox_vec_res.push_back(bbox);
  }
  return bbox_vec_res;
}

當我如下使用此功能時:

 std::shared_ptr<std::vector<pcl::PointCloud<pcl::PointXYZI>>> clustered_vec = ogm_detector_.get_clustered_cloud_vec();
 vector<BBox2D> bbox_vec = sensors_fusion::Create2DBBox(clustered_vec, this->transform_matrix_, Size(this->image_raw_.cols, image_raw_.rows));

我得到錯誤:

error: no matching function for call to ‘Create2DBBox(std::shared_ptr<std::vector<pcl::PointCloud<pcl::PointXYZI> > >&, Eigen::MatrixXf&, cv::Size)’
 D> bbox_vec = sensors_fusion::Create2DBBox(clustered_vec, this->transform_matrix_, Size(this->image_raw_.cols, image_raw_.rows));

我不知道,我想這一定是fisrt模板參數的原因。 謝謝你的幫助。

它們並不相同,因為您的函數描述了使用自定義分配器指向向量的共享指針。

由於您的函數不依賴於分配器,因此請執行以下操作:

template<typename Container>
std::vector<BBox2D> Create2DBBox(const std::shared_ptr<Container> cloudVecIn, const Eigen::MatrixXf& projectMatrix, const cv::Size& imageSize)

甚至,您也不需要共享指針,因此:

template<typename Container>
std::vector<BBox2D> Create2DBBox(const Container& cloudVecIn, const Eigen::MatrixXf& projectMatrix, const cv::Size& imageSize)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM