如何将 cv::Mat 转换为 cv::Matx33f [英] how to convert cv::Mat to cv::Matx33f

查看:160
本文介绍了如何将 cv::Mat 转换为 cv::Matx33f的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 cv::Mat,我想将它转换为 cv::Matx33f.我试着这样做:

I have a cv::Mat that I want to convert into a cv::Matx33f. I try to do it like this:

cv::Mat m;
cv::Matx33f m33;
.........
m33 = m;

但是所有数据都丢失了!知道如何做到这一点吗?

but all the data gets lost! Any idea how to do this ?

更新这是导致我的问题的代码的一部分:

UPDATE here is a part of the code which causes my problem :

cv::Point2f Order::warpPoint(cv::Point2f pTmp){
    cv::Matx33f warp = this->getTransMatrix() ; // the getter gives a cv::Mat back 
    transformMatrix.copyTo(warp); // because the first method didn't work, I tried to use the copyto function 

    // and the last try was 
    warp = cv::Matx33f(transformationMatrix); // and waro still 0 
    cv::Point3f  warpPoint = cv::Matx33f(transformMatrix)*pTmp;
    cv::Point2f result(warpPoint.x, warpPoint.y);
    return result;
}

推荐答案

http://opencv.willowgarage.com/documentation/cpp/core_basic_structures.html 说:

如果你需要在 Matx 上做一些没有实现的操作,很容易将矩阵转换为 Mat 并向后转换."

"If you need to do some operation on Matx that is not implemented, it is easy to convert the matrix to Mat and backwards."

Matx33f m(1, 2, 3,
          4, 5, 6,
          7, 8, 9);
cout << sum(Mat(m*m.t())) << endl;

这篇关于如何将 cv::Mat 转换为 cv::Matx33f的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