Program: 174884
Project: 174884
Buggy source:
private void findPose(){
  List<DMatch> matchesList=mMatches.toList();
  if (matchesList.size() < 4) {
    return;
  }
  List<KeyPoint> referenceKeypointsList=mReferenceKeypoints.toList();
  List<KeyPoint> sceneKeypointsList=mSceneKeypoints.toList();
  double maxDist=0.0;
  double minDist=Double.MAX_VALUE;
  for (  DMatch match : matchesList) {
    double dist=match.distance;
    if (dist < minDist) {
      minDist=dist;
    }
    if (dist > maxDist) {
      maxDist=dist;
    }
  }
  if (minDist > 50.0) {
    mTargetFound=false;
    return;
  }
 else   if (minDist > 25.0) {
    return;
  }
  ArrayList<Point> goodReferencePointsList=new ArrayList<Point>();
  ArrayList<Point> goodScenePointsList=new ArrayList<Point>();
  double maxGoodMatchDist=1.75 * minDist;
  for (  final DMatch match : matchesList) {
    if (match.distance < maxGoodMatchDist) {
      goodReferencePointsList.add(referenceKeypointsList.get(match.trainIdx).pt);
      goodScenePointsList.add(sceneKeypointsList.get(match.queryIdx).pt);
    }
  }
  if (goodReferencePointsList.size() < 4 || goodScenePointsList.size() < 4) {
    return;
  }
  final MatOfPoint2f goodReferencePoints=new MatOfPoint2f();
  goodReferencePoints.fromList(goodReferencePointsList);
  final MatOfPoint2f goodScenePoints=new MatOfPoint2f();
  goodScenePoints.fromList(goodScenePointsList);
  final Mat homography=Calib3d.findHomography(goodReferencePoints,goodScenePoints);
  Core.perspectiveTransform(mReferenceCorners,mCandidateSceneCorners,homography);
  mCandidateSceneCorners.convertTo(mIntSceneCorners,CvType.CV_32S);
  if (Imgproc.isContourConvex(mIntSceneCorners)) {
    return;
  }
  final double[] sceneCorner0=mCandidateSceneCorners.get(0,0);
  final double[] sceneCorner1=mCandidateSceneCorners.get(1,0);
  final double[] sceneCorner2=mCandidateSceneCorners.get(2,0);
  final double[] sceneCorner3=mCandidateSceneCorners.get(3,0);
  mSceneCorners2D.fromArray(new Point(sceneCorner0[0],sceneCorner0[1]),new Point(sceneCorner1[0],sceneCorner1[1]),new Point(sceneCorner2[0],sceneCorner2[1]),new Point(sceneCorner3[0],sceneCorner3[1]));
  final MatOfDouble projection=mCameraProjectionAdapter.getmProjectionCV();
  Calib3d.solvePnP(mReferenceCorners3D,mSceneCorners2D,projection,mDistCoeffs,mRVec,mTVec);
  final double[] rVecArray=mRVec.toArray();
  rVecArray[0]*=-1.0;
  mRVec.fromArray(rVecArray);
  Calib3d.Rodrigues(mRVec,mRotation);
  final double[] tVecArray=mTVec.toArray();
  mGLPose[0]=(float)mRotation.get(0,0)[0];
  mGLPose[1]=(float)mRotation.get(0,1)[0];
  mGLPose[2]=(float)mRotation.get(0,2)[0];
  mGLPose[3]=0f;
  mGLPose[4]=(float)mRotation.get(1,0)[0];
  mGLPose[5]=(float)mRotation.get(1,1)[0];
  mGLPose[6]=(float)mRotation.get(1,2)[0];
  mGLPose[7]=0f;
  mGLPose[8]=(float)mRotation.get(2,0)[0];
  mGLPose[9]=(float)mRotation.get(2,1)[0];
  mGLPose[10]=(float)mRotation.get(2,2)[0];
  mGLPose[11]=0f;
  mGLPose[12]=(float)tVecArray[0];
  mGLPose[13]=-(float)tVecArray[1];
  mGLPose[14]=-(float)tVecArray[2];
  mGLPose[15]=1f;
  mTargetFound=true;
}

