百度Apollo规划算法——OBB障碍物检测代码解析

2024-02-26 20:30

本文主要是介绍百度Apollo规划算法——OBB障碍物检测代码解析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

百度Apollo规划算法——Box障碍物检测代码解析

  • 前言
  • 代码
  • 代码分析
    • f1
    • f2
    • f3
    • f4
    • f5
    • f6
  • 参考

前言

本文主要分析Apollo代码中函数bool Box::HasOverlap(const Box2d &box) const {}的数学原理。

在阅读此部分代码时,第一遍没看懂return的一堆什么意思,百度之后说是采用OBB原理,所以就去了解下OBB原理,回来看还是没太明白,直到看到了博客[1],通过博主的图解才有了进一步的了解,但对照代码还是没能完全理解,后来结合向量的相关知识,才算彻底明白了HasOverlap()实现的具体数学原理。
下面,作者仅对代码进行数学解读。

代码

直接上代码,代码路径/self_driving/Optimization/Apollo-DL-IAPS/util/box2d.cc,作者在这里将代码划分为几个部分分别解读。Apollo对Box2d的碰撞检测分为两步进行,第一步使用AABB进行粗检测(f1部分)快速剔除非碰撞的box,第二部分使用OBB进行细检测(f2~f6部分),对f1检测到有碰撞的box进一步进行检测。

bool Box2d::HasOverlap(const Box2d &box) const {// f1if (box.max_x() < min_x() || box.min_x() > max_x() || box.max_y() < min_y() ||box.min_y() > max_y()) {return false;}//f2const double shift_x = box.center_x() - center_.x();const double shift_y = box.center_y() - center_.y();const double dx1 = cos_heading_ * half_length_;const double dy1 = sin_heading_ * half_length_;const double dx2 = sin_heading_ * half_width_;const double dy2 = -cos_heading_ * half_width_;const double dx3 = box.cos_heading() * box.half_length();const double dy3 = box.sin_heading() * box.half_length();const double dx4 = box.sin_heading() * box.half_width();const double dy4 = -box.cos_heading() * box.half_width();//f3return std::abs(shift_x * cos_heading_ + shift_y * sin_heading_) <=std::abs(dx3 * cos_heading_ + dy3 * sin_heading_) +std::abs(dx4 * cos_heading_ + dy4 * sin_heading_) +half_length_ &&//f4std::abs(shift_x * sin_heading_ - shift_y * cos_heading_) <=std::abs(dx3 * sin_heading_ - dy3 * cos_heading_) +std::abs(dx4 * sin_heading_ - dy4 * cos_heading_) +half_width_ &&//f5std::abs(shift_x * box.cos_heading() + shift_y * box.sin_heading()) <=std::abs(dx1 * box.cos_heading() + dy1 * box.sin_heading()) +std::abs(dx2 * box.cos_heading() + dy2 * box.sin_heading()) +box.half_length() &&//f6std::abs(shift_x * box.sin_heading() - shift_y * box.cos_heading()) <=std::abs(dx1 * box.sin_heading() - dy1 * box.cos_heading()) +std::abs(dx2 * box.sin_heading() - dy2 * box.cos_heading()) +box.half_width();
}

代码分析

f1

AABB检测用于粗检测,根据自车和障碍物的box角点构建两个长宽分别平行于坐标轴的box,查看这两个box(两个虚线box表示)是否有交集,可以直接根据新构建的box的角点的坐标值来判断。如下图所示,通过这种方式可以粗略检测到A、B有碰撞,但是是否真的有碰撞还需要通过OBB进一步检测。
AABB

f2

根据OBB检测原理,构建向量如下图所示:
分离轴投影
假设有两个Box类型的对象A和B,计算A.HasOverlap(B)的结果。
以下两行代码计算的时A的中心到B的中心的向量

  const double shift_x = box.center_x() - center_.x();const double shift_y = box.center_y() - center_.y();

