Program: 150559
Project: 150559
Buggy source:
/** 
 * Associate features between the two views. Then compute a homography and essential matrix using LSMed. Add features to the edge if they an inlier in essential. Save fit score of homography vs essential.
 */
void connectViews(CameraView viewA,CameraView viewB){
  associate.setSource(viewA.descriptions);
  associate.setDestination(viewB.descriptions);
  associate.associate();
  if (associate.getMatches().size < MIN_FEATURE_ASSOCIATED)   return;
  FastQueue<AssociatedIndex> matches=associate.getMatches();
  CameraMotion edge=new CameraMotion();
  int inliersEpipolar;
  if (calibrated) {
    ransacEssential.setIntrinsic(0,camerasIntrinsc.get(viewA.camera));
    ransacEssential.setIntrinsic(1,camerasIntrinsc.get(viewB.camera));
    if (!fitEpipolar(matches,viewA.featureNorm,viewB.featureNorm,ransacEssential,edge))     return;
    inliersEpipolar=ransacEssential.getMatchSet().size();
    edge.a_to_b.set(ransacEssential.getModelParameters());
    ransacHomography.setIntrinsic(0,camerasIntrinsc.get(viewA.camera));
    ransacHomography.setIntrinsic(1,camerasIntrinsc.get(viewB.camera));
  }
 else {
    if (!fitEpipolar(matches,viewA.featurePixels,viewB.featurePixels,ransacFundamental,edge))     return;
    inliersEpipolar=ransacFundamental.getMatchSet().size();
  }
  if (inliersEpipolar < MIN_FEATURE_ASSOCIATED)   return;
  if (!ransacHomography.process(pairs.toList())) {
    return;
  }
  edge.ratio_H_to_Epi=ransacHomography.getMatchSet().size() / (double)inliersEpipolar;
  edge.viewSrc=viewA;
  edge.viewDst=viewB;
  viewA.connections.add(edge);
  viewB.connections.add(edge);
  List<AssociatedPair> inliersEssential=ransacEssential.getMatchSet();
  for (int i=0; i < inliersEssential.size(); i++) {
    int index=ransacEssential.getInputIndex(i);
    edge.features.add(matches.get(index).copy());
  }
  graphEdges.add(edge);
}

Fixed version (ground truth):
/** 
 * Associate features between the two views. Then compute a homography and essential matrix using LSMed. Add features to the edge if they an inlier in essential. Save fit score of homography vs essential.
 */
void connectViews(CameraView viewA,CameraView viewB){
  associate.setSource(viewA.descriptions);
  associate.setDestination(viewB.descriptions);
  associate.associate();
  if (associate.getMatches().size < MIN_FEATURE_ASSOCIATED)   return;
  FastQueue<AssociatedIndex> matches=associate.getMatches();
  CameraMotion edge=new CameraMotion();
  int inliersEpipolar;
  if (calibrated) {
    ransacEssential.setIntrinsic(0,camerasIntrinsc.get(viewA.camera));
    ransacEssential.setIntrinsic(1,camerasIntrinsc.get(viewB.camera));
    if (!fitEpipolar(matches,viewA.observationNorm.toList(),viewB.observationNorm.toList(),ransacEssential,edge))     return;
    inliersEpipolar=ransacEssential.getMatchSet().size();
    edge.a_to_b.set(ransacEssential.getModelParameters());
    ransacHomography.setIntrinsic(0,camerasIntrinsc.get(viewA.camera));
    ransacHomography.setIntrinsic(1,camerasIntrinsc.get(viewB.camera));
  }
 else {
    if (!fitEpipolar(matches,viewA.observationPixels.toList(),viewB.observationPixels.toList(),ransacFundamental,edge))     return;
    inliersEpipolar=ransacFundamental.getMatchSet().size();
  }
  if (inliersEpipolar < MIN_FEATURE_ASSOCIATED)   return;
  if (!ransacHomography.process(pairs.toList())) {
    return;
  }
  edge.ratio_H_to_Epi=ransacHomography.getMatchSet().size() / (double)inliersEpipolar;
  edge.viewSrc=viewA;
  edge.viewDst=viewB;
  viewA.connections.add(edge);
  viewB.connections.add(edge);
  graphEdges.add(edge);
}