from cv2\__init__.py
def imencode(ext, img, params=None): # real signature unknown; restored from __doc__
"""
imencode(ext, img[, params]) -> retval, buf
. @brief Encodes an image into a memory buffer.
将图像编码到内存缓冲区中。
.
. The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
. result. See cv::imwrite for the list of supported formats and flags description.
imencode函数压缩图像并将其存储在已调整大小以适合结果的内存缓冲区中。
有关支持的格式和标志说明的列表,请参见cv :: imwrite。
.
. @param ext File extension that defines the output format.
定义输出格式的文件扩展名。
. @param img Image to be written.
要写入的图像。
. @param buf Output buffer resized to fit the compressed image.
调整输出缓冲区的大小以适合压缩图像。
. @param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
特定于格式的参数。 参见cv :: imwrite和cv :: ImwriteFlags。
"""
pass
发现被压缩后的图片数据量是原来的23分之一了,难道不会造成数据、像素值丢失?
它压缩的原理是什么?
应该是用到了某种算法,将有联系的数据形成一块打包,从而减少数据量,底层暂时不用管它,知道怎么用imencode()和imdecode()就行
参考文章1:利用Opencv提供的imencode和imdecode进行图像视频传输(发送端支持Linux和Windows双系统)
来源:CSDN
作者:Dontla
链接:https://blog.csdn.net/Dontla/article/details/103776982