C# 编写简单二维码条形码工具

news2025/2/5 4:52:37

C# 二维码条形码工具


该工具简单实现了二维码条形码生成与识别功能,识别方式:通过摄像头实时识别或通过图片文件识别。

在这里插入图片描述

using AForge.Genetic;
using AForge.Video.DirectShow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ZXing;
using ZXing.Common;
using ZXing.OneD;
using ZXing.QrCode;
using ZXing.QrCode.Internal;
using ZXing.Rendering;
using static System.Runtime.CompilerServices.RuntimeHelpers;

namespace BarCodeTools
{
    public partial class FormMain : Form
    {
        private Bitmap bitmap;
        private ImageFormat imgFormat = ImageFormat.Bmp; // 保存图片格式

        private string openPath = "";   // 识别图片路径
        //private string savePath = "";   // 图片保存路径
        private string logoPath = "";   // 二维码LOGO图片路径
        //private int cameraIndex = 0;    // 选择的摄像头Index

        private Color BackgroundColor = Color.White;
        private Color ForegroundColor = Color.Black;
  
        private FilterInfoCollection videoFilter;       // 摄像头设备集合
        private VideoCaptureDevice videoCaptureDevice;  // 捕获设备源

        public FormMain()
        {
            InitializeComponent();
        }

        private static Bitmap RemoveWhiteMargin(ZXing.Common.BitMatrix bitMatrix, Bitmap bitmap)
        {
            //获取参数
            int[] rec = bitMatrix.getEnclosingRectangle();
            int left = rec[0];
            int top = rec[1];
            int width = rec[2];
            int height = rec[3];
            Bitmap newImg = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(newImg);
            //截取
            g.DrawImage(bitmap, 0, 0, new Rectangle(left, top, newImg.Width, newImg.Height), GraphicsUnit.Pixel);
            return newImg;
        }


        /// <summary>
        /// 生成条形码
        /// </summary>
        /// <returns></returns>
        private Bitmap GenerateBarCode()
        {             
            BarcodeWriter barCodeWriter = new BarcodeWriter();
            EAN8Writer eAN8Writer = new EAN8Writer();
            EAN13Writer eAN13Writer = new EAN13Writer();
            UPCAWriter upCAWriter = new UPCAWriter();
            UPCEWriter UPCEWriter = new UPCEWriter();

            EncodingOptions options = new EncodingOptions()
            {
                Width = Convert.ToInt32(numBarCodeWidth.Value),
                Height = Convert.ToInt32(numBarCodeHeigh.Value),
                Margin = Convert.ToInt32(numBarCodeMargin.Value),
            };
                               
            barCodeWriter.Options = options;
            
            string text = textBoxBarCodeText.Text.Trim();

            if (cmboxBarCodeFormat.Text == "CODE_128")
            {
                barCodeWriter.Format = BarcodeFormat.CODE_128;
            }
            else if (cmboxBarCodeFormat.Text == "CODE_39") {
                barCodeWriter.Format = BarcodeFormat.CODE_39;
            }
            else if (cmboxBarCodeFormat.Text == "CODE_93")
            {
                barCodeWriter.Format = BarcodeFormat.CODE_93;
            }            
            else if (cmboxBarCodeFormat.Text == "EAN_13")
            {
                // 输入信息必须是12位数字,不能有字母
                barCodeWriter.Format = BarcodeFormat.EAN_13;
            }
            else if (cmboxBarCodeFormat.Text == "EAN_8")
            {
                // 输入信息必须是7位数字,不能有字母
                barCodeWriter.Format = BarcodeFormat.EAN_8;
            }
            else if (cmboxBarCodeFormat.Text == "UPC_A")
            {
                // 输入信息必须是11位数字,不能有字母
                barCodeWriter.Format = BarcodeFormat.UPC_A;
            }
            else if (cmboxBarCodeFormat.Text == "UPC_E")
            {
                // 输入信息必须是7位数字,不能有字母,且第一位只能是0或1
                barCodeWriter.Format = BarcodeFormat.UPC_E;
            }

            Bitmap map = null;
            try { 
                map = barCodeWriter.Write(text);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "条形码生成错误");
                Console.WriteLine(e.ToString());
            }
            return map;
        }


        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <returns></returns>
        private Bitmap GenerateQrCode()
        {
            BarcodeWriter barcodeWriter = new BarcodeWriter();
            barcodeWriter.Format = BarcodeFormat.QR_CODE;
            QrCodeEncodingOptions options = new QrCodeEncodingOptions();
            options.DisableECI = false;
            options.CharacterSet = "UTF-8";
            options.Width = Convert.ToInt32(numQrCodeWidth.Value);
            options.Height = Convert.ToInt32(numQrCodeHeight.Value);
            options.Margin = Convert.ToInt32(numQrCodeMargin.Value);          
            barcodeWriter.Options = options;

            barcodeWriter.Renderer = new BitmapRenderer
            {
                Background = BackgroundColor, //Color.White,
                Foreground = ForegroundColor  //Color.Black
            };

            Bitmap map = null;
            try
            {
                string text = richTextBoxQrCode.Text.Trim();
                map = barcodeWriter.Write(text);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "二维码生成错误", MessageBoxButtons.OK, MessageBoxIcon.Error);                
            }          

