I'm working on detecting the qrcode. My requirement is when the user show’s his/her QR code to the camera, the program has to detect and draw one box around the QR code. I’m using zxing library + C#. I searched many things but I’m not able to find any samples in this. Kindly anyone help me in this.
You can use the detector class for this. The detector constructor takes a BitMatrix object as its sole argument which can be obtained from the BlackMatrix property of the BinaryBitmap object...
public string Detect(Bitmap bitmap)
{
try
{
com.google.zxing.LuminanceSource source = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);
var binarizer = new HybridBinarizer(source);
var binBitmap = new BinaryBitmap(binarizer);
BitMatrix bm = binBitmap.BlackMatrix;
Detector detector = new Detector(bm);
DetectorResult result = detector.detect();
string retStr = "Found at points ";
foreach (ResultPoint point in result.Points)
{
retStr += point.ToString() + ", ";
}
return retStr;
}
catch
{
return "Failed to detect QR code.";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With