Example #1
0
/**
Method to register two images using the simple pairwise algorithm without allocating memory
@param srcIm: Source Image 
@param dstIm: Destination image 
@param Covar: CvMat Not used 
@param pInterframePoorFlag: Detection Flag 
@param pA: Not Used 
@param pB: Not Used
@return void
*/
void InterframeRegister::Register( Mat srcIm, Mat dstIm, Mat &pTransform, Mat pCovar, bool pInterframePoorFlag)
{

	/* init transform to identity */
	setIdentity(pTransform);
	
	/* image params */
	const Size szCurr = srcIm.size();
	
	/* registration parameters */
	double bound[2][2] = {0.0};
	double transform[3][3] = {0.0};

	vector <Point2f> ptSrc (InterframeRegister::MAX_KLT_POINTS);
	
	/* Contrast stretch */
	Mat srcStretch = srcIm.clone();
	Mat dstStretch = dstIm.clone();
	cvutStdDevStretch( srcStretch , srcStretch );
	cvutStdDevStretch( dstStretch , dstStretch );

	////////////////////////////////////////////////////////
	/* KLT ONLY. NO SWITCHING TO INTENSITY-BASED */
	int cornerCount = InterframeRegister::InitFeatures(srcStretch, ptSrc);

	vector <Point2f> ptDst (cornerCount);

	/* sanity check for sufficiency */
	if(cornerCount < InterframeRegister::INLIER_THRESH)
	{
		if(pInterframePoorFlag != NULL) pInterframePoorFlag = true;
		return;
	}
	
	/* find matching points */
	cornerCount = TrackFeatures(srcStretch, dstStretch, ptSrc, ptDst, cornerCount);

	/* Robust estimation of motion parameters */
	vector <Point2d> optInliersL (cornerCount); /* dst */
	vector <Point2d> optInliersR (cornerCount); /* src */

	pTransform = RunRansac(ptDst, ptSrc, cornerCount, optInliersL, optInliersR, srcIm, dstIm);
}
void FeatureTracker::SetPose(Vector<3, double> newpose)
{
    pose = newpose;

    if(bSensing)
    {
        vector<Feature> fs = TrackFeatures(pose);

        double rndMin = MIN_FEATURES * RAND(0.7,1.3);
        //printf("%d\n",fs.size());

        if(fs.size() < rndMin)
        {
            GenerateFeatures(rndMin - fs.size(), pose);
        }

        UpdateMatchedFeatures();
    }

}
void FeatureTracker::UpdateMatchedFeatures()
{
    matchedFeatures = TrackFeatures(pose);
}