Program: 151039
Project: 151039
Buggy source:
/** 
 * Estimates the 2D motion of an image using different models.
 * @param ransacIterations Number of RANSAC iterations
 * @param inlierThreshold Threshold which defines an inlier.
 * @param outlierPrune If a feature is an outlier for this many turns in a row it is dropped. Try 2
 * @param absoluteMinimumTracks New features will be respawned if the number of inliers drop below this number.
 * @param respawnTrackFraction If the fraction of current inliers to the original number of inliers drops belowthis fraction then new features are spawned.  Try 0.3
 * @param respawnCoverageFraction If the area covered drops by this fraction then spawn more features.  Try 0.8
 * @param refineEstimate Should it refine the model estimate using all inliers.
 * @param tracker Point feature tracker.
 * @param motionModel Instance of the model model used
 * @param < I > Image input type.
 * @param < IT > Model model
 * @return  ImageMotion2D
 */
public static <I extends ImageBase,IT extends InvertibleTransform>ImageMotion2D<I,IT> createMotion2D(int ransacIterations,double inlierThreshold,int outlierPrune,int absoluteMinimumTracks,double respawnTrackFraction,double respawnCoverageFraction,boolean refineEstimate,PointTracker<I> tracker,IT motionModel){
  ModelGenerator<IT,AssociatedPair> fitter;
  DistanceFromModel<IT,AssociatedPair> distance;
  ModelFitter<IT,AssociatedPair> modelRefiner=null;
  if (motionModel instanceof Homography2D_F64) {
    GenerateHomographyLinear mf=new GenerateHomographyLinear(true);
    fitter=(ModelGenerator)mf;
    if (refineEstimate)     modelRefiner=(ModelFitter)mf;
    distance=(DistanceFromModel)new DistanceHomographySq();
  }
 else   if (motionModel instanceof Affine2D_F64) {
    GenerateAffine2D mf=new GenerateAffine2D();
    fitter=(ModelGenerator)mf;
    if (refineEstimate)     modelRefiner=(ModelFitter)mf;
    distance=(DistanceFromModel)new DistanceAffine2DSq();
  }
 else {
    throw new RuntimeException("String_Node_Str" + motionModel.getClass().getSimpleName());
  }
  ModelMatcher<IT,AssociatedPair> modelMatcher=new Ransac(123123,fitter,distance,ransacIterations,inlierThreshold);
  ImageMotionPointTrackerKey<I,IT> lowlevel=new ImageMotionPointTrackerKey<I,IT>(tracker,modelMatcher,modelRefiner,motionModel,outlierPrune);
  ImageMotionPtkSmartRespawn<I,IT> smartRespawn=new ImageMotionPtkSmartRespawn<I,IT>(lowlevel,absoluteMinimumTracks,respawnTrackFraction,respawnCoverageFraction);
  return new WrapImageMotionPtkSmartRespawn<I,IT>(smartRespawn);
}

Fixed version (ground truth):
/** 
 * Estimates the 2D motion of an image using different models.
 * @param ransacIterations Number of RANSAC iterations
 * @param inlierThreshold Threshold which defines an inlier.
 * @param outlierPrune If a feature is an outlier for this many turns in a row it is dropped. Try 2
 * @param absoluteMinimumTracks New features will be respawned if the number of inliers drop below this number.
 * @param respawnTrackFraction If the fraction of current inliers to the original number of inliers drops belowthis fraction then new features are spawned.  Try 0.3
 * @param respawnCoverageFraction If the area covered drops by this fraction then spawn more features.  Try 0.8
 * @param refineEstimate Should it refine the model estimate using all inliers.
 * @param tracker Point feature tracker.
 * @param motionModel Instance of the model model used. Affine2D_F64 or Homography2D_F64
 * @param < I > Image input type.
 * @param < IT > Model model
 * @return  ImageMotion2D
 */
public static <I extends ImageBase,IT extends InvertibleTransform>ImageMotion2D<I,IT> createMotion2D(int ransacIterations,double inlierThreshold,int outlierPrune,int absoluteMinimumTracks,double respawnTrackFraction,double respawnCoverageFraction,boolean refineEstimate,PointTracker<I> tracker,IT motionModel){
  ModelGenerator<IT,AssociatedPair> fitter;
  DistanceFromModel<IT,AssociatedPair> distance;
  ModelFitter<IT,AssociatedPair> modelRefiner=null;
  if (motionModel instanceof Homography2D_F64) {
    GenerateHomographyLinear mf=new GenerateHomographyLinear(true);
    fitter=(ModelGenerator)mf;
    if (refineEstimate)     modelRefiner=(ModelFitter)mf;
    distance=(DistanceFromModel)new DistanceHomographySq();
  }
 else   if (motionModel instanceof Affine2D_F64) {
    GenerateAffine2D mf=new GenerateAffine2D();
    fitter=(ModelGenerator)mf;
    if (refineEstimate)     modelRefiner=(ModelFitter)mf;
    distance=(DistanceFromModel)new DistanceAffine2DSq();
  }
 else {
    throw new RuntimeException("String_Node_Str" + motionModel.getClass().getSimpleName());
  }
  ModelMatcher<IT,AssociatedPair> modelMatcher=new Ransac(123123,fitter,distance,ransacIterations,inlierThreshold);
  ImageMotionPointTrackerKey<I,IT> lowlevel=new ImageMotionPointTrackerKey<I,IT>(tracker,modelMatcher,modelRefiner,motionModel,outlierPrune);
  ImageMotionPtkSmartRespawn<I,IT> smartRespawn=new ImageMotionPtkSmartRespawn<I,IT>(lowlevel,absoluteMinimumTracks,respawnTrackFraction,respawnCoverageFraction);
  return new WrapImageMotionPtkSmartRespawn<I,IT>(smartRespawn);
}