Netty权威指南:Netty总结-服务端创建

news2024/9/17 21:03:28

第13章 服务端创建

13.1 原生NIO类库复杂性

开发高质量的NIO的程序并不简单,成本太高

13.2 服务端创建源码

通过ServerBootStrap启动辅助类启动Netty

13.2.1 创建时序图

在这里插入图片描述

以下是关键步骤:

  1. 创建ServerBootStrap实例。这是启动辅助类,提供一系列方法用于设置启动相关的参数,因为参数太多,所以构造函数没有参数

  2. 设置并绑定Reactor线程池,Netty的Reactor线程池是EventLoopGroup,就是EventGroup的数组。EventLoop就是用来处理所有注册到Selector上的Channel,由EventLoop的run方法进行轮询操作。除了处理I/O事件,也处理用户自定义的Task,和定时任务。

  3. 设置并绑定服务端Channel,Netty对NIO中的ServerSocketChannel进行了封装,对应NioServerSocketChannel。在ServerBootStrap中可以指定ServerSocketChannel的类型。

  4. 链路建立的时候创建并初始化ChannelPipeline,本质是一个负责处理网络事件的职责链,负责管理和执行ChannelHandler。网络事件以事件流的形式在ChannelPipeline中流转,由ChannelPipeline根据ChannelHandler的执行策略调度ChannelHandler,有一些典型的网络事件:

    1. 链路注册
    2. 链路激活
    3. 链路断开
    4. 接收到请求消息
    5. 请求消息接收并处理完毕
    6. 发送应答消息
    7. 链路发生异常
    8. 发生用户自定义事件
  5. 初始化ChannelPipeline后,添加并设置ChannelHandler。通过ChannelHandler可以完成用户自己的定制与扩展,同时Netty也提供了大量的系统ChannelHandler,一些实用的:

    1. 系统编解码框架-ByteToMessageCodec
    2. 通用基于长度的半包解码器-LengthFieldBasedFrameDecoder
    3. 码流日志打印Handler-LoggingHandler
    4. SSL安全认证Handler—SslHandler
    5. 链路空闲检测Handler-IdleStateHandler
    6. 流量整形Handler-ChannelTrafficShapingHandler
    7. Base64编解码-Base64Decoder和Base64Encoder

    创建和添加ChannelHandler源码:

    .childHandler(new ChannelInitializer<SocketChannel>() { // (4)
                     @Override
                     public void initChannel(SocketChannel ch) throws Exception {
                         ch.pipeline().addLast(
                                 //new LoggingHandler(LogLevel.INFO),
                                 new EchoServerHandler());
                     }
                 });
    
  6. 绑定并启动端口。将ServerSocketChannel注册到Selector上监听客户端连接

  7. Selector轮询。由Reactor线程NioEventLoop负责调度和执行Selector轮询操作,选择准备就绪的Channel集合

  8. 当轮询到准备就绪的Channel之后,就由Reactor线程NioEventLoop执行ChannelPipeline的相应方法,最终执行ChannelHandler

  9. 执行ChannelHandler,ChannelPipeline根据具体网络事件的类型,调度并执行ChannelHandler

13.2.2 服务端创建源码

public class EchoServer {
    private final int port;
    public EchoServer(int port) {
        this.port = port;
    }

