首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用opencv断言失败错误

使用opencv断言失败错误
EN

Stack Overflow用户
提问于 2017-05-25 12:28:04
回答 1查看 704关注 0票数 0

我试图在apriltag库中运行这个示例,并且一直收到以下错误:

代码语言:javascript
复制
OpenCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0)) in create, file /Users/Vijin/PersInq/opencv-3.2.0/modules/core/src/matrix.cpp, line 2559

我把它缩小到一个函数调用

代码语言:javascript
复制
detection.getRelativeTranslationRotation(m_tagSize, m_fx, m_fy, m_px, m_py,
                                         translation, rotation);

我不是opencv方面的专家,所以我希望能在这方面提供一些帮助。一旦检测到标记,就会抛出异常。否则,它就能正常运行。以下是整个功能:

代码语言:javascript
复制
void print_detection(AprilTags::TagDetection& detection) const {

cout << "  Id: " << detection.id
     << " (Hamming: " << detection.hammingDistance << ")";

// recovering the relative pose of a tag:

// NOTE: for this to be accurate, it is necessary to use the
// actual camera parameters here as well as the actual tag size
// (m_fx, m_fy, m_px, m_py, m_tagSize)

Eigen::Vector3d translation;
Eigen::Matrix3d rotation;
try{
detection.getRelativeTranslationRotation(m_tagSize, m_fx, m_fy, m_px, m_py,
                                         translation, rotation);
}
catch (const std::exception& e) 
{
  cout<<"print_detection failing";
}
Eigen::Matrix3d F;
F <<
  1, 0,  0,
  0,  -1,  0,
  0,  0,  1;
Eigen::Matrix3d fixed_rot = F*rotation;
double yaw, pitch, roll;
wRo_to_euler(fixed_rot, yaw, pitch, roll);

cout << "  distance=" << translation.norm()
     << "m, x=" << translation(0)
     << ", y=" << translation(1)
     << ", z=" << translation(2)
     << ", yaw=" << yaw
     << ", pitch=" << pitch
     << ", roll=" << roll
     << endl;

// Also note that for SLAM/multi-view application it is better to
// use reprojection error of corner points, because the noise in
// this relative pose is very non-Gaussian; see iSAM source code
// for suitable factors.

}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-15 16:26:17

此问题在较新版本的OpenCV中仍然存在。通过将第95行 of src/TagDetection.cccv::Matx33f cameraMatrix(改为cv::Matx33d cameraMatrix(,可以很容易地修复。

注意,这只是从float转换到double。或者,您也可以使用这个库(https://github.com/PrieureDeSion/apriltags-cpp),我已经对它进行了更改,并使用Ubuntu16和OpenCV进行了测试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44180584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档