使用zxing检测二维码

发布于 2024-12-19 19:59:22 字数 106 浏览 1 评论 0原文

我正在努力检测二维码。我的要求是,当用户向摄像头显示他/她的二维码时,程序必须检测并在二维码周围绘制一个框。我正在使用 zxing 库 + C#。我搜索了很多东西,但找不到任何样本。请任何人帮助我。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜司空 2024-12-26 19:59:22

您可以为此使用检测器类。检测器构造函数将 BitMatrix 对象作为其唯一参数,该参数可以从 BinaryBitmap 对象的 BlackMatrix 属性中获取...

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.";
        }
    }

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.";
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文