            return map;
        }


        private Bitmap GenerateQrCodeWithLogo()
        {
            Bitmap bmpimg = null; // 最终生成的二维码图片

            // 载入Logo图片
            Bitmap logo = new Bitmap(logoPath);

            // 构造二维码写码器
            MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
            Dictionary<EncodeHintType, object> hint = new Dictionary<EncodeHintType, object>();
            hint.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
            hint.Add(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);

            // 生成二维码
            string text = richTextBoxQrCode.Text.Trim();
            Int32 width = Convert.ToInt32(numQrCodeWidth.Value);
            Int32 height = Convert.ToInt32(numQrCodeHeight.Value);
            BitMatrix bm = multiFormatWriter.encode(text, BarcodeFormat.QR_CODE, width, height, hint);
            BarcodeWriter barcodeWriter = new BarcodeWriter();            
            barcodeWriter.Renderer = new BitmapRenderer
            {
                Background = BackgroundColor, //Color.White,
                Foreground = ForegroundColor //Color.Black
            };
            Bitmap qrcode_map = barcodeWriter.Write(bm);


            // h获取二维码实际尺寸(去掉二维码两边空白后的尺寸)
            int[] rectangle = bm.getEnclosingRectangle();

            // 计算LOGO图片插入的大小位置信息
            int W = Math.Min((int)(rectangle[2] / 3.5), logo.Width);
            int H = Math.Min((int)(rectangle[3] / 3.5), logo.Height);
            int L = (qrcode_map.Width - W) / 2;
            int T = (qrcode_map.Height - H) / 2;

#if true
            // 将img转换成bmp格式,否则后面无法创建Graphics对象
            bmpimg = new Bitmap(qrcode_map.Width, qrcode_map.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (Graphics g = Graphics.FromImage(bmpimg))
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                g.DrawImage(qrcode_map, 0, 0);
            }

            // 将二维码插入到图片
            Graphics mGraphics = Graphics.FromImage(bmpimg);

            // 白底
            mGraphics.FillRectangle(Brushes.White, L, T, W, H);
            mGraphics.DrawImage(logo, L, T, W, H);
#endif
            return bmpimg;
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            timer1.Interval = 200;  // 摄像头实时识别周期
        }

        //-----------------------------------生成条形码------------------------------------------------------

        private void btnBarCodeGenerate_Click(object sender, EventArgs e)
        {
            
            bitmap = GenerateBarCode();

            //bitmap.Save("");

            if (bitmap != null) { 
                pictureBoxBarCodePreView.Image = Image.FromHbitmap(bitmap.GetHbitmap());
            }

           //bitmap.Dispose();
        }

        private void btnBarCodeSave_Click(object sender, EventArgs e)
        {
            if (bitmap == null) {
                MessageBox.Show("请先生成条形码","图片保存失败");
                return;
            }

            try {
                //bitmap.Save(textBoxBarCodeSavePath.Text.Trim(), System.Drawing.Imaging.ImageFormat.Png);
                bitmap.Save(textBoxBarCodeSavePath.Text.Trim(), imgFormat);
                MessageBox.Show("图片保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片保存失败"+ex.ToString());
            }            
        }

        private void btnBarCodeSavePath_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "PNG Image|*.png|Bitmap Image|*.bmp";
            saveFileDialog.DefaultExt = "*.bmp";

            if (saveFileDialog.ShowDialog() == DialogResult.OK) { 
                string fName = saveFileDialog.FileName;
                textBoxBarCodeSavePath.Text = fName;

                switch (saveFileDialog.FilterIndex)
                {
                    case 0:
                        // SAVE PNG
                        imgFormat = ImageFormat.Png;
                        break;
                    case 1:
                        // SAVE BMP
                        imgFormat = ImageFormat.Bmp;
                        break;
                    default:
                        break;
                }
            }
        }

        private void cmboxBarCodeFormat_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (cmboxBarCodeFormat.Text == "CODE_128")
            {
                richTextBox1.Text = "";
            }
            else if (cmboxBarCodeFormat.Text == "CODE_39")
            {
                richTextBox1.Text = "";
            }
            else if (cmboxBarCodeFormat.Text == "CODE_93")
            {
                richTextBox1.Text = "";
            }
            else if (cmboxBarCodeFormat.Text == "EAN_13")
            {
                // 输入信息必须是12位数字,不能有字母
                richTextBox1.Text = "输入信息必须是12位数字,不能有字母";
            }
            else if (cmboxBarCodeFormat.Text == "EAN_8")
            {
                // 输入信息必须是7位数字,不能有字母
                richTextBox1.Text = "输入信息必须是7位数字,不能有字母";
            }
            else if (cmboxBarCodeFormat.Text == "UPC_A")
            {
                // 输入信息必须是11位数字,不能有字母
                richTextBox1.Text = "输入信息必须是11位数字,不能有字母";
            }
            else if (cmboxBarCodeFormat.Text == "UPC_E")
            {
                // 输入信息必须是7位数字,不能有字母,且第一位只能是0或1
                richTextBox1.Text = "输入信息必须是7位数字,不能有字母,且第一位只能是0或1";

            }
        }

        //-----------------------------------生成二维码------------------------------------------------------

        /// <summary>
        ///  
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnQrCodeLogo_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "PNG *.png|*.png|BMP *.bmp|*.bmp|JPG *.jpg|*.jpg|all files *.*|*.*";
            openFileDialog.DefaultExt = "*.png";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            { 
                logoPath = openFileDialog.FileName;

                Bitmap bmap = new Bitmap(logoPath);
                //picBoxQrCodeLogo.Image = bmap;
                picBoxQrCodeLogo.Image = Image.FromHbitmap(bmap.GetHbitmap());
            }
        }

        private void btnGenerateQrCode_Click(object sender, EventArgs e)
        {
            if (checkBokQrCodeWithLogo.Checked && logoPath != "")
            {
                bitmap = GenerateQrCodeWithLogo();
            }
            else 
            { 
                bitmap = GenerateQrCode();            
            }

            //bitmap.Save("");

            if (bitmap != null)
            {
                picBoxQrCodePreview.Image = Image.FromHbitmap(bitmap.GetHbitmap());
            }

        }

        private void btnSaveQrCode_Click(object sender, EventArgs e)
        {
            if (bitmap == null)
            {
                MessageBox.Show("请先生成二维码", "图片保存失败");
                return;
            }

            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "PNG *.png|*.png|BMP *.bmp|*.bmp|JPG *.jpg|*.jpg|all files *.*|*.*";
                saveFileDialog.DefaultExt = "*.png";

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {

                    imgFormat = ImageFormat.Bmp;

                    //bitmap.Save(textBoxBarCodeSavePath.Text.Trim(), System.Drawing.Imaging.ImageFormat.Png);
                    bitmap.Save(saveFileDialog.FileName, imgFormat);
                    MessageBox.Show("图片保存成功");
                }                
            }
            catch (Exception ex)
            {
                MessageBox.Show("图片保存失败"+ex.ToString());
            }
        }

        private void checkBokQrCodeWithLogo_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBokQrCodeWithLogo.Checked)
            {

            }
            else
            {
                picBoxQrCodeLogo.Image = null;
                logoPath = "";
            }
            
        }

        // 二维码条形码识别

        protected Result BarCodeReaderReco(Bitmap map)
        {            
            BarcodeReader reader = new BarcodeReader();
            reader.Options.CharacterSet = "UTF-8";

            Result result = reader.Decode(map);

            if (result != null)
            {
                if (result.BarcodeFormat == BarcodeFormat.QR_CODE)
                {
                    textBoxCodeFormat.Text = "QR_CODE";
                }
                else if (result.BarcodeFormat == BarcodeFormat.CODE_128)
                {
                    textBoxCodeFormat.Text = "CODE_128";
                }
                else if (result.BarcodeFormat == BarcodeFormat.CODE_39)
                {
                    textBoxCodeFormat.Text = "CODE_39";
                }
                else if (result.BarcodeFormat == BarcodeFormat.CODE_93)
                {
                    textBoxCodeFormat.Text = "CODE_93";
                }
                else if (result.BarcodeFormat == BarcodeFormat.EAN_8)
                {
                    textBoxCodeFormat.Text = "EAN_8";
                }
                else if (result.BarcodeFormat == BarcodeFormat.EAN_13)
                {
                    textBoxCodeFormat.Text = "EAN_13";
                }
                else if (result.BarcodeFormat == BarcodeFormat.UPC_A)
                {
                    textBoxCodeFormat.Text = "UPC_A";
                }
                else if (result.BarcodeFormat == BarcodeFormat.UPC_E)
                {
                    textBoxCodeFormat.Text = "UPC_E";
                }
                else
                {
                    textBoxCodeFormat.Text = "未知编码类型";
                }

                richTextBoxReco.Text = result.Text;
            }
            else 
            {
                
            }

            return result;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "图片文件 PNG *.png|*.png|BMP *.bmp|*.bmp|JPG *.jpg|*.jpg|all files *.*|*.*";
            openFileDialog.DefaultExt = "*.png";
            if (openFileDialog.ShowDialog() == DialogResult.OK) {
                openPath = openFileDialog.FileName;

                textBoxCodeFormat.Text = "";
                richTextBoxReco.Text = "";

                Bitmap bmap = new Bitmap(openPath);
                pictureBoxReco.Image = Image.FromHbitmap(bmap.GetHbitmap());
                Result ret = BarCodeReaderReco(bmap);                
            }           
        }

        private void button3_Click(object sender, EventArgs e)
        {
            videoFilter = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            MessageBox.Show("识别到:" + videoFilter.Count.ToString() + "个摄像头");

            comboBoxVideos.Items.Clear();
            
            for (int i = 0; i < videoFilter.Count; i++)
            {
                comboBoxVideos.Items.Add(videoFilter[i].Name);
            }
            
            comboBoxVideos.SelectedIndex = 0;
        }

        private void CameraClose()
        {
            if (null != videoSourcePlayer1.VideoSource) { 
                videoSourcePlayer1.SignalToStop();
                videoSourcePlayer1.WaitForStop();
                videoSourcePlayer1.VideoSource = null;
            }

            timer1.Stop();
        }
        private void comboBoxVideos_SelectedIndexChanged(object sender, EventArgs e)
        {

#if false
            if (videoFilter.Count > comboBoxVideos.SelectedIndex)
            {
                cameraIndex = comboBoxVideos.SelectedIndex;
            }
            else
            {
                cameraIndex = 0;
                MessageBox.Show("选择的摄像头不存在,请刷新重新获取摄像头!");
                return;
            }
#else
            CameraClose();
            string CameraName = "";
            if (videoFilter.Count > comboBoxVideos.SelectedIndex)
            {
                CameraName = videoFilter[comboBoxVideos.SelectedIndex].MonikerString;
            }
            else {
                MessageBox.Show("选择的摄像头不存在,请刷新重新获取摄像头!");
                return;
            }

            videoCaptureDevice = new VideoCaptureDevice(CameraName);
            videoSourcePlayer1.VideoSource = videoCaptureDevice;
            videoSourcePlayer1.Start();

            timer1.Start();
#endif
        }

        private void button2_Click(object sender, EventArgs e)
        {
#if true
             CameraClose();
#else
            if (button2.Text == "打开摄像头")
            {
                CameraClose();
                string CameraName = "";
                if (videoFilter.Count > cameraIndex)
                {
                    CameraName = videoFilter[cameraIndex].MonikerString;
                }
                else
                {
                    MessageBox.Show("选择的摄像头不存在,请刷新重新获取摄像头!");
                    return;
                }

                videoCaptureDevice = new VideoCaptureDevice(CameraName);
                videoSourcePlayer1.VideoSource = videoCaptureDevice;
                videoSourcePlayer1.Start();
                  
                timer1.Start();
                button2.Text = "关闭摄像头";
            }
            else {
                CameraClose();
                button2.Text = "打开摄像头";
            }
#endif            
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (videoSourcePlayer1.VideoSource != null) {
                Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame();  // 获取图片
                //pictureBoxReco.Image = bitmap;


                if (bitmap != null) {
                    Result ret = BarCodeReaderReco(bitmap);                    
                }
               
            }
        }

        private void btnQrCodeBackground_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                BackgroundColor = colorDialog.Color;
                labelQrCodeBackground.BackColor = BackgroundColor;
            }
        }

        private void btnQrCodeForeground_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                ForegroundColor = colorDialog.Color;
                labelQrCodeForeground.BackColor = ForegroundColor;
            }
        }

        private void labelQrCodeBackground_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                BackgroundColor = colorDialog.Color;
                labelQrCodeBackground.BackColor = BackgroundColor;
            }
        }

        private void labelQrCodeForeground_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                ForegroundColor = colorDialog.Color;
                labelQrCodeForeground.BackColor = ForegroundColor;
            }
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void FormMain_Leave(object sender, EventArgs e)
        {
           
        }

        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Console.WriteLine(" App Closing to close camera.");
            CameraClose();
        }
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1337138.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

