使用 opencv、c++ 的桑普森距离
Sampson Distance using opencv, c++
我正在尝试计算 Sampson distance
,从一个点到它对应的对极线的距离,稍后我将用它作为误差度量。我正在使用 opencv 3.1
、c++
和 windows-10 visual studio 14
。
但是函数 sampsonDistance 使代码崩溃:
Point3f point1 = Point3f(keypoints_1[good_matches[iP].queryIdx].pt.x, keypoints_1[good_matches[iP].queryIdx].pt.y, 1.0);
Point3f point2 = Point3f(keypoints_2[good_matches[iP].trainIdx].pt.x, keypoints_2[good_matches[iP].trainIdx].pt.y, 1.0);
Mat pt1(point1);
Mat pt2(point2);
double sampsonD = sampsonDistance(pt1, pt2, Flist[iF])
我收到错误消息:
OpenCV Error: Assertion failed (_pt1.type() == CV_64F && _pt1.type() == CV_64F && _F.type() == CV_64F) in cv::sampsonDistance, file D:\opencv\sources\modules\calib3d\src\fundam.cpp, line 1043
文档说:
double cv::sampsonDistance ( InputArray pt1,
InputArray pt2,
InputArray F
)
如何使用这个函数,我不太明白输入数组的用法,在上面我将一个 3d 点转换成我认为是存储为 cv::Mat 的 2D 齐次坐标。基本矩阵存储在 3x3 cv::Mat.
从错误信息来看,点和基本矩阵必须是CV_64F
(双精度类型)。
积分应该是:
Point3d point1 = Point3d(keypoints_1[good_matches[iP].queryIdx].pt.x, keypoints_1[good_matches[iP].queryIdx].pt.y, 1.0);
Point3d point2 = Point3d(keypoints_2[good_matches[iP].trainIdx].pt.x, keypoints_2[good_matches[iP].trainIdx].pt.y, 1.0);
我正在尝试计算 Sampson distance
,从一个点到它对应的对极线的距离,稍后我将用它作为误差度量。我正在使用 opencv 3.1
、c++
和 windows-10 visual studio 14
。
但是函数 sampsonDistance 使代码崩溃:
Point3f point1 = Point3f(keypoints_1[good_matches[iP].queryIdx].pt.x, keypoints_1[good_matches[iP].queryIdx].pt.y, 1.0);
Point3f point2 = Point3f(keypoints_2[good_matches[iP].trainIdx].pt.x, keypoints_2[good_matches[iP].trainIdx].pt.y, 1.0);
Mat pt1(point1);
Mat pt2(point2);
double sampsonD = sampsonDistance(pt1, pt2, Flist[iF])
我收到错误消息:
OpenCV Error: Assertion failed (_pt1.type() == CV_64F && _pt1.type() == CV_64F && _F.type() == CV_64F) in cv::sampsonDistance, file D:\opencv\sources\modules\calib3d\src\fundam.cpp, line 1043
文档说:
double cv::sampsonDistance ( InputArray pt1,
InputArray pt2,
InputArray F
)
如何使用这个函数,我不太明白输入数组的用法,在上面我将一个 3d 点转换成我认为是存储为 cv::Mat 的 2D 齐次坐标。基本矩阵存储在 3x3 cv::Mat.
从错误信息来看,点和基本矩阵必须是CV_64F
(双精度类型)。
积分应该是:
Point3d point1 = Point3d(keypoints_1[good_matches[iP].queryIdx].pt.x, keypoints_1[good_matches[iP].queryIdx].pt.y, 1.0);
Point3d point2 = Point3d(keypoints_2[good_matches[iP].trainIdx].pt.x, keypoints_2[good_matches[iP].trainIdx].pt.y, 1.0);