8

i use opencv 3.0.0 and python 2.7.5_x32

This is my code (ORB_feature_detection):

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

img1 = cv2.imread('C:\\Python27\\madar1.jpg',0)          # queryImage
img2 = cv2.imread('C:\\Python27\\madar2.jpg',0) # trainImage

# Initiate SIFT detector
orb = cv2.ORB_create()

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

# create BFMatcher object

bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

# Match descriptors.
matches = bf.match(des1,des2)

# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)

# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2)

plt.imshow(img3),plt.show()

cv2.waitKey()
cv2.destroyAllWindows()

and this is the error message, the error message is on the kp1, des1 = orb.detectAndCompute(img1,None) part, i did work on opencv 2.4.11 and it doesn't work on opencv 3.0.0 !

    Traceback (most recent call last):
  File "C:\Python27\orb_matcher.py", line 12, in <module>
   kp1, des1 = orb.detectAndCompute(img1,None)
error: ..\..\..\modules\python\src2\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate

please help me, what should i do to make this work?

3
  • Same problem still occurs on Opencv 3.1, Python 2.7 x64 running Windows, worked fine back on Opencv 2.4 though. Therefore, the accepted solution as suggested here doesn't work, at least not on Windows Commented Jan 11, 2016 at 22:42
  • Uncommenting the assertion and recompiling as suggested here does the job though; so, who's gonna file the issue? :D Commented Jan 11, 2016 at 22:54
  • It would help to include the original images so that we can reproduce whether the issue is still there. Commented May 6, 2016 at 19:56

2 Answers 2

5

You can try add this script after import cv2 and others cv2.ocl.setUseOpenCL(False) this solved my issue.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for this answer. Do you know why that line is necessary?
Because there are "a few problematic interactions between the python bindings and OpenCL" see more here: github.com/opencv/opencv/issues/6081
0

This is a known bug. You can find more information here https://github.com/opencv/opencv/issues/6081.

Today someone is fixing this issue: T-API python support implemented #6847.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.