#include <Eigen/Core>
#include <opencv2/opencv.hpp>
int main() {
// 假设你有一个包含三维点的 std::vector<Eigen::Vector3f>
std::vector<Eigen::Vector3f> mappointInCurrentFrame;
// 假设你有一个包含二维坐标的 std::vector<cv::Point2f>,这可能是通过光流法得到的关键点
std::vector<cv::Point2f> keypoints;
// 将 std::vector<Eigen::Vector3f> 转换为 cv::Mat
cv::Mat mappointInCurrentFrameMat(mappointInCurrentFrame.size(), 3, CV_32F);
for (size_t i = 0; i < mappointInCurrentFrame.size(); ++i) {
mappointInCurrentFrameMat.at<float>(i, 0) = mappointInCurrentFrame[i](0);
mappointInCurrentFrameMat.at<float>(i, 1) = mappointInCurrentFrame[i](1);
mappointInCurrentFrameMat.at<float>(i, 2) = mappointInCurrentFrame[i](2);
}
return 0;
}
将 std::vector<Eigen::Vector3f> 转换为 cv::Mat
最新推荐文章于 2024-06-21 10:18:13 发布