python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)
生活随笔
收集整理的這篇文章主要介紹了
python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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.將圖像編碼到內(nèi)存緩沖區(qū)中。. . 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函數(shù)壓縮圖像并將其存儲(chǔ)在已調(diào)整大小以適合結(jié)果的內(nèi)存緩沖區(qū)中。 有關(guān)支持的格式和標(biāo)志說明的列表,請參見cv :: imwrite。. . @param ext File extension that defines the output format.定義輸出格式的文件擴(kuò)展名。. @param img Image to be written.要寫入的圖像。. @param buf Output buffer resized to fit the compressed image.調(diào)整輸出緩沖區(qū)的大小以適合壓縮圖像。. @param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.特定于格式的參數(shù)。 參見cv :: imwrite和cv :: ImwriteFlags。"""pass發(fā)現(xiàn)被壓縮后的圖片數(shù)據(jù)量是原來的23分之一了,難道不會(huì)造成數(shù)據(jù)、像素值丟失?
它壓縮的原理是什么?
應(yīng)該是用到了某種算法,將有聯(lián)系的數(shù)據(jù)形成一塊打包,從而減少數(shù)據(jù)量,底層暫時(shí)不用管它,知道怎么用imencode()和imdecode()就行
參考文章1:利用Opencv提供的imencode和imdecode進(jìn)行圖像視頻傳輸(發(fā)送端支持Linux和Windows雙系統(tǒng))
總結(jié)
以上是生活随笔為你收集整理的python cv2.imencode()(将图像编码到内存缓冲区中。)(图像压缩原理)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: \x49\x51\x5a\x56\x54
- 下一篇: numpy ndarray.tostri