转换为数学计算为:
a b ⃗ = ( x s h i f t , y s h i f t ) = ( B . x c e n t e r − A . x c e n t e r , B . y c e n t e r − A . y c e n t e r ) (1) \vec{ab}=(x_{shift},y_{shift})=(B.x_{center}-A.x_{center},B.y_{center}-A.y_{center})\tag{1} ab =(xshift,yshift)=(B.xcenterA.xcenter,B.ycenterA.ycenter)(1)
以下四行代码是分别计算A的纵向方向(指box的朝向)和横向方向的两个向量,其中纵向方向的向量模为 l e n g t h h a l f length_{half} lengthhalf,横向方向的向量模为 w i d t h h a l f width_{half} widthhalf

  const double dx1 = cos_heading_ * half_length_;const double dy1 = sin_heading_ * half_length_;const double dx2 = sin_heading_ * half_width_;const double dy2 = -cos_heading_ * half_width_;

纵向向量:
v 1 ⃗ = ( d x 1 , d y 1 ) = A . l e n g t h h a l f ⋅ ( cos ⁡ ( h e a d i n g A ) , sin ⁡ ( h e a d i n g A ) ) (2) \vec{v_1}=(dx1,dy1)=A.length_{half}\cdot(\cos(heading_A),\sin(heading_A))\tag{2} v1 =(dx1,dy1)=A.lengthhalf(cos(headingA),sin(headingA))(2)
横向向量:
v 2 ⃗ = ( d x 2 , d y 2 ) = A . w i d t h h a l f ⋅ ( sin ⁡ ( h e a d i n g A ) , − cos ⁡ ( h e a d i n g A ) ) (3) \vec{v_2}=(dx2,dy2)=A.width_{half}\cdot(\sin(heading_A),-\cos(heading_A))\tag{3} v2 =(dx2,dy2)=A.widthhalf(sin(headingA),cos(headingA))(3)
其中, h e a d i n g A heading_A headingA为A的方向角,则 ( cos ⁡ ( h e a d i n g A ) , s i n ( h e a d i n g A ) ) (\cos(heading_A),\ sin(heading_A)) (cos(headingA), sin(headingA))为A的单位方向向量, ( sin ⁡ ( h e a d i n g A ) , − cos ⁡ ( h e a d i n g A ) (\sin(heading_A),-\cos(heading_A) (sin(headingA),cos(headingA)为A的单位法向量(为啥单位法向量这样表示?可参考线性代数相关知识)。

同理,以下四行代码分别计算的是B的纵向方向和横向方向的两个向量,纵向方向向量和横向方向向量的模分别是B的半长 l e n g t h h a l f length_{half} lengthhalf,半宽 w i d t h h a l f width_{half} widthhalf

  const double dx3 = box.cos_heading() * box.half_length();const double dy3 = box.sin_heading() * box.half_length();const double dx4 = box.sin_heading() * box.half_width();const double dy4 = -box.cos_heading() * box.half_width();

纵向向量:
v 3 ⃗ = ( d x 3 , d y 3 ) = B . l e n g t h h a l f ⋅ ( cos ⁡ ( h e a d i n g B ) , sin ⁡ ( h e a d i n g B ) ) (4) \vec{v_3}=(dx3,dy3)=B.length_{half}\cdot(\cos(heading_B),\sin(heading_B))\tag{4} v3 =(dx3,dy3)=B.lengthhalf(cos(headingB),sin(headingB))(4)
横向向量:
v 4 ⃗ = ( d x 4 , d y 4 ) = B . w i d t h h a l f ⋅ ( sin ⁡ ( h e a d i n g B ) , − cos ⁡ ( h e a d i n g B ) ) (5) \vec{v_4}=(dx4,dy4)=B.width_{half}\cdot(\sin(heading_B),-\cos(heading_B))\tag{5} v4 =(dx4,dy4)=B.widthhalf(sin(headingB),cos(headingB))(5)
其中, h e a d i n g B heading_B headingB为B的方向角,则 ( cos ⁡ ( h e a d i n g B ) , s i n ( h e a d i n g B ) ) (\cos(heading_B),\ sin(heading_B)) (cos(headingB), sin(headingB))为B的单位方向向量, ( sin ⁡ ( h e a d i n g B ) , − cos ⁡ ( h e a d i n g B ) (\sin(heading_B),-\cos(heading_B) (sin(headingB),cos(headingB)为A的单位法向量。

f3

f 3 f3 f3表示的是计算往A纵轴上的投影

std::abs(shift_x * cos_heading_ + shift_y * sin_heading_) <=std::abs(dx3 * cos_heading_ + dy3 * sin_heading_) +std::abs(dx4 * cos_heading_ + dy4 * sin_heading_) +half_length_

如下图所示
往A纵轴方向投影
结合代码和图片一块分析:
(1)代码中std::abs(shift_x * cos_heading_ + shift_y * sin_heading_)所表示的是向量 a b ⃗ \vec{ab} ab 在A的纵轴上投影的模c,结合公式(1)可知:
c = ∣ a b ⃗ ⋅ ( cos ⁡ ( h e a d i n g A ) , sin ⁡ ( h e a d i n g A ) ) ∣ = ∣ x s h i f t ⋅ cos ⁡ ( h e a d i n g A ) + y s h i f t ⋅ sin ⁡ ( h e a d i n g A ) ∣ c=|\vec{ab}\cdot(\cos(heading_A),\sin(heading_A))|=|x_{shift}\cdot\cos(heading_A)+y_{shift}\cdot\sin(heading_A)| c=ab (cos(headingA),sin(headingA))=xshiftcos(headingA)+yshiftsin(headingA)
(2)代码中std::abs(dx3 * cos_heading_ + dy3 * sin_heading_)所表示的是向量 v 3 ⃗ \vec{v_3} v3 在A的纵轴上投影的模 b 1 b1 b1,结合公式(4)可知:
b 1 = ∣ v 3 ⃗ ⋅ ( cos ⁡ ( h e a d i n g A ) , sin ⁡ ( h e a d i n g A ) ) ∣ = ∣ d x 3 ⋅ cos ⁡ ( h e a d i n g A ) + d y 3 ⋅ sin ⁡ ( h e a d i n g A ) ∣ b1=|\vec{v_3}\cdot(\cos(heading_A),\sin(heading_A))|=|dx3\cdot\cos(heading_A)+dy3\cdot\sin(heading_A)| b1=v3 (cos(headingA),sin(headingA))=dx3cos(headingA)+dy3sin(headingA)
代码中std::abs(dx4 * cos_heading_ + dy4 * sin_heading_)所表示的是向量 v 4 ⃗ \vec{v_4} v4 在A的纵轴上投影的模 b 2 b2 b2,结合公式(5)可知:
b 2 = ∣ v 4 ⃗ ⋅ ( cos ⁡ ( h e a d i n g A ) , sin ⁡ ( h e a d i n g A ) ) ∣ = ∣ d x 4 ⋅ cos ⁡ ( h e a d i n g A ) + d y 4 ⋅ sin ⁡ ( h e a d i n g A ) ∣ b2=|\vec{v_4}\cdot(\cos(heading_A),\sin(heading_A))|=|dx4\cdot\cos(heading_A)+dy4\cdot\sin(heading_A)| b2=v4 (cos(headingA),sin(headingA))=dx4cos(headingA)+dy4sin(headingA)
由上图可知:
b = b 1 + b 2 b=b1+b2 b=b1+b2
(3)代码中half_length_是向量 v 1 ⃗ \vec{v_1} v1 在其纵轴上的投影的模,另外,向量 v 2 ⃗ \vec{v_2} v2 此时在其纵轴上投影的模为0。
c 1 = b + l e n g t h h a l f c1=b+length_{half} c1=b+lengthhalf

f4

f 4 f4 f4表示的是计算往A横轴上的投影

 std::abs(shift_x * sin_heading_ - shift_y * cos_heading_) <=std::abs(dx3 * sin_heading_ - dy3 * cos_heading_) +std::abs(dx4 * sin_heading_ - dy4 * cos_heading_) +half_width_

如下图所示
往A横轴方向投影
结合代码和图片一块分析:
(1)代码中std::abs(shift_x * sin_heading_ - shift_y * cos_heading_)所表示的是向量 a b ⃗ \vec{ab} ab 在A的横轴上投影的模c,结合公式(1)可知:
c = ∣ a b ⃗ ⋅ ( sin ⁡ ( h e a d i n g A ) , − cos ⁡ ( h e a d i n g A ) ) ∣ = ∣ x s h i f t ⋅ sin ⁡ ( h e a d i n g A ) − y s h i f t ⋅ cos ⁡ ( h e a d i n g A ) ∣ c=|\vec{ab}\cdot(\sin(heading_A),-\cos(heading_A))|=|x_{shift}\cdot\sin(heading_A)-y_{shift}\cdot\cos(heading_A)| c=ab (sin(headingA),cos(headingA))=xshiftsin(headingA)yshiftcos(headingA)
(2)代码中std::abs(dx3 * sin_heading_ - dy3 * cos_heading_)所表示的是向量 v 3 ⃗ \vec{v_3} v3 在A的横轴上投影的模 b 1 b1 b1,结合公式(4)可知:
b 1 = ∣ v 3 ⃗ ⋅ ( sin ⁡ ( h e a d i n g A ) , − cos ⁡ ( h e a d i n g A ) ) ∣ = ∣ d x 3 ⋅ sin ⁡ ( h e a d i n g A ) − d y 3 ⋅ cos ⁡ ( h e a d i n g A ) ∣ b1=|\vec{v_3}\cdot(\sin(heading_A),-\cos(heading_A))|=|dx3\cdot\sin(heading_A)-dy3\cdot\cos(heading_A)| b1=v3 (sin(headingA),cos(headingA))=dx3sin(headingA)dy3cos(headingA)
代码中std::abs(dx4 * sin_heading_ - dy4 * cos_heading_)所表示的是向量 v 4 ⃗ \vec{v_4} v4 在A的横轴上投影的模 b 2 b2 b2,结合公式(5)可知:
b 2 = ∣ v 4 ⃗ ⋅ ( sin ⁡ ( h e a d i n g A ) , − cos ⁡ ( h e a d i n g A ) ) ∣ = ∣ d x 4 ⋅ sin ⁡ ( h e a d i n g A ) − d y 4 ⋅ cos ⁡ ( h e a d i n g A ) ∣ b2=|\vec{v_4}\cdot(\sin(heading_A),-\cos(heading_A))|=|dx4\cdot\sin(heading_A)-dy4\cdot\cos(heading_A)| b2=v4 (sin(headingA),cos(headingA))=dx4sin(headingA)dy4cos(headingA)
由上图可知:
b = b 1 + b 2 b=b1+b2 b=b1+b2
(3)代码中half_width_是向量 v 2 ⃗ \vec{v_2} v2 在其横轴上的投影的模,另外,向量 v 1 ⃗ \vec{v_1} v1 此时在其横轴上投影的模为0。
c 1 = b + w i d t h h a l f c1=b+width_{half} c1=b+widthhalf

f5

f 5 f5 f5表示的是计算往B纵轴上的投影

std::abs(shift_x * box.cos_heading() + shift_y * box.sin_heading()) <=std::abs(dx1 * box.cos_heading() + dy1 * box.sin_heading()) +std::abs(dx2 * box.cos_heading() + dy2 * box.sin_heading()) +box.half_length()

如下图所示:
往B纵轴方向投影
结合代码和图片一块分析:
(1)代码中std::abs(shift_x * box.cos_heading() + shift_y * box.sin_heading())所表示的是向量 a b ⃗ \vec{ab} ab 在B的纵轴上投影的模c,结合公式(1)可知:
c = ∣ a b ⃗ ⋅ ( cos ⁡ ( h e a d i n g B ) , sin ⁡ ( h e a d i n g B ) ) ∣ = ∣ x s h i f t ⋅ cos ⁡ ( h e a d i n g B ) + y s h i f t ⋅ sin ⁡ ( h e a d i n g B ) ∣ c=|\vec{ab}\cdot(\cos(heading_B),\sin(heading_B))|=|x_{shift}\cdot\cos(heading_B)+y_{shift}\cdot\sin(heading_B)| c=ab (cos(headingB),sin(headingB))=xshiftcos(headingB)+yshiftsin(headingB)
(2)代码中std::abs(dx1 * box.cos_heading() + dy1 * box.sin_heading())所表示的是向量 v 1 ⃗ \vec{v_1} v1 在B的纵轴上投影的模 a 1 a1 a1,结合公式(2)可知:
a 1 = ∣ v 1 ⃗ ⋅ ( cos ⁡ ( h e a d i n g B ) , sin ⁡ ( h e a d i n g B ) ) ∣ = ∣ d x 1 ⋅ cos ⁡ ( h e a d i n g B ) + d y 1 ⋅ sin ⁡ ( h e a d i n g B ) ∣ a1=|\vec{v_1}\cdot(\cos(heading_B),\sin(heading_B))|=|dx1\cdot\cos(heading_B)+dy1\cdot\sin(heading_B)| a1=v1 (cos(headingB),sin(headingB))=dx1cos(headingB)+dy1sin(headingB)
代码中std::abs(dx2 * box.cos_heading() + dy2 * box.sin_heading())所表示的是向量 v 2 ⃗ \vec{v_2} v2 在B的纵轴上投影的模 a 2 a2 a2,结合公式(3)可知:
a 2 = ∣ v 2 ⃗ ⋅ ( cos ⁡ ( h e a d i n g B ) , sin ⁡ ( h e a d i n g B ) ) ∣ = ∣ d x 2 ⋅ cos ⁡ ( h e a d i n g B ) + d y 2 ⋅ sin ⁡ ( h e a d i n g B ) ∣ a2=|\vec{v_2}\cdot(\cos(heading_B),\sin(heading_B))|=|dx2\cdot\cos(heading_B)+dy2\cdot\sin(heading_B)| a2=v2 (cos(headingB),sin(headingB))=dx2cos(headingB)+dy2sin(headingB)
由上图可知:
a = a 1 + a 2 a=a1+a2 a=a1+a2
(3)代码中half_length是向量 v 3 ⃗ \vec{v_3} v3 在其纵轴上的投影的模,另外,向量 v 4 ⃗ \vec{v_4} v4 此时在其纵轴上投影的模为0。
c 1 = a + l e n g t h h a l f c1=a+length_{half} c1=a+lengthhalf

f6

f 6 f6 f6表示的是计算往B横轴上的投影

std::abs(shift_x * box.sin_heading() - shift_y * box.cos_heading()) <=std::abs(dx1 * box.sin_heading() - dy1 * box.cos_heading()) +std::abs(dx2 * box.sin_heading() - dy2 * box.cos_heading()) +box.half_width()

如下图所示:
往B横轴方向投影
结合代码和图片一块分析:
(1)代码中std::abs(shift_x * box.sin_heading() - shift_y * box.cos_heading())所表示的是向量 a b ⃗ \vec{ab} ab 在B的横轴上投影的模c,结合公式(1)可知:
c = ∣ a b ⃗ ⋅ ( sin ⁡ ( h e a d i n g B ) , − cos ⁡ ( h e a d i n g B ) ) ∣ = ∣ x s h i f t ⋅ sin ⁡ ( h e a d i n g B ) − y s h i f t ⋅ cos ⁡ ( h e a d i n g B ) ∣ c=|\vec{ab}\cdot(\sin(heading_B),-\cos(heading_B))|=|x_{shift}\cdot\sin(heading_B)-y_{shift}\cdot\cos(heading_B)| c=ab (sin(headingB),cos(headingB))=xshiftsin(headingB)yshiftcos(headingB)
(2)代码中std::abs(dx1 * box.sin_heading() - dy1 * box.cos_heading())所表示的是向量 v 1 ⃗ \vec{v_1} v1 在B的横轴上投影的模 a 1 a1 a1,结合公式(2)可知:
a 1 = ∣ v 1 ⃗ ⋅ ( sin ⁡ ( h e a d i n g B ) , − cos ⁡ ( h e a d i n g B ) ) ∣ = ∣ d x 1 ⋅ sin ⁡ ( h e a d i n g B ) − d y 1 ⋅ cos ⁡ ( h e a d i n g B ) ∣ a1=|\vec{v_1}\cdot(\sin(heading_B),-\cos(heading_B))|=|dx1\cdot\sin(heading_B)-dy1\cdot\cos(heading_B)| a1=v1 (sin(headingB),cos(headingB))=dx1sin(headingB)dy1cos(headingB)
代码中std::abs(dx2 * box.sin_heading() - dy2 * box.cos_heading())所表示的是向量 v 2 ⃗ \vec{v_2} v2 在B的横轴上投影的模 a 2 a2 a2,结合公式(3)可知:
a 2 = ∣ v 2 ⃗ ⋅ ( sin ⁡ ( h e a d i n g B ) , − cos ⁡ ( h e a d i n g B ) ) ∣ = ∣ d x 2 ⋅ sin ⁡ ( h e a d i n g B ) − d y 2 ⋅ cos ⁡ ( h e a d i n g B ) ∣ a2=|\vec{v_2}\cdot(\sin(heading_B),-\cos(heading_B))|=|dx2\cdot\sin(heading_B)-dy2\cdot\cos(heading_B)| a2=v2 (sin(headingB),cos(headingB))=dx2sin(headingB)dy2cos(headingB)
由上图可知:
a = a 1 + a 2 a=a1+a2 a=a1+a2
(3)代码中half_width是向量 v 4 ⃗ \vec{v_4} v4 在其横轴上的投影的模,另外,向量 v 3 ⃗ \vec{v_3} v3 此时在其横轴上投影的模为0。
c 1 = a + w i d t h h a l f c1=a+width_{half} c1=a+widthhalf

若步骤f3~f6均满足 c < = c 1 c<=c1 c<=c1,则可判定两个Box存在碰撞(具体原理可参考OBB原理)。

参考

[1] Apollo中Lattice轨迹碰撞检测
[2]自动驾驶运动规划中的碰撞检测

这篇关于百度Apollo规划算法——OBB障碍物检测代码解析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/750067

相关文章

Golang HashMap实现原理解析

《GolangHashMap实现原理解析》HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持高效的插入、查找和删除操作,:本文主要介绍GolangH... 目录HashMap是一种基于哈希表实现的键值对存储结构,它通过哈希函数将键映射到数组的索引位置,支持

利用Python调试串口的示例代码

《利用Python调试串口的示例代码》在嵌入式开发、物联网设备调试过程中,串口通信是最基础的调试手段本文将带你用Python+ttkbootstrap打造一款高颜值、多功能的串口调试助手,需要的可以了... 目录概述:为什么需要专业的串口调试工具项目架构设计1.1 技术栈选型1.2 关键类说明1.3 线程模

Python Transformers库(NLP处理库)案例代码讲解

《PythonTransformers库(NLP处理库)案例代码讲解》本文介绍transformers库的全面讲解,包含基础知识、高级用法、案例代码及学习路径,内容经过组织,适合不同阶段的学习者,对... 目录一、基础知识1. Transformers 库简介2. 安装与环境配置3. 快速上手示例二、核心模

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http

Python利用ElementTree实现快速解析XML文件

《Python利用ElementTree实现快速解析XML文件》ElementTree是Python标准库的一部分,而且是Python标准库中用于解析和操作XML数据的模块,下面小编就来和大家详细讲讲... 目录一、XML文件解析到底有多重要二、ElementTree快速入门1. 加载XML的两种方式2.

Java的栈与队列实现代码解析

《Java的栈与队列实现代码解析》栈是常见的线性数据结构,栈的特点是以先进后出的形式,后进先出,先进后出,分为栈底和栈顶,栈应用于内存的分配,表达式求值,存储临时的数据和方法的调用等,本文给大家介绍J... 目录栈的概念(Stack)栈的实现代码队列(Queue)模拟实现队列(双链表实现)循环队列(循环数组

java解析jwt中的payload的用法

《java解析jwt中的payload的用法》:本文主要介绍java解析jwt中的payload的用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Java解析jwt中的payload1. 使用 jjwt 库步骤 1:添加依赖步骤 2:解析 JWT2. 使用 N

Python中__init__方法使用的深度解析

《Python中__init__方法使用的深度解析》在Python的面向对象编程(OOP)体系中,__init__方法如同建造房屋时的奠基仪式——它定义了对象诞生时的初始状态,下面我们就来深入了解下_... 目录一、__init__的基因图谱二、初始化过程的魔法时刻继承链中的初始化顺序self参数的奥秘默认

Java 正则表达式URL 匹配与源码全解析

《Java正则表达式URL匹配与源码全解析》在Web应用开发中,我们经常需要对URL进行格式验证,今天我们结合Java的Pattern和Matcher类,深入理解正则表达式在实际应用中... 目录1.正则表达式分解:2. 添加域名匹配 (2)3. 添加路径和查询参数匹配 (3) 4. 最终优化版本5.设计思

使用Java将DOCX文档解析为Markdown文档的代码实现

《使用Java将DOCX文档解析为Markdown文档的代码实现》在现代文档处理中,Markdown(MD)因其简洁的语法和良好的可读性,逐渐成为开发者、技术写作者和内容创作者的首选格式,然而,许多文... 目录引言1. 工具和库介绍2. 安装依赖库3. 使用Apache POI解析DOCX文档4. 将解析