In a first step I use opencv to find barcode areas. This works well and I have 300dpi images which only contain one barcode and nothing else.
Unfortunately zxing only detects 13 of my 17 test codes.
I am able to scan all failed codes with the android app directly from my computer screen.
I believe that the app uses the same core library as my java programme.
core-3.2.1.jar
javase-3.2.1.jar
Here is my code to find the barcode:
LuminanceSource lumSource = new BufferedImageLuminanceSource(scanImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(lumSource));
Map<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
try {
// Look for barcode
Result result = reader.decode(bitmap, hints);
...
I attached one of the failed images.
If I leave
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
only 2 codes are recognized.
I also checked the bitmap.getBitMatrix() and wrote it back to a BufferedImage. The result was exactly the barcode image.
I have no idea what else to try but i am sure that there is a solution since the android app is able to decode the image.
Thanks
Peter
I elimanted pixels with some neighbour conditions and now all 17 codes are recognized.
See attached file with the processed image from my first post. I will spend some further research on this and make it more flexible.
The android app recognized the code in the processed image much faster than in the original one.
That is a wide topic and commercial tools seem to have a lot of built in extras to improve recognition.
Cheers
BitMatrix matrix = bitmap.getBlackMatrix();
When I rerun
reader.decode(bitmap, hints);
after modification of the BitMatrix the reader still processed the old data. For a start I created a new BufferedImage + LuminanceSource + BitMap
Is there a way to manipulate the BitMatrix and rerun the reader?