nus-yam/ex-repair huggingface dataset:
Program: 150748
Project: 150748
Buggy source:
private void putGridIntoCanonical_horizontal(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid<>(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  g=flipHorizontal(g);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}

Fixed version (ground truth):
private void putGridIntoCanonical_horizontal(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  g=flipHorizontal(g);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}
Program: 150749
Project: 150749
Buggy source:
@Override public boolean process(GrayF32 input){
  if (alg.process(input)) {
    detected=new CalibrationObservation();
    List<Point2D_F64> found=alg.getCalibrationPoints();
    for (int i=0; i < found.size(); i++) {
      detected.add(found.get(i),i);
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean process(GrayF32 input){
  detected=new CalibrationObservation();
  if (alg.process(input)) {
    List<Point2D_F64> found=alg.getCalibrationPoints();
    for (int i=0; i < found.size(); i++) {
      detected.add(found.get(i),i);
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 150750
Project: 150750
Buggy source:
@Override public boolean process(GrayF32 input){
  detector.process(input);
  List<Grid> grids=detector.getGrids();
  if (grids.size() != 1)   return false;
  if (!keypoint.process(grids.get(0)))   return false;
  FastQueue<Point2D_F64> foundPixels=keypoint.getKeyPoints();
  results=new CalibrationObservation();
  for (int i=0; i < foundPixels.size; i++) {
    results.add(foundPixels.get(i),i);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean process(GrayF32 input){
  results=new CalibrationObservation();
  detector.process(input);
  List<Grid> grids=detector.getGrids();
  if (grids.size() != 1)   return false;
  if (!keypoint.process(grids.get(0)))   return false;
  FastQueue<Point2D_F64> foundPixels=keypoint.getKeyPoints();
  for (int i=0; i < foundPixels.size; i++) {
    results.add(foundPixels.get(i),i);
  }
  return true;
}
Program: 150751
Project: 150751
Buggy source:
@Override public boolean process(GrayF32 input){
  if (!detector.detect(input)) {
    return false;
  }
  observations=new CalibrationObservation();
  List<DetectFiducialSquareGrid.Detection> detections=detector.getDetections();
  for (int i=0; i < detections.size(); i++) {
    DetectFiducialSquareGrid.Detection d=detections.get(i);
    int row=d.gridIndex / numCols;
    int col=d.gridIndex % numCols;
    int pointRow=row * 2;
    int pointCol=col * 2;
    observations.add(d.location.a,getPointIndex(pointRow,pointCol));
    observations.add(d.location.b,getPointIndex(pointRow,pointCol + 1));
    observations.add(d.location.c,getPointIndex(pointRow + 1,pointCol + 1));
    observations.add(d.location.d,getPointIndex(pointRow + 1,pointCol));
  }
  observations.sort();
  return true;
}

Fixed version (ground truth):
@Override public boolean process(GrayF32 input){
  observations=new CalibrationObservation();
  if (!detector.detect(input)) {
    return false;
  }
  List<DetectFiducialSquareGrid.Detection> detections=detector.getDetections();
  for (int i=0; i < detections.size(); i++) {
    DetectFiducialSquareGrid.Detection d=detections.get(i);
    int row=d.gridIndex / numCols;
    int col=d.gridIndex % numCols;
    int pointRow=row * 2;
    int pointCol=col * 2;
    observations.add(d.location.a,getPointIndex(pointRow,pointCol));
    observations.add(d.location.b,getPointIndex(pointRow,pointCol + 1));
    observations.add(d.location.c,getPointIndex(pointRow + 1,pointCol + 1));
    observations.add(d.location.d,getPointIndex(pointRow + 1,pointCol));
  }
  observations.sort();
  return true;
}
Program: 150752
Project: 150752
Buggy source:
@Override public boolean process(GrayF32 input){
  if (detect.process(input)) {
    detected=new CalibrationObservation();
    List<Point2D_F64> found=detect.getCalibrationPoints();
    for (int i=0; i < found.size(); i++) {
      detected.add(found.get(i),i);
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean process(GrayF32 input){
  detected=new CalibrationObservation();
  if (detect.process(input)) {
    List<Point2D_F64> found=detect.getCalibrationPoints();
    for (int i=0; i < found.size(); i++) {
      detected.add(found.get(i),i);
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 150756
Project: 150756
Buggy source:
public boolean touchesBorder(){
  if (borderCorners.size() == 0)   return false;
 else {
    for (int i=0; i < borderCorners.size(); i++) {
      if (borderCorners.get(i))       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks to see if some part of the contour touches the image border.  Most likely cropped
 */
protected final boolean touchesBorder(List<Point2D_I32> contour){
  int endX=labeled.width - 1;
  int endY=labeled.height - 1;
  for (int j=0; j < contour.size(); j++) {
    Point2D_I32 p=contour.get(j);
    if (p.x == 0 || p.y == 0 || p.x == endX || p.y == endY) {
      return true;
    }
  }
  return false;
}
Program: 150757
Project: 150757
Buggy source:
/** 
 * <p>Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite coordinates.  The undistorted image is never explicitly created.</p> <p> WARNING: The undistorted image must have the same bounds as the distorted input image.  This is because several of the bounds checks use the image shape.  This are simplified greatly by this assumption. </p>
 * @param width Input image width.  Used in sanity check only.
 * @param height Input image height.  Used in sanity check only.
 * @param distToUndist Transform from distorted to undistorted image.
 * @param undistToDist Transform from undistorted to distorted image.
 */
public void setLensDistortion(int width,int height,PixelTransform2_F32 distToUndist,PixelTransform2_F32 undistToDist){
  this.distToUndist=distToUndist;
  this.undistToDist=undistToDist;
  RectangleLength2D_F32 rect=DistortImageOps.boundBox_F32(width,height,distToUndist);
  float x1=rect.x0 + rect.width;
  float y1=rect.y0 + rect.height;
  float tol=1e-4f;
  if (rect.getX() < -tol || rect.getY() < -tol || x1 > width + tol || y1 > height + tol) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (refinePolygon != null) {
    refinePolygon.setLensDistortion(width,height,distToUndist,undistToDist);
  }
  edgeIntensity.setTransform(undistToDist);
}

Fixed version (ground truth):
/** 
 * <p>Specifies transforms which can be used to change coordinates from distorted to undistorted and the opposite coordinates.  The undistorted image is never explicitly created.</p>
 * @param width Input image width.  Used in sanity check only.
 * @param height Input image height.  Used in sanity check only.
 * @param distToUndist Transform from distorted to undistorted image.
 * @param undistToDist Transform from undistorted to distorted image.
 */
public void setLensDistortion(int width,int height,PixelTransform2_F32 distToUndist,PixelTransform2_F32 undistToDist){
  this.distToUndist=distToUndist;
  this.undistToDist=undistToDist;
  if (refinePolygon != null) {
    refinePolygon.setLensDistortion(width,height,distToUndist,undistToDist);
  }
  edgeIntensity.setTransform(undistToDist);
}
Program: 150758
Project: 150758
Buggy source:
/** 
 * Estimates the stability by perturbing each land mark by the specified number of pixels in the distorted image.
 */
@Override public boolean computeStability(int which,double disturbance,FiducialStability results){
  if (!getFiducialToCamera(which,targetToCamera))   return false;
  targetToCamera.invert(referenceCameraToTarget);
  maxOrientation=0;
  maxLocation=0;
  for (int i=0; i < detected2D3D.size(); i++) {
    Point2D3D p23=detected2D3D.get(i);
    Point2D_F64 p=detectedPixels.get(i);
    workPt.set(p);
    perturb(disturbance,workPt,p,p23);
  }
  results.location=maxLocation;
  results.orientation=maxOrientation;
  return true;
}

Fixed version (ground truth):
/** 
 * Estimates the stability by perturbing each land mark by the specified number of pixels in the distorted image.
 */
@Override public boolean computeStability(int which,double disturbance,FiducialStability results){
  if (!getFiducialToCamera(which,targetToCamera))   return false;
  targetToCamera.invert(referenceCameraToTarget);
  maxOrientation=0;
  maxLocation=0;
  for (int i=0; i < detected2D3D.size(); i++) {
    estimatePose(which,detected2D3D,targetToCameraSample);
    referenceCameraToTarget.concat(targetToCameraSample,difference);
    Point2D3D p23=detected2D3D.get(i);
    Point2D_F64 p=detectedPixels.get(i);
    workPt.set(p);
    perturb(which,disturbance,workPt,p,p23);
  }
  results.location=maxLocation;
  results.orientation=maxOrientation;
  return true;
}
Program: 150759
Project: 150759
Buggy source:
private void computeDisturbance(Point2D_F64 pixel,Point2D3D p23){
  pixelToNorm.compute(pixel.x,pixel.y,p23.observation);
  if (estimatePose(detected2D3D,targetToCameraSample)) {
    referenceCameraToTarget.concat(targetToCameraSample,difference);
    double d=difference.getT().norm();
    ConvertRotation3D_F64.matrixToRodrigues(difference.getR(),rodrigues);
    double theta=Math.abs(rodrigues.theta);
    if (theta > maxOrientation) {
      maxOrientation=theta;
    }
    if (d > maxLocation) {
      maxLocation=d;
    }
  }
}

Fixed version (ground truth):
private void computeDisturbance(int which,Point2D_F64 pixel,Point2D3D p23){
  pixelToNorm.compute(pixel.x,pixel.y,p23.observation);
  if (estimatePose(which,detected2D3D,targetToCameraSample)) {
    referenceCameraToTarget.concat(targetToCameraSample,difference);
    double d=difference.getT().norm();
    ConvertRotation3D_F64.matrixToRodrigues(difference.getR(),rodrigues);
    double theta=Math.abs(rodrigues.theta);
    if (theta > maxOrientation) {
      maxOrientation=theta;
    }
    if (d > maxLocation) {
      maxLocation=d;
    }
  }
}
Program: 150760
Project: 150760
Buggy source:
/** 
 * Given the mapping of 2D observations to known 3D points estimate the pose of the fiducial. This solves the P-n-P problem.
 */
protected boolean estimatePose(List<Point2D3D> points,Se3_F64 fiducialToCamera){
  return estimatePnP.process(points,initialEstimate) && refinePnP.fitModel(points,initialEstimate,fiducialToCamera);
}

Fixed version (ground truth):
/** 
 * Given the mapping of 2D observations to known 3D points estimate the pose of the fiducial. This solves the P-n-P problem.
 */
protected boolean estimatePose(int which,List<Point2D3D> points,Se3_F64 fiducialToCamera){
  return estimatePnP.process(points,initialEstimate) && refinePnP.fitModel(points,initialEstimate,fiducialToCamera);
}
Program: 150761
Project: 150761
Buggy source:
@Override public boolean getFiducialToCamera(int which,Se3_F64 fiducialToCamera){
  if (!hasCameraModel)   return false;
  detectedPixels=getDetectedControl(which);
  if (detectedPixels.size() < 3)   return false;
  createDetectedList(which,detectedPixels);
  return estimatePose(detected2D3D,fiducialToCamera);
}

Fixed version (ground truth):
@Override public boolean getFiducialToCamera(int which,Se3_F64 fiducialToCamera){
  if (!hasCameraModel)   return false;
  detectedPixels=getDetectedControl(which);
  if (detectedPixels.size() < 3)   return false;
  createDetectedList(which,detectedPixels);
  return estimatePose(which,detected2D3D,fiducialToCamera);
}
Program: 150762
Project: 150762
Buggy source:
private void perturb(double disturbance,Point2D_F64 pixel,Point2D_F64 original,Point2D3D p23){
  pixel.x=original.x + disturbance;
  computeDisturbance(pixel,p23);
  pixel.x=original.x - disturbance;
  computeDisturbance(pixel,p23);
  pixel.y=original.y;
  pixel.y=original.y + disturbance;
  computeDisturbance(pixel,p23);
  pixel.y=original.y - disturbance;
  computeDisturbance(pixel,p23);
}

Fixed version (ground truth):
private void perturb(int which,double disturbance,Point2D_F64 pixel,Point2D_F64 original,Point2D3D p23){
  pixel.x=original.x + disturbance;
  computeDisturbance(which,pixel,p23);
  pixel.x=original.x - disturbance;
  computeDisturbance(which,pixel,p23);
  pixel.y=original.y;
  pixel.y=original.y + disturbance;
  computeDisturbance(which,pixel,p23);
  pixel.y=original.y - disturbance;
  computeDisturbance(which,pixel,p23);
}
Program: 150763
Project: 150763
Buggy source:
@Override protected boolean estimatePose(List<Point2D3D> points,Se3_F64 fiducialToCamera){
  quad.a.set(points.get(0).observation);
  quad.b.set(points.get(1).observation);
  quad.c.set(points.get(2).observation);
  quad.d.set(points.get(3).observation);
  if (!poseEstimator.process(quad)) {
    return false;
  }
  fiducialToCamera.set(poseEstimator.getWorldToCamera());
  return true;
}

Fixed version (ground truth):
@Override protected boolean estimatePose(int which,List<Point2D3D> points,Se3_F64 fiducialToCamera){
  quad.a.set(points.get(0).observation);
  quad.b.set(points.get(1).observation);
  quad.c.set(points.get(2).observation);
  quad.d.set(points.get(3).observation);
  if (!poseEstimator.process(quad)) {
    return false;
  }
  fiducialToCamera.set(poseEstimator.getWorldToCamera());
  double width=getWidth(which);
  fiducialToCamera.T.x*=width;
  fiducialToCamera.T.y*=width;
  fiducialToCamera.T.z*=width;
  return true;
}
Program: 150764
Project: 150764
Buggy source:
/** 
 * <p>Estimate the 3D pose of the camera from the observed location of the fiducial.</p> MUST call   {@link #setFiducial} and {@link #setLensDistoriton} before calling this function.
 * @param corners Observed corners of the fiducial in normalized image coordinates.
 * @return true if successful or false if not
 */
public boolean process(Quadrilateral_F64 corners){
  normToPixel.compute(corners.a.x,corners.a.y,pixelCorners.a);
  normToPixel.compute(corners.b.x,corners.b.y,pixelCorners.b);
  normToPixel.compute(corners.c.x,corners.c.y,pixelCorners.c);
  normToPixel.compute(corners.d.x,corners.d.y,pixelCorners.d);
  double length0=pixelCorners.getSideLength(0);
  double length1=pixelCorners.getSideLength(1);
  double ratio=Math.max(length0,length1) / Math.min(length0,length1);
  boolean success;
  if (ratio < 1.3 && length0 < SMALL_PIXELS && length1 < SMALL_PIXELS) {
    success=estimatePathological(outputFiducialToCamera);
  }
 else {
    success=estimate(pixelCorners,outputFiducialToCamera);
  }
  if (success) {
    outputError=computeErrors(outputFiducialToCamera);
  }
  return success;
}

Fixed version (ground truth):
/** 
 * <p>Estimate the 3D pose of the camera from the observed location of the fiducial.</p> MUST call   {@link #setFiducial} and {@link #setLensDistoriton} before calling this function.
 * @param corners Observed corners of the fiducial in normalized image coordinates.
 * @return true if successful or false if not
 */
public boolean process(Quadrilateral_F64 corners){
  normToPixel.compute(corners.a.x,corners.a.y,pixelCorners.a);
  normToPixel.compute(corners.b.x,corners.b.y,pixelCorners.b);
  normToPixel.compute(corners.c.x,corners.c.y,pixelCorners.c);
  normToPixel.compute(corners.d.x,corners.d.y,pixelCorners.d);
  double length0=pixelCorners.getSideLength(0);
  double length1=pixelCorners.getSideLength(1);
  double ratio=Math.max(length0,length1) / Math.min(length0,length1);
  boolean success;
  success=estimate(pixelCorners,outputFiducialToCamera);
  if (success) {
    outputError=computeErrors(outputFiducialToCamera);
  }
  return success;
}
Program: 150765
Project: 150765
Buggy source:
@Override protected void updateAlgGUI(Planar<I> frame,BufferedImage imageGUI,double fps){
  if (firstFrame) {
    panel.setPreferredSize(new Dimension(imageGUI.getWidth(),imageGUI.getHeight()));
    firstFrame=false;
  }
  int height=getHeight();
  Graphics2D g2=imageGUI.createGraphics();
  Se3_F64 targetToSensor=new Se3_F64();
  for (int i=0; i < detector.totalFound(); i++) {
    detector.getFiducialToCamera(i,targetToSensor);
    double width=detector.getWidth(i);
    long id=detector.getId(i);
    VisualizeFiducial.drawLabelCenter(targetToSensor,intrinsic,"String_Node_Str" + id,g2);
    VisualizeFiducial.drawCube(targetToSensor,intrinsic,width,3,g2);
    if (computeStability.isSelected()) {
      handleStability(height,g2,i,id);
    }
  }
  panel.setBufferedImageSafe(imageGUI);
  panel.repaint();
}

Fixed version (ground truth):
@Override protected void updateAlgGUI(Planar<I> frame,BufferedImage imageGUI,double fps){
  if (firstFrame) {
    panel.setPreferredSize(new Dimension(imageGUI.getWidth(),imageGUI.getHeight()));
    firstFrame=false;
    imageCopy=new BufferedImage(imageGUI.getWidth(),imageGUI.getHeight(),BufferedImage.TYPE_INT_RGB);
  }
  int height=getHeight();
  Graphics2D g2=imageCopy.createGraphics();
  g2.drawImage(imageGUI,0,0,null);
  Se3_F64 targetToSensor=new Se3_F64();
  for (int i=0; i < detector.totalFound(); i++) {
    detector.getFiducialToCamera(i,targetToSensor);
    double width=detector.getWidth(i);
    long id=detector.getId(i);
    VisualizeFiducial.drawLabelCenter(targetToSensor,intrinsic,"String_Node_Str" + id,g2);
    VisualizeFiducial.drawCube(targetToSensor,intrinsic,width,3,g2);
    if (computeStability.isSelected()) {
      handleStability(height,g2,i,id);
    }
  }
  panel.setBufferedImageSafe(imageCopy);
  panel.repaint();
}
Program: 150766
Project: 150766
Buggy source:
public void configure(LensDistortionWideFOV wide,LensDistortionNarrowFOV narrow){
  narrowToNorm=narrow.undistort_F32(true,false);
  unitToWide=wide.distortStoP_F32();
}

Fixed version (ground truth):
public void configure(LensDistortionNarrowFOV narrow,LensDistortionWideFOV wide){
  narrowToNorm=narrow.undistort_F32(true,false);
  unitToWide=wide.distortStoP_F32();
}
Program: 150767
Project: 150767
Buggy source:
/** 
 * Apply the transformation
 * @param x x-coordinate of point in pixels.  Synthetic narrow FOV camera
 * @param y y-coordinate of point in pixels.  Synthetic narrow FOV camera
 * @param out Pixel location of point in wide FOV camera.
 */
@Override public void compute(double x,double y,Point2D_F64 out){
  narrowToNorm.compute(x,y,norm);
  unit.set(norm.x,norm.y,1.0);
  GeometryMath_F64.mult(rotateWideToNarrow,unit,unit);
  double n=unit.norm();
  unit.x/=n;
  unit.y/=n;
  unit.z/=n;
  System.out.println("String_Node_Str" + norm);
  System.out.println("String_Node_Str" + unit);
  unitToWide.compute(unit.x,unit.y,unit.z,out);
  System.out.println("String_Node_Str" + out);
  Point3D_F64 hack=new Point3D_F64();
  wideToUnit.compute(out.x,out.y,hack);
  System.out.println("String_Node_Str" + hack);
}

Fixed version (ground truth):
/** 
 * Apply the transformation
 * @param x x-coordinate of point in pixels.  Synthetic narrow FOV camera
 * @param y y-coordinate of point in pixels.  Synthetic narrow FOV camera
 * @param out Pixel location of point in wide FOV camera.
 */
@Override public void compute(double x,double y,Point2D_F64 out){
  narrowToNorm.compute(x,y,norm);
  unit.set(norm.x,norm.y,1.0);
  GeometryMath_F64.mult(rotateWideToNarrow,unit,unit);
  double n=unit.norm();
  unit.x/=n;
  unit.y/=n;
  unit.z/=n;
  unitToWide.compute(unit.x,unit.y,unit.z,out);
}
Program: 150768
Project: 150768
Buggy source:
public void configure(LensDistortionNarrowFOV narrow,LensDistortionWideFOV wide){
  narrowToNorm=narrow.undistort_F64(true,false);
  unitToWide=wide.distortStoP_F64();
  wideToUnit=wide.undistortPtoS_F64();
}

Fixed version (ground truth):
public void configure(LensDistortionNarrowFOV narrow,LensDistortionWideFOV wide){
  narrowToNorm=narrow.undistort_F64(true,false);
  unitToWide=wide.distortStoP_F64();
}
Program: 150769
Project: 150769
Buggy source:
/** 
 * Static function for removing radial and tangential distortion
 * @param x Distorted x-coordinate normalized image coordinate
 * @param y Distorted y-coordinate normalized image coordinate
 * @param radial Radial distortion parameters
 * @param t1 tangential distortion
 * @param t2 tangential distortion
 * @param out Undistorted normalized image coordinate
 * @param tol convergence tolerance
 */
public static void removeRadial(float x,float y,float[] radial,float t1,float t2,Point2D_F32 out,float tol){
  float origX=x;
  float origY=y;
  float prevSum=0;
  for (int iter=0; iter < 20; iter++) {
    float r2=x * x + y * y;
    float ri2=r2;
    float sum=0;
    for (int i=0; i < radial.length; i++) {
      sum+=radial[i] * ri2;
      ri2*=r2;
    }
    float tx=2.0f * t1 * x* y + t2 * (r2 + 2.0f * x * x);
    float ty=t1 * (r2 + 2.0f * y * y) + 2.0f * t2 * x* y;
    x=(origX - tx) / (1.0f + sum);
    y=(origY - ty) / (1.0f + sum);
    if ((float)Math.abs(prevSum - sum) <= tol) {
      break;
    }
 else {
      prevSum=sum;
    }
  }
  out.set(x,y);
}

Fixed version (ground truth):
/** 
 * Static function for removing radial and tangential distortion
 * @param x Distorted x-coordinate normalized image coordinate
 * @param y Distorted y-coordinate normalized image coordinate
 * @param radial Radial distortion parameters
 * @param t1 tangential distortion
 * @param t2 tangential distortion
 * @param out Undistorted normalized image coordinate
 * @param tol convergence tolerance
 */
public static void removeRadial(float x,float y,float[] radial,float t1,float t2,Point2D_F32 out,float tol){
  float origX=x;
  float origY=y;
  float prevSum=0;
  for (int iter=0; iter < 500; iter++) {
    float r2=x * x + y * y;
    float ri2=r2;
    float sum=0;
    for (int i=0; i < radial.length; i++) {
      sum+=radial[i] * ri2;
      ri2*=r2;
    }
    float tx=2.0f * t1 * x* y + t2 * (r2 + 2.0f * x * x);
    float ty=t1 * (r2 + 2.0f * y * y) + 2.0f * t2 * x* y;
    x=(origX - tx) / (1.0f + sum);
    y=(origY - ty) / (1.0f + sum);
    if ((float)Math.abs(prevSum - sum) <= tol) {
      break;
    }
 else {
      prevSum=sum;
    }
  }
  out.set(x,y);
}
Program: 150770
Project: 150770
Buggy source:
@Override public void compute(float x,float y,Point3D_F32 out){
  p2.x=x;
  p2.y=y;
  GeometryMath_F32.mult(K_inv,p2,p2);
  removeRadial(p2.x,p2.y,distortion.radial,distortion.t1,distortion.t2,p2,tol);
  float u=p2.x;
  float v=p2.y;
  float a;
  float xi=mirrorOffset;
  if (mirrorOffset == 1.0f) {
    a=2.0f / (u * u + v * v + 1.0f);
  }
 else {
    float c0=u * u + v * v + 1.0f;
    float c1=-2.0f * xi;
    float c2=xi * xi - 1;
    a=(-c1 + (float)Math.sqrt(c1 * c1 - 4.0f * c0 * c2)) / (2.0f * c0);
  }
  out.x=u * a;
  out.y=v * a;
  out.z=a - xi;
}

Fixed version (ground truth):
@Override public void compute(float x,float y,Point3D_F32 out){
  p2.x=x;
  p2.y=y;
  GeometryMath_F32.mult(K_inv,p2,p2);
  removeRadial(p2.x,p2.y,distortion.radial,distortion.t1,distortion.t2,p2,tol);
  float u=p2.x;
  float v=p2.y;
  float a;
  float xi=mirrorOffset;
  float c0=u * u + v * v + 1.0f;
  float c1=-2.0f * xi;
  float c2=xi * xi - 1;
  a=(-c1 + (float)Math.sqrt(c1 * c1 - 4.0f * c0 * c2)) / (2.0f * c0);
  out.x=u * a;
  out.y=v * a;
  out.z=a - xi;
}
Program: 150771
Project: 150771
Buggy source:
@Override public void compute(double x,double y,Point3D_F64 out){
  p2.x=x;
  p2.y=y;
  GeometryMath_F64.mult(K_inv,p2,p2);
  removeRadial(p2.x,p2.y,distortion.radial,distortion.t1,distortion.t2,p2,tol);
  double u=p2.x;
  double v=p2.y;
  double a;
  double xi=mirrorOffset;
  if (mirrorOffset == 1.0) {
    a=2.0 / (u * u + v * v + 1.0);
  }
 else {
    double c0=u * u + v * v + 1.0;
    double c1=-2.0 * xi;
    double c2=xi * xi - 1;
    a=(-c1 + Math.sqrt(c1 * c1 - 4.0 * c0 * c2)) / (2.0 * c0);
  }
  out.x=u * a;
  out.y=v * a;
  out.z=a - xi;
}

Fixed version (ground truth):
@Override public void compute(double x,double y,Point3D_F64 out){
  p2.x=x;
  p2.y=y;
  GeometryMath_F64.mult(K_inv,p2,p2);
  removeRadial(p2.x,p2.y,distortion.radial,distortion.t1,distortion.t2,p2,tol);
  double u=p2.x;
  double v=p2.y;
  double a;
  double xi=mirrorOffset;
  double c0=u * u + v * v + 1.0;
  double c1=-2.0 * xi;
  double c2=xi * xi - 1;
  a=(-c1 + Math.sqrt(c1 * c1 - 4.0 * c0 * c2)) / (2.0 * c0);
  out.x=u * a;
  out.y=v * a;
  out.z=a - xi;
}
Program: 150772
Project: 150772
Buggy source:
@Override public void compute(float x,float y,float z,Point2D_F32 out){
  float[] radial=distortion.radial;
  float t1=distortion.t1;
  float t2=distortion.t2;
  float r2=x * x + y * y;
  float ri2=r2;
  float sum=0;
  for (int i=0; i < radial.length; i++) {
    sum+=radial[i] * ri2;
    ri2*=r2;
  }
  z+=mirrorOffset;
  x/=z;
  y/=z;
  x=x * (1 + sum);
  y=y * (1 + sum);
  x+=2 * t1 * x* y + t2 * (r2 + 2 * x * x);
  y+=t1 * (r2 + 2 * y * y) + 2 * t2 * x* y;
  out.x=fx * x + skew * y + cx;
  out.y=fy * y + cy;
}

Fixed version (ground truth):
@Override public void compute(float x,float y,float z,Point2D_F32 out){
  float[] radial=distortion.radial;
  float t1=distortion.t1;
  float t2=distortion.t2;
  z+=mirrorOffset;
  x/=z;
  y/=z;
  float r2=x * x + y * y;
  float ri2=r2;
  float sum=0;
  for (int i=0; i < radial.length; i++) {
    sum+=radial[i] * ri2;
    ri2*=r2;
  }
  x=x * (1.0f + sum);
  y=y * (1.0f + sum);
  x+=2.0f * t1 * x* y + t2 * (r2 + 2.0f * x * x);
  y+=t1 * (r2 + 2.0f * y * y) + 2.0f * t2 * x* y;
  out.x=fx * x + skew * y + cx;
  out.y=fy * y + cy;
}
Program: 150773
Project: 150773
Buggy source:
@Override public void compute(double x,double y,double z,Point2D_F64 out){
  double[] radial=distortion.radial;
  double t1=distortion.t1;
  double t2=distortion.t2;
  double r2=x * x + y * y;
  double ri2=r2;
  double sum=0;
  for (int i=0; i < radial.length; i++) {
    sum+=radial[i] * ri2;
    ri2*=r2;
  }
  z+=mirrorOffset;
  x/=z;
  y/=z;
  x=x * (1 + sum);
  y=y * (1 + sum);
  x+=2 * t1 * x* y + t2 * (r2 + 2 * x * x);
  y+=t1 * (r2 + 2 * y * y) + 2 * t2 * x* y;
  out.x=fx * x + skew * y + cx;
  out.y=fy * y + cy;
}

Fixed version (ground truth):
@Override public void compute(double x,double y,double z,Point2D_F64 out){
  double[] radial=distortion.radial;
  double t1=distortion.t1;
  double t2=distortion.t2;
  z+=mirrorOffset;
  x/=z;
  y/=z;
  double r2=x * x + y * y;
  double ri2=r2;
  double sum=0;
  for (int i=0; i < radial.length; i++) {
    sum+=radial[i] * ri2;
    ri2*=r2;
  }
  x=x * (1.0 + sum);
  y=y * (1.0 + sum);
  x+=2.0 * t1 * x* y + t2 * (r2 + 2.0 * x * x);
  y+=t1 * (r2 + 2.0 * y * y) + 2.0 * t2 * x* y;
  out.x=fx * x + skew * y + cx;
  out.y=fy * y + cy;
}
Program: 150774
Project: 150774
Buggy source:
@Test public void pixel_unit_pixel_F64(){
  LensDistortionWideFOV alg=create();
  Point2Transform3_F64 undistort=alg.undistortPtoS_F64();
  Point3Transform2_F64 distort=alg.distortStoP_F64();
  Point3D_F64 middle=new Point3D_F64();
  Point2D_F64 found=new Point2D_F64();
  undistort.compute(240,260,middle);
  distort.compute(middle.x,middle.y,middle.z,found);
  assertEquals(240,found.x,pixel_tol_F32);
  assertEquals(260,found.y,pixel_tol_F32);
}

Fixed version (ground truth):
@Test public void pixel_unit_pixel_F64(){
  LensDistortionWideFOV alg=create();
  Point2Transform3_F64 undistort=alg.undistortPtoS_F64();
  Point3Transform2_F64 distort=alg.distortStoP_F64();
  Point3D_F64 middle=new Point3D_F64();
  Point2D_F64 found=new Point2D_F64();
  undistort.compute(240,260,middle);
  distort.compute(middle.x,middle.y,middle.z,found);
  assertEquals(240,found.x,pixel_tol_F64);
  assertEquals(260,found.y,pixel_tol_F64);
}
Program: 150775
Project: 150775
Buggy source:
/** 
 * Request points at the border and see if it has the expected vertical and horizontal FOV
 */
@Test public void checkFOVBounds(){
  NarrowToWidePtoP_F64 alg=createAlg();
  Point2D_F64 foundA=new Point2D_F64();
  Point2D_F64 foundB=new Point2D_F64();
  Point3D_F64 vA=new Point3D_F64();
  Point3D_F64 vB=new Point3D_F64();
  alg.compute(0,250,foundA);
  alg.compute(499,250,foundB);
  Point2Transform3_F64 wideToSphere=createModelWide().undistortPtoS_F64();
  wideToSphere.compute(foundA.x,foundA.y,vA);
  wideToSphere.compute(foundB.x,foundB.y,vB);
  double angle=UtilVector3D_F64.acute(new Vector3D_F64(vA),new Vector3D_F64(vB));
  double expected=2.0 * Math.atan(250.0 / 400.0);
  assertEquals(expected,angle,0.01);
}

Fixed version (ground truth):
/** 
 * Request points at the border and see if it has the expected vertical and horizontal FOV
 */
@Test public void checkFOVBounds(){
  NarrowToWidePtoP_F64 alg=createAlg();
  Point2D_F64 foundA=new Point2D_F64();
  Point2D_F64 foundB=new Point2D_F64();
  Point3D_F64 vA=new Point3D_F64();
  Point3D_F64 vB=new Point3D_F64();
  alg.compute(0,250,foundA);
  alg.compute(500,250,foundB);
  Point2Transform3_F64 wideToSphere=createModelWide().undistortPtoS_F64();
  wideToSphere.compute(foundA.x,foundA.y,vA);
  wideToSphere.compute(foundB.x,foundB.y,vB);
  double found=UtilVector3D_F64.acute(new Vector3D_F64(vA),new Vector3D_F64(vB));
  double expected=2.0 * Math.atan(250.0 / 400.0);
  assertEquals(expected,found,0.01);
  alg.compute(250,0,foundA);
  alg.compute(250,500,foundB);
  wideToSphere.compute(foundA.x,foundA.y,vA);
  wideToSphere.compute(foundB.x,foundB.y,vB);
  found=UtilVector3D_F64.acute(new Vector3D_F64(vA),new Vector3D_F64(vB));
  expected=2.0 * Math.atan(250.0 / 400.0);
  assertEquals(expected,found,0.001);
}
Program: 150776
Project: 150776
Buggy source:
@Override protected String getPatternName(int num){
  return "String_Node_Str" + numbers.get(num);
}

Fixed version (ground truth):
@Override protected String getPatternName(int num){
  return "String_Node_Str" + gridWidth + "String_Node_Str"+ numbers.get(num);
}
Program: 150777
Project: 150777
Buggy source:
public EquirectangularRotatingApp(List<?> exampleInputs,ImageType<T> imageType){
  super(exampleInputs,imageType);
  panelImage=new ImagePanel();
  add(panelImage,BorderLayout.CENTER);
  BorderType borderType=BorderType.EXTENDED;
  InterpolatePixel<T> interp=FactoryInterpolation.createPixel(0,255,TypeInterpolate.BILINEAR,borderType,imageType);
  distortImage=FactoryDistort.distort(true,interp,imageType);
  distortImage.setRenderAll(true);
  distorted=imageType.createImage(1,1);
  inputCopy=imageType.createImage(1,1);
  panelImage.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      Point2D_F32 latlon=new Point2D_F32();
      Point2D_F32 r=new Point2D_F32();
      EquirectangularTools_F32 tools=distorter.getTools();
      distorter.compute(e.getX(),e.getY());
      tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
      distorter.setCenter(latlon.x,latlon.y);
      distortImage.setModel(distorter);
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
);
}

Fixed version (ground truth):
public EquirectangularRotatingApp(List<?> exampleInputs,ImageType<T> imageType){
  super(exampleInputs,imageType);
  panelImage=new ImagePanel();
  add(panelImage,BorderLayout.CENTER);
  BorderType borderType=BorderType.EXTENDED;
  InterpolatePixel<T> interp=FactoryInterpolation.createPixel(0,255,TypeInterpolate.BILINEAR,borderType,imageType);
  distortImage=FactoryDistort.distort(true,interp,imageType);
  distortImage.setRenderAll(true);
  distorted=imageType.createImage(1,1);
  inputCopy=imageType.createImage(1,1);
  panelImage.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      Point2D_F32 latlon=new Point2D_F32();
      EquirectangularTools_F32 tools=distorter.getTools();
      double scale=panelImage.scale;
      distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
      tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
      distorter.setCenter(latlon.x,latlon.y);
      distortImage.setModel(distorter);
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
);
}
Program: 150778
Project: 150778
Buggy source:
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  Point2D_F32 r=new Point2D_F32();
  EquirectangularTools_F32 tools=distorter.getTools();
  distorter.compute(e.getX(),e.getY());
  tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
  distorter.setCenter(latlon.x,latlon.y);
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    renderOutput(inputCopy);
  }
}

Fixed version (ground truth):
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  EquirectangularTools_F32 tools=distorter.getTools();
  double scale=panelImage.scale;
  distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
  tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
  distorter.setCenter(latlon.x,latlon.y);
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    renderOutput(inputCopy);
  }
}
Program: 150779
Project: 150779
Buggy source:
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  BufferedImage img=this.img;
  if (img != null) {
    if (scaling != ScaleOptions.NONE) {
      double ratioW=(double)getWidth() / (double)img.getWidth();
      double ratioH=(double)getHeight() / (double)img.getHeight();
      double ratio=Math.min(ratioW,ratioH);
      if (scaling == ScaleOptions.DOWN && ratio >= 1)       ratio=1;
      if (ratio == 1) {
        g.drawImage(img,0,0,this);
      }
 else {
        AffineTransform tran=AffineTransform.getScaleInstance(ratio,ratio);
        g2.drawImage(img,tran,null);
      }
    }
 else {
      g2.drawImage(img,0,0,this);
    }
  }
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  BufferedImage img=this.img;
  if (img != null) {
    if (scaling != ScaleOptions.NONE) {
      double ratioW=(double)getWidth() / (double)img.getWidth();
      double ratioH=(double)getHeight() / (double)img.getHeight();
      scale=Math.min(ratioW,ratioH);
      if (scaling == ScaleOptions.DOWN && scale >= 1)       scale=1;
      if (scale == 1) {
        g.drawImage(img,0,0,this);
      }
 else {
        AffineTransform tran=AffineTransform.getScaleInstance(scale,scale);
        g2.drawImage(img,tran,null);
      }
    }
 else {
      scale=1;
      g2.drawImage(img,0,0,this);
    }
  }
}
Program: 150780
Project: 150780
Buggy source:
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  double scale=panelEqui.scale;
  int x=(int)(e.getX() / scale);
  int y=(int)(e.getY() / scale);
  if (!equi.isInBounds(x,y))   return;
  distorter.getTools().equiToLonlat(x,y,latlon);
  distorter.setDirection(latlon.x,latlon.y,0);
  DenseMatrix64F A=ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX,Math.PI / 2,0,-Math.PI / 2,null);
  DenseMatrix64F tmp=distorter.getRotation().copy();
  CommonOps.mult(tmp,A,distorter.getRotation());
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    rerenderPinhole();
  }
}

Fixed version (ground truth):
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  double scale=panelEqui.scale;
  int x=(int)(e.getX() / scale);
  int y=(int)(e.getY() / scale);
  if (!equi.isInBounds(x,y))   return;
  distorter.getTools().equiToLonlatFV(x,y,latlon);
  distorter.setDirection(latlon.x,latlon.y,0);
  DenseMatrix64F A=ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX,Math.PI / 2,0,Math.PI / 2,null);
  DenseMatrix64F tmp=distorter.getRotation().copy();
  CommonOps.mult(tmp,A,distorter.getRotation());
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    rerenderPinhole();
  }
}
Program: 150781
Project: 150781
Buggy source:
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  DenseMatrix64F R=distorter.getRotation();
  v.set(0,0,1);
  GeometryMath_F64.mult(R,v,v);
  distorter.getTools().normToEqui((float)v.x,(float)v.y,(float)v.z,p);
  circle.setFrame(p.x * scale - 10,p.y * scale - 10,20,20);
  g2.setStroke(stroke1);
  g2.setColor(Color.BLACK);
  g2.draw(circle);
  g2.setStroke(stroke0);
  g2.setColor(Color.RED);
  g2.draw(circle);
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  DenseMatrix64F R=distorter.getRotation();
  v.set(0,0,1);
  GeometryMath_F64.mult(R,v,v);
  distorter.getTools().normToEquiFV((float)v.x,(float)v.y,(float)v.z,p);
  circle.setFrame(p.x * scale - 10,p.y * scale - 10,20,20);
  g2.setStroke(stroke1);
  g2.setColor(Color.BLACK);
  g2.draw(circle);
  g2.setStroke(stroke0);
  g2.setColor(Color.RED);
  g2.draw(circle);
}
Program: 150783
Project: 150783
Buggy source:
public EquirectangularRotatingApp(List<?> exampleInputs,ImageType<T> imageType){
  super(exampleInputs,imageType);
  panelImage=new ImagePanel();
  add(panelImage,BorderLayout.CENTER);
  BorderType borderType=BorderType.EXTENDED;
  InterpolatePixel<T> interp=FactoryInterpolation.createPixel(0,255,TypeInterpolate.BILINEAR,borderType,imageType);
  distortImage=FactoryDistort.distort(true,interp,imageType);
  distortImage.setRenderAll(true);
  distorted=imageType.createImage(1,1);
  inputCopy=imageType.createImage(1,1);
  panelImage.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      Point2D_F32 latlon=new Point2D_F32();
      EquirectangularTools_F32 tools=distorter.getTools();
      double scale=panelImage.scale;
      distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
      tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
      distorter.setDirection(latlon.x,latlon.y,0);
      distortImage.setModel(distorter);
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
);
}

Fixed version (ground truth):
public EquirectangularRotatingApp(List<?> exampleInputs,ImageType<T> imageType){
  super(exampleInputs,imageType);
  panelImage=new ImagePanel();
  add(panelImage,BorderLayout.CENTER);
  BorderType borderType=BorderType.EXTENDED;
  InterpolatePixel<T> interp=FactoryInterpolation.createPixel(0,255,TypeInterpolate.BILINEAR,borderType,imageType);
  distortImage=FactoryDistort.distort(true,interp,imageType);
  distortImage.setRenderAll(true);
  distorted=imageType.createImage(1,1);
  inputCopy=imageType.createImage(1,1);
  panelImage.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      Point2D_F32 latlon=new Point2D_F32();
      EquirectangularTools_F32 tools=distorter.getTools();
      double scale=panelImage.scale;
      distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
      tools.equiToLonlatFV(distorter.distX,distorter.distY,latlon);
      distorter.setDirection(latlon.x,latlon.y,0);
      distortImage.setModel(distorter);
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
);
}
Program: 150784
Project: 150784
Buggy source:
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  EquirectangularTools_F32 tools=distorter.getTools();
  double scale=panelImage.scale;
  distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
  tools.equiToLonlat(distorter.distX,distorter.distY,latlon);
  distorter.setDirection(latlon.x,latlon.y,0);
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    renderOutput(inputCopy);
  }
}

