Preprocessors¶
Photo by Alyson McPhee on Unsplash
Preprocessors take an initial image from a webcam or file, and transform it into a processable image, typically by resizing the image or converting the color space of the image to a proper format.
These preprocessors are derived from the BasePreprocessor class, which defines the methods that all preprocessors need to have.
Documented below are the main methods of preprocessor classes.
-
resize
(image, width, height)¶ Resize an image.
Parameters: - image (np.ndarray) – The image object to resize.
- width (int) – The width of the resulting image.
- height (int) – The height of the resulting image.
Returns: The resized image object.
Return type: np.ndarray
-
recolor
(image, colorspace)¶ Change the color space of an image using OpenCV’s color conversion methods.
Parameters: - image (np.ndarray) – Image to change color space of.
- colorspace (int) – Color space to change image to. Comes from cv2.COLOR_* enum.
Returns: The recolored image object.
Return type: np.ndarray