I am getting Segmentation fault (core dumped)

asked 2020-02-19 05:33:18 -0500

updated 2020-02-19 06:38:07 -0500

LBerger gravatar image

I am running ubuntu, python and trying to use AKAZE features on my camera.

here is my code


from __future__ import print_function
import roslib
import sys
import rospy
import cv2
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import matplotlib.pyplot as plt
import numpy as np

class image_converter:

  def __init__(self):

    #self.image_pub = rospy.Publisher("pylon_camera_node/image_raw",Image)
    self.bridge = CvBridge()
    self.image_sub = rospy.Subscriber("pylon_camera_node/image_raw", Image, self.callback)

  def callback(self,data):
      cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
    except CvBridgeError as e:

    #Detector >>> AKAZE
    detector = cv2.AKAZE_create()

    #keypoints and descriptor
    (kps, descs) = detector.detectAndCompute(cv_image, 0)

    #Draw keypoints and show image(stream)
    cv2.drawKeypoints(cv_image, kps, cv_image, (0, 1000, 0))
    cv2.imshow("Image window", cv_image)

def main(args):
  ic = image_converter()
  rospy.init_node('image_converter', anonymous = True)
  except KeyboardInterrupt:
    print("Shutting down")
if __name__ == '__main__':
edit retag flag offensive close merge delete


Well, now you need to find out where that happens and how the variables look at that point. That's just elementary debugging

mvuori gravatar imagemvuori ( 2020-02-19 07:05:55 -0500 )edit

@muvori , The script is working, but after a while the video stops and it gives me this error, not sure if it is still can be debugged from the script?

eslamelgourany gravatar imageeslamelgourany ( 2020-02-19 08:08:14 -0500 )edit

cv2.release() -- seriously ? where did you find that ?

(kps, descs) = detector.detectAndCompute(cv_image, 0) -- 0 is for sure wrong as a 'mask', try Null instead

please try without ros first, we cannot help you with that, anyway.

berak gravatar imageberak ( 2020-02-19 08:10:47 -0500 )edit