我正在使用g ++和opencv 2.4.6编写OpenCV项目
我有一些像这样的代码:
try
{
H = findHomography( obj, scene, CV_RANSAC );
}
catch (Exception &e)
{
if (showOutput)
cout<< "Error throwed when finding homography"<<endl;
errorCount++;
if (errorCount >=10)
{
errorCount = 0;
selected_temp = -99;
foundBB = false;
bb_x1 = 0;
bb_x2 = 0;
bb_y1 = 0;
bb_y2 = 0;
}
return -1;
}
Run Code Online (Sandbox Code Playgroud)
当findHomography无法找到时,将抛出错误.错误消息包括:
OpenCV Error: Assertion failed (npoints >= 0 && points2.checkVector(2)
== npoints && points1.type() == points2.type()) in findHomography,
file /Users/dji-mini/Downloads/opencv- 2.4.6/modules/calib3d/src/fundam.cpp,
line 1074
OpenCV …Run Code Online (Sandbox Code Playgroud) 我想问一下如何在C++中格式化OpenCV Mat并打印出来?
例如,一个带有双内容 M 的 Mat,当我写
cout<<M<<endl;
Run Code Online (Sandbox Code Playgroud)
我会得到
[-7.7898273846583732e-15, -0.03749374753019832; -0.0374787251930463, -7.7893623846343843e-15]
Run Code Online (Sandbox Code Playgroud)
但我想要一个整洁的输出,例如
[0.0000, -0.0374; -0.0374, 0.0000]
Run Code Online (Sandbox Code Playgroud)
有没有内置的方法来做到这一点?
我知道我们可以使用
cout<<format(M,"C")<<endl;
Run Code Online (Sandbox Code Playgroud)
设置输出样式。所以我正在寻找类似的东西。
非常感谢!