nus-yam/ex-repair huggingface dataset:
Program: 150632
Project: 150632
Buggy source:
protected void bitsToMessage(PackedBits8 stream){
  stream.append(0,(8 - (stream.size % 8)) % 8,false);
  QrCode.VersionInfo info=QrCode.VERSION_INFO[qr.version];
  QrCode.ErrorBlock block=info.levels.get(qr.error);
  qr.rawbits=new byte[info.codewords];
  int wordsBlockAllA=block.codewords;
  int wordsBlockDataA=block.dataCodewords;
  int wordsEcc=wordsBlockAllA - wordsBlockDataA;
  int numBlocksA=block.eccBlocks;
  int wordsBlockAllB=wordsBlockAllA + 1;
  int wordsBlockDataB=wordsBlockDataA + 1;
  int numBlocksB=(info.codewords - wordsBlockAllA * numBlocksA) / wordsBlockAllB;
  message.resize(wordsBlockDataA + 1);
  int startEcc=numBlocksA * wordsBlockDataA + numBlocksB * wordsBlockDataB;
  int totalBlocks=numBlocksA + numBlocksB;
  rscodes.generator(wordsEcc);
  ecc.resize(wordsEcc);
  encodeBlocks(stream,wordsBlockDataA,numBlocksA,0,0,startEcc,totalBlocks);
  encodeBlocks(stream,wordsBlockDataB,numBlocksB,wordsBlockDataA * numBlocksA,numBlocksA,startEcc,totalBlocks);
}

Fixed version (ground truth):
protected void bitsToMessage(PackedBits8 stream){
  stream.append(0,(8 - (stream.size % 8)) % 8,false);
  QrCode.VersionInfo info=QrCode.VERSION_INFO[qr.version];
  QrCode.ErrorBlock block=info.levels.get(qr.error);
  qr.rawbits=new byte[info.codewords];
  int wordsBlockAllA=block.codewords;
  int wordsBlockDataA=block.dataCodewords;
  int wordsEcc=wordsBlockAllA - wordsBlockDataA;
  int numBlocksA=block.blocks;
  int wordsBlockAllB=wordsBlockAllA + 1;
  int wordsBlockDataB=wordsBlockDataA + 1;
  int numBlocksB=(info.codewords - wordsBlockAllA * numBlocksA) / wordsBlockAllB;
  message.resize(wordsBlockDataA + 1);
  int startEcc=numBlocksA * wordsBlockDataA + numBlocksB * wordsBlockDataB;
  int totalBlocks=numBlocksA + numBlocksB;
  rscodes.generator(wordsEcc);
  ecc.resize(wordsEcc);
  encodeBlocks(stream,wordsBlockDataA,numBlocksA,0,0,startEcc,totalBlocks);
  encodeBlocks(stream,wordsBlockDataB,numBlocksB,wordsBlockDataA * numBlocksA,numBlocksA,startEcc,totalBlocks);
}
Program: 150633
Project: 150633
Buggy source:
/** 
 * Can through version info and see if it passes a few simple checks. It's still possible for wrong entries to exist.
 */
@Test public void sanityVersionInfo(){
  for (int version=1; version <= QrCode.MAX_VERSION; version++) {
    QrCode.VersionInfo info=QrCode.VERSION_INFO[version];
    int totalBits=new QrCodeCodeWordLocations(version).bits.size();
    assertEquals(totalBits / 8,info.codewords);
    for (    QrCode.ErrorLevel level : QrCode.ErrorLevel.values()) {
      QrCode.ErrorBlock block=info.levels.get(level);
      assertTrue(block.dataCodewords < block.codewords);
      int byteBlockB=block.codewords + 1;
      int byteDataB=block.dataCodewords + 1;
      int countB=(info.codewords - block.codewords * block.eccBlocks);
      assertTrue(countB >= 0);
      if (countB > 0) {
        assertTrue(countB % byteBlockB == 0);
        countB/=byteBlockB;
        assertEquals(info.codewords,block.codewords * block.eccBlocks + byteBlockB * countB);
        assertTrue(byteDataB < byteBlockB);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Can through version info and see if it passes a few simple checks. It's still possible for wrong entries to exist.
 */
@Test public void sanityVersionInfo(){
  for (int version=1; version <= QrCode.MAX_VERSION; version++) {
    QrCode.VersionInfo info=QrCode.VERSION_INFO[version];
    int totalBits=new QrCodeCodeWordLocations(version).bits.size();
    assertEquals(totalBits / 8,info.codewords);
    for (    QrCode.ErrorLevel level : QrCode.ErrorLevel.values()) {
      QrCode.ErrorBlock block=info.levels.get(level);
      assertTrue(block.dataCodewords < block.codewords);
      int byteBlockB=block.codewords + 1;
      int byteDataB=block.dataCodewords + 1;
      int countB=(info.codewords - block.codewords * block.blocks);
      assertTrue(countB >= 0);
      if (countB > 0) {
        assertTrue(countB % byteBlockB == 0);
        countB/=byteBlockB;
        assertEquals(info.codewords,block.codewords * block.blocks + byteBlockB * countB);
        assertTrue(byteDataB < byteBlockB);
      }
    }
  }
}
Program: 150634
Project: 150634
Buggy source:
protected void bitsToMessage(PackedBits8 stream){
}

Fixed version (ground truth):
protected void bitsToMessage(PackedBits8 stream){
  stream.append(0,(8 - (stream.size % 8)) % 8,false);
  QrCode.VersionInfo info=QrCode.VERSION_INFO[qr.version];
  QrCode.ErrorBlock block=info.levels.get(qr.error);
  qr.dataRaw=new byte[info.codewords];
  int wordsBlockAllA=block.codewords;
  int wordsBlockDataA=block.dataCodewords;
  int wordsEcc=wordsBlockAllA - wordsBlockDataA;
  int numBlocksA=block.eccBlocks;
  int wordsBlockAllB=wordsBlockAllA + 1;
  int wordsBlockDataB=wordsBlockDataA + 1;
  int numBlocksB=(info.codewords - wordsBlockAllA * numBlocksA) / wordsBlockAllB;
  input.resize(wordsBlockDataA + 1);
  int startEcc=numBlocksA * wordsBlockDataA + numBlocksB * wordsBlockDataB;
  int totalBlocks=numBlocksA + numBlocksB;
  codes.generator(wordsEcc);
  ecc.resize(wordsEcc);
  encodeBlocks(stream,wordsBlockDataA,numBlocksA,0,0,startEcc,totalBlocks);
  encodeBlocks(stream,wordsBlockDataB,numBlocksB,wordsBlockDataA * numBlocksA,numBlocksA,startEcc,totalBlocks);
}
Program: 150635
Project: 150635
Buggy source:
/** 
 * Renders the raw data bit output while applying the selected mask
 */
private void renderData(){
  QrCodeMaskPattern mask=qr.mask;
  int count=0;
  while (count < bitLocations.size()) {
    int bits=qr.dataRaw[count / 8] & 0xFF;
    int N=Math.min(8,bitLocations.size() - count);
    for (int i=0; i < N; i++) {
      Point2D_I32 coor=bitLocations.get(count + i);
      int value=mask.apply(coor.y,coor.x,((bits >> i) & 0x01));
      if (value > 0) {
        square(coor.y,coor.x);
      }
    }
    count+=8;
  }
}

Fixed version (ground truth):
/** 
 * Renders the raw data bit output while applying the selected mask
 */
private void renderData(){
  QrCodeMaskPattern mask=qr.mask;
  int count=0;
  int length=bitLocations.size() - bitLocations.size() % 8;
  while (count < length) {
    int bits=qr.dataRaw[count / 8] & 0xFF;
    int N=Math.min(8,bitLocations.size() - count);
    for (int i=0; i < N; i++) {
      Point2D_I32 coor=bitLocations.get(count + i);
      int value=mask.apply(coor.y,coor.x,((bits >> i) & 0x01));
      if (value > 0) {
        square(coor.y,coor.x);
      }
    }
    count+=8;
  }
}
Program: 150636
Project: 150636
Buggy source:
/** 
 * Generates a QR Code with the specified message. An exception is thrown if the message is too long to be encoded.
 */
public void render(QrCode qr){
  this.qr=qr;
  this.numModules=QrCode.totalModules(qr.version);
  this.moduleWidth=markerWidth / numModules;
  init();
  positionPattern(0,0,qr.ppCorner);
  positionPattern((numModules - 7) * moduleWidth,0,qr.ppRight);
  positionPattern(0,(numModules - 7) * moduleWidth,qr.ppDown);
  timingPattern(7 * moduleWidth,6 * moduleWidth,moduleWidth,0);
  timingPattern(6 * moduleWidth,7 * moduleWidth,0,moduleWidth);
  formatInformation();
  if (qr.version >= QrCode.VERSION_VERSION)   versionInformation();
  int alignment[]=QrCode.VERSION_INFO[qr.version].alignment;
  for (int i=0; i < alignment.length; i++) {
    int row=alignment[i];
    for (int j=0; j < alignment.length; j++) {
      if (i == 0 & j == 0)       continue;
      if (i == alignment.length - 1 & j == 0)       continue;
      if (i == alignment.length - 1 & j == alignment.length - 1)       continue;
      int col=alignment[j];
      alignmentPattern(col,numModules - row - 1);
    }
  }
  bitLocations=new QrCodeCodeWordLocations(numModules,alignment,qr.version >= QrCode.VERSION_VERSION).bits;
  int numBytes=bitLocations.size() / 8;
  if (numBytes != qr.dataRaw.length)   throw new RuntimeException("String_Node_Str");
  renderData();
}

Fixed version (ground truth):
/** 
 * Generates a QR Code with the specified message. An exception is thrown if the message is too long to be encoded.
 */
public void render(QrCode qr){
  this.qr=qr;
  this.numModules=QrCode.totalModules(qr.version);
  this.moduleWidth=markerWidth / numModules;
  if (qr.dataRaw.length != QrCode.VERSION_INFO[qr.version].codewords)   throw new RuntimeException("String_Node_Str");
  init();
  positionPattern(0,0,qr.ppCorner);
  positionPattern((numModules - 7) * moduleWidth,0,qr.ppRight);
  positionPattern(0,(numModules - 7) * moduleWidth,qr.ppDown);
  timingPattern(7 * moduleWidth,6 * moduleWidth,moduleWidth,0);
  timingPattern(6 * moduleWidth,7 * moduleWidth,0,moduleWidth);
  formatInformation();
  if (qr.version >= QrCode.VERSION_VERSION)   versionInformation();
  int alignment[]=QrCode.VERSION_INFO[qr.version].alignment;
  for (int i=0; i < alignment.length; i++) {
    int row=alignment[i];
    for (int j=0; j < alignment.length; j++) {
      if (i == 0 & j == 0)       continue;
      if (i == alignment.length - 1 & j == 0)       continue;
      if (i == alignment.length - 1 & j == alignment.length - 1)       continue;
      int col=alignment[j];
      alignmentPattern(col,numModules - row - 1);
    }
  }
  bitLocations=new QrCodeCodeWordLocations(qr.version).bits;
  int numBytes=bitLocations.size() / 8;
  if (numBytes != qr.dataRaw.length)   throw new RuntimeException("String_Node_Str");
  renderData();
}
Program: 150637
Project: 150637
Buggy source:
@Test public void savePolyline(){
  PolylineSplitMerge alg=new PolylineSplitMerge();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.addCorner(0).object.sideError=10;
  alg.addCorner(0);
  alg.addCorner(0);
  alg.addCorner(0);
  alg.savePolyline(20);
  assertTrue(alg.getPolylines().get(1).score > 0);
  assertEquals(4,alg.getPolylines().get(1).splits.size);
  fail("String_Node_Str");
}

Fixed version (ground truth):
@Test public void savePolyline(){
  PolylineSplitMerge alg=new PolylineSplitMerge();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.getPolylines().grow();
  alg.addCorner(0).object.sideError=10;
  alg.addCorner(0);
  alg.addCorner(0);
  alg.addCorner(0);
  alg.savePolyline();
  assertTrue(alg.getPolylines().get(1).score > 0);
  assertEquals(4,alg.getPolylines().get(1).splits.size);
  fail("String_Node_Str");
}
Program: 150638
Project: 150638
Buggy source:
@Override protected List<Polygon2D_F64> getFoundPolygons(){
  return alg.getFindSeeds().getDetectorSquare().getPolygons(null);
}

Fixed version (ground truth):
@Override protected List<Polygon2D_F64> getFoundPolygons(){
  return alg.getFindSeeds().getDetectorSquare().getPolygons(null,null);
}
Program: 150639
Project: 150639
Buggy source:
@Override protected List<Polygon2D_F64> getFoundPolygons(){
  return alg.getDetectorSquare().getPolygons(null);
}

Fixed version (ground truth):
@Override protected List<Polygon2D_F64> getFoundPolygons(){
  return alg.getDetectorSquare().getPolygons(null,null);
}
Program: 150641
Project: 150641
Buggy source:
/** 
 * Called when how the data is visualized has changed
 */
public void viewUpdated(){
  BufferedImage active=null;
  if (controls.selectedView == 0) {
    active=original;
  }
 else   if (controls.selectedView == 1) {
synchronized (this) {
      VisualizeBinaryData.renderBinary(detector.getBinaryImage(),false,work);
    }
    active=work;
    work.setRGB(0,0,work.getRGB(0,0));
  }
 else {
    Graphics2D g2=work.createGraphics();
    g2.setColor(Color.BLACK);
    g2.fillRect(0,0,work.getWidth(),work.getHeight());
    active=work;
  }
  guiImage.setBufferedImage(active);
  guiImage.setScale(controls.zoom);
  guiImage.repaint();
}

Fixed version (ground truth):
/** 
 * Called when how the data is visualized has changed
 */
public void viewUpdated(){
  BufferedImage active=null;
  if (controls.selectedView == 0) {
    active=original;
  }
 else   if (controls.selectedView == 1) {
synchronized (lockProcessing) {
      VisualizeBinaryData.renderBinary(detector.getBinaryImage(),false,work);
    }
    active=work;
    work.setRGB(0,0,work.getRGB(0,0));
  }
 else {
    Graphics2D g2=work.createGraphics();
    g2.setColor(Color.BLACK);
    g2.fillRect(0,0,work.getWidth(),work.getHeight());
    active=work;
  }
  guiImage.setBufferedImage(active);
  guiImage.setScale(controls.zoom);
  guiImage.repaint();
}
Program: 150642
Project: 150642
Buggy source:
protected void createDetector(boolean initializing){
  if (!initializing)   BoofSwingUtil.checkGuiThread();
synchronized (this) {
    ConfigThreshold configThresh=controls.polygonPanel.getThresholdPanel().createConfig();
    ConfigFiducialBinary configFid=controls.getConfig();
    final InputToBinary<GrayF32> binary=FactoryThresholdBinary.threshold(configThresh,GrayF32.class);
    final DetectPolygonBinaryGrayRefine<GrayF32> squareDetector=FactoryShapeDetector.polygon(configFid.squareDetector,GrayF32.class);
    detector=new Detector(configFid,binary,squareDetector);
  }
}

Fixed version (ground truth):
protected void createDetector(boolean initializing){
  if (!initializing)   BoofSwingUtil.checkGuiThread();
synchronized (lockProcessing) {
    ConfigThreshold configThresh=controls.polygonPanel.getThresholdPanel().createConfig();
    ConfigFiducialBinary configFid=controls.getConfig();
    final InputToBinary<GrayF32> binary=FactoryThresholdBinary.threshold(configThresh,GrayF32.class);
    final DetectPolygonBinaryGrayRefine<GrayF32> squareDetector=FactoryShapeDetector.polygon(configFid.squareDetector,GrayF32.class);
    detector=new Detector(configFid,binary,squareDetector);
  }
}
Program: 150643
Project: 150643
Buggy source:
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  final double timeInSeconds;
synchronized (this) {
    long before=System.nanoTime();
    detector.process((GrayF32)input);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  final double timeInSeconds;
synchronized (lockProcessing) {
    long before=System.nanoTime();
    detector.process((GrayF32)input);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}
Program: 150646
Project: 150646
Buggy source:
private static void processImages(String[] files,DetectPolygonBinaryGrayRefine<GrayU8> detector,ListDisplayPanel panel){
  for (  String fileName : files) {
    BufferedImage image=UtilImageIO.loadImage(UtilIO.pathExample(fileName));
    GrayU8 input=ConvertBufferedImage.convertFromSingle(image,null,GrayU8.class);
    GrayU8 binary=new GrayU8(input.width,input.height);
    int threshold=GThresholdImageOps.computeOtsu(input,0,255);
    ThresholdImageOps.threshold(input,binary,threshold,true);
    detector.process(input,binary);
    java.util.List<Polygon2D_F64> found=detector.getPolygons(null);
    Graphics2D g2=image.createGraphics();
    g2.setStroke(new BasicStroke(3));
    for (int i=0; i < found.size(); i++) {
      g2.setColor(Color.RED);
      VisualizeShapes.drawPolygon(found.get(i),true,g2,true);
      g2.setColor(Color.CYAN);
      VisualizeShapes.drawPolygonCorners(found.get(i),2,g2,true);
    }
    panel.addImage(image,new File(fileName).getName());
  }
}

Fixed version (ground truth):
private static void processImages(String[] files,DetectPolygonBinaryGrayRefine<GrayU8> detector,ListDisplayPanel panel){
  for (  String fileName : files) {
    BufferedImage image=UtilImageIO.loadImage(UtilIO.pathExample(fileName));
    GrayU8 input=ConvertBufferedImage.convertFromSingle(image,null,GrayU8.class);
    GrayU8 binary=new GrayU8(input.width,input.height);
    int threshold=GThresholdImageOps.computeOtsu(input,0,255);
    ThresholdImageOps.threshold(input,binary,threshold,true);
    detector.process(input,binary);
    java.util.List<Polygon2D_F64> found=detector.getPolygons(null,null);
    Graphics2D g2=image.createGraphics();
    g2.setStroke(new BasicStroke(3));
    for (int i=0; i < found.size(); i++) {
      g2.setColor(Color.RED);
      VisualizeShapes.drawPolygon(found.get(i),true,g2,true);
      g2.setColor(Color.CYAN);
      VisualizeShapes.drawPolygonCorners(found.get(i),2,g2,true);
    }
    panel.addImage(image,new File(fileName).getName());
  }
}
Program: 150647
Project: 150647
Buggy source:
public SplitMergeLineRefine_to_PointsToPolyline(double splitFraction,ConfigLength minimumSplit,int maxIterations,int refineIterations,double pruneSplitPentially,boolean loop){
  if (loop) {
    splitMerge=new SplitMergeLineFitLoop(splitFraction,minimumSplit,maxIterations);
  }
 else {
    splitMerge=new SplitMergeLineFitSegment(splitFraction,minimumSplit,maxIterations);
  }
  if (refineIterations > 0) {
    refine=new RefinePolyLineCorner(loop,refineIterations);
  }
  if (pruneSplitPentially > 0) {
    pruner=new MinimizeEnergyPrune(pruneSplitPentially);
  }
}

Fixed version (ground truth):
public SplitMergeLineRefine_to_PointsToPolyline(double splitFraction,ConfigLength minimumSplit,int maxIterations,int refineIterations,double pruneSplitPentially,boolean loop){
  minimumSplit=minimumSplit.copy();
  if (loop) {
    splitMerge=new SplitMergeLineFitLoop(splitFraction,minimumSplit,maxIterations);
  }
 else {
    splitMerge=new SplitMergeLineFitSegment(splitFraction,minimumSplit,maxIterations);
  }
  if (refineIterations > 0) {
    refine=new RefinePolyLineCorner(loop,refineIterations);
  }
  if (pruneSplitPentially > 0) {
    pruner=new MinimizeEnergyPrune(pruneSplitPentially);
  }
}
Program: 150648
Project: 150648
Buggy source:
/** 
 * Returns a list of all polygons with an edge threshold above the minimum
 */
public List<Polygon2D_F64> getPolygons(List<Polygon2D_F64> storage){
  if (storage == null)   storage=new ArrayList<>();
 else   storage.clear();
  List<DetectPolygonFromContour.Info> detections=detector.getFound().toList();
  for (int i=0; i < detections.size(); i++) {
    DetectPolygonFromContour.Info d=detections.get(i);
    if (d.computeEdgeIntensity() >= minimumRefineEdgeIntensity)     storage.add(d.polygon);
  }
  return storage;
}

Fixed version (ground truth):
/** 
 * Returns a list of all polygons with an edge threshold above the minimum
 * @param storageInfo Optional storage for info associated with polygons. Pruning is done so the info listand the returned polygon list are not in synch with each other
 */
public List<Polygon2D_F64> getPolygons(List<Polygon2D_F64> storage,List<DetectPolygonFromContour.Info> storageInfo){
  if (storage == null)   storage=new ArrayList<>();
 else   storage.clear();
  if (storageInfo != null)   storageInfo.clear();
  List<DetectPolygonFromContour.Info> detections=detector.getFound().toList();
  for (int i=0; i < detections.size(); i++) {
    DetectPolygonFromContour.Info d=detections.get(i);
    if (d.computeEdgeIntensity() >= minimumRefineEdgeIntensity) {
      storage.add(d.polygon);
      if (storageInfo != null) {
        storageInfo.add(d);
      }
    }
  }
  return storage;
}
Program: 150649
Project: 150649
Buggy source:
/** 
 * Specifies the image's intrinsic parameters and target size
 * @param width Width of the input image
 * @param height Height of the input image
 */
private void configure(int width,int height){
  labeled.reshape(width,height);
  this.minimumContour=minimumContourConfig.computeI(Math.min(width,height));
  this.minimumArea=Math.pow(this.minimumContour / 4.0,2);
  contourFinder.setMinContourSize(minimumContour);
  if (helper != null)   helper.setImageShape(width,height);
}

Fixed version (ground truth):
/** 
 * Specifies the image's intrinsic parameters and target size
 * @param width Width of the input image
 * @param height Height of the input image
 */
private void configure(int width,int height){
  labeled.reshape(width,height);
  this.minimumContour=minimumContourConfig.computeI(Math.min(width,height));
  this.minimumContour=Math.max(4,minimumContour);
  this.minimumArea=Math.pow(this.minimumContour / 4.0,2);
  contourFinder.setMinContourSize(minimumContour);
  if (helper != null)   helper.setImageShape(width,height);
}
Program: 150650
Project: 150650
Buggy source:
@Override public void checkValidity(){
}

Fixed version (ground truth):
@Override public void checkValidity(){
  minimumContour.checkValidity();
}
Program: 150651
Project: 150651
Buggy source:
/** 
 * Process the image and detect the calibration target
 * @param image Input image
 * @return true if a calibration target was found and false if not
 */
public boolean process(T image){
  configureContourDetector(image);
  binary.reshape(image.width,image.height);
  inputToBinary.process(image,binary);
  detectorSquare.process(image,binary);
  detectorSquare.refineAll();
  detectorSquare.getPolygons(found);
  clusters=s2c.process(found);
  c2g.process(clusters);
  List<SquareGrid> grids=c2g.getGrids();
  SquareGrid match=null;
  double matchSize=0;
  for (  SquareGrid g : grids) {
    if (g.columns != numCols || g.rows != numRows) {
      if (g.columns == numRows && g.rows == numCols) {
        tools.transpose(g);
      }
 else {
        continue;
      }
    }
    double size=tools.computeSize(g);
    if (size > matchSize) {
      matchSize=size;
      match=g;
    }
  }
  if (match != null) {
    if (tools.checkFlip(match)) {
      tools.flipRows(match);
    }
    tools.putIntoCanonical(match);
    if (!tools.orderSquareCorners(match))     return false;
    extractCalibrationPoints(match);
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Process the image and detect the calibration target
 * @param image Input image
 * @return true if a calibration target was found and false if not
 */
public boolean process(T image){
  configureContourDetector(image);
  binary.reshape(image.width,image.height);
  inputToBinary.process(image,binary);
  detectorSquare.process(image,binary);
  detectorSquare.refineAll();
  detectorSquare.getPolygons(found,null);
  clusters=s2c.process(found);
  c2g.process(clusters);
  List<SquareGrid> grids=c2g.getGrids();
  SquareGrid match=null;
  double matchSize=0;
  for (  SquareGrid g : grids) {
    if (g.columns != numCols || g.rows != numRows) {
      if (g.columns == numRows && g.rows == numCols) {
        tools.transpose(g);
      }
 else {
        continue;
      }
    }
    double size=tools.computeSize(g);
    if (size > matchSize) {
      matchSize=size;
      match=g;
    }
  }
  if (match != null) {
    if (tools.checkFlip(match)) {
      tools.flipRows(match);
    }
    tools.putIntoCanonical(match);
    if (!tools.orderSquareCorners(match))     return false;
    extractCalibrationPoints(match);
    return true;
  }
  return false;
}
Program: 150653
Project: 150653
Buggy source:
@Test public void computePotentialSplitScore(){
  PolylineSplitMerge alg=new PolylineSplitMerge();
  alg.setMinimumSideLength(5);
  alg.setThresholdSideSplitScore(0);
  List<Point2D_I32> contour=new ArrayList<>();
  for (int i=0; i < 20; i++) {
    contour.add(new Point2D_I32(i,0));
  }
  contour.get(3).y=5;
  contour.get(15).y=5;
  contour.get(10).y=20;
  alg.addCorner(0);
  alg.addCorner(19);
  Element<Corner> e=alg.list.getHead();
  e.object.sideError=20;
  alg.computePotentialSplitScore(contour,e);
  assertTrue(e.object.splitable);
  assertTrue(e.object.splitError0 > 0);
  assertTrue(e.object.splitError1 > 0);
  assertEquals(10,e.object.splitLocation);
}

Fixed version (ground truth):
@Test public void computePotentialSplitScore(){
  PolylineSplitMerge alg=new PolylineSplitMerge();
  alg.setMinimumSideLength(5);
  alg.setThresholdSideSplitScore(0);
  List<Point2D_I32> contour=new ArrayList<>();
  for (int i=0; i < 20; i++) {
    contour.add(new Point2D_I32(i,0));
  }
  contour.get(3).y=5;
  contour.get(15).y=5;
  contour.get(10).y=20;
  alg.addCorner(0);
  alg.addCorner(19);
  Element<Corner> e=alg.list.getHead();
  e.object.sideError=20;
  alg.computePotentialSplitScore(contour,e,false);
  assertTrue(e.object.splitable);
  assertTrue(e.object.splitError0 > 0);
  assertTrue(e.object.splitError1 > 0);
  assertEquals(10,e.object.splitLocation);
}
Program: 150654
Project: 150654
Buggy source:
/** 
 * Computes the error locator polynomial using  Berlekamp-Massey algorithm [1] <p>[1] Massey, J. L. (1969), "Shift-register synthesis and BCH decoding" (PDF), IEEE Trans. Information Theory, IT-15 (1): 122–127</p>
 * @param syndromes (Input) The syndromes
 * @param errorLocator (Output) Error locator polynomial. Coefficients are large to small.
 */
void findErrorLocatorPolynomialBM(GrowQueue_I8 syndromes,GrowQueue_I8 errorLocator){
  GrowQueue_I8 C=errorLocator;
  GrowQueue_I8 B=new GrowQueue_I8();
  initToOne(C,syndromes.size + 1);
  initToOne(B,syndromes.size + 1);
  GrowQueue_I8 tmp=new GrowQueue_I8(syndromes.size);
  int b=1;
  for (int n=0; n < syndromes.size; n++) {
    int delta=syndromes.data[n] & 0xFF;
    for (int j=1; j < C.size; j++) {
      delta^=math.multiply(C.data[C.size - j - 1] & 0xFF,syndromes.data[n - j] & 0xFF);
    }
    B.data[B.size++]=0;
    if (delta != 0) {
      int scale=math.multiply(delta,math.inverse(b));
      math.polyAddScaleB(C,B,scale,tmp);
      if (2 * C.size > syndromes.size) {
      }
 else {
        B.setTo(C);
        b=delta;
      }
      C.setTo(tmp);
    }
  }
  removeLeadingZeros(C);
}

Fixed version (ground truth):
/** 
 * Computes the error locator polynomial using  Berlekamp-Massey algorithm [1] <p>[1] Massey, J. L. (1969), "Shift-register synthesis and BCH decoding" (PDF), IEEE Trans. Information Theory, IT-15 (1): 122–127</p>
 * @param syndromes (Input) The syndromes
 * @param errorLocator (Output) Error locator polynomial. Coefficients are large to small.
 */
void findErrorLocatorPolynomialBM(GrowQueue_I8 syndromes,GrowQueue_I8 errorLocator){
  GrowQueue_I8 C=errorLocator;
  GrowQueue_I8 B=new GrowQueue_I8();
  initToOne(C,syndromes.size + 1);
  initToOne(B,syndromes.size + 1);
  GrowQueue_I8 tmp=new GrowQueue_I8(syndromes.size);
  int b=1;
  for (int n=0; n < syndromes.size; n++) {
    int delta=syndromes.data[n] & 0xFF;
    for (int j=1; j < C.size; j++) {
      delta^=math.multiply(C.data[C.size - j - 1] & 0xFF,syndromes.data[n - j] & 0xFF);
    }
    B.data[B.size++]=0;
    if (delta != 0) {
      int scale=math.multiply(delta,math.inverse(b));
      math.polyAddScaleB(C,B,scale,tmp);
      if (B.size <= C.size) {
      }
 else {
        B.setTo(C);
        b=delta;
      }
      C.setTo(tmp);
    }
  }
  removeLeadingZeros(C);
}
Program: 150655
Project: 150655
Buggy source:
/** 
 * Randomly correct the message and ECC. See if the message is correctly reconstructed.
 */
@Test public void correctErrors_random(){
  GrowQueue_I8 ecc=new GrowQueue_I8();
  GrowQueue_I8 syndromes=new GrowQueue_I8();
  GrowQueue_I8 errorLocator=new GrowQueue_I8();
  GrowQueue_I32 locations=new GrowQueue_I32();
  int nsyn=10;
  ReidSolomonCodes alg=new ReidSolomonCodes(8,primitive8);
  alg.generator(nsyn);
  for (int i=0; i < 2000; i++) {
    GrowQueue_I8 message=randomMessage(100);
    GrowQueue_I8 corrupted=message.copy();
    int numErrors=4;
    int eccErrors=0;
    for (int j=0; j < numErrors; j++) {
      int selected=rand.nextInt(message.size);
      corrupted.data[selected]^=(0x12 + j);
    }
    alg.computeECC(message,ecc);
    int N=message.size + ecc.size;
    alg.computeSyndromes(corrupted,ecc,syndromes);
    alg.findErrorLocatorPolynomialBM(syndromes,errorLocator);
    if (!alg.findErrorLocations_BruteForce(errorLocator,N,locations)) {
      fail("String_Node_Str" + numErrors + "String_Node_Str"+ eccErrors);
    }
    alg.correctErrors(corrupted,N,syndromes,errorLocator,locations);
    assertEquals(corrupted.size,message.size);
    for (int j=0; j < corrupted.size; j++) {
      assertEquals(corrupted.get(j),message.get(j));
    }
  }
}

Fixed version (ground truth):
/** 
 * Randomly correct the message and ECC. See if the message is correctly reconstructed.
 */
@Test public void correctErrors_random(){
  GrowQueue_I8 ecc=new GrowQueue_I8();
  GrowQueue_I8 syndromes=new GrowQueue_I8();
  GrowQueue_I8 errorLocator=new GrowQueue_I8();
  GrowQueue_I32 locations=new GrowQueue_I32();
  int nsyn=10;
  ReidSolomonCodes alg=new ReidSolomonCodes(8,primitive8);
  alg.generator(nsyn);
  for (int i=0; i < 20000; i++) {
    GrowQueue_I8 message=randomMessage(10);
    GrowQueue_I8 corrupted=message.copy();
    alg.computeECC(message,ecc);
    int numErrors=rand.nextInt(6);
    int eccErrors=0;
    for (int j=0; j < numErrors; j++) {
      int selected=rand.nextInt(message.size);
      corrupted.data[selected]^=(0x12 + j);
    }
    if (numErrors < 5 && rand.nextInt(5) < 1) {
      numErrors++;
      ecc.data[rand.nextInt(ecc.size)]^=0x13;
    }
    int N=message.size + ecc.size;
    alg.computeSyndromes(corrupted,ecc,syndromes);
    alg.findErrorLocatorPolynomialBM(syndromes,errorLocator);
    if (!alg.findErrorLocations_BruteForce(errorLocator,N,locations)) {
      message.printHex();
      System.out.println();
      corrupted.printHex();
      fail("String_Node_Str" + numErrors + "String_Node_Str"+ eccErrors);
    }
    alg.correctErrors(corrupted,N,syndromes,errorLocator,locations);
    assertEquals(corrupted.size,message.size);
    for (int j=0; j < corrupted.size; j++) {
      assertEquals(corrupted.get(j),message.get(j));
    }
  }
}
Program: 150656
Project: 150656
Buggy source:
/** 
 * Computes the split location and the score of the two new sides if it's split there
 */
void computePotentialSplitScore(List<Point2D_I32> contour,LinkedList.Element<Corner> e0){
  LinkedList.Element<Corner> e1=next(e0);
  e0.object.splitable=canBeSplit(contour,e0);
  if (e0.object.splitable) {
    splitter.selectSplitPoint(contour,e0.object.index,e1.object.index,resultsA);
    e0.object.splitLocation=resultsA.index;
    e0.object.splitScore0=scoreSide(contour,e0.object.index,resultsA.index);
    e0.object.splitScore1=scoreSide(contour,resultsA.index,e1.object.index);
  }
}

Fixed version (ground truth):
/** 
 * Computes the split location and the score of the two new sides if it's split there
 */
void computePotentialSplitScore(List<Point2D_I32> contour,LinkedList.Element<Corner> e0){
  LinkedList.Element<Corner> e1=next(e0);
  e0.object.splitable=canBeSplit(contour.size(),e0);
  if (e0.object.splitable) {
    splitter.selectSplitPoint(contour,e0.object.index,e1.object.index,resultsA);
    e0.object.splitLocation=resultsA.index;
    e0.object.splitScore0=computeSideError(contour,e0.object.index,resultsA.index);
    e0.object.splitScore1=computeSideError(contour,resultsA.index,e1.object.index);
  }
}
Program: 150657
Project: 150657
Buggy source:
/** 
 * See if removing a corner will improve the overall score. If it will remove the score remove the corner (merging two sides)
 * @param contour Shape's contour
 * @param target The corner which is to be removed
 * @param scoreCurrent Score of the current polygon
 */
private void considerAndRemoveCorner(List<Point2D_I32> contour,LinkedList.Element<Corner> target,double scoreCurrent){
  LinkedList.Element<Corner> p=previous(target);
  LinkedList.Element<Corner> n=next(target);
  double sumSides=0;
  LinkedList.Element<Corner> e=list.getHead();
  while (e != null) {
    sumSides+=e.object.sideScore;
    e=e.next;
  }
  sumSides-=target.object.sideScore + p.object.sideScore;
  double scoreNewSide=scoreSide(contour,p.object.index,n.object.index);
  sumSides+=scoreNewSide;
  double scoreNoCorner=sumSides / (list.size() - 1) + cornerScorePenalty * (list.size() - 1);
  if (scoreNoCorner < scoreCurrent) {
    list.remove(target);
    p.object.splitLocation=target.object.index;
    p.object.splitScore0=target.object.sideScore;
    p.object.splitScore1=n.object.sideScore;
    p.object.sideScore=scoreNewSide;
    savePolyline();
  }
}

Fixed version (ground truth):
/** 
 * See if removing a corner will improve the overall score. If it will remove the score remove the corner (merging two sides)
 * @param contour Shape's contour
 * @param target The corner which is to be removed
 * @param scoreCurrent Score of the current polygon
 */
private void considerAndRemoveCorner(List<Point2D_I32> contour,LinkedList.Element<Corner> target,double scoreCurrent){
  LinkedList.Element<Corner> p=previous(target);
  LinkedList.Element<Corner> n=next(target);
  double sumSides=0;
  LinkedList.Element<Corner> e=list.getHead();
  while (e != null) {
    sumSides+=e.object.sideScore;
    e=e.next;
  }
  sumSides-=target.object.sideScore + p.object.sideScore;
  double scoreNewSide=computeSideError(contour,p.object.index,n.object.index);
  sumSides+=scoreNewSide;
  double scoreNoCorner=sumSides / (list.size() - 1) + cornerScorePenalty * (list.size() - 1);
  if (scoreNoCorner < scoreCurrent) {
    list.remove(target);
    p.object.splitLocation=target.object.index;
    p.object.splitScore0=target.object.sideScore;
    p.object.splitScore1=n.object.sideScore;
    p.object.sideScore=scoreNewSide;
    savePolyline();
  }
}
Program: 150658
Project: 150658
Buggy source:
private boolean findInitialTriangle(List<Point2D_I32> contour){
  int cornerSeed=findCornerSeed(contour);
  if (convex) {
    if (!sanityCheckConvex(contour,0,cornerSeed))     return false;
  }
  splitter.selectSplitPoint(contour,0,cornerSeed,resultsA);
  splitter.selectSplitPoint(contour,cornerSeed,0,resultsB);
  if (splitter.compareScore(resultsA.score,resultsB.score) >= 0) {
    addCorner(resultsA.index);
    addCorner(cornerSeed);
  }
 else {
    addCorner(cornerSeed);
    addCorner(resultsA.index);
  }
  int index0=list.getHead().object.index;
  int index1=list.getHead().next.object.index;
  splitter.selectSplitPoint(contour,index0,index1,resultsA);
  addCorner(resultsA.index);
  LinkedList.Element<Corner> e=list.getHead();
  while (e != null) {
    LinkedList.Element<Corner> n=e.next;
    double score;
    if (n == null) {
      score=scoreSide(contour,e.object.index,list.getHead().object.index);
    }
 else {
      score=scoreSide(contour,e.object.index,n.object.index);
    }
    e.object.sideScore=score;
    e=n;
  }
  e=list.getHead();
  while (e != null) {
    computePotentialSplitScore(contour,e);
    e=e.next;
  }
  return true;
}

Fixed version (ground truth):
private boolean findInitialTriangle(List<Point2D_I32> contour){
  int cornerSeed=findCornerSeed(contour);
  if (convex) {
    if (!sanityCheckConvex(contour,0,cornerSeed))     return false;
  }
  splitter.selectSplitPoint(contour,0,cornerSeed,resultsA);
  splitter.selectSplitPoint(contour,cornerSeed,0,resultsB);
  if (splitter.compareScore(resultsA.score,resultsB.score) >= 0) {
    addCorner(resultsA.index);
    addCorner(cornerSeed);
  }
 else {
    addCorner(cornerSeed);
    addCorner(resultsA.index);
  }
  int index0=list.getHead().object.index;
  int index1=list.getHead().next.object.index;
  splitter.selectSplitPoint(contour,index0,index1,resultsA);
  addCorner(resultsA.index);
  LinkedList.Element<Corner> e=list.getHead();
  while (e != null) {
    LinkedList.Element<Corner> n=e.next;
    double score;
    if (n == null) {
      score=computeSideError(contour,e.object.index,list.getHead().object.index);
    }
 else {
      score=computeSideError(contour,e.object.index,n.object.index);
    }
    e.object.sideScore=score;
    e=n;
  }
  e=list.getHead();
  while (e != null) {
    computePotentialSplitScore(contour,e);
    e=e.next;
  }
  return true;
}
Program: 150659
Project: 150659
Buggy source:
public static void assignLine(List<Point2D_I32> contour,int indexA,int indexB,LineParametric2D_F64 line){
  Point2D_I32 endA=contour.get(indexA);
  Point2D_I32 endB=contour.get(indexB);
  line.p.x=endA.x;
  line.p.y=endA.y;
  line.slope.x=endB.x - endA.x;
  line.slope.y=endB.y - endA.y;
}

Fixed version (ground truth):
/** 
 * Assigns the line so that it passes through points A and B.
 */
public static void assignLine(List<Point2D_I32> contour,int indexA,int indexB,LineParametric2D_F64 line){
  Point2D_I32 endA=contour.get(indexA);
  Point2D_I32 endB=contour.get(indexB);
  line.p.x=endA.x;
  line.p.y=endA.y;
  line.slope.x=endB.x - endA.x;
  line.slope.y=endB.y - endA.y;
}
Program: 150660
Project: 150660
Buggy source:
/** 
 * For convex shapes no point along the contour can be farther away from A is from B. Thus the maximum number of points can't exceed a 1/2 circle. NOTE: indexA is probably the top left point in the contour, since that's how most contour algorithm scan but this isn't known for sure. If it was known you could make this requirement tighter.
 * @param contour Contour points
 * @param indexA index of first point
 * @param indexB index of second point
 * @return if it passes the sanity check
 */
static boolean sanityCheckConvex(List<Point2D_I32> contour,int indexA,int indexB){
  double d=Math.sqrt(distanceSq(contour.get(indexA),contour.get(indexB)));
  int maxAllowed=(int)(2 * Math.PI * d + 0.5);
  if (indexB - indexA > maxAllowed)   return false;
  if (indexA + contour.size() - indexB > maxAllowed)   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * For convex shapes no point along the contour can be farther away from A is from B. Thus the maximum number of points can't exceed a 1/2 circle. NOTE: indexA is probably the top left point in the contour, since that's how most contour algorithm scan but this isn't known for sure. If it was known you could make this requirement tighter.
 * @param contour Contour points
 * @param indexA index of first point
 * @param indexB index of second point
 * @return if it passes the sanity check
 */
static boolean sanityCheckConvex(List<Point2D_I32> contour,int indexA,int indexB){
  double d=Math.sqrt(distanceSq(contour.get(indexA),contour.get(indexB)));
  int maxAllowed=(int)(2 * Math.PI * d + 0.5);
  if (indexA > indexB) {
    int tmp=indexA;
    indexA=indexB;
    indexB=tmp;
  }
  if (indexB - indexA > maxAllowed)   return false;
  if (indexA + contour.size() - indexB > maxAllowed)   return false;
  return true;
}
Program: 150661
Project: 150661
Buggy source:
private void addCorner(int where){
  Corner c=corners.grow();
  c.index=where;
  list.pushTail(c);
}

Fixed version (ground truth):
void addCorner(int where){
  Corner c=corners.grow();
  c.index=where;
  list.pushTail(c);
}
Program: 150662
Project: 150662
Buggy source:
/** 
 * Determines if the side can be split again
 */
boolean canBeSplit(List<Point2D_I32> contour,LinkedList.Element<Corner> e0){
  LinkedList.Element<Corner> e1=next(e0);
  int length=CircularIndex.distance(e0.object.index,e1.object.index,contour.size());
  if (length < minimumSideLength) {
    return false;
  }
  return !(e0.object.sideScore <= perfectSideScore);
}

Fixed version (ground truth):
/** 
 * Determines if the side can be split again. A side can always be split as long as its >= the minimum length or that the side score is larger the the split threshold
 */
boolean canBeSplit(int contourSize,LinkedList.Element<Corner> e0){
  LinkedList.Element<Corner> e1=next(e0);
  int length=CircularIndex.distance(e0.object.index,e1.object.index,contourSize);
  if (length < minimumSideLength) {
    return false;
  }
  return !(e0.object.sideScore < thresholdSideSplitScore);
}
Program: 150663
Project: 150663
Buggy source:
protected void handleDirectory(){
  final CalibrateMonoPlanar calibrationAlg=new CalibrateMonoPlanar(detector);
  final CalibratedPlanarPanel gui;
switch (modeType) {
case PINHOLE:
    calibrationAlg.configurePinhole(zeroSkew,numRadial,tangential);
  gui=new MonoPlanarPanel();
break;
case UNIVERSAL:
calibrationAlg.configureUniversalOmni(zeroSkew,numRadial,tangential);
gui=new FisheyePlanarPanel();
break;
default :
throw new RuntimeException("String_Node_Str" + modeType);
}
File directory=new File(inputDirectory);
if (!directory.exists()) {
System.err.println("String_Node_Str");
System.err.println("String_Node_Str" + inputDirectory);
System.exit(0);
}
List<File> files=Arrays.asList(directory.listFiles());
Collections.sort(files);
if (files.isEmpty()) {
System.err.println("String_Node_Str");
System.err.println(inputDirectory);
System.exit(0);
}
boolean first=true;
for (File f : files) {
if (f.isDirectory() || f.isHidden()) continue;
BufferedImage buffered=UtilImageIO.loadImage(f.getPath());
if (buffered == null) continue;
GrayF32 image=ConvertBufferedImage.convertFrom(buffered,(GrayF32)null);
if (gui != null) {
gui.addImage(f);
if (first) {
first=false;
ShowImages.showWindow(gui,"String_Node_Str",true);
}
}
if (!calibrationAlg.addImage(image)) System.err.println("String_Node_Str" + f.getName());
}
final CameraModel intrinsic=calibrationAlg.process();
if (gui != null) {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
gui.setObservations(calibrationAlg.getObservations());
gui.setResults(calibrationAlg.getErrors());
gui.setCalibration(calibrationAlg.getZhangParam());
gui.setCorrection(intrinsic);
gui.repaint();
}
}
);
}
calibrationAlg.printStatistics();
System.out.println();
System.out.println("String_Node_Str" + modeType + "String_Node_Str");
System.out.println();
switch (modeType) {
case PINHOLE:
{
CameraPinholeRadial m=(CameraPinholeRadial)intrinsic;
switch (formatType) {
case BOOFCV:
CalibrationIO.save(m,outputFileName);
break;
case OPENCV:
UtilOpenCV.save(m,outputFileName);
break;
}
m.print();
}
break;
case UNIVERSAL:
{
CameraUniversalOmni m=(CameraUniversalOmni)intrinsic;
CalibrationIO.save(m,outputFileName);
m.print();
}
break;
default :
throw new RuntimeException("String_Node_Str" + modeType);
}
System.out.println();
System.out.println("String_Node_Str" + formatType);
System.out.println();
}

Fixed version (ground truth):
protected void handleDirectory(){
}
Program: 150665
Project: 150665
Buggy source:
/** 
 * Takes the detected squares and turns it into a list of   {@link PositionPatternNode}.
 */
private void squaresToPositionList(){
  this.positionPatterns.reset();
  List<DetectPolygonFromContour.Info> infoList=squareDetector.getPolygonInfo();
  for (int i=0; i < infoList.size(); i++) {
    DetectPolygonFromContour.Info info=infoList.get(i);
    if (info.hasInternal())     continue;
    double grayThreshold=(info.edgeInside + info.edgeOutside) / 2;
    if (!checkPositionPatternAppearance(info.polygon,(float)grayThreshold))     continue;
    squareDetector.refine(info);
    PositionPatternNode pp=this.positionPatterns.grow();
    pp.reset();
    pp.square=info.polygon;
    pp.grayThreshold=grayThreshold;
    graph.computeNodeInfo(pp);
  }
}

Fixed version (ground truth):
/** 
 * Takes the detected squares and turns it into a list of   {@link PositionPatternNode}.
 */
private void squaresToPositionList(){
  this.positionPatterns.reset();
  List<DetectPolygonFromContour.Info> infoList=squareDetector.getPolygonInfo();
  for (int i=0; i < infoList.size(); i++) {
    DetectPolygonFromContour.Info info=infoList.get(i);
    if (!info.hasInternal())     continue;
    double grayThreshold=(info.edgeInside + info.edgeOutside) / 2;
    if (!checkPositionPatternAppearance(info.polygon,(float)grayThreshold))     continue;
    squareDetector.refine(info);
    PositionPatternNode pp=this.positionPatterns.grow();
    pp.reset();
    pp.square=info.polygon;
    pp.grayThreshold=grayThreshold;
    graph.computeNodeInfo(pp);
  }
}
Program: 150667
Project: 150667
Buggy source:
public DetectQrCodeApp(List<String> examples,Class<T> imageType){
  super(examples,imageType);
  setupGui(new VisualizePanel(),new DetectQrCodeControlPanel(this));
}

Fixed version (ground truth):
public DetectQrCodeApp(List<String> examples,Class<T> imageType){
  super(examples,imageType);
  final VisualizePanel gui=new VisualizePanel();
  setupGui(gui,new DetectQrCodeControlPanel(this));
  gui.getImagePanel().addMouseListener(new MouseAdapter(){
    @Override public void mousePressed(    MouseEvent e){
      double scale=gui.getScale();
      System.out.printf("String_Node_Str",e.getX() / scale,e.getY() / scale);
    }
  }
);
}
Program: 150668
Project: 150668
Buggy source:
@Override public void actionPerformed(ActionEvent e){
  if (e.getSource() == imageView) {
    selectedView=imageView.getSelectedIndex();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showSquares) {
    bShowSquares=showSquares.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showPositionPattern) {
    bShowPositionPattern=showPositionPattern.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showContour) {
    bShowContour=showContour.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == setBorder) {
    config.polygon.detector.canTouchBorder=setBorder.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRefineContour) {
    config.polygon.refineContour=setRefineContour.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRefineGray) {
    bRefineGray=setRefineGray.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRemoveBias) {
    config.polygon.adjustForThresholdBias=setRemoveBias.isSelected();
    owner.configUpdate();
  }
}

Fixed version (ground truth):
@Override public void actionPerformed(ActionEvent e){
  if (e.getSource() == imageView) {
    selectedView=imageView.getSelectedIndex();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showSquares) {
    bShowSquares=showSquares.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showPositionPattern) {
    bShowPositionPattern=showPositionPattern.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showAlignmentPattern) {
    bShowAlignmentPattern=showAlignmentPattern.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == showContour) {
    bShowContour=showContour.isSelected();
    owner.viewUpdated();
  }
 else   if (e.getSource() == setBorder) {
    config.polygon.detector.canTouchBorder=setBorder.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRefineContour) {
    config.polygon.refineContour=setRefineContour.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRefineGray) {
    bRefineGray=setRefineGray.isSelected();
    owner.configUpdate();
  }
 else   if (e.getSource() == setRemoveBias) {
    config.polygon.adjustForThresholdBias=setRemoveBias.isSelected();
    owner.configUpdate();
  }
}
Program: 150670
Project: 150670
Buggy source:
/** 
 * Returns an algorithm for estimating a homography matrix given a set of  {@link AssociatedPair}.
 * @see HomographyLinear4
 * @param normalize If input is in pixel coordinates set to true.  False if in normalized image coordinates.
 * @return Homography estimator.
 */
public static Estimate1ofEpipolar computeHomography(boolean normalize){
  HomographyLinear4 alg=new HomographyLinear4(normalize);
  return new WrapHomographyLinear(alg);
}

Fixed version (ground truth):
/** 
 * Returns an algorithm for estimating a homography matrix given a set of  {@link AssociatedPair}.
 * @see HomographyLinear4
 * @param normalizeInput If input is in pixel coordinates set to true.  False if in normalized image coordinates.
 * @return Homography estimator.
 */
public static Estimate1ofEpipolar computeHomography(boolean normalizeInput){
  HomographyLinear4 alg=new HomographyLinear4(normalizeInput);
  return new WrapHomographyLinear(alg);
}