cv2.rectangle--TypeError: an integer is required (got type tuple)
在图片上框出人脸,出现了下面的错误:
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
TypeError: an integer is required (got type tuple)
以前没有遇到过,在stackoverflow上找到了解释,是PIL.Image读出来的图像不能使用cv2的原因。
在此留下翻译的解释:
cv2模块用来处理numpy arrays的图像,而不是PIL.Image的实例。因为cv2.rectangle和Image类型都是完全用编译代码实现的,所以回溯对于理解出了什么问题并没有那么大帮助。在引擎盖下,本机cv2.rectangle()代码试图访问图像对象上需要整数,但cv2.rectangle()传入元组的内容,因为它希望与numpy arrays交互。
解决方法:
1)img = cv2.imread(imgpath)
2)转换PIL.Image为numpy.arrays
nparray = np.array(img)
另附:numpy array 转化为PIL.Image
img = Image.fromarray(nparray)
cv2.rectangle--TypeError: an integer is required (got type tuple)相关推荐
- python an integer is required_Python TypeError: an integer is required (got type tuple)
Python TypeError: an integer is required (got type tuple) 关注:256 答案:2 mip版 解决时间 2021-01-12 12:36 提 ...
- pyinstaller打包任何py文件TypeError: an integer is required (got type bytes)
pyinstaller打包任何py文件TypeError: an integer is required (got type bytes) 目录 pyinstaller打包任何py文件TypeErro ...
- 读取文件:TypeError: an integer is required (got type str)
读取文件的时候报错: Traceback (most recent call last): File "D:\Python35\test\csdn.py", line 46, in ...
- python:使用PyInstaller打包成exe文件,以及TypeError: an integer is required (got type bytes)异常解决
本文主要介绍安装pyinstaller教程与pyinstaller打包出现 TypeError: an integer is required (got type bytes)异常问题解决办法: 1. ...
- Python 使用pyinstaller打包exe文件报错: TypeError: an integer is required (got type bytes) 的解决方法
python打包成exe文件首先需要安装pyinstaller库,再进入到目标文件目录,输入命令行打包py文件,但出现报错:TypeError: an integer is required (got ...
- TypeError: an integer is required (got type bytes)
win10下spark2.4不能与python3.8及以上版本兼容,替换3.8为3.7完美解决
- an integer is required (got type tuple) 报错解决
今天在调用Opencv的一个函数的时候出现如下报错: 原代码为: blur2 = cv2.boxFilter(img1, (3, 3), normalize=True) 这是在调用一个opencv 图 ...
- python报错 TypeError: an integer is required
问题描述: 在本地使用socket向NetAssist传送数据的时候,执行python文件后发现报出python 报错TypeError: an integer is required错误 代码: 1 ...
- python opencv cv2.rectangle 参数含义
因为做程序图像剪切一直不太明白是怎么切片的,这里就用 cv2.rectangle 这个函数来看一下 opencv 是怎么计量图像的坐标轴的. cv2.rectangle 这个函数的作用是在图像上绘制一 ...
- cv2.rectangle()画出矩形的用法
cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 2) 功能:画出矩行框 参数:img:原图 (x,y):矩阵的左上点坐标 (x+w,y+h):矩阵的右下 ...
最新文章
- ThinkPHP入门(二)
- Android多线程分析之一:使用Thread异步下载图像
- ORA-01123:无法启动联机备份;未启用介质恢复(错误分析)
- yii mysql 缓存_yii2优化 - 开启 Schema 缓存
- 练习算法之前必须了解的多件事
- Docker学习总结(20)——Docker 容器实践精华问答集锦
- libsvm-3.1-[FarutoUltimate3.1Mcode]——辅助函数简介(修改)
- 单线程实现同时监听多个端口(windows平台c++代码)
- 能力风暴机器人编程 | 详解使用能力风暴机器人以及配套VJC 4.3 CH做一个物联网——智慧物流项目
- C根据输入的城市坐标求各城市间的距离
- 基于Matlab高斯光束菲涅耳衍射的模拟
- 18年怎么将win7升级到win10教程
- 页面置换算法java_页面置换算法之Clock算法
- 2022年TikTok的9个变现模式
- 【不收藏一定后悔】超智能三子棋——和电脑比一把
- Ranger功能验证
- 告别光棍节——见习情圣(恋爱培训导师)
- mybatisplus 自增主键失效,自增主键超大
- 龙岭迷窟真的这么好看?今天我们就用 Java 爬取豆瓣数据好好分析一下!
- Android反编译修改apk并重新打包
热门文章
- 云免流usb共享电脑_手机怎么使用USB数据线共享PC网络
- Bitmap 图片缩放
- c语言用控制台写——俄罗斯方块
- python实现word自动化操作
- 月薪2300深圳流水线女工,逆袭为年薪80万谷歌工程师,又因疫情失业:我绝不轻易认输...
- 英语的计算机软件如何拼写,软的英文单词
- 84 岁 iOS 女程序员,不得不服!
- flea-common使用之本地国际化实现
- 外星人笔记本计算机在哪里,笔记本电脑没声音,教您外星人笔记本没声音如何解决...
- Android 高通Camx架构学习 - 第1章