Fixed version (ground truth):
@Override public void mouseClicked(MouseEvent e){
  Point2D_F32 latlon=new Point2D_F32();
  EquirectangularTools_F32 tools=distorter.getTools();
  double scale=panelImage.scale;
  distorter.compute((int)(e.getX() / scale),(int)(e.getY() / scale));
  tools.equiToLonlatFV(distorter.distX,distorter.distY,latlon);
  distorter.setDirection(latlon.x,latlon.y,0);
  distortImage.setModel(distorter);
  if (inputMethod == InputMethod.IMAGE) {
    renderOutput(inputCopy);
  }
}
Program: 150785
Project: 150785
Buggy source:
/** 
 * Input is in pinhole camera pixel coordinates.  Output is in equirectangular coordinates
 * @param x Pixel x-coordinate in rendered pinhole camera
 * @param y Pixel y-coordinate in rendered pinhole camera
 */
@Override public void compute(int x,int y){
  Vector3D_F32 v=vectors[y * outWidth + x];
  GeometryMath_F32.mult(R,v,n);
  tools.normToEqui(n.x,n.y,n.z,out);
  distX=out.x;
  distY=out.y;
}

Fixed version (ground truth):
/** 
 * Input is in pinhole camera pixel coordinates.  Output is in equirectangular coordinates
 * @param x Pixel x-coordinate in rendered pinhole camera
 * @param y Pixel y-coordinate in rendered pinhole camera
 */
