I thing it's not about horizontal and vertical changing, but about
mapping image into linear array (named bits) in
com.google.zxing.common.BitMatrix class.
The image is saved into BitMatrix by rows, it is mapped into bits
array, but when detector try to find pattern, indexes are changed,
wrong bits are returned and pattern finder detects error.
Jiri Petras
This is my code for QRcode creation:
...
System.Drawing.Bitmap bMap =
(System.Drawing.Bitmap)image;
LuminanceSource source = new RGBLuminanceSource(bMap,
bMap.Width, bMap.Height);
BinaryBitmap bitmap = new BinaryBitmap(new
HybridBinarizer(source));
QRCodeReader dec = new QRCodeReader();
Hashtable hint = new Hashtable();
hint.Add(DecodeHintType.POSSIBLE_FORMATS,
BarcodeFormat.QR_CODE);
hint.Add(DecodeHintType.TRY_HARDER, true);
Result result = dec.decode(bitmap, hint);
...
You can see, I am using RGBLuminanceSource and HybridBinarizer for
converting source image into BinaryBitmap array.
Is here something wrong?
Thank's for answer.
Jiri Petras
on http://www.petras-cz.eu/QR/Error.qr.png you can find example of not
detected QR code, if I'm not mistaken :-)
JP
On Nov 28, 5:01 am, Bas Vijfwinkel <bas5win...@gmail.com> wrote:
I confirm, using the above C# code and compiled ZXing (C#) library
(from distribution 1.7) for decoding the above published QRcode image
Exception of type 'com.google.zxing.ReaderException' was thrown
(QRCode Matrix is not detected).
Try it.
Jiri Petras
On Nov 28, 4:59 pm, Steven Parkes <smpar...@smparkes.net> wrote:
> This decodes fine in both Java and C++ from the command line, i.e., if it doesn't decode on a device, it's probably code related to the device.
>
> On Nov 28, 2011, at 7:52 AM, Jiri Petras wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > onhttp://www.petras-cz.eu/QR/Error.qr.pngyou can find example of not
Sorry. I lost track of the fact that you were using the C# port. Thought you were using Java.
So that means it's probably bit rot in the C# port: something's been fixed in Java and C++ that hasn't gotten ported to C#.
Unless there are other things I've lost track of as well ...
The patch (for me) does not completely solve the problem but decrease
the errors.
This is the code I use to encode/decode the QRCode in C#:
****************** ENCODE ***********************
QRCodeWriter writer = new QRCodeWriter();
com.google.zxing.common.ByteMatrix matrix;
Hashtable hints = new Hashtable();
hints.Add(EncodeHintType.ERROR_CORRECTION, correctionLevel);
matrix = writer.encode(textToEncode, BarcodeFormat.QR_CODE, sizex,
sizey, hints);
Bitmap img = new Bitmap(sizex, sizey);
Color Color = Color.FromArgb(0, 0, 0);
for (int y = 0; y < matrix.Height; ++y)
{
for (int x = 0; x < matrix.Width; ++x)
{
Color pixelColor = img.GetPixel(x, y);
//Find the colour of the dot
if (matrix.get_Renamed(x, y) == -1)
img.SetPixel(x, y, Color.White);
else
img.SetPixel(x, y, Color.Black);
}
}
return img;
*******************************************
****************** DECODE ***********************
LuminanceSource ls = new RGBLuminanceSource(image, image.Width,
image.Height);
Result result = new QRCodeReader().decode(new BinaryBitmap(new
HybridBinarizer(ls)));
return result.Text;
*******************************************
I noted that, in the encode function, if I decrease the sizex and
sizex (for example from 200 to 120) the erroneous QRCode disappears.
And now some question:
- Are my methods right?
- Is the patch you suggest working for you with any dimension?
Thanks a lot
The only method for digging into this is to feed the C# and java core
library the same data and compare to see where
the data differs. The data should essentially be the same during the
whole decoding process.
It is a very tedious and time consuming process but that might be the
only way to hunt down the bug....
Maybe check if java casts and C# casts work in the same way.
When creating the actionscript port, I noticed that java and
actionscript don't handle float->int casts in the same way.
I don't know if the core library or perhaps some of the other ports
does have such a list for testing?