Fixed version (ground truth):
private void findPose(){
  final List<DMatch> matchesList=mMatches.toList();
  if (matchesList.size() < 4) {
    return;
  }
  final List<KeyPoint> referenceKeypointsList=mReferenceKeypoints.toList();
  final List<KeyPoint> sceneKeypointsList=mSceneKeypoints.toList();
  double maxDist=0.0;
  double minDist=Double.MAX_VALUE;
  for (  final DMatch match : matchesList) {
    final double dist=match.distance;
    if (dist < minDist) {
      minDist=dist;
    }
    if (dist > maxDist) {
      maxDist=dist;
    }
  }
  if (minDist > 50.0) {
    mTargetFound=false;
    return;
  }
 else   if (minDist > 25.0) {
    return;
  }
  final List<Point> goodReferencePointsList=new ArrayList<Point>();
  final ArrayList<Point> goodScenePointsList=new ArrayList<Point>();
  final double maxGoodMatchDist=1.75 * minDist;
  for (  final DMatch match : matchesList) {
    if (match.distance < maxGoodMatchDist) {
      goodReferencePointsList.add(referenceKeypointsList.get(match.trainIdx).pt);
      goodScenePointsList.add(sceneKeypointsList.get(match.queryIdx).pt);
    }
  }
  if (goodReferencePointsList.size() < 4 || goodScenePointsList.size() < 4) {
    return;
  }
  final MatOfPoint2f goodReferencePoints=new MatOfPoint2f();
  goodReferencePoints.fromList(goodReferencePointsList);
  final MatOfPoint2f goodScenePoints=new MatOfPoint2f();
  goodScenePoints.fromList(goodScenePointsList);
  final Mat homography=Calib3d.findHomography(goodReferencePoints,goodScenePoints);
  Core.perspectiveTransform(mReferenceCorners,mCandidateSceneCorners,homography);
  mCandidateSceneCorners.convertTo(mIntSceneCorners,CvType.CV_32S);
  if (!Imgproc.isContourConvex(mIntSceneCorners)) {
    return;
  }
  final double[] sceneCorner0=mCandidateSceneCorners.get(0,0);
  final double[] sceneCorner1=mCandidateSceneCorners.get(1,0);
  final double[] sceneCorner2=mCandidateSceneCorners.get(2,0);
  final double[] sceneCorner3=mCandidateSceneCorners.get(3,0);
  mSceneCorners2D.fromArray(new Point(sceneCorner0[0],sceneCorner0[1]),new Point(sceneCorner1[0],sceneCorner1[1]),new Point(sceneCorner2[0],sceneCorner2[1]),new Point(sceneCorner3[0],sceneCorner3[1]));
  final MatOfDouble projection=mCameraProjectionAdapter.getmProjectionCV();
  Calib3d.solvePnP(mReferenceCorners3D,mSceneCorners2D,projection,mDistCoeffs,mRVec,mTVec);
  final double[] rVecArray=mRVec.toArray();
  rVecArray[0]*=-1.0;
  mRVec.fromArray(rVecArray);
  Calib3d.Rodrigues(mRVec,mRotation);
  final double[] tVecArray=mTVec.toArray();
  mGLPose[0]=(float)mRotation.get(0,0)[0];
  mGLPose[1]=(float)mRotation.get(0,1)[0];
  mGLPose[2]=(float)mRotation.get(0,2)[0];
  mGLPose[3]=0f;
  mGLPose[4]=(float)mRotation.get(1,0)[0];
  mGLPose[5]=(float)mRotation.get(1,1)[0];
  mGLPose[6]=(float)mRotation.get(1,2)[0];
  mGLPose[7]=0f;
  mGLPose[8]=(float)mRotation.get(2,0)[0];
  mGLPose[9]=(float)mRotation.get(2,1)[0];
  mGLPose[10]=(float)mRotation.get(2,2)[0];
  mGLPose[11]=0f;
  mGLPose[12]=(float)tVecArray[0];
  mGLPose[13]=-(float)tVecArray[1];
  mGLPose[14]=-(float)tVecArray[2];
  mGLPose[15]=1f;
  mTargetFound=true;
}