summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2010-06-24 20:08:43 -0400
committerGuillaume Seguin <guillaume@segu.in>2010-06-24 20:08:43 -0400
commit7490195addb30b95a4323076139bd9ac61067a6f (patch)
treead94542b5d8d193de56d43c797c5dc637ae618fa
parent97ae9c454f4ce2a65ce5453924b7747034f0074e (diff)
downloadcmu-7490195addb30b95a4323076139bd9ac61067a6f.tar.gz
cmu-7490195addb30b95a4323076139bd9ac61067a6f.tar.bz2
Compute T
-rw-r--r--libmoped/src/config.hpp2
-rw-r--r--libmoped/src/sfm/SFM_F.hpp5
-rw-r--r--libmoped/src/sfm/SFM_TRACKING.hpp58
-rw-r--r--libmoped/src/util.hpp12
4 files changed, 41 insertions, 36 deletions
diff --git a/libmoped/src/config.hpp b/libmoped/src/config.hpp
index 0c222b8..bd94439 100644
--- a/libmoped/src/config.hpp
+++ b/libmoped/src/config.hpp
@@ -40,6 +40,7 @@
#include <sfm/SFM_TRACKING.hpp>
#include <sfm/SFM_TRACKING_DISPLAY.hpp>
#include <sfm/SFM_F.hpp>
+#include <sfm/SFM_T.hpp>
//#include <sfm/SFM_RECONSTRUCTION.hpp> /* FIXME : TODO */
#include <STATUS_DISPLAY.hpp>
@@ -129,6 +130,7 @@ namespace MopedNS {
pipeline.addAlg( "TRACKING", new SFM_TRACKING() );
pipeline.addAlg( "TRACKING_DISPLAY", new SFM_TRACKING_DISPLAY(DEFAULT_DISPLAY_LEVEL) );
pipeline.addAlg( "SFM_F", new SFM_F() );
+ pipeline.addAlg( "SFM_T", new SFM_T() );
//pipeline.addAlg( "POSE2_DISPLAY", new POSE_DISPLAY( DEFAULT_DISPLAY_LEVEL ) );
diff --git a/libmoped/src/sfm/SFM_F.hpp b/libmoped/src/sfm/SFM_F.hpp
index b49d84b..e942059 100644
--- a/libmoped/src/sfm/SFM_F.hpp
+++ b/libmoped/src/sfm/SFM_F.hpp
@@ -15,8 +15,9 @@ namespace MopedNS {
void setConfig (map<string,string> &config) {
}
- void process(FrameData &frameData) {
- for( int i=0; i<(int)frameData.images.size(); i++) {
+ void process (FrameData &frameData) {
+ for (int i = 0; i < (int) frameData.images.size(); i++)
+ {
vector<Point2f> & new_points = frameData.trackingNewPoints[i];
vector<KeyPoint> & key_points = frameData.trackedFeatures[i];
vector<int> & old_points_indices = frameData.trackingPrevIndices[i];
diff --git a/libmoped/src/sfm/SFM_TRACKING.hpp b/libmoped/src/sfm/SFM_TRACKING.hpp
index 8bde249..78fff09 100644
--- a/libmoped/src/sfm/SFM_TRACKING.hpp
+++ b/libmoped/src/sfm/SFM_TRACKING.hpp
@@ -26,8 +26,15 @@ namespace MopedNS {
IplImage *prevprev;
IplImage *prev;
+ /* kp of the previous image */
vector<KeyPoint> key_points;
+#ifdef PREVPREV_TRACKING
+ KLTTracker feature_matcher_prev;
+ /* kp of the previous previous image */
+ vector<KeyPoint> prev_key_points;
+#endif
+
public:
SFM_TRACKING ()
@@ -39,8 +46,8 @@ namespace MopedNS {
void setConfig (map<string,string> &config) {}
- void processOne (FrameData &frameData, int i) {
- Image *image = frameData.images[i].get ();
+ inline void processOne (FrameData &frameData, int i) {
+ Image *image = frameData.images[i].get ();
IplImage* img0 = cvCreateImage (cvSize (image->width,
image->height),
IPL_DEPTH_8U, 3);
@@ -69,9 +76,24 @@ namespace MopedNS {
feature_matcher.search (img2, new_points, old_points_indices);
}
if (prevprev)
+ {
+#ifdef PREVPREV_TRACKING
+ vector<Point2f> & new_points = frameData.prevTrackingNewPoints[i];
+ vector<int> & old_points_indices = frameData.prevTrackingPrevIndices[i];
+ frameData.prevTrackedFeatures[i] = prev_key_points;
+ feature_matcher_prev.search (img2, new_points, old_points_indices);
+#endif
cvReleaseImage (&prevprev);
+ }
prevprev = prev;
prev = img2;
+#ifdef PREVPREV_TRACKING
+ if (prevprev)
+ {
+ prev_key_points = key_points;
+ feature_matcher_prev.add(prevprev, key_points);
+ }
+#endif
feature_detector.detect(img2, key_points);
feature_matcher.add(img2, key_points);
}
@@ -79,39 +101,7 @@ namespace MopedNS {
void process (FrameData &frameData) {
for (int i = 0; i < (int) frameData.images.size(); i++)
- {
processOne (frameData, i);
- /*
-
- vector<FrameData::DetectedFeature> &detectedFeatures = frameData.detectedFeatures[_stepName];
-
- // Convert to a floating point image with pixels in range [0,1].
- SFImage image = CreateImage(img->height, img->width);
- for (int y = 0; y < img->height; y++)
- for (int x = 0; x < img->width; x++)
- image->pixels[y*image->stride+x] = ((float) img->data[img->width*y+x]) * 1./255.;
-
- Keypoint keypts = GetKeypoints(image);
- Keypoint key = keypts;
- while (key) {
-
- detectedFeatures.resize(detectedFeatures.size()+1);
-
- detectedFeatures.back().imageIdx = i;
-
- detectedFeatures.back().descriptor.resize(128);
- for (int x=0; x<128; x++) detectedFeatures.back().descriptor[x] = key->descrip[x];
-
- detectedFeatures.back().coord2D[0] = key->col;
- detectedFeatures.back().coord2D[1] = key->row;
-
- key = key->next;
- }
-
- FreeKeypoints(keypts);
- DestroyAllImages(); // we can't destroy just one!
- */
- }
}
};
};
diff --git a/libmoped/src/util.hpp b/libmoped/src/util.hpp
index 77d4b98..a778518 100644
--- a/libmoped/src/util.hpp
+++ b/libmoped/src/util.hpp
@@ -23,6 +23,9 @@ inline CvPoint cvPoint (double a, double b)
namespace MopedNS {
+ typedef struct {
+ Mat m[3];
+ } TrifocalTensor;
struct FrameData {
@@ -54,7 +57,16 @@ namespace MopedNS {
map< int, vector<KeyPoint> > trackedFeatures;
map< int, vector<int> > trackingPrevIndices;
map< int, vector<Point2f> > trackingNewPoints;
+ /* Features in the /previous previous/ image */
+#define PREVPREV_TRACKING
+#ifdef PREVPREV_TRACKING
+ map< int, vector<KeyPoint> > prevTrackedFeatures;
+ map< int, vector<int> > prevTrackingPrevIndices;
+ map< int, vector<Point2f> > prevTrackingNewPoints;
+#endif
+ /* Fundamental matrix between prev image and current */
map<int, Mat> F;
+ map<int, TrifocalTensor> T;
map< string, vector< DetectedFeature > > detectedFeatures;