    public void run() throws Exception {
        // Configure the server.
        EventLoopGroup bossGroup = new NioEventLoopGroup();  // (1)
        EventLoopGroup workerGroup = new NioEventLoopGroup();  
        try {
            ServerBootstrap b = new ServerBootstrap(); // (2)
            b.group(bossGroup, workerGroup)
             .channel(NioServerSocketChannel.class) // (3)
             .option(ChannelOption.SO_BACKLOG, 100)
             .handler(new LoggingHandler(LogLevel.INFO))
             .childHandler(new ChannelInitializer<SocketChannel>() { // (4)
                 @Override
                 public void initChannel(SocketChannel ch) throws Exception {
                     ch.pipeline().addLast(
                             //new LoggingHandler(LogLevel.INFO),
                             new EchoServerHandler());
                 }
             });

            // Start the server.
            ChannelFuture f = b.bind(port).sync(); // (5)

            // Wait until the server socket is closed.
            f.channel().closeFuture().sync();
        } finally {
            // Shut down all event loops to terminate all threads.
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }

    public static void main(String[] args) throws Exception {
        int port;
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        } else {
            port = 8080;
        }
        new EchoServer(port).run();
    }
}
  1. NioEventLoopGroup是用来处理I/O操作的线程池,Netty对 EventLoopGroup 接口针对不同的传输协议提供了不同的实现。在本例子中,需要实例化两个NioEventLoopGroup,通常第一个称为“boss”,用来accept客户端连接,另一个称为“worker”,处理客户端数据的读写操作。
  2. ServerBootStrap是启动服务的辅助类,有关socket的参数可以通过ServerBootStrap进行设置
  3. 这里指定为NioServerSocketChannel类初始化channel
  4. 通常会为新SocketChannel通过添加一些handler,来设置ChannelPipeline。ChannelInitializer 是一个特殊的handler,其中initChannel方法可以为SocketChannel 的pipeline添加指定handler。
  5. 通过绑定端口8080,就可以对外提供服务。

EchoServerHandler实现:

public class EchoServerHandler extends ChannelInboundHandlerAdapter {  
  
    private static final Logger logger = Logger.getLogger(  
            EchoServerHandler.class.getName());  
  
    @Override  
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {  
        ctx.write(msg);  
    }  
  
    @Override  
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {  
        ctx.flush();  
    }  
  
    @Override  
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {  
        // Close the connection when an exception is raised.  
        logger.log(Level.WARNING, "Unexpected exception from downstream.", cause);  
        ctx.close();  
    }  
}  
具体分析

一切从ServerBootstrap开始,逐层深入。ServerBootStrap需要两个NioEventLoopGroup实例,按照职责划分成boss和work:boss负责请求的accept,work负责请求的read、write

NioEventLoopGroup

NioEventLoopGroup主要管理eventLoop的生命周期

eventLoop可以被视为一个处理线程,数量默认是处理器个数的两倍
在这里插入图片描述

NioEventLoopGroup的构造方法:

public NioEventLoopGroup() {  
    this(0);  
}  
  
public NioEventLoopGroup(int nThreads) {  
    this(nThreads, null); 
}  
  
public NioEventLoopGroup(int nThreads, ThreadFactory threadFactory) {  
    this(nThreads, threadFactory, SelectorProvider.provider());  
}  
  
public NioEventLoopGroup(  
            int nThreads, ThreadFactory threadFactory, final SelectorProvider selectorProvider) {  
    super(nThreads, threadFactory, selectorProvider);  
}  

可以看出参数最终都传入了父类,MultithreadEventLoopGroup是NioEventLoopGroup的父类,它的构造方法:

protected MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, Object... args) {  
    super(nThreads == 0? DEFAULT_EVENT_LOOP_THREADS : nThreads, threadFactory, args);  
}  

其中 DEFAULT_EVENT_LOOP_THREADS 为处理器数量的两倍。

MultithreadEventExecutorGroup是核心,也就是MultithreadEventLoopGroup的父类,管理eventLoop 的生命周期,变量:

  1. children:EventExecutor数组,保存eventLoop。
  2. chooser:从children中选取一个eventLoop的策略。

构造方法:

//略
  1. 根据数组的大小,采用不同策略初始化chooser,如果大小为2的幂次方,则采用PowerOfTwoEventExecutorChooser,否则使用GenericEventExecutorChooser。
  2. newChild方法重载,初始化EventExecutor时,实际执行的是NioEventLoopGroup中的newChild方法,所以children元素的实际类型为NioEventLoop。
NioEventLoop

每个eventLoop会维护一个selector和taskQueue,负责处理客户端请求和内部任务,如ServerSocketChannel注册和ServerSocket绑定等。
在这里插入图片描述

NioEventLoop构造方法:

 NioEventLoop(NioEventLoopGroup parent, ThreadFactory threadFactory, SelectorProvider selectorProvider) {  
      super(parent, threadFactory, false);  
      if (selectorProvider == null) {  
          throw new NullPointerException("selectorProvider");  
      }  
      provider = selectorProvider;  
      selector = openSelector();  
}  