@Override public void compute(int x,int y){
  Vector3D_F32 v=vectors[y * outWidth + x];
  GeometryMath_F32.mult(R,v,n);
  tools.normToEquiFV(n.x,n.y,n.z,out);
  distX=out.x;
  distY=out.y;
}
Program: 150786
Project: 150786
Buggy source:
/** 
 * Input is in pinhole camera pixel coordinates.  Output is in equirectangular coordinates
 * @param x Pixel x-coordinate in rendered pinhole camera
 * @param y Pixel y-coordinate in rendered pinhole camera
 */
@Override public void compute(int x,int y){
  Vector3D_F64 v=vectors[y * outWidth + x];
  GeometryMath_F64.mult(R,v,n);
  tools.normToEqui(n.x,n.y,n.z,out);
  distX=out.x;
  distY=out.y;
}

Fixed version (ground truth):
/** 
 * Input is in pinhole camera pixel coordinates.  Output is in equirectangular coordinates
 * @param x Pixel x-coordinate in rendered pinhole camera
 * @param y Pixel y-coordinate in rendered pinhole camera
 */
@Override public void compute(int x,int y){
  Vector3D_F64 v=vectors[y * outWidth + x];
  GeometryMath_F64.mult(R,v,n);
  tools.normToEquiFV(n.x,n.y,n.z,out);
  distX=out.x;
  distY=out.y;
}
Program: 150787
Project: 150787
Buggy source:
/** 
 * Specifies the image's width and height
 * @param width Image width
 * @param height Image height
 */
