惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
腾讯CDC
J
Java Code Geeks
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
云风的 BLOG
云风的 BLOG
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
雷峰网
雷峰网
B
Blog RSS Feed
博客园_首页
量子位
F
Fortinet All Blogs
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog

C#

.NET 11 的 async 性能改进过于逆天 - V2EX macos10.15 上如何配置 vscode C#环境 asp net core 的工作站模式和服务器模式的区别 C#上位机开发是用 winform 那种传统工业风还是 WPF 现代风 paddleocr 的 C#集成问题 C#中异步相关的问题 .NET 换新的异步编程模型了,性能很强 想念 C# 200 块有偿求助 C#高速读取串口,导致软件闪退的问题。 老师,我太想进步了——关于 C#学习 visual studio 2022 代码提示消失 Cursor 生成的代码有个大坑,排查了一晚上才找出原因 C# 有哪些显著的缺点? 有没有 Sematic Kernel 可以落地的应用推荐? 请教下 C#有没有办法用装饰器全局监控方法执行时间 想用 c#的 mvc 实现一个功能. Unity 双击 C#脚本默认打开 Visual Studio 没有代码提示如何解决? 请问 c#有没有一些能规范学习的生产管理系统开源项目? C#串口通信问题 求教 C# 怎么同时交叉编译 windows Linux mac ?跟 go 一样 ClosedXML 如何对一列数据设置高亮重复项?(高亮重复项是 Excel 的一种功能;不能手动给重复单元格设置背景颜色,这样的话用户删除重复项后不会自动去除高亮) 求推荐软件开发练习项目的教学视频或书籍 如何在 visual studio 2022 中新建单元测试项目时默认使用最新版本? C#有像 C++的 libevent 同样定位的高性能跨平台网络库吗? 求助,如何正確劫持系統 DLL 調用 C#生态里有啥简单一点的容易上手的开源后台管理系统吗? .NET6 HttpClient 无反应也不超时? 关于.NET6 httpclient 用 IPV6 还是 IPV4 的疑问 关于 C#调用 DLL 的疑惑 C#程序员开发手机页面有什么适合的 UI 框架?
C#的二维码摆渡解码遇到点问题
zhoufan47 · 2023-11-26 · via C#

之前在网上找到个 python 写的二维码摆渡程序,识别率颇高,但是 python 的 UI 界面实在难画,自己对 python 也不是很熟悉。 最近用 C#重写了一份,可以实现一些特定功能,但是发现无论是 ZXing.net 还是 Zbar ,识别效率和成功率对比之前 python 用的 CV2 打开摄像头+pyzbar 识别二维码的组合差很多很多。 python 下我是采用固定 10ms 读取摄像头识别一次,单次 6 图,效率大约是 60/s 。 c#下我是采用绑定 timer 的形式,20ms 触发一次从摄像头获取 bitmap ,送进 decoder 解码,效率只有 1/S ,甚至经常识别不出。 各位大佬帮忙看看。 C#核心代码

 private void decodeCurrentFrame()
    {
        if (graphics == null)
        {
            return;
        }
        //复制图像
        this.graphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
        this.pictureBox1.Image = this.bitmapSrc;
        Stopwatch sw = new Stopwatch();
        sw.Start();
        Bitmap bitmap = (Bitmap)this.bitmapSrc.Clone();
        //解码图片
        Result[] results = reader.DecodeMultiple(bitmap);
        //读取识别出来的二维码
        if (results != null)
        {
            foreach (Result result in results)
            {
                {
                    Console.WriteLine("成功识别");
                    string content = result.ToString();
                    if (content.Length <= 20)
                    {
                        return;
                    }
                    string prefix = content.Substring(0, 16); //获取文件前缀
                    string currentIndex = prefix.Substring(0, 8); //获取当前切片索引编号
                    string total = prefix.Substring(8); //获取总索引数
                    if (content.Contains("|"))
                    {
                        int prefixIndex = content.LastIndexOf("|");
                        int qrCurrentIndex = content.IndexOf("|");
                        currentIndex = content.Substring(0, qrCurrentIndex);
                        string raw = content.Substring(prefixIndex + 1);
                        content = "0000000000000000" + raw;
                        Console.WriteLine("旧版数据" + raw + "索引编号:" + currentIndex);
                    }
                    initResultMap(total);
                    dealData(currentIndex, content.Substring(16));
                    checkResultMap();
                }
            }
        }
        //统计数据
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        string costed = ts.TotalMilliseconds + "ms";
        labelTickCost.Text = costed;
    }
    

pyhon 核心代码

   def decodeDisplay(img):
        global number
        barcodes = pyzbar.decode(img)
        for barcode in barcodes:
            barcodeData = barcode.data.decode()
            try:
                i = int(barcodeData[:8])
            except ValueError:
                return img
            try:
                max = int(barcodeData[8:16])
            except ValueError:
                return img
            ll = ''

            if not os.path.exists("temp/result" + str(i) + ".txt"):
                barcodeData = barcodeData[16:]
                with open("temp/result" + str(i) + ".txt", "w+") as f:
                    f.write(barcodeData)
                    number = number + 1
                    global sat
                if number == max:
                    filecount = len(os.listdir('temp/result'))
                    if number != filecount:
                        number = filecount
                        continue
                    j = 1
                    while j <= number:
                        with open("temp/result" + str(j) + ".txt", "r+") as f:
                            txt = f.read()
                        ll = ll + txt
                        j = j + 1
                    global starttime
                    ent = time.time()
                    theLB.insert(END, "识别结束")
                    theLB.see(END)
                    with open("result/b64.txt", "w") as f:
                        f.write(ll)
                    temp = base64.b64decode(ll)
                    with open("result/result.txt", "wb") as f:
                        f.write(temp)
                    if tkinter.messagebox.askyesno(title='识别成功', message='另存为'):
                        old_path = tk.filedialog.askdirectory()
                        shutil.copy("result/result.txt", old_path)
                    theLB.insert(END, "识别成功")
                    del_file()
        return img