treadscan.extractor
TireModel
- class treadscan.extractor.TireModel(image_size: (<class 'int'>, <class 'int'>))
Model representing a tire. Consists of two ellipses - outer and inner.
- Attributes
- image_size(int, int)
Height and width of image in which the TireModel is placed (required for perspective transformations).
- main_ellipsetreadscan.Ellipse
Ellipse defined by the wheel rim.
- outer_ellipsetreadscan.Ellipse
Ellipse defined by the outer tire perimeter.
- inner_ellipsetreadscan.Ellipse
Ellipse defined by the inner tire perimeter.
- beta_anglefloat
Angle of tire (in degrees) relative to camera’s point of view.
- tire_sidewallint
Height of tire sidewall (in pixels).
- tire_widthint
Tire width (in pixels).
Methods
from_keypoints(t: (int, int), b: (int, int), r: (int, int), s: (int, int), w: (int, int))
Initializes TireModel using 5 keypoints.
from_main_ellipse(main_ellipse: treadscan.Ellipse, tire_sidewall: int, tire_width: int, left_oriented: bool)
Initializes TireModel using main ellipse (which is defined by the wheel rim).
draw(image: numpy.ndarray, color: Union[int, tuple], thickness: int, lineType: int)
Draws TireModel on image.
bounding_box()
Returns top left and bottom right points of TireModel’s bounding box.
unwrap(image: numpy.ndarray, start: int, end: int):
Unwraps tread into a rectangle from an image.
- bounding_box() -> ((<class 'int'>, <class 'int'>), (<class 'int'>, <class 'int'>))
Create bounding box of tire model.
- Returns
- ((int, int), (int, int))
Top left and bottom right points.
- Raises
- RuntimeError
If TireModel is not initialized.
- draw(image: ndarray, color: Union[int, tuple], thickness: int = 1, lineType: int = 8) ndarray
Draws TireModel on image.
- Parameters
- image: numpy.ndarray
Image on which to draw on.
- color: Union[int, tuple]
Color of resulting drawing (grayscale color or BGR, RGB… depending on image color scheme)
- thickness: int
Thickness of the drawn TireModel.
- lineType: int
Type of line (cv2.FILLED, cv2.LINE_4, cv2.LINE8 or cv2.LINE_AA).
- Returns
- numpy.ndarray
Original image with drawn TireModel.
- Raises
- RuntimeError
When TireModel is not initialized.
- from_keypoints(t: (<class 'int'>, <class 'int'>), b: (<class 'int'>, <class 'int'>), r: (<class 'int'>, <class 'int'>), s: (<class 'int'>, <class 'int'>), w: (<class 'int'>, <class 'int'>))
Initializes TireModel using 5 keypoints.
- Parameters
- t(int, int)
Top of rim.
- b(int, int)
Bottom of rim.
- r(int, int)
Third point on the rim perimeter.
- s(int, int)
Point above t, where tire sidewall ends.
- w(int, int)
Point on the inner side of tire.
- from_main_ellipse(main_ellipse: Ellipse, tire_sidewall: int = 0, tire_width: int = 0, left_oriented: bool = False)
Initializes TireModel using main ellipse (which is defined by the wheel rim).
- Parameters
- main_ellipsetreadscan.Ellipse
Ellipse defined by wheel rim.
- tire_sidewallint
Height of tire sidewall in pixels. If 0, then the sidewall height is approximated as 1/5 of the wheel diameter.
- tire_widthint
Width of tire in pixels. If 0, then the tire width is approximated as 1/2 of the wheel diameter.
- left_orientedbool
Defines if the inner side is on the left rather than the right. (TireModel is defined by outer and inner ellipses, inner ellipse is on the ‘inside’ of the wheel well, while the outer ellipse is visible.)
- unwrap(image: ndarray, start: int = -10, end: int = 80) ndarray
Unwrap tire tread as a rectangle.
- Parameters
- imagenumpy.ndarray
Image from which to unwrap the tread from.
- startint
Beginning (top) of tire tread represented in degrees.
- endint
End (bottom) of tire tread represented in degrees.
- Returns
- numpy.ndarray
Image containing unwrapped tread.
- Raises
- RuntimeError
When TireModel is not initialized or has 0 width (or height).