Traceback (most recent call last):

文章讲述了在使用OpenCV集成Mediapipe库进行姿态检测时遇到的TypeError,原因是Mediapipe更新后新增了参数`enable_segmentation`。通过在初始化Pose对象时添加`enable_segmentation=False`解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

相信许多小伙伴和我一样,刚接触OpenCV,遇到了如下问题,具体代码如下:

Traceback (most recent call last):
  File "D:\Light\pycharm\code\pose gesture\PoseModule.py", line 74, in <module>
    main()
  File "D:\Light\pycharm\code\pose gesture\PoseModule.py", line 53, in main
    detector = poseDetector()
  File "D:\Light\pycharm\code\pose gesture\PoseModule.py", line 22, in __init__
    self.pose = self.mpPose.Pose(self.mode, self.upBody, self.smooth,
  File "D:\Light\pycharm\python\code\lib\site-packages\mediapipe\python\solutions\pose.py", line 146, in __init__
    super().__init__(
  File "D:\Light\pycharm\python\code\lib\site-packages\mediapipe\python\solution_base.py", line 289, in __init__
    self._input_side_packets = {
  File "D:\Light\pycharm\python\code\lib\site-packages\mediapipe\python\solution_base.py", line 290, in <dictcomp>
    name: self._make_packet(self._side_input_type_info[name], data)
  File "D:\Light\pycharm\python\code\lib\site-packages\mediapipe\python\solution_base.py", line 592, in _make_packet
    return getattr(packet_creator, 'create_' + packet_data_type.value)(data)
TypeError: create_bool(): incompatible function arguments. The following argument types are supported:
    1. (arg0: bool) -> mediapipe.python._framework_bindings.packet.Packet

Invoked with: 0.5

这个是由于版本更新了,新增了个参数:enable_segmentation=False,具体添加位置如下:

self.pose = self.mpPose.Pose(self.mode, self.upBody, self.smooth,
                             self.detectionCon, self.trackCon)

改为:

self.pose = self.mpPose.Pose(self.mode, self.upBody, self.smooth,False, 
                             self.detectionCon, self.trackCon)

大功告成!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值