实习知识整理6:前后端利用jQuery $.ajax数据传输的四种方式

方式1&#xff1a;前端发送key/value(String字符串)&#xff0c;后台返回文本 前端&#xff1a; <input id"test1" type"button" value"前端发送key/value(String字符串)&#xff0c;后台返回文本"/> $(function() {$("#test1&quo…

YHZ001 Python 简介

配套视频链接: YHZ001 Python 简介 目录 &#x1f649; Python的历史&#x1fab1; Python的作者&#x1f98a; Python 的优缺点&#x1f417; Python 的应用领域&#x1f41e; Python 哲学&#x1f430; Python 解释器 &#x1f649; Python的历史 1989年圣诞节&#xff1a; …

数据智慧:C#中编程实现自定义计算的Excel数据透视表

前言 数据透视表&#xff08;Pivot Table&#xff09;是一种数据分析工具&#xff0c;通常用于对大量数据进行汇总、分析和展示。它可以帮助用户从原始数据中提取关键信息、发现模式和趋势&#xff0c;并以可视化的方式呈现。 在数据透视表中&#xff0c;数据分析师通常希望进…

Redis Streams在Spring Boot中的应用:构建可靠的消息队列解决方案【redis实战 二】

欢迎来到我的博客&#xff0c;代码的世界里&#xff0c;每一行都是一个故事 Redis Streams在Spring Boot中的应用&#xff1a;构建可靠的消息队列解决方案 引言前言Redis Streams的基本概念和特性1. 日志数据结构2. 消息和字段3. 消费者组4. 消息ID5. 实时和历史数据处理6. 性能…

