Feature Discovery in OpenCV Pinton Bindings

I combed the website trying to find OpenCV 2.3.1a extract / descriptor links to splash out any taste of image functions / descriptors (STAR ​​/ SURF / ORB / SIFT / FAST). I am well aware that OpenCV has a "goodFeaturesToTrack" method. This does not help me, since there are no function descriptors (this is what I really need). I followed the documentation mentioned here:

http://opencv.itseez.com/modules/features2d/doc/feature_detection_and_description.html

Nothing seems to work. I tried all options for descriptors / functions. I tried using single and multi-channel images (for example, color and black and white) and several image formats (8 bits and 32 f). I worked with the current distribution and created bindings from the source repo. Most methods result in a "unknown is not numpy array" error. Here is an example:

SimpleCV:1>import cv2 SimpleCV:2>img = Image("aerospace.jpg") SimpleCV:3>bwimg = img._getGrayscaleBitmap() SimpleCV:4>bwimg SimpleCV:4><iplimage(nChannels=1 width=600 height=400 widthStep=600 )> SimpleCV:5>surfer = cv2.SURF(0.5,4,2,False,False) SimpleCV:6>points = surfer.detect(bwimg,None) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Library/Python/2.6/site-packages/SimpleCV-1.2-py2.6.egg/SimpleCV/Shell/Shell.pyc in <module>() - TypeError: <unknown> is not a numpy array SimpleCV:7> 

It’s worth noting that I use SimpleCV to load the image, but the _getGrayscaleBitmap () method returns the gray 8-bit IPL image used by OpenCV. I am sure this works, as I use it with a hundred other OpenCV methods without incident.

So can anyone give me an example of WORKING this code on the web. I came up with dozens of examples and found nothing.

+6
source share
2 answers

Kat, this works for me:

 s = cv2.SURF() mask = uint8(ones(gray.shape)) keypoints = s.detect(gray,mask) 

I can draw key points and that’s it. To get the descriptors you can try this

 k,d = s.detect(gray,mask,False) d = d.reshape((-1,128)) print d.shape, len(k) 

d must be the same length in the list of key points.

I have this example in the OpenCV chapter: http://www.maths.lth.se/matematiklth/personal/solem/book.html

+10
source

It looks like you have a PIL image. Try converting to a numeric image: npImage = np.array (img)

0
source

Source: https://habr.com/ru/post/907588/


All Articles