pixel_bearing#
- rapidtools.processing.street_localization.pixel_bearing(x: float, y: float, camera_type: str = 'spherical', width: int | None = None, height: int | None = None, camera_parameters: Sequence[float] | None = None) ndarray[source]#
Unit direction in the camera frame of a normalised image point.
Follows OpenSfM’s camera models, which is what Mapillary’s
camera_typeandcamera_parametersdescribe. The camera frame hasxto the right,ydown andzforward.- Parameters:
x – Column as a fraction of the image width (
0left,1right).y – Row as a fraction of the image height (
0top,1bottom).camera_type –
'spherical'/'equirectangular'for panoramas,'perspective'/'brown'for rectilinear images, or'fisheye'. Unknown types are treated as perspective.width – Image width in pixels. Needed with
heightfor the aspect ratio; a 2:1 panorama or a 4:3 frame is assumed when unknown.height – Image height in pixels.
camera_parameters –
[focal, k1, k2]with the focal length normalised by the larger image side (OpenSfM convention). Ignored for spherical cameras;[0.85, 0, 0]is assumed when missing.
- Returns:
numpy.ndarray – Unit vector
(x, y, z)in the camera frame.
Example
>>> [round(float(v), 3) for v in pixel_bearing(0.5, 0.5)] # pano centre [0.0, 0.0, 1.0] >>> [round(float(v), 3) for v in pixel_bearing(0.75, 0.5)] # 90 deg right [1.0, 0.0, 0.0] >>> [round(float(v), 3) for v in pixel_bearing(0.5, 1.0)] # straight down [0.0, 1.0, 0.0] >>> b = pixel_bearing(0.5, 0.5, 'perspective', 4000, 3000, [0.9, 0, 0]) >>> [round(float(v), 3) for v in b] [0.0, 0.0, 1.0]