1.决策树

目录 1. 什么是决策树? 2. 决策树的原理 2.1 如何构建决策树&#xff1f; 2.2 构建决策树的数据算法 2.2.1 信息熵 2.2.2 ID3算法 2.2.2.1 信息的定义 2.2.2.2 信息增益 2.2.2.3 ID3算法举例 2.2.2.4 ID3算法优缺点 2.2.3 C4.5算法 2.2.3.1 C4.5算法举例 2.2.4 CART算法 2.2.4…

智能优化算法应用:基于孔雀算法3D无线传感器网络(WSN)覆盖优化 - 附代码

智能优化算法应用&#xff1a;基于孔雀算法3D无线传感器网络(WSN)覆盖优化 - 附代码 文章目录 智能优化算法应用&#xff1a;基于孔雀算法3D无线传感器网络(WSN)覆盖优化 - 附代码1.无线传感网络节点模型2.覆盖数学模型及分析3.孔雀算法4.实验参数设定5.算法结果6.参考文献7.MA…

机械革命极光Pro重装Win10系统图解

机械革命极光Pro是性能优秀的笔记本电脑&#xff0c;深受广大用户的喜欢&#xff0c;现在用户想给笔记本电脑重新安装一下操作系统&#xff0c;但不知道重装系统的详细步骤。下面小编将带来机械革命极光Pro笔记本电脑重装系统Win10版本的步骤介绍&#xff0c;帮助更多的用户完成…