public void setImageShape(int width,int height){
  tools.configure(width,height);
  declareVectors(width,height);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tools.equiToNorm(x,y,vectors[y * width + x]);
    }
  }
}

Fixed version (ground truth):
/** 
 * Specifies the image's width and height
 * @param width Image width
 * @param height Image height
 */
public void setImageShape(int width,int height){
  tools.configure(width,height);
  declareVectors(width,height);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tools.equiToNormFV(x,y,vectors[y * width + x]);
    }
  }
}
Program: 150788
Project: 150788
Buggy source:
/** 
 * Specifies the image's width and height
 * @param width Image width
 * @param height Image height
 */
public void setImageShape(int width,int height){
  tools.configure(width,height);
  declareVectors(width,height);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tools.equiToNorm(x,y,vectors[y * width + x]);
    }
  }
}

Fixed version (ground truth):
/** 
 * Specifies the image's width and height
 * @param width Image width
 * @param height Image height
 */
public void setImageShape(int width,int height){
  tools.configure(width,height);
  declareVectors(width,height);
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tools.equiToNormFV(x,y,vectors[y * width + x]);
    }
  }
}
Program: 150789
Project: 150789
Buggy source:
/** 
 * Converts the equirectangular coordinate into a latitude and longitude
 * @param x pixel coordinate in equirectangular image
 * @param y pixel coordinate in equirectangular image
 * @param latlon  (output) x = longitude, y = latitude
 */
