Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/machinevisiontoolbox/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,9 +2785,20 @@ def points2F(
if seed is not None:
cv2.setRNGSeed(seed)

F, mask = cv2.findFundamentalMat(
points1=p1.T, points2=p2.T, method=points2F_dict[method], **kwargs
)
try:
F, mask = cv2.findFundamentalMat(
points1=p1.T, points2=p2.T, method=points2F_dict[method], **kwargs
)
except cv2.error as e:
# on some degenerate point configurations cv2.findFundamentalMat
# raises a raw C++ assertion (eg. a Mat rowRange error) instead
# of returning None -- same underlying cause as the F is None
# case below, just surfaced differently by OpenCV
raise ValueError(
f"cv2.findFundamentalMat could not estimate F from "
f"{p1.shape[1]} point correspondences using method={method!r} "
f"-- points are likely too degenerate (eg. coplanar, collinear): {e}"
) from e

if F is None or mask is None:
# already know p1.shape[1] >= min_points (checked above), so a
Expand Down
Loading