Python 对象检测opencv需要一个整数(Get类型元组)
当我运行代码以使用网络摄像头进行对象检测时,会收到以下错误消息:Python 对象检测opencv需要一个整数(Get类型元组),python,opencv,Python,Opencv,当我运行代码以使用网络摄像头进行对象检测时,会收到以下错误消息: frame = cv2.rectangle(open_cv_stream, t1, br, color, 5) TypeError:需要整数(获取类型元组) 有什么问题吗 在此追溯: Building net ... Source | Train? | Layer description | Output size -------+--------+------------------------
frame = cv2.rectangle(open_cv_stream, t1, br, color, 5)
TypeError:需要整数(获取类型元组)
有什么问题吗
在此追溯:
Building net ...
Source | Train? | Layer description | Output size
-------+--------+----------------------------------+---------------
WARNING:tensorflow:From C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
| | input | (?, 608, 608, 3)
Load | Yep! | conv 3x3p1_1 +bnorm leaky | (?, 608, 608, 32)
…
Load | Yep! | conv 1x1p0_1 linear | (?, 19, 19, 425)
-------+--------+----------------------------------+---------------
GPU mode with 1.0 usage
Finished in 28.833083629608154s
Traceback (most recent call last):
File "webcam.py", line 38, in <module>
frame = cv2.rectangle(open_cv_stream, t1, br, color, 5)
TypeError: an integer is required (got type tuple)
建筑网络。。。
来源|列车|层描述|输出大小
-------+--------+----------------------------------+---------------
警告:tensorflow:From C:\Anaconda3\envs\tensorflow\lib\site packages\tensorflow\python\framework\op_def_library.py:263:colocate_with(From tensorflow.python.framework.ops)已被弃用,并将在将来的版本中删除。
更新说明:
由placer自动处理Colocations。
||输入|(?,608,608,3)
装载|是的!|conv 3x3p1_1+b形式泄漏(?,608,608,32)
…
装载|是的!|conv 1x1p0_1线性(?,19,19,425)
-------+--------+----------------------------------+---------------
使用1.0的GPU模式
完成时间为28.833083629608154秒
回溯(最近一次呼叫最后一次):
文件“webcam.py”,第38行,在
frame=cv2.矩形(开放式循环流,t1,br,彩色,5)
TypeError:需要整数(获取类型元组)
我注意到您在br变量中漏掉了一个['y']
for color, result in zip(colors, results):
t1 = (result['topleft']['x'], result['topleft']['y'])
br = (result['bottomright']['x'], result['bottomright']['y'])
label = result['label']
confidence = result['confidence']
text = '{}: {:.0f}%'.format(label,confidence * 100)
frame = cv2.rectangle(frame, t1, br, color, 5)
frame = cv2.putText(frame, text, t1, cv2.FONT_ITALIC, 1, (0,0,0),2)
看看这样行不行 尝试发布完整的回溯,而不仅仅是错误行。知道错误发生的位置很有帮助。打印t1、br、颜色
for color, result in zip(colors, results):
t1 = (result['topleft']['x'], result['topleft']['y'])
br = (result['bottomright']['x'], result['bottomright']['y'])
label = result['label']
confidence = result['confidence']
text = '{}: {:.0f}%'.format(label,confidence * 100)
frame = cv2.rectangle(frame, t1, br, color, 5)
frame = cv2.putText(frame, text, t1, cv2.FONT_ITALIC, 1, (0,0,0),2)