Something about my own studies, programming notes, and also English writing exercise.
Monday, July 25, 2011
[Py] Example code of FAST corner detection
Edward Rosten developed the FAST corner detection algorithm and gives several versions of source code. Python code is one of them. I downloaded the Python source code but found there was no example to illustrate the basic usage. Fortunately, the Matlab code has one example m-file. Based on the m-file, I tried to write a Python version and it works.
There are fast9, fast10, fast11, fast12, and faster modules. I have not had time to dive into the differences between them, but just took simple tests. The ``faster'' module caused the program keep running for several minutes and took most of my laptop's resource, so I terminated it without final output. Other modules gave the following results. As I mentioned, I haven't had any idea about the algorithms as well as the meanings of these results. Just for your reference.
Corners detected by fast9.py
Corners detected by fast10.py
Corners detected by fas11.py
Corners detected by fast12.py
The example code used to get the above results is listed as the follows:
(Example usage: python example.py 9)
import Image, ImageDraw
import numpy
import sys
import fast9, fast10, fast11, fast12
im = Image.open('lab.pgm')
pix = numpy.array(im)
draw = ImageDraw.Draw(im)
method = 'fast' + str(sys.argv[1])
filetosave = 'lab_corners_' + method + '.png'
(corners, scores) = eval(method).detect(pix, 30, 1)
#draw.point(corners, fill='white') # points are too small for the illustration
r = 5
for (x,y) in corners:
draw.ellipse((x, y, x+r, y+r), fill='white', outline='black')
im.save(filetosave)
im.show()
No comments:
Post a Comment