C# 调用摄像头实时识别二维码

该博客介绍了如何使用C#编程语言调用摄像头进行实时的二维码识别。内容包括源码实现和winform控件的应用,读者需要下载源码进行详细学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注释和winform控件自己做,源码需要下载。

// 功能:调用zxing生成和解析二维码,调用摄像头根据图片识别二维 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge.Video.DirectShow;
using AForge.Video;
using com.google.zxing.common;
using com.google.zxing;

namespace CameraQRCode
{
   
    public partial class FrmCamera : Form
    {
   
        #region 变量定义
        ///调用AForge使用摄像头
        FilterInfoCollection Use_Webcams = null;
        VideoCaptureDevice cam = null;

        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        #endregion

        public FrmCamera()
        {
   
            InitializeComponent();
        }

        #region 事件

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmCamera_Load(object sender, EventArgs e)
        {
   
            ///初始化AForge内容
            Use_Webcams = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if (Use_Webcams.Count > 0)
            {
   
                //实例化对象
                cam = new VideoCaptureDevice(Use_Webcams[0].MonikerString);

                //绑定事件
                cam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);
            }

        }

        /// <summary>
        /// 生成二维码并保存图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnQRCode_Click(object sender
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值