我正在使用 SIFT 算法进行图像匹配,并计算单应矩阵以了解对象和场景之间是否存在有效的对应关系。下面发布的方法“isValidHMatrix”是我如何检查 H 矩阵是否良好,正如在这个问题中发布的那样,我计算 H 矩阵中左上角 2x2 矩阵的行列式,如果行列式 >= 0 那么否则 H 矩阵不好是好的。
但是当我应用该概念来查找某些对象和场景之间的匹配时,我得到了以下发布的图像结果:
请让我知道如何正确检查 H 矩阵的有效性
结果:
for image 1: the object is part of the scene, but i got "invalid HMatrix,
det(H): -8.978588811689873"
for image 2: the object is not part of the scene, but i got "valid HMatrix,
det(H): 3.32362768456779"
for image 3: the object is not part of the scene, but i got
"goodMatchesList.size() < 4 points"
for image 4: the object is part of the scene, but i got "valid HMatrix,
det(H): 0.153917265625088"
for image 5: the object is part of the scene, but i got "valid HMatrix,
det(H): 1.0012971075010808"
for image 6: the object is part of the scene, but i got "valid HMatrix,
det(H): 0.0037162733516824488"
for image 7: the object is not part of the scene, but i got "invalid
HMatrix, det(H): -2.397038481177457E-6"
for image 8: the object is not part of the scene, but i got "valid HMatrix,
det(H): 0.0"
代码:
private boolean isValidHMatrix(Mat hMatrix, String token) {
// TODO Auto-generated method stub
//double det = Core.determinant(hMatrix);
double det = Core.determinant(hMatrix.submat(new Rect (new Point(0, 0), new Point(2, 2))));
if (det >= 0) {
Log.V(TAG, "isValidHMatrix", token+"_valid HMatrix, det(H): "+det);
return true;
} else {
Log.V(TAG, "isValidHMatrix", token+"_invalid HMatrix, det(H): "+det);
return false;
}
}