我正在研究二维码检测。我的需求是当用户向相机展示他/她的二维码时,程序必须检测并在二维码周围绘制一个框。我正在使用zxing库和C#语言。我搜索了很多内容,但是我找不到任何相关样例。请帮忙解决这个问题。
我正在研究二维码检测。我的需求是当用户向相机展示他/她的二维码时,程序必须检测并在二维码周围绘制一个框。我正在使用zxing库和C#语言。我搜索了很多内容,但是我找不到任何相关样例。请帮忙解决这个问题。
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.";
}
}