Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

orb detect crashes when try to detect

I am trying to create a basic image detector with open cv. I am using ORB, I try to open an image and then I try to detect keypoints in the image. Here is my code

import cv2
from cv2 import ORB

image1 = cv2.imread("original.jpg", cv2.IMREAD_GRAYSCALE)

orb = ORB()

# find the keypoints with ORB
kp = orb.detect(image1, None)

However when I run my code the program crashes with the following error

Process finished with exit code -1073741819 (0xC0000005)

I search for this error and I found out that this is a memory access violation but I dont know where there it could be a violation?

like image 684
Yedidya kfir Avatar asked Mar 01 '20 17:03

Yedidya kfir


1 Answers

I got the same error. After some searching I got that ORB_create() instead of ORB() fixes it.

Sources:

matching error in ORB with opencv 3

outImage error fix,

https://github.com/opencv/opencv/issues/6487

Code:

import numpy as np
import cv2
from matplotlib import pyplot as plt

img = cv2.imread('extra/sample.jpg',0)

## ERROR
#orb = cv2.ORB()

## FIX
orb = cv2.ORB_create()

# find the keypoints with ORB
kp = orb.detect(img,None)


# compute the descriptors with ORB
kp, des = orb.compute(img, kp)

## ERROR
#img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)


## Use This or the one below, One at a time
#img2 = cv2.drawKeypoints(img, kp, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

img2 = cv2.drawKeypoints(img, kp, outImage = None, color=(255,0,0))

plt.imshow(img2),plt.show()
like image 129
B200011011 Avatar answered Nov 16 '22 09:11

B200011011