SingleThreadEventLoop是NioEventLoop的父类,构造方法:

protected SingleThreadEventLoop(EventLoopGroup parent, ThreadFactory threadFactory, boolean addTaskWakesUp) {
    super(parent, threadFactory, addTaskWakesUp);
}

传给父类SingleThreadEventExecutor,一个只有一个线程的线程池,其中的几个变量:

  1. state:线程池当前的状态
  2. taskQueue:存放任务的队列
  3. thread:线程池维护的唯一线程
  4. scheduledTaskQueue:定义在其父类AbstractScheduledEventExecutor中,用以保存延迟执行的任务。

SingleThreadEventExecutor构造方法略,内容如下:

  1. 初始化一个线程,并在线程内执行NioEventLoop类的run方法,但不会立刻执行
  2. 使用LinkedBlockingQueue类初始化taskQueue

到这里,处理线程已经初始化完成。

ServerBootStrap

通过ServerBootStrap.bind(port)启动,过程:

/**
 * Create a new {@link Channel} and bind it.
 */
public ChannelFuture bind() {
    validate();
    SocketAddress localAddress = this.localAddress;
    if (localAddress == null) {
       throw new IllegalStateException("localAddress not set");
    }
    return doBind(localAddress);
 }

在这里插入图片描述

doBind实现:代码略

  1. 方法initAndRegister返回一个ChannelFuture实例regFuture,通过regFuture可以判断initAndRegister执行结果
  2. 如果regFuture.isDone()为true,说明initAndRegister已经执行完,则直接执行doBind0进行socket绑定。
  3. 否则regFuture添加一个ChannelFutureListener监听,当initAndRegister执行完成时,调用operationComplete方法并执行doBind0进行socket绑定。

当initAndRegister操作结束后进行bind操作

initAndRegister实现如下:

final ChannelFuture initAndRegister() {
    final Channel channel = channelFactory().newChannel();
    try {
        init(channel); //这里调用了init(channel)
    } catch (Throwable t) {
        channel.unsafe().closeForcibly();
        // as the Channel is not registered yet we need to force the usage of the GlobalEventExecutor
        return new DefaultChannelPromise(channel, GlobalEventExecutor.INSTANCE).setFailure(t);
    }

    ChannelFuture regFuture = group().register(channel);
    if (regFuture.cause() != null) {
        if (channel.isRegistered()) {
            channel.close();
        } else {
            channel.unsafe().closeForcibly();
        }
    }
    return regFuture;
}
  1. 负责创建服务端的NioServerSocketChannel实例
  2. 为NioServerSocketChannel的pipieline添加Handler
  3. 注册NioServerSocketChannel到selector上

大部分与NIO类似

NioServerSocketChannel

对Nio的ServerSocketChannel和SelectionKey进行了封装

构造方法:

public NioServerSocketChannel() {
    this(newSocket(DEFAULT_SELECTOR_PROVIDER));
}

private static ServerSocketChannel newSocket(SelectorProvider provider) {
    try {
        return provider.openServerSocketChannel();
    } catch (IOException e) {
        throw new ChannelException(
                "Failed to open a server socket.", e);
    }
}

public NioServerSocketChannel(ServerSocketChannel channel) {
    super(null, channel, SelectionKey.OP_ACCEPT);
    config = new NioServerSocketChannelConfig(this, javaChannel().socket());
}
  1. 方法newSocket利用provider.openServerSocketChannel()生成Nio中的ServerSocketChannel对象
  2. 设置SelectionKey.OP_ACCEPT事件

父类AbstractNioMessageChannel的构造方法:

它的父类AbstractNioChannel的构造方法:

  • 但设置了当前ServerSocketChannel为非阻塞通道

继续,顶层父类AbstractChannel构造方法:

protected AbstractChannel(Channel parent) {
    this.parent = parent;
    unsafe = newUnsafe();
    pipeline = new DefaultChannelPipeline(this);
}
  1. 初始化unsafe,这里的Unsafe并非是jdk中底层Unsafe类,用来负责底层的connect、register、read和write等操作。
  2. 初始化pipeline,每个Channel都有自己的pipeline,当有请求事件发生时,pipeline负责调用相应的hander进行处理。
