解决cv2. imread、imwrite无法读取或保存中文路径图片问题

cv2.imwrite(filename, img)

修改为

cv2.imencode('.jpg', img)[1].tofile(filename)

cv2.imread(filename, cv2.IMREAD_GRAYSCALE)

修改为

cv2.imdecode(np.fromfile(filename, dtype=np.uint8), cv2.IMREAD_GRAYSCALE)

复制代码
cv2.imwrite(filename, img)
修改为
cv2.imencode('.jpg', img)[1].tofile(filename)
 
cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
修改为
cv2.imdecode(np.fromfile(filename, dtype=np.uint8), cv2.IMREAD_GRAYSCALE)
相关推荐
Dfreedom.15 分钟前
图像处理中的对比度增强与锐化
图像处理·人工智能·opencv·锐化·对比度增强
Olamyh21 分钟前
【 超越 ReAct:手搓 Plan-and-Execute (Planner) Agent】
python·ai
deepxuan23 分钟前
Day7--python
开发语言·python
曲幽32 分钟前
FastAPI不止于API:手把手教你用Jinja2打造动态Web页面
python·fastapi·backend·jinja2·full stack·template engine·web development
禹凕38 分钟前
Python编程——进阶知识(多线程)
开发语言·爬虫·python
Ulyanov41 分钟前
基于Pymunk物理引擎的2D坦克对战游戏开发
python·游戏·pygame·pymunk
铉铉这波能秀41 分钟前
LeetCode Hot100数据结构背景知识之字典(Dictionary)Python2026新版
数据结构·python·算法·leetcode·字典·dictionary
Ryan老房1 小时前
智能家居AI-家庭场景物体识别标注实战
人工智能·yolo·目标检测·计算机视觉·ai·智能家居
程序媛徐师姐1 小时前
Python基于爬虫的网络小说数据分析系统【附源码、文档说明】
爬虫·python·python爬虫·网络小说数据分析系统·pytho网络小说数据分析系统·python爬虫网络小说·python爬虫的网络小说数据
清水白石0081 小时前
深入解析 LRU 缓存:从 `@lru_cache` 到手动实现的完整指南
java·python·spring·缓存