user1081305
user1081305

Reputation: 51

Required Qr code Detector sample using zxing

I'm a beginer in QR code application and now I'm trying to develop application to detect QR code in the image. but i count not find any reference/sample in it.I'm using Zbar crossing zxing library and C# for this .kindly guide me in this or refer me some sample code.

Upvotes: 2

Views: 4108

Answers (1)

Gert Arnold
Gert Arnold

Reputation: 109079

We've also experienced that it is hard to find working samples for zxing.Net. After combining some of them (I can't remember where we found them) and some trial and error we found this to be satisfactory (excerpt):

[DebuggerHidden]
string findQrCodeText(com.google.zxing.Reader decoder, Bitmap bitmap)
{
  var rgb = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);
  var hybrid = new com.google.zxing.common.HybridBinarizer(rgb);
  com.google.zxing.BinaryBitmap binBitmap = new com.google.zxing.BinaryBitmap(hybrid);
  string decodedString = decoder.decode(binBitmap, null).Text;
  return decodedString;
}

which is called by

findQrCodeText(new com.google.zxing.qrcode.QRCodeReader(), bitmap);

We do some image voodoo around that to obtain just a little better results, but I'm afraid can't disclose that. This piece of code is the zxing part, though.

We added the DebuggerHiddenAttribute because zxing throws and swallows tons of exceptions internally, which is a real PITA when running in debug mode.

Upvotes: 2

Related Questions