ServerBootStrap的init(Channel channel)方法

添加Handler到Channel的Pipeline中

//略

过程:

  1. 设置channel的options和attrs。
  2. 在pipeline中添加一个ChannelInitializer对象。

init执行完,需要把当前channel注册到EventLoopGroup,最终目的就是实现NIO中把ServerSocket注册到Selector上,实现client请求的监听。

Netty’实现:

public ChannelFuture register(Channel channel, ChannelPromise promise) {
    return next().register(channel, promise);
}

public EventLoop next() {
    return (EventLoop) super.next();
}

public EventExecutor next() {
    return children[Math.abs(childIndex.getAndIncrement() % children.length)];
}

因为EventLoopGroup中维护了多个eventLoop,next方法会调用chooser策略找到下一个eventLoop,并执行eventLoop的register方法进行注册,register方法如下。

public ChannelFuture register(final Channel channel, final ChannelPromise promise) {
    ...
    channel.unsafe().register(this, promise);
    return promise;
}

这里会使用到channel.unsafe():

NioServerSocketChannel初始化时,会创建一个NioMessageUnsafe实例,用于实现底层的register、read、write等操作。

eventLoop.execute(new Runnable() {
   @Override
   public void run() {
      register0(promise);
   }
});

private void register0(ChannelPromise promise) {
    try {
        if (!ensureOpen(promise)) {
            return;
        }
        Runnable postRegisterTask = doRegister();
        registered = true;
        promise.setSuccess();
        pipeline.fireChannelRegistered();
        if (postRegisterTask != null) {
            postRegisterTask.run();
        }
        if (isActive()) {
            pipeline.fireChannelActive();
        }
    } catch (Throwable t) {
        // Close the channel directly to avoid FD leak.
        closeForcibly();
        if (!promise.tryFailure(t)) {
            
        }
        closeFuture.setClosed();
    }
}

public void execute(Runnable task) {
    if (task == null) {
        throw new NullPointerException("task");
    }

    boolean inEventLoop = inEventLoop();
    if (inEventLoop) {
        addTask(task);
    } else {
        startThread();
        addTask(task);
        if (isShutdown() && removeTask(task)) {
            reject();
        }
    }

    if (!addTaskWakesUp) {
        wakeup(inEventLoop);
    }
}
  1. register0方法提交到eventLoop线程池中执行,这个时候会启动eventLoop中的线程。
  2. 方法doRegister()才是最终Nio中的注册方法,方法javaChannel()获取ServerSocketChannel。
protected Runnable doRegister() throws Exception {
    boolean selected = false;
    for (;;) {
        try {
            selectionKey = javaChannel().register(eventLoop().selector, 0, this);
            return null;
        } catch (CancelledKeyException e) {
            if (!selected) {
                // Force the Selector to select now  as the "canceled" SelectionKey may still be
                // cached and not removed because no Select.select(..) operation was called yet.
                eventLoop().selectNow();
                selected = true;
            } else {
                // We forced a select operation on the selector before but the SelectionKey is still cached
                // for whatever reason. JDK bug ?
                throw e;
            }
        }
    }
}

ServerSocketChannel注册完之后,通知pipeline执行fireChannelRegistered方法,pipeline中维护了handler链表,通过遍历链表,执行InBound类型handler的channelRegistered方法,最终执行init中添加的ChannelInitializer handler。

channelRegistered方法

  1. initChannel方法最终把ServerBootstrapAcceptor添加到ServerSocketChannel的pipeline,负责accept客户端请求。
  2. 在pipeline中删除对应的handler。
  3. 触发fireChannelRegistered方法,可以自定义handler的channelRegistered方法。

到这里,ServerSocketChannel完成了初始化并注册到了Selector上,启动线程执行selector.select方法接收客户端请求。


