opencv - 向Mat对象添加另一行

标签 opencv matrix row

我基本上是尝试将另一行添加到使用findHomography()函数发现的2x3单应性矩阵中。

    Mat insert = (Mat_<double>(1,3)<<0 , 0 , 1);
    Mat homography = findHomography(features1 , features2 , CV_RANSAC);
    resize(affine , affine , Size(3,3));
    homgraphy.push_back(insert);
    cout<<"Homography"<<" "<<homography;

但是,当我打印单应性时,第三行没有两个零,而只有很小的数字。我希望最后一行恰好是{0,0,1}。我该怎么做?

最佳答案

如果找不到导致矩阵损坏的内容(尝试打印insert以查看其是否已更改),则可以通过以下方式强制使用此问题:

Mat insert = (Mat_<double>(1,3)<<0 , 0 , 1);
Mat homography = findHomography(features1 , features2 , CV_RANSAC);
resize(affine , affine , Size(3,3));
homgraphy.push_back(insert);     // ADD EXTRA ROW TO HOMOGRAPHY RESULT

homgraphy.at<Vec3d>(2,0) = Vec3d(0.0, 0.0, 1.0);  // OVERWRITE BOTTOM ROW OF MAT

关于opencv - 向Mat对象添加另一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25320791/

相关文章:

python-3.x - 无法使用Gstreamer-Python设置两个摄像机的参数

python - 如何在python中将分割图像叠加在主图像之上

python - 如何生成带有 ids 偏移量的 charuco 板

android - 有关 android.graphics.Camera 和 android.graphics.Matrix 的文档或教程?

python - 如何在 Python 中访问由嵌套 defaultdict 创建的矩阵的一行?

xhtml - 重新渲染特定行富:dataTable

c++ - cvHoughLines2 内存泄漏

r - R创建缺少值的p值矩阵

html - 主 slider 调整大小以适应行容器

python - 从未知行创建数据框