網(wǎng)站首頁 編程語言 正文
OpenCV的imread不能讀取中文路徑問題
import numpy as np
import cv2
cv_img = cv2.imdecode(np.fromfile(jpg_path, dtype=np.uint8), -1) # 讀取8位圖像
OpenCV imread()函數(shù) (從文件加載圖像)
def imread(filename, flags=None): # real signature unknown; restored from __doc__
"""
imread(filename[, flags]) -> retval
. @brief Loads an image from a file. 從文件加載圖像。
.
. @anchor imread
.
. The function imread loads an image from the specified file and returns it. If the image cannot be
. read (because of missing file, improper permissions, unsupported or invalid format), the function
. returns an empty matrix ( Mat::data==NULL ).
該函數(shù)imread從指定的文件加載圖像并返回它。
如果無法讀取圖像(由于缺少文件,權(quán)限不正確,格式不受支持或格式無效),
該函數(shù)將返回一個空矩陣(Mat :: data == NULL)。
.
. Currently, the following file formats are supported: 當(dāng)前,支持以下文件格式:
.
. - Windows bitmaps - \*.bmp, \*.dib (always supported)
. - JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section)
. - JPEG 2000 files - \*.jp2 (see the *Note* section)
. - Portable Network Graphics - \*.png (see the *Note* section)
. - WebP - \*.webp (see the *Note* section)
. - Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported)
. - PFM files - \*.pfm (see the *Note* section)
. - Sun rasters - \*.sr, \*.ras (always supported)
. - TIFF files - \*.tiff, \*.tif (see the *Note* section)
. - OpenEXR Image files - \*.exr (see the *Note* section)
. - Radiance HDR - \*.hdr, \*.pic (always supported)
. - Raster and Vector geospatial data supported by GDAL (see the *Note* section)
.
. @note
. - The function determines the type of an image by the content, not by the file extension.
該功能通過內(nèi)容而不是文件擴(kuò)展名確定圖像的類型
. - In the case of color images, the decoded images will have the channels stored in **B G R** order.
對于彩色圖像,解碼后的圖像將具有以** B G R **順序存儲的通道。
. - When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
. Results may differ to the output of cvtColor()
使用IMREAD_GRAYSCALE時,將使用編解碼器的內(nèi)部灰度轉(zhuǎn)換(如果有)。 結(jié)果可能與cvtColor()的輸出不同
. - On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
. libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
. and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
. that currently these native image loaders give images with different pixel values because of
. the color management embedded into MacOSX.
在Microsoft Windows \ * OS和MacOSX \ *上,
默認(rèn)使用OpenCV映像附帶的編解碼器(libjpeg,libpng,libtiff和libjasper)。
因此,OpenCV始終可以讀取JPEG,PNG和TIFF。
在MacOSX上,還可以選擇使用本機(jī)MacOSX圖像讀取器。
但是請注意,由于MacOSX中嵌入了色彩管理,當(dāng)前這些本機(jī)圖像加載器會為圖像提供不同的像素值。
. - On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for
. codecs supplied with an OS image. Install the relevant packages (do not forget the development
. files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn
. on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
在Linux \ *,BSD版本和其他類似Unix的開源操作系統(tǒng)上,OpenCV會尋找OS映像隨附的編解碼器。
安裝相關(guān)的軟件包(不要忘記在Debian \ *和Ubuntu \ *中忘記開發(fā)文件,
例如“ libjpeg-dev”)以獲得編碼解碼器支持或在CMake中打開OPENCV_BUILD_3RDPARTY_LIBS標(biāo)志。
. - In the case you set *WITH_GDAL* flag to true in CMake and @ref IMREAD_LOAD_GDAL to load the image,
. then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting
. the following formats: [Raster](http://www.gdal.org/formats_list.html),
. [Vector](http://www.gdal.org/ogr_formats.html).
如果您在CMake中將* WITH_GDAL *標(biāo)志設(shè)置為true并使用@ref IMREAD_LOAD_GDAL加載圖像,則將使用[GDAL](http://www.gdal.org)驅(qū)動程序?qū)D像進(jìn)行解碼,以支持 以下格式:[Raster](http://www.gdal.org/formats_list.html)、[Vector](http://www.gdal.org/ogr_formats.html)。
. - If EXIF information are embedded in the image file, the EXIF orientation will be taken into account
. and thus the image will be rotated accordingly except if the flag @ref IMREAD_IGNORE_ORIENTATION is passed.
如果將EXIF信息嵌入到圖像文件中,則將考慮EXIF方向,
因此,除非傳遞了@ref IMREAD_IGNORE_ORIENTATION標(biāo)志,否則圖像將相應(yīng)旋轉(zhuǎn)。
. - Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image.
使用IMREAD_UNCHANGED標(biāo)志保留PFM圖像中的浮點值。
. - By default number of pixels must be less than 2^30. Limit can be set using system
. variable OPENCV_IO_MAX_IMAGE_PIXELS
默認(rèn)情況下,像素數(shù)必須小于2 ^ 30。 可以使用系統(tǒng)變量OPENCV_IO_MAX_IMAGE_PIXELS設(shè)置限制
.
. @param filename Name of file to be loaded. 要加載的文件名。
. @param flags Flag that can take values of cv::ImreadModes 可以采用cv :: ImreadModes值的標(biāo)志
"""
pass
原文鏈接:https://blog.csdn.net/qq_43650934/article/details/121056571
相關(guān)推薦
- 2022-08-17 R語言UpSet包實現(xiàn)集合可視化示例詳解_R語言
- 2022-08-18 Docker搭建私有GitLab服務(wù)的方法_docker
- 2022-05-05 Nginx配置ssl實現(xiàn)https的全過程記錄_nginx
- 2022-10-03 C++內(nèi)存泄漏的檢測與實現(xiàn)詳細(xì)流程_C 語言
- 2022-12-27 python中內(nèi)置庫csv的使用及說明_python
- 2023-03-03 PostgreSQL實時查看數(shù)據(jù)庫實例正在執(zhí)行的SQL語句實例詳解_PostgreSQL
- 2023-07-10 如何用Nacos完成配置管理
- 2023-11-20 python設(shè)置matplotlib.plot的坐標(biāo)刻度和坐標(biāo)范圍
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支