pythonopencvpattern-matchingsift

Python - computing SIFT freatures using Opencv: the kernel died :Segmentation fault (core dumped) how can we prevent that?


I m trying to execute a program to detect SIFT features of an image in python, but regulary i m receiving an error message : "Segmentation fault (core dumped)". My piece of code :

# -*- 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)

I tried it in python and sometimes i got this error message: Segmentation fault (core dumped). Thus i would like to prevent it or use a more stable approach. I m looking at Skimage to find an equivalent


Solution

  • This error occurs because you are using too much of your device's memory(RAM). Now there are few plausible solutions -


    Note - SIFT is computationally expensive and finding out interest points take a lot of memory, so you better try one image at a time,or maybe scale down image and then try