img = cv2.imread('yahboom.jpg', 0) The first parameter is the path of the image, and the second parameter is how to read the image.
cv2.IMREAD_UNCHANGED: Keep the original format unchanged, -1;
cv2.IMREAD_GRAYSCALE: Read the image in grayscale mode, which can be represented by 0;
cv2.IMREAD_COLOR: Read a color image, which can be represented by 1; the default value
cv2.IMREAD_UNCHANGED: Read an image and include its alpha channel, which can be represented by 2.
cv.imshow('frame', frame): Open a window named frame and display frame data (image/video data)
Parameter meaning:
The first parameter indicates the name of the window to be opened
The second parameter indicates the image to be displayed
Code path:
/home/pi/project_demo/06.Open_source_cv_fundamentals_course/A.introduction/Introduction_to_OpenCV/02_OpenCV_Img_Read_Display.ipynb
ximport cv2
img = cv2.imread('yahboom.jpg', 1)
#cv2.imshow('image', img) #This line can only be executed in the command line py file, and a video window will pop up
#cv2.waitKey (0) ``` ```python #bgr8 to jpeg format import enum import cv2 def bgr8_to_jpeg(value, quality=75): return bytes(cv2.imencode('.jpg', value)[1]) ``` ```python import ipywidgets.widgets as widgets image_widget = widgets.Image(format='jpg', width=800, height =800) display(image_widget) image_widget.value = bgr8_to_jpeg(img) ```` 