You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenCV Python调用createBinaryDescriptor报AttributeError问题求助

解决AttributeError: module 'cv2' has no attribute 'createBinaryDescriptor'问题

createBinaryDescriptor属于OpenCV的line_descriptor子模块,且该模块仅包含在opencv-contrib扩展包中,默认的opencv-python包不包含此功能。按以下步骤解决:

  • 安装/更新opencv-contrib-python
    打开终端执行:

    pip install --upgrade opencv-contrib-python
    

    注意:如果已安装opencv-python,需保证它和opencv-contrib-python版本完全一致,避免版本冲突导致的异常。

  • 正确调用函数
    代码中需通过line_descriptor子模块访问该函数,示例:

    import cv2
    # 直接通过子模块调用
    bd = cv2.line_descriptor.createBinaryDescriptor()
    
    # 或先导入子模块再调用
    from cv2 import line_descriptor
    bd = line_descriptor.createBinaryDescriptor()
    
  • 验证版本兼容性
    确认你的OpenCV版本为4.x及以上(与你参考的教程版本匹配),可通过以下代码查看:

    import cv2
    print(cv2.__version__)
    

内容的提问来源于stack exchange,提问作者Yuri Soeda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 10:17:06