Python 基础面试第三弹

1. 获取当前目录下所有文件名 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import os def get_all_files(directory): file_list []<br> # <code>os.walk</code>返回一个生成器&#xff0c;每次迭代时返回当前目录路径、子目录列表和文件列表 for…

【Kafka】Kafka客户端认证失败:Cluster authorization failed.

背景 kafka客户端是公司内部基于spring-kafka封装的spring-boot版本&#xff1a;3.xspring-kafka版本&#xff1a;2.1.11.RELEASE集群认证方式&#xff1a;SASL_PLAINTEXT/SCRAM-SHA-512经过多年的经验&#xff0c;以及实际验证&#xff0c;配置是没问题的&#xff0c;但是业务…

数据结构:图文详解 树与二叉树(树与二叉树的概念和性质,存储,遍历)

目录 一.树的概念 二.树中重要的概念 三.二叉树的概念 满二叉树 完全二叉树 四.二叉树的性质 五.二叉树的存储 六.二叉树的遍历 前序遍历 中序遍历 后序遍历 一.树的概念 树是一种非线性数据结构&#xff0c;它由节点和边组成。树的每个节点可以有零个或多个子节点…

113基于matlab的PSO-SVM多输入单输出预测程序

基于matlab的PSO-SVM多输入单输出预测程序。PSO对SVM的两个参数进行优化得到最佳参数值进行预测。并输出预测误差等相应结果。程序已调通&#xff0c;可直接运行。 113matlabPSO-SVM多输入单输出 (xiaohongshu.com)

