Stitching模块中focalsFromHomography初步研究
{
CV_Assert(H.type() == CV_64F && H.size() == Size( 3, 3));
const double * h = H.ptr < double >();
double d1, d2; // Denominators
double v1, v2; // Focal squares value candidates
f1_ok = true;
d1 = h[ 6] * h[ 7];
d2 = (h[ 7] - h[ 6]) * (h[ 7] + h[ 6]);
v1 = -(h[ 0] * h[ 1] + h[ 3] * h[ 4]) / d1;
v2 = (h[ 0] * h[ 0] + h[ 3] * h[ 3] - h[ 1] * h[ 1] - h[ 4] * h[ 4]) / d2;
if (v1 < v2) std : :swap(v1, v2);
if (v1 > 0 && v2 > 0) f1 = std : :sqrt(std : :abs(d1) > std : :abs(d2) ? v1 : v2);
else if (v1 > 0) f1 = std : :sqrt(v1);
else f1_ok = false;
f0_ok = true;
d1 = h[ 0] * h[ 3] + h[ 1] * h[ 4];
d2 = h[ 0] * h[ 0] + h[ 1] * h[ 1] - h[ 3] * h[ 3] - h[ 4] * h[ 4];
v1 = -h[ 2] * h[ 5] / d1;
v2 = (h[ 5] * h[ 5] - h[ 2] * h[ 2]) / d2;
if (v1 < v2) std : :swap(v1, v2);
if (v1 > 0 && v2 > 0) f0 = std : :sqrt(std : :abs(d1) > std : :abs(d2) ? v1 : v2);
else if (v1 > 0) f0 = std : :sqrt(v1);
else f0_ok = false;
}
Tries to estimate focal lengths from the given homography
under the assumption that the camera undergoes rotations around its centre only.
Parameters
H – Homography.
f0 – Estimated focal length along X axis.
f1 – Estimated focal length along Y axis.
f0_ok – True, if f0 was estimated successfully, false otherwise.
f1_ok – True, if f1 was estimated successfully, false otherwise.
那么
v1 = -h[ 2] * h[ 5] / d1 = -h[ 2] * h[ 5] /(h[ 0] * h[ 3] + h[ 1] * h[ 4])
则
v2 = (h[ 5] * h[ 5] - h[ 2] * h[ 2]) / d2 = (h[ 5] * h[ 5] - h[ 2] * h[ 2]) / (h[ 0] * h[ 0] + h[ 1] * h[ 1] - h[ 3] * h[ 3] - h[ 4] * h[ 4])
目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

