Merge pull request #26921 from shyama7004:sampsonDistance

Fix assertion in cv2.sampsonDistance
This commit is contained in:
Alexander Smorkalov 2025-02-17 09:25:30 +03:00 committed by GitHub
commit 8065f10521
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -84,5 +84,13 @@ class calibration_test(NewOpenCVTests):
self.assertTrue(imagePoints is not None)
self.assertTrue(jacobian is not None)
def test_sampsonDistance_valid2D(self):
pt1 = (np.random.rand(3, 10) * 256).astype(np.float64)
pt2 = (np.random.rand(3, 10) * 256).astype(np.float64)
F = (np.random.rand(3, 3) * 256).astype(np.float64)
dist = cv.sampsonDistance(pt1, pt2, F)
self.assertTrue(isinstance(dist, (float, np.floating)))
self.assertGreaterEqual(dist, 0.0)
if __name__ == '__main__':
NewOpenCVTests.bootstrap()

View File

@ -1224,7 +1224,7 @@ double cv::sampsonDistance(InputArray _pt1, InputArray _pt2, InputArray _F)
{
CV_INSTRUMENT_REGION();
CV_Assert(_pt1.type() == CV_64F && _pt2.type() == CV_64F && _F.type() == CV_64F);
CV_Assert(_pt1.depth() == CV_64F && _pt2.depth() == CV_64F && _F.depth() == CV_64F);
CV_DbgAssert(_pt1.rows() == 3 && _F.size() == Size(3, 3) && _pt1.rows() == _pt2.rows());
Mat pt1(_pt1.getMat());