普中STM32-PZ6806L开发板(STM32CubeMX创建项目并点亮LED灯)

简介 搭建一个用于驱动 STM32F103ZET6 GPIO点亮LED灯的任务;电路原理图 LED电路原理图 芯片引脚连接LED驱动引脚原理图 创建一个点亮LED灯的Keil 5项目 创建STM32CubeMX项目 New Project -> 单击 -> 芯片搜索STM32F103ZET6->双击创建 初始化时钟 初始化LED G…

基于双闭环PI的SMO无速度控制系统simulink建模与仿真

目录 1.课题概述 2.系统仿真结果 3.核心程序与模型 4.系统原理简介 5.完整工程文件 1.课题概述 基于双闭环PI的SMO无速度控制系统simulink建模与仿真&#xff0c;基于双闭环PI的SMO无速度控制系统主要由两个闭环组成&#xff1a;一个是电流环&#xff0c;另一个是速度环。…

Flink CDC 1.0至3.0回忆录

Flink CDC 1.0至3.0回忆录 一、引言二、CDC概述三、Flink CDC 1.0&#xff1a;扬帆起航3.1 架构设计3.2 版本痛点 四、Flink CDC 2.0&#xff1a;成长突破4.1 DBlog 无锁算法4.2 FLIP-27 架构实现4.3 整体流程 五、Flink CDC 3.0&#xff1a;应运而生六、Flink CDC 的影响和价值…

