Search code examples
javabarcodezxing

The method WhiteRectangleDetector is undefined for the type main


I'm trying to use the WhiteRectangleDetector() function with the zxing library with Java (Eclipse). I added the core-3.3.0.jar and javase-3.3.0.jar as User-Library.

LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

Reader reader = new MultiFormatReader();
result = reader.decode(bitmap);
ResultPoint[] scannedCoord = result.getResultPoints();

System.out.println("ResultPoint 1: " + scannedCoord[0]); 
System.out.println("ResultPoint 2: " + scannedCoord[1]);

System.out.println("\n Barcode text is " + result.getText() + "\n");

System.out.println("-------------------------------------------------------------------");

BitMatrix bitMatrix = bitmap.getBlackMatrix();
System.out.println(bitMatrix.getTopLeftOnBit());
System.out.println(bitMatrix.getBottomRightOnBit());

ResultPoint[] wrpts = WhiteRectangleDetector(bitMatrix);

I get this error message: The method WhiteRectangleDetector(BitMatrix) is undefined for the type main!


Solution

  • WhiteRectangleDetector is a class, not method. To use it you need to create an instance of it with a new call:

    WhiteRectangleDetector detector = new WhiteRectangleDetector(bitMatrix);
    //now you can call methods
    ResultPoint[] wrpts = detector.detect();