Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

data_transformer.cpp 504 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. #include "data_transformer.hpp"
  2. Eigen::MatrixXf OpenCV2Eigen(const cv::Mat& image)
  3. {
  4. cv::Mat imageGray;
  5. if (image.channels() != 1)
  6. {
  7. cv::cvtColor(image, imageGray, CV_RGB2GRAY);
  8. }
  9. else
  10. {
  11. imageGray = cv::Mat(image);
  12. }
  13. imageGray.convertTo(imageGray, CV_32FC1);
  14. Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> imageMatrix(imageGray.ptr<float>(), imageGray.rows, imageGray.cols);
  15. return std::move(imageMatrix);
  16. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...