gpt4 book ai didi

Python - 使用 Opencv : the kernel died :Segmentation fault (core dumped) how can we prevent that? 计算 SIFT 特征

转载 作者:行者123 更新时间:2023-12-02 17:39:59 26 4
gpt4 key购买 nike

我正在尝试执行一个程序来检测 python 中图像的 SIFT 特征,但我经常收到一条错误消息:“段错误(核心转储)”。我的一段代码:

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import cv2

img1 = plt.imread("test1.png").astype('uint8')
img2 = plt.imread("test2.png").astype('uint8')
sift = cv2.SIFT()

###find the keypoints and descriptors with SIFT
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)

###FLANN parameters
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)

###match of the points
flann = cv2.FlannBasedMatcher(index_params,search_params)
matches = flann.knnMatch(des1,des2,k=2)

我在 python 中尝试过,有时会收到以下错误消息:段错误(核心转储)。因此,我想阻止它或使用更稳定的方法。我正在查看 Skimage 以找到等效的

最佳答案

发生此错误是因为您使用了过多的设备内存 (RAM)。现在几乎没有可行的解决方案-

  • 升级设备。升级您的设备或使用 AWS(也提供免费套餐)
  • 改进代码。


  • 注意 - SIFT 计算量很大,找出兴趣点会占用大量内存,因此您最好一次尝试一张图像,或者缩小图像然后尝试

    关于Python - 使用 Opencv : the kernel died :Segmentation fault (core dumped) how can we prevent that? 计算 SIFT 特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46398605/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com