Home How to create cv::Mat from buffer (array of T* data) using a template function?
Reply: 0

How to create cv::Mat from buffer (array of T* data) using a template function?

user631
1#
user631 Published in May 25, 2018, 11:11 am

I'd like to write a template function to copy data referenced by pointer T* image to cv::Mat. I am confusing how to generalize T and cv_type matching.

template<typename T>
cv::Mat convert_mat(T *image, int rows, int cols) {
    // Here we need to match T to cv_types like CV_32F, CV_8U and etc.
    // The key point is how to connect these two
    cv::Mat mat(rows, cols, cv_types, image);
    return mat;
}

I am new to template programming, I am quite confused how to implement T-cv_types correspondence.

Anyone has any idea? Thank you!!!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325187 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO