須要引入頭文件: import cv2ide
參數說明: 函數
filename: 文件路徑,絕對路徑和相對路徑均可以。spa
首先定義路徑,而後直接調用函數cv2.imread()便可。3d
1 import cv2 2 3 4 def cv2_image(): 5 image_dir = 'D:/pytorch_code/pytorch_study/fusion_datasets/lytro-01-A.jpg' 6 image = cv2.imread(image_dir) 7 print("image_shape: ", image.shape) 8 print("image_dtype: ", image.dtype) 9 print("image_type: ", type(image)) 10 cv2.imshow('image', image) 11 cv2.waitKey(0) 12 13 14 if __name__ == "__main__": 15 cv2_image()