improutils.perspective package
Submodules
improutils.perspective.coordconversion module
- improutils.perspective.coord_conversion.convert_pt_from_homogenous(pt)[source]
Convert input point in homogeneous coordinates to inhomogeneous.
- Parameters:
pt (ndarray) – Input point in homogeneous coordinates.
- Returns:
_ – Input point in inhomogeneous coordinates.
- Return type:
tuple
- improutils.perspective.coord_conversion.convert_pt_to_homogenous(pt)[source]
Convert the input point from inhomogeneous coordinates to homogeneous ones.
- Parameters:
pt (ndarray) – Input point in inhomogeneous coordinates.
- Returns:
_ – Input point in homogeneous coordinates.
- Return type:
ndarray
- improutils.perspective.coord_conversion.convert_pts_from_homogenous(pts)[source]
Convert input points in homogeneous coordinates to inhomogeneous.
- Parameters:
pts (array_like, shape (n_points, n_dims + 1) in homogeneous coordinates.) – Input points in homogeneous coordinates.
- Returns:
inhomogeneous_pts – Points in inhomogeneous coordinates.
- Return type:
ndarray, shape (n_points, n_dims)
- improutils.perspective.coord_conversion.convert_pts_to_homogenous(pts)[source]
Convert input points from inhomogeneous to homogeneous coordinates.
- Parameters:
pts (array_like, shape (n_points, n_dims)) – Inhomogeneous input points.
- Returns:
homogeneous_pts – Points in homogeneous coordinates, with a 1 appended as the last component.
- Return type:
ndarray, shape (n_points, n_dims + 1)
improutils.perspective.heightestimator module
- class improutils.perspective.height_estimator.HeightEstimator(ref_measurements, vl, vz)[source]
Bases:
objectEstimate real world object height based on two points (top and bottom) measured on image plane.
- calc_height(top_point, bottom_point)[source]
Calculate real-world height from image-plane measurements.
Given the top and bottom points of an object in the image plane, this function estimates the real-world height of the object.
- Parameters:
top_point (ndarray) – Top point of the object in the reference direction, in inhomogeneous format.
bottom_point (ndarray) – Ground plane point of the object in inhomogeneous format.
- Returns:
Real-world height of the object.
- Return type:
float
- improutils.perspective.height_estimator.compute_vanishing_points(image, clip_factor=6, reestimate=False)[source]
Rectified image with vanishing point computed using ransac.
- Parameters:
image (ndarray) – Image which has to be rectified.
clip_factor (float, optional) – Proportion of image in multiples of image size to be retained if gone out of bounds after homography.
reestimate (bool) – If ransac results are to be reestimated using least squares with inlers. Turn this off if getting bad results.
- Returns:
warped_img – Rectified image.
- Return type:
ndarray
Module contents
- class improutils.perspective.HeightEstimator(ref_measurements, vl, vz)[source]
Bases:
objectEstimate real world object height based on two points (top and bottom) measured on image plane.
- calc_height(top_point, bottom_point)[source]
Calculate real-world height from image-plane measurements.
Given the top and bottom points of an object in the image plane, this function estimates the real-world height of the object.
- Parameters:
top_point (ndarray) – Top point of the object in the reference direction, in inhomogeneous format.
bottom_point (ndarray) – Ground plane point of the object in inhomogeneous format.
- Returns:
Real-world height of the object.
- Return type:
float
- improutils.perspective.compute_vanishing_points(image, clip_factor=6, reestimate=False)[source]
Rectified image with vanishing point computed using ransac.
- Parameters:
image (ndarray) – Image which has to be rectified.
clip_factor (float, optional) – Proportion of image in multiples of image size to be retained if gone out of bounds after homography.
reestimate (bool) – If ransac results are to be reestimated using least squares with inlers. Turn this off if getting bad results.
- Returns:
warped_img – Rectified image.
- Return type:
ndarray
- improutils.perspective.convert_pt_from_homogenous(pt)[source]
Convert input point in homogeneous coordinates to inhomogeneous.
- Parameters:
pt (ndarray) – Input point in homogeneous coordinates.
- Returns:
_ – Input point in inhomogeneous coordinates.
- Return type:
tuple
- improutils.perspective.convert_pt_to_homogenous(pt)[source]
Convert the input point from inhomogeneous coordinates to homogeneous ones.
- Parameters:
pt (ndarray) – Input point in inhomogeneous coordinates.
- Returns:
_ – Input point in homogeneous coordinates.
- Return type:
ndarray
- improutils.perspective.convert_pts_from_homogenous(pts)[source]
Convert input points in homogeneous coordinates to inhomogeneous.
- Parameters:
pts (array_like, shape (n_points, n_dims + 1) in homogeneous coordinates.) – Input points in homogeneous coordinates.
- Returns:
inhomogeneous_pts – Points in inhomogeneous coordinates.
- Return type:
ndarray, shape (n_points, n_dims)
- improutils.perspective.convert_pts_to_homogenous(pts)[source]
Convert input points from inhomogeneous to homogeneous coordinates.
- Parameters:
pts (array_like, shape (n_points, n_dims)) – Inhomogeneous input points.
- Returns:
homogeneous_pts – Points in homogeneous coordinates, with a 1 appended as the last component.
- Return type:
ndarray, shape (n_points, n_dims + 1)