python-3.x - 使用 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
解决方案
我有同样的问题。使用较新的 OpenCV 版本,您必须通过fast = cv2.FastFeatureDetector_create()
. 请注意,由于其他 API 更改,您可能需要调整其余代码。
推荐阅读
- html - 通过 XSLT 漂亮地打印 HTML 而不引入大量空白
- ruby - 使用 Ruby 检查用户名是否存在于 sqlite3 数据库中
- r - 用百分比绘制部分聚合数据(点图或散点图)
- python - 将 CNN Pytorch 中的预训练权重传递给 Tensorflow 中的 CNN
- python - 如何创建一个机器人在 python 中为我玩游戏?
- python - AttributeError:'str'对象没有属性'seek'与python
- c# - SSRS Reportviewer 导出 Excel 无效文件
- jquery - 如何在单击按钮时使用 jquery 将输入字段的值设置为会话变量的值
- sql - Group By 的基本 SQL 问题(在 Netezza 中)
- r - 使用自己的 crs 进行投影时,projectRaster 会产生不同的输出