Closed Zehaos closed 7 years ago
Hi, orientation of what? Camera or vehicle?
@JakubSochor, of the vehicle
Yes, it is possible to compute the viewpoint vector to any point on the screen using following code.
def getFocal(vp1, vp2, pp):
return math.sqrt(- np.dot(vp1[0:2]-pp[0:2], vp2[0:2]-pp[0:2]))
def getViewpoint(p, vp1, vp2, pp):
try:
focal = getFocal(vp1, vp2, pp)
except ValueError:
return None
vp1W = np.concatenate((vp1[0:2]-pp[0:2], [focal]))
vp2W = np.concatenate((vp2[0:2]-pp[0:2], [focal]))
if vp1[0] < vp2[0]:
vp2W = -vp2W
vp3W = np.cross(vp1W, vp2W)
vp1W, vp2W, vp3W = tuple(map(lambda u: u/np.linalg.norm(u), [vp1W, vp2W, vp3W]))
pW = np.concatenate((p[0:2]-pp[0:2], [focal]))
pW = pW/np.linalg.norm(pW)
viewPoint = -np.dot(np.array([vp1W, vp2W, vp3W]), pW)
return viewPoint
To compute the viewpoint to the vehicle, you can use center of the 3D bounding box. The center can be obtained as intersection of diagonals of the 3D bounding box.
@JakubSochor, It is seem that function below need a point from the original image.
def getViewpoint(p, vp1, vp2, pp):
The problem is that the given images only contains part(car region) of the original, and the 3DBB's coordinate is related to this region, such we can not calculate the center of the 3DBB on the original image.
Do I make myself clear?
The 3DBB coordinates are in the original image space. To convert them to the cropped image space you need to subtract the 3DBB_offset. Therefore, you can just use the 3DBB in the original image space to compute the center of the vehicle.
Got it, thank you very much : )
@Zehaos Hi! The orientation you get is the center point of 3Dbox corresponding to the origin of the World Coordinate System, Right? But What should I do if I want to get the real front orientation of the vehicle? Can you please guide me on how to deal with it? Thanks~
Hi, @JakubSochor, Is it possible to derived the orientation from existing label (camera intrinsics, vanishing points and so on)? Thank you~