OpenCV image quality

After entering the Raspberry Pi 5 desktop, open a terminal and run the following command to start the container corresponding to Dofbot:

Access Jupyter Lab within Docker:

Code path:/root/Dofbot/4.opencv/1.OpenCV_basic/03_quality_pic.ipynb

  1. Compression method.

cv2.imwrite('yahboomTest.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 50])

cv2.CV_IMWRITE_JPEG_QUALITY: Set the image quality of the image format to .jpeg or .jpg, the value is 0---100 (the larger the value, the higher the quality), the default is 95

cv2.CV_IMWRITE_WEBP_QUALITY: Set the image format to .webp format image quality, the value is 0--100

cv2.CV_IMWRITE_PNG_COMPRESSION: Set the compression ratio of .png format, the value is 0--9 (the larger the value, the greater the compression ratio), the default is 3

The main code is as follows:

When the code block runs to the end, you can see the comparison of the two photos.