public void equiToLonlat(float x,float y,Point2D_F32 latlon){
  latlon.x=(x / width - 0.5f) * GrlConstants.F_PI2;
  latlon.y=(y / height - 0.5f) * GrlConstants.F_PI;
}

Fixed version (ground truth):
/** 
 * Converts the equirectangular coordinate into a latitude and longitude
 * @param x pixel coordinate in equirectangular image
 * @param y pixel coordinate in equirectangular image
 * @param lonlat  (output) x = longitude, y = latitude
 */
public void equiToLonlat(float x,float y,Point2D_F32 lonlat){
  lonlat.x=(x / width - 0.5f) * GrlConstants.F_PI2;
  lonlat.y=(y / height - 0.5f) * GrlConstants.F_PI;
}
Program: 150790
Project: 150790
Buggy source:
/** 
 * Converts the equirectangular coordinate into a latitude and longitude
 * @param x pixel coordinate in equirectangular image
 * @param y pixel coordinate in equirectangular image
 * @param latlon  (output) x = longitude, y = latitude
 */
public void equiToLonlat(double x,double y,Point2D_F64 latlon){
  latlon.x=(x / width - 0.5) * GrlConstants.PI2;
  latlon.y=(y / height - 0.5) * GrlConstants.PI;
}

Fixed version (ground truth):
/** 
 * Converts the equirectangular coordinate into a latitude and longitude
 * @param x pixel coordinate in equirectangular image
 * @param y pixel coordinate in equirectangular image
 * @param lonlat  (output) x = longitude, y = latitude
 */