Netty实现将socket绑到指定端口,Netty把注册操作放到了eventLoop中,最终由unsafe实现端口的bind操作。bind完成后,且ServerSocketChannel也已经注册完成,则触发pipeline的fireChannelActive方法,所以在这里可以自定义fireChannelActive方法,默认执行tail的fireChannelActive(当channel变为活动状态时,Netty会调用这个方法通过ChannelPipeline中的所有ChannelHandler来处理这个channel)。具体为这个方法会调用channel.read()方法,read方法会触发pipeline的行为,最终会在pipeline中找到handler执行read方法,默认是head。

Server启动完毕!

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

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

相关文章

AI写作培训课创业参考模式:《如何与AI共同写作》

在数字化时代,写作能力已成为职场和生活中不可或缺的一项技能。随着人工智能技术的发展,AI工具开始在写作过程中发挥越来越重要的作用。《如何与AI共同写作》正是这样一门专业的在线写作课程,它通过结合AI技术和实践操作,帮助学员在30天内掌握高效的写作技巧,提升个人品牌…

网络安全-原型链污染

目录 一、简单介绍一下原型链 二、举个例子 三、那原型链污染是什么呢 四、我们来看一道题-hackit 2018 4.1 环境 4.2开始解题 4.3 解答&#xff1a; 一、简单介绍一下原型链 JavaScript 常被描述为一种基于原型的语言 (prototype-based language)——每个对象拥有一个原…

MySQL基础——DQL

DQL&#xff08;Data Query Language&#xff0c;数据查询语言&#xff09;是SQL中的一个子集&#xff0c;主要用于查询数据库中的数据。DQL的核心语句是 SELECT&#xff0c;它用于从一个或多个表中提取数据&#xff0c;并能够通过各种条件进行过滤、排序和聚合操作。下面是DQL…

Android解析XML格式数据

文章目录 Android解析XML格式数据搭建Web服务器Pull解析方式SAX解析方式 Android解析XML格式数据 通常情况下&#xff0c;每个需要访问网络的应用程序都会有一个自己的服务器&#xff0c;我们可以向服务器提交数据&#xff0c;也可以从服务器上获取数据。不过这个时候就出现了…

Vant 按需引入导致 Typescript,eslint 报错问题

目录 1&#xff0c;按需引入问题2&#xff0c;Typescript 报错解决3&#xff0c;eslint 报错解决 1&#xff0c;按需引入问题 vant4 通过按需引入的配置 使用组件时&#xff0c;会同时将样式自动导入。 所以可直接使用相关的 API 方法&#xff0c;样式也没有问题。比如&#…

如何使用VeilTransfer评估和提升组织的数据安全态势

关于VeilTransfer VeilTransfer是一款功能强大的企业数据安全检测与增强工具&#xff0c;该工具基于Go语言开发&#xff0c;旨在帮助广大研究人员完成企业环境下的数据安全测试并增强检测能力。 此工具模拟了高级威胁行为者使用的真实数据泄露技术&#xff0c;使组织能够评估和…

基于SpringBoot的求职招聘管理系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、SSM项目源码 系统展示 【2025最新】基于JavaSpringBootVueMySQL的求职招聘管理系统…

1.10 DFT示例2

1.10 DFT示例2 1.10.2 一个通用正弦波 通过将复正弦波的表达式代入DFT的定义&#xff0c;并按照矩形序列示例中的相同步骤&#xff0c;可以类似地推导出通用正弦波的DFT。 尽管如此&#xff0c;在理解了上述概念后&#xff0c;我们可以通过一种更简单的方法看到一般正弦波的…

校园二手数码交易系统小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;卖家管理&#xff0c;用户管理&#xff0c;二手商品管理&#xff0c;商品类型管理&#xff0c;商品求购管理&#xff0c;用户通知管理&#xff0c;退货管理 微信端账号功能包括&#xff1a;系统首页&a…

索尼发布新款PS5 Pro主机 算力与定价齐飞 9成玩家感叹“价格贵”

北京时间周二深夜&#xff0c;消费电子大厂索尼如期发布游戏主机PlayStation 5的升级版本PS5 Pro。虽然机器参数与事前预期完全一致&#xff0c;但发布会后仍然出现了舆论争议——索尼的定价超出预期了。 &#xff08;PS5首席架构师马克塞尔尼发布新机器&#xff0c;来源&#…

