Closed mandrend closed 7 years ago
You are on the correct path; however, there are other steps necessary to compute the IMAGE coordinates of VP3. See the functions bellow.
def getFocal(vp1, vp2, pp):
return math.sqrt(- np.dot(vp1[0:2]-pp[0:2], vp2[0:2]-pp[0:2]))
def homogenizeAndNormalize(p):
p = np.array(p)
p = p.flatten()
assert len(p) == 2 or len(p) == 3
if len(p) == 2:
return np.concatenate((p, [1]))
else:
return p/p[2]
"""
Compute camera calibration from two van points and principal point
"""
def computeCameraCalibration(_vp1, _vp2, _pp):
vp1 = homogenizeAndNormalize(_vp1)
vp2 = homogenizeAndNormalize(_vp2)
pp = homogenizeAndNormalize(_pp)
focal = getFocal(vp1, vp2, pp)
vp1W = np.concatenate((vp1[0:2], [focal]))
vp2W = np.concatenate((vp2[0:2], [focal]))
ppW = np.concatenate((pp[0:2], [0]))
vp3W = np.cross(vp1W-ppW, vp2W-ppW)
vp3 = np.concatenate((vp3W[0:2]/vp3W[2]*focal + ppW[0:2], [1]))
vp3Direction = np.concatenate((vp3[0:2], [focal]))-ppW
roadPlane = np.concatenate((vp3Direction/np.linalg.norm(vp3Direction), [10]))
return vp1, vp2, vp3, pp, roadPlane, focal
In the dataset.pkl, every camera has three VPs' 2d coordinates, and I wonder whether those coordinates are the VPs' position in the image plane? To validate this , I use the equation(5) :U= (ux, uy, f), V= (ux, uy, f),P= (px, py, 0),W= (U− P) × (V− P) in the article 'Fully Automatic Roadside Camera Calibration for Traffic Surveillance'. The VPs I use are the VPs of camera videnska, I use vp1=[ 2018.41228263, 77.64316627], vp2=[ 63.71104018, 64.09228882], pp=[ 350.5, 250.5] and f=667.9198918 to compute vp3, and the result is array([-716.16197463, 48.24208282, 667.9198918 ]), it is very different to the position [ 334.37621358, 2675.97844949] given in dtaset.pkl, and it seems that the VPs' coordinates given in the dataset.pkl are not the VPs' positions in the image plane, so I want to ask what's the coordiante system of VPs given in dataset.pkl