【问题标题】:camera calibration sample code (bigmat matrix)相机标定示例代码(bigmat 矩阵)
【发布时间】:2013-03-04 13:06:55
【问题描述】:

我正在查看 opencv 中的相机校准示例代码。

现在,我很难理解代码的某些行。此代码位于 Opencv 2.4.3 的示例代码文件夹中。

我的问题是关于 C++ 而不是 opencv。

这是opencv中的示例代码。

if( !rvecs.empty() && !tvecs.empty() )
{   
  CV_Assert(rvecs[0].type() == tvecs[0].type());
  Mat bigmat((int)rvecs.size(), 6, rvecs[0].type());

  for( int i = 0; i < (int)rvecs.size(); i++ )
  {
     Mat r = bigmat(Range(i, i+1), Range(0,3));
     Mat t = bigmat(Range(i, i+1), Range(3,6));

     CV_Assert(rvecs[i].rows == 3 && rvecs[i].cols == 1);
     CV_Assert(tvecs[i].rows == 3 && tvecs[i].cols == 1);
     //*.t() is MatExpr (not Mat) so we can use assignment operator
     r = rvecs[i].t();
     t = tvecs[i].t();
  }
  cvWriteComment( *fs, "a set of 6-tuples (rotation vector + translation vector) for each view",       0 );
  fs << "Extrinsic_Parameters" << bigmat;

我的问题是如何将数据放入“bigmat”中。要为变量设置值,'bigmat' 应该位于右侧,但没有。

有人熟悉这种代码吗?帮我。

谢谢

【问题讨论】:

  • 如果正确,请采纳。

标签: c++ opencv camera calibration


【解决方案1】:

rt 矩阵实际上是为 bigmat 数据子集构建的标头。因此,当您将某些内容放入r 时,您实际上是在对 bigmat 进行操作。为了防止这样的事情发生,您需要使用cv::MAt::clone()Look up the documentation for mat, fourth bullet.

【讨论】:

  • 没有问题,但欢迎您接受答案。答案分数下方的绿色勾号。
猜你喜欢
  • 1970-01-01
  • 2013-01-27
  • 2020-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-01
  • 1970-01-01
  • 2017-10-14
相关资源
最近更新 更多