OpenCV  3.4.14
Open Source Computer Vision
Functions
Eigen support

Functions

template<typename _Tp , int _layout>
static void cv::cv2eigen (const Mat &src, Eigen::Tensor< _Tp, 3, _layout > &dst)
 Converts a cv::Mat to an Eigen::Tensor. More...
 
template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::cv2eigen (const Mat &src, Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &dst)
 
template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::cv2eigen (const Matx< _Tp, _rows, _cols > &src, Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &dst)
 
template<typename _Tp >
static void cv::cv2eigen (const Mat &src, Eigen::Matrix< _Tp, Eigen::Dynamic, Eigen::Dynamic > &dst)
 
template<typename _Tp , int _rows, int _cols>
static void cv::cv2eigen (const Matx< _Tp, _rows, _cols > &src, Eigen::Matrix< _Tp, Eigen::Dynamic, Eigen::Dynamic > &dst)
 
template<typename _Tp >
static void cv::cv2eigen (const Mat &src, Eigen::Matrix< _Tp, Eigen::Dynamic, 1 > &dst)
 
template<typename _Tp , int _rows>
static void cv::cv2eigen (const Matx< _Tp, _rows, 1 > &src, Eigen::Matrix< _Tp, Eigen::Dynamic, 1 > &dst)
 
template<typename _Tp >
static void cv::cv2eigen (const Mat &src, Eigen::Matrix< _Tp, 1, Eigen::Dynamic > &dst)
 
template<typename _Tp , int _cols>
static void cv::cv2eigen (const Matx< _Tp, 1, _cols > &src, Eigen::Matrix< _Tp, 1, Eigen::Dynamic > &dst)
 
template<typename _Tp >
static Eigen::TensorMap< Eigen::Tensor< _Tp, 3, Eigen::RowMajor > > cv::cv2eigen_tensormap (InputArray src)
 Maps cv::Mat data to an Eigen::TensorMap. More...
 
template<typename _Tp , int _layout>
static void cv::eigen2cv (const Eigen::Tensor< _Tp, 3, _layout > &src, OutputArray dst)
 Converts an Eigen::Tensor to a cv::Mat. More...
 
template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::eigen2cv (const Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &src, OutputArray dst)
 
template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::eigen2cv (const Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &src, Matx< _Tp, _rows, _cols > &dst)
 

Detailed Description

These functions are provided for OpenCV-Eigen interoperability. They convert Mat objects to corresponding Eigen::Matrix objects and vice-versa. Consult the Eigen documentation for information about the Matrix template type.

Note
Using these functions requires the Eigen/Dense or similar header to be included before this header.

Function Documentation

◆ cv2eigen() [1/9]

template<typename _Tp , int _layout>
static void cv::cv2eigen ( const Mat src,
Eigen::Tensor< _Tp, 3, _layout > &  dst 
)
inlinestatic

#include <opencv2/core/eigen.hpp>

Converts a cv::Mat to an Eigen::Tensor.

The method converts a cv::Mat to an Eigen Tensor with shape (H x W x C) where: H = number of rows W = number of columns C = number of channels

Usage:

Mat a_mat(...);
// populate Mat with values
Eigen::Tensor<float, 3, Eigen::RowMajor> a_tensor(...);
cv2eigen(a_mat, a_tensor);

◆ cv2eigen() [2/9]

template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::cv2eigen ( const Mat src,
Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &  dst 
)
inlinestatic

◆ cv2eigen() [3/9]

template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::cv2eigen ( const Matx< _Tp, _rows, _cols > &  src,
Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &  dst 
)
inlinestatic

◆ cv2eigen() [4/9]

template<typename _Tp >
static void cv::cv2eigen ( const Mat src,
Eigen::Matrix< _Tp, Eigen::Dynamic, Eigen::Dynamic > &  dst 
)
inlinestatic

◆ cv2eigen() [5/9]

template<typename _Tp , int _rows, int _cols>
static void cv::cv2eigen ( const Matx< _Tp, _rows, _cols > &  src,
Eigen::Matrix< _Tp, Eigen::Dynamic, Eigen::Dynamic > &  dst 
)
inlinestatic

◆ cv2eigen() [6/9]

template<typename _Tp >
static void cv::cv2eigen ( const Mat src,
Eigen::Matrix< _Tp, Eigen::Dynamic, 1 > &  dst 
)
inlinestatic

◆ cv2eigen() [7/9]

template<typename _Tp , int _rows>
static void cv::cv2eigen ( const Matx< _Tp, _rows, 1 > &  src,
Eigen::Matrix< _Tp, Eigen::Dynamic, 1 > &  dst 
)
inlinestatic

◆ cv2eigen() [8/9]

template<typename _Tp >
static void cv::cv2eigen ( const Mat src,
Eigen::Matrix< _Tp, 1, Eigen::Dynamic > &  dst 
)
inlinestatic

◆ cv2eigen() [9/9]

template<typename _Tp , int _cols>
static void cv::cv2eigen ( const Matx< _Tp, 1, _cols > &  src,
Eigen::Matrix< _Tp, 1, Eigen::Dynamic > &  dst 
)
inlinestatic

◆ cv2eigen_tensormap()

template<typename _Tp >
static Eigen::TensorMap<Eigen::Tensor<_Tp, 3, Eigen::RowMajor> > cv::cv2eigen_tensormap ( InputArray  src)
inlinestatic

#include <opencv2/core/eigen.hpp>

Maps cv::Mat data to an Eigen::TensorMap.

The method wraps an existing Mat data array with an Eigen TensorMap of shape (H x W x C) where: H = number of rows W = number of columns C = number of channels

Explicit instantiation of the return type is required.

Note
Caller should be aware of the lifetime of the cv::Mat instance and take appropriate safety measures. The cv::Mat instance will retain ownership of the data and the Eigen::TensorMap will lose access when the cv::Mat data is deallocated.

The example below initializes a cv::Mat and produces an Eigen::TensorMap:

float arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
Mat a_mat(2, 2, CV_32FC3, arr);
Eigen::TensorMap<Eigen::Tensor<float, 3, Eigen::RowMajor>> a_tensormap = cv2eigen_tensormap<float>(a_mat);

◆ eigen2cv() [1/3]

template<typename _Tp , int _layout>
static void cv::eigen2cv ( const Eigen::Tensor< _Tp, 3, _layout > &  src,
OutputArray  dst 
)
inlinestatic

#include <opencv2/core/eigen.hpp>

Converts an Eigen::Tensor to a cv::Mat.

The method converts an Eigen::Tensor with shape (H x W x C) to a cv::Mat where: H = number of rows W = number of columns C = number of channels

Usage:

Eigen::Tensor<float, 3, Eigen::RowMajor> a_tensor(...);
// populate tensor with values
Mat a_mat;
eigen2cv(a_tensor, a_mat);

◆ eigen2cv() [2/3]

template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::eigen2cv ( const Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &  src,
OutputArray  dst 
)
inlinestatic

◆ eigen2cv() [3/3]

template<typename _Tp , int _rows, int _cols, int _options, int _maxRows, int _maxCols>
static void cv::eigen2cv ( const Eigen::Matrix< _Tp, _rows, _cols, _options, _maxRows, _maxCols > &  src,
Matx< _Tp, _rows, _cols > &  dst 
)
inlinestatic