Python编码系列—Python项目维护与迭代:持续进化的艺术

&#x1f31f;&#x1f31f; 欢迎来到我的技术小筑&#xff0c;一个专为技术探索者打造的交流空间。在这里&#xff0c;我们不仅分享代码的智慧&#xff0c;还探讨技术的深度与广度。无论您是资深开发者还是技术新手&#xff0c;这里都有一片属于您的天空。让我们在知识的海洋中…

面试官:聊聊MySQL的binlog

前言 MySQL 日志 主要包括错误日志、查询日志、慢查询日志、事务日志、二进制日志几大类。 其中&#xff0c;比较重要的还要属二进制日志 binlog&#xff08;归档日志&#xff09;和事务日志 redo log&#xff08;重做日志&#xff09;和 undo log&#xff08;回滚日志&#…

idea中git提交的代码回退到指定版本

一.先在本地仓库回退到指定版本的代码 选中项目&#xff0c;右键依次点击【Git】——>【Show History】&#xff0c;如下图&#xff1a; 2. 查看提交到远程仓库的git记录&#xff0c;下图中为每次提交的git记录&#xff0c;回退到其中一个指定的即可&#xff0c;如下图&…

ICM20948 DMP代码详解(13)

接前一篇文章&#xff1a;ICM20948 DMP代码详解&#xff08;12&#xff09; 上一回完成了对inv_icm20948_set_chip_to_body_axis_quaternion函数第2步即inv_rotation_to_quaternion函数的解析。回到inv_icm20948_set_chip_to_body_axis_quaternion中来&#xff0c;继续往下进行…

开放式激光振镜运动控制器在Ubuntu+Qt下的文本标刻

开放式激光振镜运动控制器在UbuntuQt下的文本标刻 上节课程我们讲述了如何通过UbuntuQt进行振镜校正&#xff08;详情点击→开放式激光振镜运动控制器在UbuntuQt下的激光振镜校正&#xff09;&#xff0c;本节文本标刻是在振镜校正的前提下实现的。 在正式学习之前&#xff0…

首个大模型供应链安全领域的国际标准,WDTA《大模型供应链安全要求》标准解读

9月6日,WDTA世界数字技术院在2024 外滩大会上正式发布了国际标准《大模型供应链安全要求》。这一标准为管理大型语言模型(LLM)供应链中的安全风险提出了系统性的框架,涵盖了LLM的整个生命周期,从开发、训练到部署和维护,为每个阶段提供了详尽的指导。 文末附标准获取方式 一…

re题(17)BUUCTF-[BJDCTF2020]JustRE

BUUCTF在线评测 (buuoj.cn) 放到ida&#xff0c;shiftF12可以直接看到有个类似flag的字符串&#xff0c;可以跳转过去 这里我们先不跳转&#xff0c;进入main&#xff08;&#xff09;的各个函数看一下 找到flag 本题学到一堆c的系统库函数

ImDisk Toolkit将一部分RAM模拟成硬盘分区

ImDisk Toolkit 是一个用于虚拟磁盘管理的工具&#xff0c;它可以将 RAM&#xff08;一部分内存&#xff09;模拟成硬盘分区&#xff0c;从而创建一个高速的临时存储空间&#xff0c;通常称为“RAM Disk”。以下是如何使用 ImDisk Toolkit 来将一部分 RAM 模拟成硬盘分区的步骤…

C++ | Leetcode C++题解之第398题随机数索引

题目&#xff1a; 题解&#xff1a; class Solution {vector<int> &nums; public:Solution(vector<int> &nums) : nums(nums) {}int pick(int target) {int ans;for (int i 0, cnt 0; i < nums.size(); i) {if (nums[i] target) {cnt; // 第 cnt 次…

Python OpenCV精讲系列 - 高级图像处理技术(三)

&#x1f496;&#x1f496;⚡️⚡️专栏&#xff1a;Python OpenCV精讲⚡️⚡️&#x1f496;&#x1f496; 本专栏聚焦于Python结合OpenCV库进行计算机视觉开发的专业教程。通过系统化的课程设计&#xff0c;从基础概念入手&#xff0c;逐步深入到图像处理、特征检测、物体识…