0

I have a RGB CV::Mat object and I want to convert it to std::vector<Eigen::Vector3d> to be used in open3d pointcloud color, is it possible to do this without loop?

Thanks.

Tim
  • 47
  • 7
  • Please mind that placing Eigen vectors in std vectors requires special care. Please check the eigen [docs](https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html) – Bart Feb 16 '20 at 20:32
  • Thanks. According to the docs, the issues arise only with fixed-size vectorizable Eigen types and structures having such Eigen objects as member. So Vector3d is technically fine? – Tim Feb 17 '20 at 21:06

1 Answers1

1

Easy, provided you go the other way around:

std::vector<Eigen::Vector3d> pixel_data(height * width);
cv::Mat mat = cv::Mat(height, width, CV_64FC3, &(pixel_data[0](0)));
fill_the_matrix_as_you_wish(mat);
Francesco Callari
  • 11,300
  • 2
  • 25
  • 40