cv2.CHAIN_APPROX_SIMPLE) ValueError: too many values to unpack (expected 2)
时间: 2023-08-28 16:21:01 浏览: 169
出现"ValueError: too many values to unpack (expected 2)"的错误是因为在执行cv2.findContours()函数时,返回的结果与期望的不一致。根据引用和引用的信息,可以看出这个函数应该返回两个值,即轮廓和层次结构。然而,在代码中尝试解包结果时,期望得到2个值,但实际上返回的值数量超过了预期。
为了解决这个问题,可以根据引用的建议进行修改。在调用cv2.findContours()函数时,将其返回值解包为3个变量,即binary、contours和hierarchy。这样就能够正确地获得所需的值,避免出现"ValueError: too many values to unpack (expected 2)"的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ValueError: too many values to unpack (expected 2)](https://blog.csdn.net/qq_41701723/article/details/129177910)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [opencv : ValueError: too many values to unpack (expected 2)](https://blog.csdn.net/u011304078/article/details/100134073)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文