解决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)
相关推荐
ch6235 小时前
《AI 辅助编程实战:从零跑通一个 Excel 报表生成脚本的踩坑与复盘》
人工智能·python
import_random5 小时前
[python]conda和pip(区别和联系2)
python
Aurorar0rua6 小时前
CS50 x 2024 Notes Python - 01
开发语言·python·学习方法
用户6602676118796 小时前
备注接口返回成功,数据库却没变:怎样限定一次修复的范围?
python
Dumbness6 小时前
用 Python + UI Automation 读写微信 PC 版:一个群消息自动回复程序的实现与踩坑
python
艺杯羹6 小时前
Windows跨平台编码地雷全解:从GBK静默崩溃到内核级原子写入防御
人工智能·python·桌面客户端
用户8356290780516 小时前
使用 Python 在 Excel 中识别并高亮重复数据与唯一数据
后端·python
CCblandy6 小时前
Agent 工具调用怎么编排?本机实测:并行只到 2.63 倍,慢的先发省 30ms,CPU 活加 worker 无效
人工智能·后端·python·性能优化
用户8356290780517 小时前
使用 Python 在 Excel 中查找、替换数据并高亮显示
后端·python
GPU实战笔记7 小时前
PyCharm 接云 GPU:远端项目连接与远程解释器别混为一谈
python·pycharm·ssh·远程开发·云gpu