I have the following code to calculate and present epipolar lines by multiplying the given points by the fundamental matrix:
# This should open a new figure window outside of jupyter notebook
%matplotlib qt
imL = cv2.imread('Left.tif', cv2.IMREAD_GRAYSCALE)
imR = cv2.imread('Right.tif', cv2.IMREAD_GRAYSCALE)
plt.rcParams['figure.figsize'] = (14.0, 14.0)
f, ((ax1, ax2)) = plt.subplots(1, 2, sharex='col', sharey='row')
ax1.imshow(imL, cmap='gray'), ax1.set_title('Left image')
ax2.imshow(imR, cmap='gray'), ax2.set_title('Right image')
data = plt.ginput(3)
x_val = [x[0] for x in data]
y_val = [x[1] for x in data]
ax2.scatter(x_val, y_val, color='r')
for x in data:
Lleft = np.matmul(np.append(x,1).T,F)
y_0 = -Lleft[2]/Lleft[1]
x_width = imL.shape[1]
y_width = -(Lleft[2] + Lleft[0]*x_width)/Lleft[1]
ax1.plot((0, x_width),(y_0, y_width))
Lright = np.matmul(F,np.append(x,1))
y_0 = -Lright[2]/Lright[1]
x_width = imR.shape[1]
y_width = -(Lright[2] + Lright[0]*x_width)/Lright[1]
ax2.plot((0, x_width),(y_0, y_width))
The most bottom part (inside the for loop) should show the epipolar lines on the original image where the points were taken for, and therefore the lines must go through the points like so:
But instead, there is sometimes a "shift" between the line and the point, for example:
Any idea why this could be?