数据库原理及应用·数据库保护

7.1 事务 7.1.1 事务定义 1.事务是用户定义的一个数据操作序列&#xff0c;这些操作要么全部执行、要么全部不执行&#xff0c;是一个不可分割的工作单元。 事务是恢复和并发控制的基本单位 事务的两种方式&#xff1a; 7.1.2 事务处理模型 1.ISO事务处理模型&#xff1a…

隐私第一:在几分钟内部署本地大语言模型!

彻底改变您的数据安全游戏&#xff1a;快速无缝部署本地大语言模型&#xff0c;实现无与伦比的隐私! 2023年是人工智能领域加速发展的一年。除了健壮的商业上可用的大型语言模型之外&#xff0c;还出现了许多值得称赞的开源方案&#xff0c;例如Llama2、Codellama、Mistral和Vi…

鸿蒙开发中的坑(持续更新……)

最近在使用鸿蒙开发时&#xff0c;碰到了一些坑&#xff0c;特做记录&#xff0c;如&#xff1a;鸿蒙的preview不能预览&#xff0c;轮播图组件Swiper使用时的问题&#xff0c;console.log() 打印的内容 一、鸿蒙的preview不能预览 首先&#xff0c;只有 ets文件才能预览。 其…

HarmonyOS应用抓包实战

Charles抓包原理 Charles是一个HTTP代理服务器,HTTP监视器,反转代理服务器&#xff0c;当浏览器连接Charles的代理访问互联网时&#xff0c;Charles可以监控浏览器发送和接收的所有数据。 在开发OpenHarmony/HarmonyOS应用开发时&#xff0c;我们使用的是ohos/axios来进行网络…

2023.12.25 关于 Redis 数据类型 Hash 常用命令、内部编码、应用场景

目录 Hash 数据类型 Hash 操作命令 HSET HGET HEXISTS HDEL HKEYS HVALS HGETALL HMGET HLEN HSETNX HINCRBY HINCRBYFLOAT HSTRLEN Hash 编码方式 理解什么是压缩 Hash 实际应用 Cache 缓存 Hash 数据类型 整体上来说 Redis 是键值对结构&#xff0c;其中 …

基于JSP+Servlet+Mysql的学生宿舍管理系统(简单的增删改查)

基于JSPServletMysql的学生宿舍管理系统 一、系统介绍二、功能展示1.登陆、注册2.主页3.增加3.修改4.删除 四、其它1.其他系统实现五.获取源码 一、系统介绍 项目名称&#xff1a;基于JSPServletMysql的学生宿舍管理系统(简单的增删改查) 项目架构&#xff1a;B/S架构 开发语…