0

我正在查看 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' 应该位于右侧,但没有。

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

谢谢

4

1 回答 1

0

rt矩阵实际上是为 bigmat 数据子集构建的标头。所以当你把东西放进去时r,你实际上是在 bigmat 上操作。为了防止这样的事情发生,您需要使用cv::MAt::clone(). 查找 mat, Fourth bullet 的文档

于 2013-03-05T09:40:01.807 回答