saviopalmieri / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

Error when attempting to use cvExtractSURF from either opencv1.0 or opencv1.1 #45

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Code to reproduce:

--------------------------------------------------------------------

from opencv.cv import *
from opencv.highgui import *

if __name__ == "__main__":
    object = cvLoadImage( "test.jpg", CV_LOAD_IMAGE_GRAYSCALE )

    objectKeypoints = CvSeq()
    objectDescriptors = CvSeq()
    storage = cvCreateMemStorage( 0 )

    cvExtractSURF( object, 0, objectKeypoints, objectDescriptors, storage,
cvSURFParams( 500, 1 ) )
    print "Object Descriptors: %d" % objectDescriptors.total

--------------------------------------------------------------------

System:
Linux bolt 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009
i686 GNU/Linux
Ubuntu 9.04

Expected:
Object Descriptors: 300 (ish)

Outcome:
OpenCV ERROR: Internal error (Assertion: img != 0 && CV_MAT_TYPE(img->type)
== CV_8UC1 && (mask == 0 || (CV_ARE_SIZES_EQ(img,mask) &&
CV_MAT_TYPE(mask->type) == CV_8UC1)) && storage != 0 &&
params.hessianThreshold >= 0 && params.nOctaves > 0 && params.nOctaveLayers
> 0 failed)
    in function cvExtractSURF, cvsurf.cpp(291)
Terminating the application...

Using latest release version 0.7.3

Original issue reported on code.google.com by rojabuck@gmail.com on 14 Jul 2009 at 3:32

GoogleCodeExporter commented 8 years ago
I have also looked into what seems to be the issue a little more and have 
expanded
out the assertion to:

    CV_ASSERT( img != 0 );
    CV_ASSERT( CV_MAT_TYPE(img->type) == CV_8UC1 );
    CV_ASSERT( (mask == 0 || (CV_ARE_SIZES_EQ(img,mask) && CV_MAT_TYPE(mask->type) ==
CV_8UC1)) );
    CV_ASSERT( storage != 0 );
    CV_ASSERT( params.hessianThreshold >= 0 );
    CV_ASSERT( params.nOctaves > 0 );
    CV_ASSERT( params.nOctaveLayers > 0 );

which results in:

OpenCV ERROR: Internal error (Assertion: storage != 0 failed)
    in function cvExtractSURF, cvsurf.cpp(290)
Terminating the application...

So i would appear that the python interface is failing to create/pass the 
required
storage container which should be created with; storage = cvCreateMemStorage( 0 
)

Original comment by rojabuck@gmail.com on 14 Jul 2009 at 3:54

GoogleCodeExporter commented 8 years ago
Thanks. I'll take a look asap. I'm a bit busy now.

Original comment by pmtri80@gmail.com on 16 Jul 2009 at 4:44

GoogleCodeExporter commented 8 years ago
I found an error in your code. You should pass a CvSeq_p for the 'keypoints_ptr'
argument in calling cvExtractSURF instead of a CvSeq. The same goes for the
'descriptors_ptr' argument. Perhaps, you may want to have a look at the 
'find_obj'
file in the demo package. It has an example of calling cvExtractSURF.

Also, cvExtractSURF is not available in opencv 1.0.

Best regards,

Minh Tri

Original comment by pmtri80@gmail.com on 18 Jul 2009 at 5:18