首页 > 解决方案 > 使用 cv2.FastFeatureDetector() 时 Anaconda 内核和 Google Colab 崩溃

问题描述

我正在尝试使用 cv2.FastFeatureDetector() 方法,每次我运行此代码以提取功能时,我的内核在 Google Collab 和 Anaconda 中都因某种原因崩溃。最初我认为这是我的系统的内存管理问题,但同样的事情正在 Colab 中发生。

    import cv2
    import numpy as np
    image=cv2.imread('tree.jpg',0)
    fast=cv2.FastFeatureDetector()
    keypoints=fast.detect(image,None)
    #After running this code my kernel crashes

由于内核崩溃,没有错误消息。图像尺寸相当小,计算成本也不高。这是图片: https ://www.setaswall.com/wp-content/uploads/2017/06/Sun-Tree-Branches-1920-x-1080.jpg

标签: python-3.xcv2

解决方案


我有同样的问题。使用较新的 OpenCV 版本,您必须通过fast = cv2.FastFeatureDetector_create(). 请注意,由于其他 API 更改,您可能需要调整其余代码。


推荐阅读