I found a mathematical calculation library Eigen, which can convert cv::Mat to Eigen::MatrixXd matrix, but can not convert cv::UMat to Eigen::MatrixXd matrix
Here’s my code
#include <eigen3/Eigen/Dense>
#include <opencv2/core/eigen.hpp>
//#include <opencv2/core/eigen.hpp>
#include <opencv2/opencv.hpp>
#include<iostream>
#include <opencv2/core/ocl.hpp>
#include<opencv2/core/utility.hpp>
using namespace Eigen;
using namespace cv;
using namespace std;
int main() {
cv::Mat cvMat = (cv::Mat_<double>(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9);
cv::UMat UMatimg= cvMat.getUMat(ACCESS_READ);
Eigen::MatrixXd eigenMat, eigenMat1;
cv::cv2eigen(cvMat, eigenMat);
//cv::cv2eigen(UMatimg, eigenMat1);//not work
std::cout << "Mat transform after " << eigenMat << std::endl;
std::cout << "UMat transform after " << eigenMat1 << std::endl;
cv::Mat resultMat;
cv::eigen2cv(eigenMat, resultMat);
std::cout << "eigen to mat" << resultMat << std::endl;
return 0;
}