imread
-
Description: Reads an image using different methods based on the image format. Supported formats are as follows:
.heic: Usesread_heic_to_numpyto read and converts toBGRformat..jpg: Usesjpgreadto read and converts toBGRformat.- Other formats: Uses
cv2.imreadto read and converts toBGRformat. - If
jpgreadreturnsNone,cv2.imreadwill be used as a fallback.
-
Parameters:
- path (
Union[str, Path]): The path to the image file. - color_base (
str): The color space of the image. If it is notBGR, the function will convert it using theimcvtcolorfunction. Default isBGR. - verbose (
bool): If set toTrue, a warning will be issued when the image read result isNone. Default isFalse.
- path (
-
Return value:
- np.ndarray: Returns the image as a NumPy ndarray if successful, otherwise returns
None.
- np.ndarray: Returns the image as a NumPy ndarray if successful, otherwise returns
-
Example:
import capybara as cb
img = cb.imread('lena.png')