[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd Makefile.in cvd/fast_corner.h cvd/nonmax... [FAS
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd Makefile.in cvd/fast_corner.h cvd/nonmax... [FAST_cleanup] |
Date: |
Wed, 27 Jun 2007 23:00:04 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Branch: FAST_cleanup
Changes by: Edward Rosten <edrosten> 07/06/27 23:00:04
Modified files:
. : Makefile.in
cvd : fast_corner.h nonmax_suppression.h
cvd_src : fast_corner.cxx nonmax_suppression.cxx
Log message:
Many fixes.
NB Still broken, since SSE2 fast_corner_detect requires plain C++
detector
for narrow images. At the moment, it will just recurse forever.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/Makefile.in?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.52.2.2&r2=1.52.2.3
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/fast_corner.h?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.14.2.1&r2=1.14.2.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/nonmax_suppression.h?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/fast_corner.cxx?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.13&r2=1.13.2.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/nonmax_suppression.cxx?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.1.2.1&r2=1.1.2.2
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/Makefile.in,v
retrieving revision 1.52.2.2
retrieving revision 1.52.2.3
diff -u -b -r1.52.2.2 -r1.52.2.3
--- Makefile.in 27 Jun 2007 22:36:43 -0000 1.52.2.2
+++ Makefile.in 27 Jun 2007 23:00:03 -0000 1.52.2.3
@@ -99,7 +99,6 @@
pnm_src/bmp.o \
pnm_src/save_postscript.o \
cvd_src/fast_corner.o \
- cvd_src/faster_corner.o \
cvd_src/convolution.o \
cvd_src/nonmax_suppression.o \
cvd_src/fast/address@hidden@address@hidden@.o \
@@ -222,7 +221,7 @@
CVD_OBJS+=\
cvd_src/fast/address@hidden@address@hidden@.o \
cvd_src/fast/address@hidden@address@hidden@.o \
- cvd_src/fast/address@hidden@address@hidden@.o \
+ cvd_src/fast/address@hidden@address@hidden@.o
endif
Index: cvd/fast_corner.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/fast_corner.h,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -b -r1.14.2.1 -r1.14.2.2
--- cvd/fast_corner.h 27 Jun 2007 22:36:43 -0000 1.14.2.1
+++ cvd/fast_corner.h 27 Jun 2007 23:00:03 -0000 1.14.2.2
@@ -48,10 +48,10 @@
@param im The image used to generate the FAST features
@param corners The FAST features previously detected (e.g. by calling
fast_corner_detect())
@param barrier The barrier used to calculate the score, which should
be the same as that passed to fast_corner_detect()
- @param nonmax_corners Vector to be filled with the new list of
non-maximally-suppressed corners
+ @param max_corners Vector to be filled with the new list of locally
maximal corners.
@ingroup gVision
*/
- void fast_nonmax( const BasicImage<byte>& im, const
std::vector<ImageRef>& corners, int barrier, std::vector<ImageRef>&
nonmax_corners);
+ void fast_nonmax( const BasicImage<byte>& im, const
std::vector<ImageRef>& corners, int barrier, std::vector<ImageRef>&
max_corners);
/** Perform non-maximal suppression on a set of FAST features, also
returning
the score for each remaining corner. This function cleans up areas where
@@ -62,14 +62,14 @@
@param im The image used to generate the FAST features
@param corners The FAST features previously detected (e.g. by calling
fast_corner_detect())
@param barrier The barrier used to calculate the score, which should be
the same as that passed to fast_corner_detect()
- @param nonmax_corners Vector to be filled with the new list of
- non-maximally-suppressed corners, and their scores.
+ @param max_corners Vector to be filled with the new list of
+ locally maximal corners, and their scores.
<code>non_maxcorners[i].first</code> gives the location and
<code>non_maxcorners[i].second</code> gives the score (higher is
better).
@ingroup gVision
*/
- void fast_nonmax_with_scores( const BasicImage<byte>& im, const
std::vector<ImageRef>& corners, int barrier,
std::vector<std::pair<ImageRef,int> >& nonmax_corners);
+ void fast_nonmax_with_scores( const BasicImage<byte>& im, const
std::vector<ImageRef>& corners, int barrier,
std::vector<std::pair<ImageRef,int> >& max_corners);
/** Return the score for the corner as used by fast_nonmax
Note that this is not the same score as used in @ref fast_score
.
Index: cvd/nonmax_suppression.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Attic/nonmax_suppression.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- cvd/nonmax_suppression.h 27 Jun 2007 22:26:53 -0000 1.1.2.1
+++ cvd/nonmax_suppression.h 27 Jun 2007 23:00:03 -0000 1.1.2.2
@@ -2,6 +2,7 @@
#define CVD_NONMAX_SUPPRESSION_H
#include <vector>
+#include <utility>
#include <cvd/image_ref.h>
namespace CVD
@@ -13,7 +14,7 @@
@param max_corners The locally maximal corners.
@ingroup gVision
*/
- void nonmax_suppression(const vector<ImageRef>& corners, const
vector<int>& scores, vector<ImageRef>& nmax_corners);
+ void nonmax_suppression(const std::vector<ImageRef>& corners, const
std::vector<int>& scores, std::vector<ImageRef>& nmax_corners);
/**Perform nonmaximal suppression on a set of features.
@@ -23,6 +24,8 @@
@param max_corners The locally maximal corners, and their scores.
@ingroup gVision
*/
- void nonmax_suppression_with_scores(const vector<ImageRef>& corners,
const vector<int>& socres, vector<pair<ImageRef,int> >& max_corners);
+ void nonmax_suppression_with_scores(const std::vector<ImageRef>&
corners, const std::vector<int>& socres, std::vector<std::pair<ImageRef,int> >&
max_corners);
}
+
+#endif
Index: cvd_src/fast_corner.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/fast_corner.cxx,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -u -b -r1.13 -r1.13.2.1
--- cvd_src/fast_corner.cxx 25 Jul 2006 12:54:41 -0000 1.13
+++ cvd_src/fast_corner.cxx 27 Jun 2007 23:00:04 -0000 1.13.2.1
@@ -1,4 +1,5 @@
#include <cvd/fast_corner.h>
+#include <cvd/nonmax_suppression.h>
using namespace CVD;
using namespace std;
@@ -319,7 +320,7 @@
fast_score<12>(i,c,s,1);
}
-int corner_score(const BasicImage<byte>& im, ImageRef c, const int
*pointer_dir, int barrier)
+int old_style_corner_score(const BasicImage<byte>& im, ImageRef c, const int
*pointer_dir, int barrier)
{
//The score for a positive feature is sum of the difference between the
pixels
//and the barrier if the difference is positive. Negative is similar.
@@ -353,145 +354,32 @@
return sn;
}
-// fast_nonmax_t is templated so you can have either of:
-// 1: A vector of ImageRefs of the nonmax corners
-// 2: A vector of <ImageRef, int> pairs of the corners and their scores.
-// It's internal, the user-visible functions instantiate it below..
-template<class ReturnType, class Collector>
-inline void fast_nonmax_t(const BasicImage<byte>& im, const vector<ImageRef>&
corners, int barrier, vector<ReturnType>& nonmax_corners)
+void compute_fast_score_old(const BasicImage<byte>& im, const
vector<ImageRef>& corners, int barrier, vector<int>& scores)
{
- if(corners.size() < 1)
- return;
-
- ImageRef size = im.size();
- nonmax_corners.clear();
-
- //Create a list of integer pointer offstes, corresponding to the
- //direction offsets in dir[]
int pointer_dir[16];
for(int i=0; i < 16; i++)
- pointer_dir[i] = dir[i].x + dir[i].y * size.x;
-
- //Compute the score for each detected corner, and find where each row begins
- // (the corners are output in raster scan order). A beginning of -1 signifies
- // that there are no corners on that row.
-
- vector<int> row_start(size.y);
- vector<int> scores(corners.size());
-
- for(int i=0; i <size.y; i++)
- row_start[i] = -1;
-
- int prev_row = -1;
-
- for(unsigned int i=0; i< corners.size(); i++)
- {
- if(corners[i].y != prev_row)
- {
- row_start[corners[i].y] = i;
- prev_row = corners[i].y;
- }
-
- if(corners[i].y < im.size().y - 4)
- prefetch(im[ (corners[i].y+4)]);
-
- scores[i] = corner_score(im, corners[i], pointer_dir, barrier);
- }
-
-
- //Point above points (roughly) to the pixel above the one of interest, if
there
- //is a feature there.
- int point_above = 0;
- int point_below = 0;
-
- const unsigned int sz = corners.size();
-
- for(unsigned int i=0; i < sz; i++)
- {
- int score = scores[i];
- ImageRef pos = corners[i];
-
- //Check left
- if(i > 0)
- if(corners[i-1] == pos-ImageRef(1,0) && scores[i-1] > score)
- continue;
-
- //Check right
- if(i < (sz - 1))
- if(corners[i+1] == pos+ImageRef(1,0) && scores[i+1] > score)
- continue;
-
- //Check above
- if(pos.y != 0 && row_start[pos.y - 1] != -1)
- {
- if(corners[point_above].y < pos.y - 1)
- point_above = row_start[pos.y-1];
-
- //Make point above point to the first of the pixels above the current
point,
- //if it exists.
- for(; corners[point_above].y < pos.y && corners[point_above].x <
pos.x - 1; point_above++);
-
-
- for(int i=point_above; corners[i].y < pos.y && corners[i].x <= pos.x
+ 1; i++)
- {
- int x = corners[i].x;
- if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && scores[i] >
score)
- {
- goto cont;
- }
- }
-
- }
-
- //Check below
- if(pos.y != size.y-1 && row_start[pos.y + 1] != -1 && point_below < sz)
//Nothing below
- {
- if(corners[point_below].y < pos.y + 1)
- point_below = row_start[pos.y+1];
-
- // Make point below point to one of the pixels belowthe current
point, if it
- // exists.
- for(; point_below < sz && corners[point_below].y == pos.y+1 &&
corners[point_below].x < pos.x - 1; point_below++);
-
- for(int i=point_below; i < sz && corners[i].y == pos.y+1 &&
corners[i].x <= pos.x + 1; i++)
- {
- int x = corners[i].x;
- if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && scores[i] >
score)
- {
- goto cont;
- }
- }
- }
+ pointer_dir[i] = fast_pixel_ring[i].x + fast_pixel_ring[i].y *
im.size().x;
- nonmax_corners.push_back(Collector::collect(corners[i],scores[i]));
+ scores.resize(corners.size());
- cont:
- ;
- }
+ for(unsigned int i=0; i < corners.size(); i++)
+ scores[i] = old_style_corner_score(im, corners[i], pointer_dir,
barrier);
}
-// The two collectors which either return just the ImageRef or the
<ImageRef,int> pair
-struct collect_pos
-{
- static inline ImageRef collect(const ImageRef& pos, int score){return pos;}
-};
-struct collect_score
-{
- static inline pair<ImageRef, int> collect(const ImageRef& pos, int
score){return make_pair(pos,score);}
-};
-// The callable functions
-void fast_nonmax(const BasicImage<byte>& im, const vector<ImageRef>& corners,
- int barrier, vector<ImageRef>& nonmax_corners)
+void fast_nonmax(const BasicImage<byte>& im, const vector<ImageRef>& corners,
int barrier, vector<ImageRef>& max_corners)
{
- fast_nonmax_t<ImageRef, collect_pos>(im, corners, barrier, nonmax_corners);
+ vector<int> scores;
+ compute_fast_score_old(im, corners, barrier, scores);
+ nonmax_suppression(corners, scores, max_corners);
}
-void fast_nonmax_with_scores(const BasicImage<byte>& im, const
vector<ImageRef>& corners, int barrier, vector<pair<ImageRef,int> >&
nonmax_corners)
+void fast_nonmax_with_scores(const BasicImage<byte>& im, const
vector<ImageRef>& corners, int barrier, vector<pair<ImageRef,int> >&
max_corners)
{
- fast_nonmax_t<pair<ImageRef,int> , collect_score>(im, corners, barrier,
- nonmax_corners);
+ vector<int> scores;
+ compute_fast_score_old(im, corners, barrier, scores);
+ nonmax_suppression_with_scores(corners, scores, max_corners);
}
Index: cvd_src/nonmax_suppression.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Attic/nonmax_suppression.cxx,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- cvd_src/nonmax_suppression.cxx 27 Jun 2007 22:26:52 -0000 1.1.2.1
+++ cvd_src/nonmax_suppression.cxx 27 Jun 2007 23:00:04 -0000 1.1.2.2
@@ -1,4 +1,5 @@
#include <cvd/image_ref.h>
+#include <cvd/nonmax_suppression.h>
#include <vector>
using namespace std;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd Makefile.in cvd/fast_corner.h cvd/nonmax... [FAST_cleanup],
Edward Rosten <=