Regarding the error message "The data should normally be NULL"

asked 2015-11-21 16:30:06 -0600

soboh gravatar image

updated 2015-11-22 02:15:35 -0600

berak gravatar image

I have compiled OpenCV 3.0.0 for python on Windows.
When I tried to run the code bellow I got this error message: "The data should normally be NULL!"

import numpy as np
import cv2

img1 = cv2.imread('C:\\Users\\soboh\\Documents\\pcb.jpg',0)          # queryImage
img2 = cv2.imread('C:\\Users\\soboh\\Documents\\pcb.jpg',0) # trainImage

sift = cv2.xfeatures2d.SURF_create()

kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)


FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)   # or pass empty dictionary

flann = cv2.FlannBasedMatcher(index_params,search_params)

matches = flann.knnMatch(des1,des2,k=2)

The error happens when calling the function flann.knnMatch(). The full error message is:
"cv2.error: cv2.cpp:161: error: (-215) The data should normally be NULL! in function allocate"

So I have opened the file cv2.cpp and looked at line 161 and found these lines of code:
"
if( data != 0 )
{
CV_Error(Error::StsAssert, "The data should normally be NULL!");
// probably this is safe to do in such extreme case
return stdAllocator->allocate(dims0, sizes, type, data, step, flags, usageFlags);
}
"
so I have put the line that starts with "CV_Error" in a comment and compiled again the OpenCV and tried to run the same code and everything worked fine, but I am not sure that what I did is ok!!! Any help?

edit retag flag offensive close merge delete

Comments

1

imho, this is a valid issue

behaviour can be reproduced e.g. from the plane_tracker.py sample

berak gravatar imageberak ( 2015-11-22 02:45:23 -0600 )edit

Does anyone know if this has been fixed in OpenCV 3.1.0_x and if so, what is the minor version number?

fmw42 gravatar imagefmw42 ( 2016-09-01 19:05:49 -0600 )edit

@fmw42, please do not post answers, if you have a question or comment.

berak gravatar imageberak ( 2016-09-01 19:33:25 -0600 )edit

Sorry! I am a novice to OpenCV and this forum.

fmw42 gravatar imagefmw42 ( 2016-10-01 18:45:12 -0600 )edit