SimpleCV icon indicating copy to clipboard operation
SimpleCV copied to clipboard

TypeError When Got No Descriptors in ImageClass.py

Open qbx2 opened this issue 13 years ago • 2 comments

ERROR: object of type 'NoneType' has no len() Traceback (most recent call last): File "C:\Users\Administrator\Desktop\1.py", line 22, in img = img.drawKeypointMatches(Image("box.jpg")) File "C:\Users\qbx2\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 7496, in drawKeypointMatches skp,sd = self._getRawKeypoints(thresh) File "C:\Users\qbx2\Python27\lib\site-packages\SimpleCV\ImageClass.py", line 7370, in _getRawKeypoints if( len(self._mKPDescriptors) == 0 ): TypeError: object of type 'NoneType' has no len()

around line 7370:

        elif( new_version >=1  and flavor in ["ORB", "SIFT", "SURF"] ):
           FeatureDetector = cv2.FeatureDetector_create(flavor)
           DescriptorExtractor = cv2.DescriptorExtractor_create(flavor)
           self._mKeyPoints = FeatureDetector.detect(self.getGrayNumpy())
           self._mKeyPoints,self._mKPDescriptors = DescriptorExtractor.compute(self.getGrayNumpy(),self._mKeyPoints)
           if( len(self._mKPDescriptors) == 0 ):
                return None, None     
           self._mKPFlavor = flavor

I have changed if( len(self._mKPDescriptors) == 0 ): to if( self._mKPDescriptors == None or len(self._mKPDescriptors) == 0 ): and now it works well

qbx2 avatar Nov 19 '13 08:11 qbx2

Does the above code still exists in the latest version? I tried to fix it but I cannot find any such code in ImageClass.py

richajain avatar Feb 04 '14 14:02 richajain

This issue has been resolved.

jayrambhia avatar Feb 04 '14 15:02 jayrambhia