I want to calculate the depth of image pixel in world unit using stereo triangulation principle. Using stereo triangulation principle one get perpendicular distance from base line connecting left and right camera. I want to calculate depth from left camera instead of base line. I am using single camera to capture two images. My camera is mounted on moving vehicle. I take consecutive two images. As vehicle is moving baseline between two view is not horizontal to viewing direction. I calculate the distance of particular image pixel using triangulation principle. I select the corresponding pixel from left and right image manually with mouse click.
Let (x1,y1) and (x2,y2) are corresponding pixels from left and right image repectively. 'CamDistance' is Capturing distance between two views. By calculating disparity I get the depth of pixel in world unit. But obtained depth is perpendicular distance from base line. I want to calculate depth from left or right camera. Please suggest me what changes I shold make in below formula to calculate depth from camera instead of base line.
I tried following function for calculating depth of pixel
def PixDistance(x1,y1,x2,y2):
Disparity=x1-x2
Depth=CamDistance*f/Disparity
AbsDepth=abs(Depth)
return AbsDepth;
Thanks in advance !!