public void equiToLonlat(double x,double y,Point2D_F64 lonlat){
  lonlat.x=(x / width - 0.5) * GrlConstants.PI2;
  lonlat.y=(y / height - 0.5) * GrlConstants.PI;
}
Program: 150791
Project: 150791
Buggy source:
/** 
 * Finds all valid ellipses in the binary image
 * @param binary binary image
 */
public void process(GrayU8 binary){
  labeled.reshape(binary.width,binary.height);
  contourFinder.process(binary,labeled);
  FastQueue<Contour> blobs=contourFinder.getContours();
  for (int i=0; i < blobs.size; i++) {
    Contour c=blobs.get(i);
    if (c.external.size() < minimumContour || (maximumContour > 0 && c.external.size() > maximumContour)) {
      if (verbose)       System.out.println("String_Node_Str" + c.external.size());
      continue;
    }
    pointsF.reset();
    undistortContour(c.external,pointsF);
    if (!algebraic.process(pointsF.toList())) {
      if (verbose)       System.out.println("String_Node_Str" + pointsF.size());
      continue;
    }
    EllipseQuadratic_F64 quad=algebraic.getEllipse();
    Found f=found.grow();
    UtilEllipse_F64.convert(quad,f.ellipse);
    if (!isApproximatelyElliptical(f.ellipse,pointsF.toList(),20)) {
      if (verbose)       System.out.println("String_Node_Str" + pointsF.size());
      found.removeTail();
    }
    if (verbose)     System.out.println("String_Node_Str" + pointsF.size());
    f.contour=c.external;
  }
}

Fixed version (ground truth):
/** 
 * Finds all valid ellipses in the binary image
 * @param binary binary image
 */
public void process(GrayU8 binary){
  found.reset();
  labeled.reshape(binary.width,binary.height);
  contourFinder.process(binary,labeled);
  FastQueue<Contour> blobs=contourFinder.getContours();
  for (int i=0; i < blobs.size; i++) {
    Contour c=blobs.get(i);
    proccessContour(c.external);
    if (internalContour) {
      for (int j=0; j < c.internal.size(); j++) {
        proccessContour(c.internal.get(j));
      }
    }
  }
}