相关疑难解决方法(0)

AttributeError:'module'对象没有属性'xfeatures2d'[Python/OpenCV 2.4]

这一行:

sift = cv2.xfeatures2d.SIFT_create()
Run Code Online (Sandbox Code Playgroud)

返回错误:

Traceback (most recent call last):
  File "C:/Python27/openCVskrypty/GUI/SOLUTION2.py", line 11, in <module>
    sift = cv2.xfeatures2d.SIFT_create()
AttributeError: 'module' object has no attribute 'xfeatures2d'
Run Code Online (Sandbox Code Playgroud)

我读了一些关于这个错误的内容,它出现在OpenCV 3.0版中.这很奇怪,因为我有2.4.11版本.

我检查dir(cv2),我没有xfeatures2d模块.有谁知道为什么?我可以单独下载吗?

感谢您帮忙解决这个问题.

python opencv

12
推荐指数
6
解决办法
5万
查看次数

错误: (-2:Unspecified error) 函数未实现。使用 Windows、GTK+ 2.x 或 Cocoa 支持重建库

我正在 jupyter notebook 上进行手语检测项目。在运行实时检测代码时,我遇到了如下所示的错误:

OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-1drr4hl0\opencv\modules\highgui\src\window.cpp:651: 错误: (-2:Unspecified错误)该功能未实现。使用 Windows、GTK+ 2.x 或 Cocoa 支持重建库。如果您使用的是 Ubuntu 或 Debian,请安装 libgtk2.0-dev 和 pkg-config,然后重新运行 cmake 或在函数 'cvShowImage' 中配置脚本

尽管尝试了我在网上找到的许多解决方案,但我仍然遇到相同的错误。

遇到错误的代码是:while True: ret, frame = cap.read() image_np = np.array(frame)

input_tensor = tf.convert_to_tensor(np.expand_dims(image_np, 0), dtype=tf.float32)
detections = detect_fn(input_tensor)

num_detections = int(detections.pop('num_detections'))
detections = {key: value[0, :num_detections].numpy()
              for key, value in detections.items()}
detections['num_detections'] = num_detections

# detection_classes should be ints.
detections['detection_classes'] = detections['detection_classes'].astype(np.int64)

label_id_offset = 1
image_np_with_detections = image_np.copy()

viz_utils.visualize_boxes_and_labels_on_image_array(
            image_np_with_detections,
            detections['detection_boxes'],
            detections['detection_classes']+label_id_offset,
            detections['detection_scores'],
            category_index,
            use_normalized_coordinates=True,
            max_boxes_to_draw=5,
            min_score_thresh=.5, …
Run Code Online (Sandbox Code Playgroud)

python opencv machine-learning computer-vision tensorflow

6
推荐指数
5
解决办法
6105
查看次数

ModuleNotFoundError:没有名为“ cv2”的模块

我已经为这个错误工作了很长时间了。我有Python 3.6和Python 2.7。我尝试分别在Python 2.7和Python 3.6中安装opencv 2和3。我知道我使用的python解释器,可以在需要时在它们之间互换。

当我运行Python解释器并编写import cv2它时,它确实将其导入。当我从命令提示符运行代码时,它说ModuleNotFoundError:没有名为'cv2'的模块。模块已安装。cv2.pyd文件在其中,C:\Python27\Lib\site-packages我附上了显示Python27中模块的屏幕截图

在此处输入图片说明

我已经习惯了pip install opencv-python。我已经从其他站点下载了该模块,并手动将其复制粘贴到正确的文件夹中。什么都没有,我现在严重缺乏想法。

编辑:我在Windows 10上通过anaconda安装了python 3.6,并且直接安装了python 2.7。两者都在路径中设置了变量

python opencv python-2.7 python-3.x cv2

5
推荐指数
2
解决办法
2万
查看次数