Skip to content

Commit

Permalink
added files for settings and other ideas
Browse files Browse the repository at this point in the history
  • Loading branch information
exiledsoul2 committed Apr 14, 2011
1 parent df58075 commit 0163e66
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 0 deletions.
111 changes: 111 additions & 0 deletions ZGZ/include/dataAssociation.hpp
@@ -0,0 +1,111 @@
/*
* dataAssociation.hpp
*
* Created on: Apr 8, 2011
* Author: yasir
*/

#ifndef DATAASSOCIATION_HPP_
#define DATAASSOCIATION_HPP_

#include <ZGZ.hpp>

using namespace Eigen;
using namespace cv;

/*
template <typename T, dataAssocation_t method>
class dataAssociator{
private:
dataAssociation_t _method;
public:
dataAssociator(){
_method = method;
}
dataAssociation_t getAssociationMethod()
{
return _method;
}
*
* @param prediction for NN,JCBB contains prediction of points for FM, NED contains
* @param observations
* @return
T Hypothesis(MatrixXf& prediction, MatrixXf& observations)
{
}
};
typedef dataAssociator< Eigen::Matrix<float,Dynamic,2>, dataAssociation_t::NN > NN;
typedef dataAssociator< Eigen::Matrix<float,Dynamic,2>, dataAssociation_t::JCBB > JCBB;
typedef dataAssociator< Eigen::Matrix<float,Dynamic,1>, dataAssociation_t::FM > FundamentalMatrix;
typedef dataAssociator< Eigen::Matrix<float,Dynamic,1>, dataAssociation_t::NED > NED;
*/


//template <dataAssociation_t(NED)>
std::vector<int> Hypothesis(MatrixXf& Errors, int Nbins) //!< Error is a 2Nx1 Vector of residuals Errors
{

int rows = Errors.rows();
int cols = Errors.cols();

std::vector<int> H(rows/2,0);

MatrixXf ErrorOrientations = MatrixXf(rows/2,cols);

Vector2f E ;

std::vector<int> V(Nbins,0);


for(int i=0;i<rows;i+=2)
{
E << Errors(i,0),Errors(i+1,0);
if(E.norm()> 0)
E.normalize();
else
{
E<< 0 , 1e-15;
}
double orient = atan2(E(1),E(0));
int index = int((orient+PI)/(2*PI)*(Nbins-1));
index = (index>(Nbins-1))? Nbins-1:index;
std::cout<<i<<" : "<<E(0)<<","<<E(1)<<"->"<<index<<" "<<"("<<orient<<")"<<std::endl;
V[index]++;
ErrorOrientations(i/2)=index;
}

/*
std::cout<<Mat(V)<<std::endl;
std::cout<<ErrorOrientations<<std::endl;
*/
double maxValue;
Point maxLoc;

minMaxLoc(Mat(V),NULL,&maxValue,NULL,&maxLoc);

//std::cout<<"Mat at "<<maxLoc.x<<","<<maxLoc.y<<std::endl;

for(int i=0 ; i<rows/2 ; i++)
{
int loc = ErrorOrientations(i)-maxLoc.y;
if(loc == 0 )
H[i]=(1);
else
H[i]=(0);
}

return H;

}

#endif /* DATAASSOCIATION_HPP_ */
72 changes: 72 additions & 0 deletions ZGZ/include/settings.hpp
@@ -0,0 +1,72 @@
/*
* settings.hpp
*
* Created on: Apr 12, 2011
* Author: yasir
*/

#ifndef SETTINGS_HPP_
#define SETTINGS_HPP_
enum DetectionMethod{
HarrisCorners = 0, //!< Harris Corner Detector
FastCorners, //!< FAST Corner Detector
SIFT, //!< SIFT Detector (only Detector)
SURF, //!< SURF Detector (only Detector)

};

enum AssociationMethod{
NN = 0, //!< Nearest Neighbours
JCBB, //!< Joint Compatibility
RJCBB, //!< Randomized JCBB
};

struct TrackerSettings{
float linearVelocity; //<! Variance of linearVelocity sigma-square
float angularVelocity; //<! Variance of angularVelocity sigma-square
AssociationMethod associationMethod;
float w_eps; //<! Initial error in angular Velocity
float v_eps; //<! Initial error in linear Velocity
float measurementUncertanity; //<! Measurement Noise (R)


};

struct DetectorSettings{
int maxNumFeatures; //<! The max number of features we want;
DetectionMethod detectionMethod; //<! One of DetectionMethod s
int thershold; //<! Appropriate Threshold for the detector
int nonMaximalSuppression; //<! nonMaximal suppression (FAST CORNERS ONLY)
bool gridAdapted; //<! Divides the image into a grid and then detect?
int gridRows; //<! Bins in the X directions
int gridCols; //<! Bins in the Y directions

};

struct Settings{
TrackerSettings tracker;
DetectorSettings detector;
};

static Settings settings;

static void initSettings()
{
settings.tracker.angularVelocity = 1;
settings.tracker.linearVelocity = 1;
settings.tracker.associationMethod = NN;
settings.tracker.w_eps = 1e-15;
settings.tracker.v_eps = 0;
settings.tracker.measurementUncertanity = 2;

settings.detector.detectionMethod = FastCorners;
settings.detector.gridAdapted = true;
settings.detector.gridRows = 5;
settings.detector.gridCols = 5;
settings.detector.maxNumFeatures = 1000;
settings.detector.nonMaximalSuppression = true;


}

#endif /* SETTINGS_HPP_ */
16 changes: 16 additions & 0 deletions ZGZ/include/transformations.hpp
@@ -0,0 +1,16 @@
/*
* transformations.hpp
*
* Created on: Apr 6, 2011
* Author: yasir
*/

#ifndef TRANSFORMATIONS_HPP_
#define TRANSFORMATIONS_HPP_

#include <ZGZ.hpp>

using namespace Eigen;


#endif /* TRANSFORMATIONS_HPP_ */
9 changes: 9 additions & 0 deletions ZGZ/src/settings.cpp
@@ -0,0 +1,9 @@
/*
* settings.cpp
*
* Created on: Apr 12, 2011
* Author: yasir
*/
#include <settings.hpp>


5 changes: 5 additions & 0 deletions ZGZ/thingstodo.txt
@@ -0,0 +1,5 @@
1. Restrict the search area to a predifed number of pixels
2. Affine transformation of patches as the camera moves
3. (Wishful) structure for all the different settings
4. Move Patches into its own class so that functions like transformation can be called on each
5. Organize the code into more a logical bunch .. so tat data sharing is easy

0 comments on commit 0163e66

Please sign in to comment.