自动驾驶算法(一):Dijkstra算法讲解与代码实现

目录

0 本节关键词:栅格地图、算法、路径规划

1 Dijkstra算法详解

2 Dijkstra代码详解


0 本节关键词:栅格地图、算法、路径规划

1 Dijkstra算法详解

        用于图中寻找最短路径。节点是地点,边是权重。

        从起点开始逐步扩展,每一步为一个节点找到最短路径:

        While True:
                1.从未访问的节点选择距离最小的节点收录(贪心思想)
                2.收录节点后遍历该节点的邻接节点,更新距离

        我们举例子说明一下,在机器人路径规划中,通常用open list、closed list表达:

        open list 表示从该节点到起点已经有路径的节点

        closed list 表示已经找到最短路径的节点

        Step1:从起点开始,将起点放入open list中,选择距离最短的节点进行收录。

open list    1(0)(min)
closed list

|
|

open list    
closed list  1(0)

        Step2:遍历1号节点的邻接节点(4、2号节点)

open list    2(2)(1-->2) 4(1)(1-->4)(min)
closed list  1(0)

|
|

open list    2(2)(1-->2)
closed list  1(0)  4(1)(1-->4)

        4号节点收录后我们需要对其邻接节点更新距离。(3、6、7号节点)

        Step3:3号节点我们找到1->4->3路径,6号节点我们找到1->4->6路径,7号节点我们找到1->4->7路径。

open list    2(2)(1-->2)(min) 3(3)(1-->4-->3) 6(9)(1-->4-->6) 7(5)(1-->4-->7)
closed list  1(0)

|
|

open list    3(3)(1-->4-->3) 6(9)(1-->4-->6) 7(5)(1-->4-->7)
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2)

        Step4:遍历2的邻接节点,我们发现4号节点已经在close list中(不需要被更新),我们更新5号节点。

open list    3(3)(1-->4-->3)(min) 6(9)(1-->4-->6) 7(5)(1-->4-->7) 5(13)(1->2-->5)
closed list  1(0)

|
|

open list    6(9)(1-->4-->6) 7(5)(1-->4-->7) 5(13)(1->2-->5)
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2) 3(3)(1-->4-->3)

        Step5:遍历3的邻接节点,(3-->1无需更新,更新3-->6  1436(8) (因为我们有到3的最短距离)),而我们已经为6号节点找到路径6(9)(146),更新6号节点的路径。

open list    6(9)(1-->4-->6)(1->4->3-->6 7) 7(5)(1-->4-->7)(min) 5(13)(1->2-->5)
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2) 3(3)(1-->4-->3)

|
|

open list    6(8)(1->4->3-->6) 5(13)(1->2-->5)
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2) 3(3)(1-->4-->3) 7(5)(1-->4-->7)

        Step6:遍历7的邻接节点(6号节点)(1 4 7 6 = 6)比之前的8小,对6号距离再次更新。

open list    6(8)(1->4->3-->6)(1->4->7-->6 6)(min)  5(13)(1->2-->5) 
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2) 3(3)(1-->4-->3) 7(5)(1-->4-->7) 

|
|

open list    5(13)(1->2-->5) 
closed list  1(0)  4(1)(1-->4) 2(2)(1-->2) 3(3)(1-->4-->3) 7(5)(1-->4-->7)  6(6)(1-->4-->7-->6)

        Step7:遍历6的邻接节点(6号节点)结束

        栅格地图初介绍:

        假设图中灰色的是障碍物,红色的是机器人。在避障时,我们的常用做法是通过膨胀障碍物,将机器人视为质点来规划路径,然后对地图进行栅格化,将地图弄成一块一块的。最后将栅格地图转化为有权地图。我们可以把栅格地图的每个栅格看作是有权图的节点,机器人的运动范围可以看作是有权图的节点和节点之间的连接。

2 Dijkstra代码详解

        这里我们先配置下代码环境,最好是在python3.9下,我们创建conda虚拟环境:

conda create -n nav python=3.9

        安装所需库:

pip install numpy scipy matplotlib pandas cvxpy pytest -i https://pypi.tuna.tsinghua.edu.cn/simple

        我们的代码如下:

"""

Grid based Dijkstra planning

author: Atsushi Sakai(@Atsushi_twi)

"""

import matplotlib.pyplot as plt
import math

show_animation = True


class Dijkstra:

    def __init__(self, ox, oy, resolution, robot_radius):
        """
        Initialize map for planning

        ox: x position list of Obstacles [m]
        oy: y position list of Obstacles [m]
        resolution: grid resolution [m]
        rr: robot radius[m]
        """

        self.min_x = None
        self.min_y = None
        self.max_x = None
        self.max_y = None
        self.x_width = None
        self.y_width = None
        self.obstacle_map = None

        self.resolution = resolution
        self.robot_radius = robot_radius
        self.calc_obstacle_map(ox, oy)
        self.motion = self.get_motion_model()

    class Node:
        def __init__(self, x, y, cost, parent_index):
            self.x = x  # index of grid
            self.y = y  # index of grid
            self.cost = cost  # g(n)
            self.parent_index = parent_index  # index of previous Node

        def __str__(self):
            return str(self.x) + "," + str(self.y) + "," + str(
                self.cost) + "," + str(self.parent_index)

    def planning(self, sx, sy, gx, gy):
        """
        dijkstra path search

        input:
            s_x: start x position [m]
            s_y: start y position [m]
            gx: goal x position [m]
            gx: goal x position [m]

        output:
            rx: x position list of the final path
            ry: y position list of the final path
        """

        start_node = self.Node(self.calc_xy_index(sx, self.min_x),
                               self.calc_xy_index(sy, self.min_y), 0.0, -1)   # round((position - minp) / self.resolution)
        goal_node = self.Node(self.calc_xy_index(gx, self.min_x),
                              self.calc_xy_index(gy, self.min_y), 0.0, -1)

        open_set, closed_set = dict(), dict()     # key - value: hash表
        open_set[self.calc_index(start_node)] = start_node

        while 1:
            c_id = min(open_set, key=lambda o: open_set[o].cost)  # 取cost最小的节点
            current = open_set[c_id]

            # show graph
            if show_animation:  # pragma: no cover
                plt.plot(self.calc_position(current.x, self.min_x),
                         self.calc_position(current.y, self.min_y), "xc")
                # for stopping simulation with the esc key.
                plt.gcf().canvas.mpl_connect(
                    'key_release_event',
                    lambda event: [exit(0) if event.key == 'escape' else None])
                if len(closed_set.keys()) % 10 == 0:
                    plt.pause(0.001)

            # 判断是否是终点
            if current.x == goal_node.x and current.y == goal_node.y:
                print("Find goal")
                goal_node.parent_index = current.parent_index
                goal_node.cost = current.cost
                break

            # Remove the item from the open set
            del open_set[c_id]

            # Add it to the closed set
            closed_set[c_id] = current

            # expand search grid based on motion model
            for move_x, move_y, move_cost in self.motion:
                node = self.Node(current.x + move_x,
                                 current.y + move_y,
                                 current.cost + move_cost, c_id)
                n_id = self.calc_index(node)

                if n_id in closed_set:
                    continue

                if not self.verify_node(node):
                    continue

                if n_id not in open_set:
                    open_set[n_id] = node  # Discover a new node
                else:
                    if open_set[n_id].cost >= node.cost:
                        # This path is the best until now. record it!
                        open_set[n_id] = node

        rx, ry = self.calc_final_path(goal_node, closed_set)

        return rx, ry

    def calc_final_path(self, goal_node, closed_set):
        # generate final course
        rx, ry = [self.calc_position(goal_node.x, self.min_x)], [
            self.calc_position(goal_node.y, self.min_y)]
        parent_index = goal_node.parent_index
        while parent_index != -1:
            n = closed_set[parent_index]
            rx.append(self.calc_position(n.x, self.min_x))
            ry.append(self.calc_position(n.y, self.min_y))
            parent_index = n.parent_index

        return rx, ry

    def calc_position(self, index, minp):
        pos = index * self.resolution + minp
        return pos

    def calc_xy_index(self, position, minp):
        return round((position - minp) / self.resolution)

    def calc_index(self, node):
        return node.y * self.x_width + node.x

    def verify_node(self, node):
        px = self.calc_position(node.x, self.min_x)
        py = self.calc_position(node.y, self.min_y)

        if px < self.min_x:
            return False
        if py < self.min_y:
            return False
        if px >= self.max_x:
            return False
        if py >= self.max_y:
            return False

        if self.obstacle_map[node.x][node.y]:
            return False

        return True

    def calc_obstacle_map(self, ox, oy):
        ''' 第1步:构建栅格地图 '''
        self.min_x = round(min(ox))
        self.min_y = round(min(oy))
        self.max_x = round(max(ox))
        self.max_y = round(max(oy))
        print("min_x:", self.min_x)
        print("min_y:", self.min_y)
        print("max_x:", self.max_x)
        print("max_y:", self.max_y)

        self.x_width = round((self.max_x - self.min_x) / self.resolution)
        self.y_width = round((self.max_y - self.min_y) / self.resolution)
        print("x_width:", self.x_width)
        print("y_width:", self.y_width)

        # obstacle map generation
        # 初始化地图
        self.obstacle_map = [[False for _ in range(self.y_width)]
                             for _ in range(self.x_width)]
        # 设置障碍物
        for ix in range(self.x_width):
            x = self.calc_position(ix, self.min_x)
            for iy in range(self.y_width):
                y = self.calc_position(iy, self.min_y)
                for iox, ioy in zip(ox, oy):
                    d = math.hypot(iox - x, ioy - y)
                    if d <= self.robot_radius:
                        self.obstacle_map[ix][iy] = True
                        break

    @staticmethod
    def get_motion_model():
        # dx, dy, cost
        motion = [[1, 0, 1],
                  [0, 1, 1],
                  [-1, 0, 1],
                  [0, -1, 1],
                  [-1, -1, math.sqrt(2)],
                  [-1, 1, math.sqrt(2)],
                  [1, -1, math.sqrt(2)],
                  [1, 1, math.sqrt(2)]]

        return motion

def main():
    # start and goal position
    sx = -5.0  # [m]
    sy = -5.0  # [m]
    gx = 50.0  # [m]
    gy = 50.0  # [m]
    grid_size = 2.0  # [m]
    robot_radius = 1.0  # [m]

    # set obstacle positions
    ox, oy = [], []
    for i in range(-10, 60):
        ox.append(i)
        oy.append(-10.0)
    for i in range(-10, 60):
        ox.append(60.0)
        oy.append(i)
    for i in range(-10, 61):
        ox.append(i)
        oy.append(60.0)
    for i in range(-10, 61):
        ox.append(-10.0)
        oy.append(i)
    for i in range(-10, 40):
        ox.append(20.0)
        oy.append(i)
    for i in range(0, 40):
        ox.append(40.0)
        oy.append(60.0 - i)

    if show_animation:  # pragma: no cover
        plt.plot(ox, oy, ".k")
        plt.plot(sx, sy, "og")
        plt.plot(gx, gy, "xb")
        plt.grid(True)
        plt.axis("equal")

    dijkstra = Dijkstra(ox, oy, grid_size, robot_radius)
    rx, ry = dijkstra.planning(sx, sy, gx, gy)

    if show_animation:  # pragma: no cover
        plt.plot(rx, ry, "-r")
        plt.pause(0.01)
        plt.show()

if __name__ == '__main__':
    main()

        先执行一下看看效果:

        我们现在来详解一下:

        我们从main函数开始:

    # 1. 设置起点和终点
    sx = -5.0  # [m]
    sy = -5.0  # [m]
    gx = 50.0  # [m]
    gy = 50.0  # [m]
    # 2. 设置珊格的大小和机器人的半径
    grid_size = 2.0  # [m]
    robot_radius = 1.0  # [m]

    # 3. 设置障碍物的位置(图中的黑点就是)
    ox, oy = [], []
    # 3.1 设置外围的四堵墙  (-10,-10)  --> (60,-10) 最下面的一条线
    for i in range(-10, 60):
        ox.append(i)
        oy.append(-10.0)
    # 3.1 设置外围的四堵墙  (60,-10)  -->  (60,60)  最右面的一条线
    for i in range(-10, 60):
        ox.append(60.0)
        oy.append(i)
    # 3.1 设置外围的四堵墙  (-10,60)  -->  (61,60)  最上面的一条线
    for i in range(-10, 61):
        ox.append(i)
        oy.append(60.0)
    # 3.1 设置外围的四堵墙  (-10,-10)  -->  (-10,61) 最左面的一条线
    for i in range(-10, 61):
        ox.append(-10.0)
        oy.append(i)

    # 3.2 障碍物
    for i in range(-10, 40):
        ox.append(20.0)
        oy.append(i)
    for i in range(0, 40):
        ox.append(40.0)
        oy.append(60.0 - i)

    # 4 画图 起点、终点、障碍物都画出来
    if show_animation:  # pragma: no cover
        plt.plot(ox, oy, ".k")
        plt.plot(sx, sy, "og")
        plt.plot(gx, gy, "xb")
        plt.grid(True)
        plt.axis("equal")

        这段代码就设置了边框和障碍物区域并把他们可视化了:

        就是我图中画的区域。

    #生成了Dijkstra的对象 调用其中的方法(障碍物信息、珊格大小、机器人半径)
    dijkstra = Dijkstra(ox, oy, grid_size, robot_radius)

        生成了Dijkstra的对象。我们来看这个类的构造函数,进入一个类首先执行构造函数:

    def __init__(self, ox, oy, resolution, robot_radius):
        """
        Initialize map for planning

        ox: x position list of Obstacles [m]
        oy: y position list of Obstacles [m]
        resolution: grid resolution [m]
        rr: robot radius[m]
        """

        self.min_x = None
        self.min_y = None
        self.max_x = None
        self.max_y = None
        self.x_width = None
        self.y_width = None
        self.obstacle_map = None

        # 珊格大小
        self.resolution = resolution
        # 机器人半径
        self.robot_radius = robot_radius
        # 构建珊格地图
        self.calc_obstacle_map(ox, oy)
        self.motion = self.get_motion_model()

        我们先来看是怎么创建珊格地图的:

    def calc_obstacle_map(self, ox, oy):
        ''' 第1步:构建栅格地图 '''

        # 1. 获得地图的边界值
        self.min_x = round(min(ox))
        self.min_y = round(min(oy))
        self.max_x = round(max(ox))
        self.max_y = round(max(oy))
        print("min_x:", self.min_x)
        print("min_y:", self.min_y)
        print("max_x:", self.max_x)
        print("max_y:", self.max_y)

        # 2.计算x、y方向珊格个数
        self.x_width = round((self.max_x - self.min_x) / self.resolution)
        self.y_width = round((self.max_y - self.min_y) / self.resolution)
        print("x_width:", self.x_width)
        print("y_width:", self.y_width)

        # obstacle map generation
        # 3.初始化地图 都设置为false 表示还没有设置障碍物
        self.obstacle_map = [[False for _ in range(self.y_width)]
                             for _ in range(self.x_width)]
        # 4.设置障碍物 遍历每一个栅格
        for ix in range(self.x_width):
            # 通过下标计算珊格位置
            x = self.calc_position(ix, self.min_x)
            for iy in range(self.y_width):
                y = self.calc_position(iy, self.min_y)
                # 遍历障碍物
                for iox, ioy in zip(ox, oy):
                    # 计算障碍物到珊格的距离
                    d = math.hypot(iox - x, ioy - y)
                    # 膨胀障碍物 如果距离比机器人半径小 机器人不能通行
                    if d <= self.robot_radius:
                        # 设置为true
                        self.obstacle_map[ix][iy] = True
                        break

        首先我们获得了地图的边界值,算出了每一个方向上有多少珊格数量。

        比如我们的长是100m(self.max_x - self.min_x = 100),珊格大小为3,那么我们每一行不就是有33个珊格啦~。

        我们初始化obstacle_map,这个大小为珊格长 * 珊格宽的大小,我们将他们初始化为false表示这个地方没有障碍物。

        然后我们遍历每一个珊格for ix in range(self.x_width)、for iy in range(self.y_width)。我们来看看calc_position这个方法做了什么。

    def calc_position(self, index, minp):
        pos = index * self.resolution + minp
        return pos

        其实就计算了珊格所在位置的真实(x,y)坐标,比如我们的self.minx = 10,ix = 0,那么他的pos = 0 * 2 + 10 = 10,比如我们的self.minx = 10,ix = 1,那么他的pos = 1 * 2 + 10 = 12。我们遍历所有障碍物体的坐标,计算障碍物体(真实坐标)与这个机器人的距离,如果这个距离比机器人自身的大小小的话,我们将这个地方的珊格标志置为false表示有东西。

        那么,在完成这个函数calc_obstacle_map时候,我们有了一张珊格地图,里面充斥着false和true,如果为true的话,那么机器人是过不去的,这块也就是设置成了障碍物区域。

        我们接着往下看构造函数:

        self.calc_obstacle_map(ox, oy)
        self.motion = self.get_motion_model()

         self.motion = self.get_motion_model()这段代码建立了机器人的运动模型和运动代价:

    def get_motion_model():
        # dx, dy, cost
        motion = [[1, 0, 1],                    #x增加1,y不变 代价为1
                  [0, 1, 1],
                  [-1, 0, 1],
                  [0, -1, 1],
                  [-1, -1, math.sqrt(2)],
                  [-1, 1, math.sqrt(2)],
                  [1, -1, math.sqrt(2)],
                  [1, 1, math.sqrt(2)]]

        return motion

        这里也就是机器人向左走(x+1,y+0)代价为1,斜着走代价为根号2。到此为止,我们构造函数讲解完了。我们返回主函数。

open_set

        这里开始正式进入路径规划了。传入的参数为起点坐标和终点坐标:

自动驾驶算法(一):Dijkstra算法讲解与代码实现

        我们先看下node类。

    class Node:
        def __init__(self, x, y, cost, parent_index):
            self.x = x  # index of grid
            self.y = y  # index of grid
            self.cost = cost  # g(n)
            self.parent_index = parent_index  # index of previous Node

        def __str__(self):
            return str(self.x) + "," + str(self.y) + "," + str(
                self.cost) + "," + str(self.parent_index)

        首先执行构造函数,我们发现就是把珊格的(x,y)坐标(并非真实坐标是珊格的)还有cost(后文说)以及父节点的ID赋值了。(so easy)        

        我们在看一下calc_xy_index函数:

    def calc_xy_index(self, position, minp):
        return round((position - minp) / self.resolution)

        它就是计算出真实世界的点点属于哪一个珊格的某一维度的坐标,我们举个例子:

self.calc_xy_index(sx, self.min_x)  sx = 30  minx = 20

        这就代表我们的地图边界的 x 坐标为20,这个点的坐标x=30,我们用(30-20)/2 = 5,那么这个珊格坐标的x方向的坐标就是5。

        start_node = self.Node(self.calc_xy_index(sx, self.min_x),
                               self.calc_xy_index(sy, self.min_y), 0.0, -1)   # round((position - minp) / self.resolution)
        goal_node = self.Node(self.calc_xy_index(gx, self.min_x),
                              self.calc_xy_index(gy, self.min_y), 0.0, -1)

        因此,这段代码的含义就是我们计算出了起始和终止点的珊格坐标,并且将代价置为0,且他们的父节点为-1(没有父亲节点)。封装成了node。

        下面进入算法部分,我们看流程图:

        代码部分和流程图是一样的:

        1.首先我们把起点放入openlist中:

        # 设置openlist closelist 基于哈希表
        open_set, closed_set = dict(), dict()     # key - value: hash表
        # 将startnode放进openset里面 索引为一维数组
        open_set[self.calc_index(start_node)] = start_node

        看一下calc_index函数:这里将珊格地图映射成了一个一维数组,返回数组的ID,类似C++中的二维数组降维。这里openset是一个字典,里面的key是珊格地图点的ID,value是这个珊格节点。

    def calc_index(self, node):
        return node.y * self.x_width + node.x

        2.while True进入循环

        while 1:

        2.1 取openlist cost最小的节点作为当前节点

            c_id = min(open_set, key=lambda o: open_set[o].cost)
            current = open_set[c_id]

        2.2.1 判断当前是否为终点,如果是终点,如果是终点的话把终点的cost修改为当前点的cost值,且终点的父亲节点为当前点的父亲节点。

            # 判断是否是终点
            if current.x == goal_node.x and current.y == goal_node.y:
                print("Find goal")
                # 当前节点的信息赋值给终点
                goal_node.parent_index = current.parent_index
                goal_node.cost = current.cost
                break

        2.2.2 不是最终节点的话从openlist删除加入到closelist

            # 把当前节点从openset里面删掉
            del open_set[c_id]

            # 加入到closed set
            closed_set[c_id] = current

        2.3 遍历其9个邻接运动节点

            for move_x, move_y, move_cost in self.motion:

        2.3.1 封装邻接节点

node = self.Node(current.x + move_x,
                                 current.y + move_y,
                                 current.cost + move_cost, c_id)

        这个点到邻接节点的移动就是 x +-( 1或-1或+根号2或-根号2),然后移动上下的话它的代价值需要+1,斜着移动需要 + 根号2,这样递归的进行我们就求出来所有点的代价值了,同样这个新走的点是通过我们这个点走过来的,因此新点的父节点就是我们这个点。

        2.3.2 求当前节点的一维索引判断是否收录到closelist并判断是否可行,如果收录了,那么已经有最小路径了不需要我们再去处理了,还需要判断这个节点是否在珊格地图标记为false点上(珊格地图就是这么用的....)如果这个地方有障碍物那么我们也走不了。

                # 求当前节点的key
                n_id = self.calc_index(node)

                # 是否已经收录到close set里面
                if n_id in closed_set:
                    continue

                # 邻接节点是否可行
                if not self.verify_node(node):
                    continue

        2.3.3 如果不在openset里面我们就将她作为一个新节点加入,如果在openset比较值是否是最优更新,是否和之前的最优路径有重叠。

                if n_id not in open_set:
                    open_set[n_id] = node  # Discover a new node
                else:
                    if open_set[n_id].cost >= node.cost:
                        # This path is the best until now. record it!
                        open_set[n_id] = node

        到这里我们的算法就结束了。我们迭代找到最终点后算法就break掉了~。

        最后我们计算路径:

    def calc_final_path(self, goal_node, closed_set):
        # generate final course
        rx, ry = [self.calc_position(goal_node.x, self.min_x)], [
            self.calc_position(goal_node.y, self.min_y)]
        parent_index = goal_node.parent_index
        while parent_index != -1:
            n = closed_set[parent_index]
            rx.append(self.calc_position(n.x, self.min_x))
            ry.append(self.calc_position(n.y, self.min_y))
            parent_index = n.parent_index

        return rx, ry

        我们将最终节点的珊格坐标还原成真实的三维坐标,并向前找他们的父亲节点直到起始节点(parent_index= -1),我们就出来这个路径了。

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Plist编辑软件 PlistEdit Pro mac中文版功能介绍

PlistEdit Pro mac是一款功能强大的Plist文件编辑软件。Plist文件是苹果公司开发的一种XML文件格式&#xff0c;用于存储应用程序的配置信息和数据。PlistEdit Pro可以帮助用户轻松地编辑和管理Plist文件。 PlistEdit Pro具有直观的用户界面和丰富的功能。用户可以使用该软件打…

计算机网络第4章-网络层(1)

引子 网络层能够被分解为两个相互作用的部分&#xff1a; 数据平面和控制平面。 网络层概述 路由器具有截断的协议栈&#xff0c;即没有网络层以上的部分。 如下图所示&#xff0c;是一个简单网络&#xff1a; 转发和路由选择&#xff1a;数据平面和控制平面 网络层的作用…

C语言--分段函数

要求&#xff1a;写一个程序&#xff0c;输入x的值&#xff0c;输出y的值 思路&#xff1a;定义两个变量&#xff0c;一个y&#xff0c;一个x&#xff0c;当x<1时&#xff0c;yx&#xff0c;当x>1&&x<10&#xff0c;y2x-1&#xff0c;当x>10,y3x-11.用一个…

【基于卷积和Transformer:多光谱图像光谱重建】

Spectral Reconstruction From Satellite Multispectral Imagery Using Convolution and Transformer Joint Network &#xff08;基于卷积和Transformer联合网络的卫星多光谱图像光谱重建&#xff09; 基于卫星多光谱&#xff08;MS&#xff09;图像的光谱重建&#xff08;S…

用于 GaN-HEMT 功率器件仿真的 TCAD 方法论

目录 标题&#xff1a;TCAD Methodology for Simulation of GaN-HEMT Power Devices来源&#xff1a;Proceedings of the 26th International Symposium on Power Semiconductor Devices & ICs(14年 ISPSD)GaN-HEMT仿真面临的挑战文章研究了什么文章的创新点文章的研究方法…

【JVM经典面试题(五十二道)】

文章目录 JVM经典面试题&#xff08;五十二道&#xff09;引言1.什么是JVM 内存管理2.能说一下JVM的内存区域吗&#xff1f;3.说一下JDK1.6、1.7、1.8内存区域的变化&#xff1f;4.为什么使用元空间替代永久代作为方法区的实现&#xff1f;5.对象创建的过程了解吗&#xff1f;6…

配置OpenCV

Open CV中包含很多图像处理的算法&#xff0c;因此学会正确使用Open CV也是人脸识别研究的一项重要工作。在 VS2017中应用Open CV&#xff0c;需要进行手动配置&#xff0c;下面给出在VS2017中配置Open CV的详细步骤。 1.下载并安装OpenCV3.4.1与VS2017的软件。 2.配置Open CV环…

opencv第一个例子

目的 这是用用QTopencv实现的一个完整的展示图片的例子&#xff0c;包括了项目的配置文件&#xff0c;完整的代码&#xff0c;以用做初次学习opencv用。 代码 工程文件&#xff1a; QT core guigreaterThan(QT_MAJOR_VERSION, 4): QT widgetsTARGET openCv1 TEMPL…

react中的useReducer复杂的状态管理

一、useReducer reducer官网教程 useReducer 是 React 提供的一个用于状态管理的 Hook。它可以替代 useState&#xff0c;更适用于处理复杂的状态逻辑。 useReducer 接受一个reducer函数和一个初始状态&#xff0c;并返回当前状态以及一个 dispatch 函数&#xff0c;用来触发…

科学计数法 [极客大挑战 2019]BuyFlag1

打开题目 注意中说&#xff0c;我们需要买flag&#xff0c;首先必须是cuit的学生&#xff0c;其次必须输对正确的密码 查看源代码得到 代码审计 首先&#xff0c;检查是否存在名为 password 的POST请求。 如果 password 存在&#xff0c;将其存储在变量 $password 中。 然后…

一百九十七、Java——IDEA项目中把多层文件夹拆开显示

一、目的 由于IDEA项目中&#xff0c;默认的是把文件夹连在一起显示&#xff0c;于是为了方便需要把这些连在一起的文件夹拆开&#xff0c;分层显示 如文件夹cn.kgc 二、解决措施 解决方法很简单 &#xff08;一&#xff09;找到IDEA项目上的小齿轮 &#xff08;二&#xf…

AI:50-基于深度学习的柑橘类水果分类

🚀 本文选自专栏:AI领域专栏 从基础到实践,深入了解算法、案例和最新趋势。无论你是初学者还是经验丰富的数据科学家,通过案例和项目实践,掌握核心概念和实用技能。每篇案例都包含代码实例,详细讲解供大家学习。 📌📌📌本专栏包含以下学习方向: 机器学习、深度学…

arcgis删除细长图斑的方法

1、有一张图斑数据如下&#xff1a; 如上图&#xff0c;有很多细长的面要素&#xff0c;需要保留的仅是图中的块状要素。 2、首先要将被合并的要素进行拆分&#xff0c;具体拆分步骤如下&#xff1a; 将所有要素选中&#xff0c;点击高级编辑中的拆分按钮。 3、拆分后图斑就…

树莓派安装Ubuntu22.04LTS桌面版

工具&#xff1a;树莓派4B Raspberry Pi 自己下载的ubuntu22.04LTS img磁盘镜像文件 这里有一个小技巧&#xff1a;这个Raspberry Pi的选择镜像的时候在最后面一行可以选择自定义的镜像&#xff0c;哈哈哈哈&#xff0c;这就使得我们可以自己下载&#xff0c;而且知道那个文…

Redis 应用问题

1-缓存穿透 1.1-问题描述 Key 对应的数据在数据源并不存在&#xff0c;每次针对此 Key 的请求从缓存获取不到&#xff0c;请求都会压到数据源&#xff0c;从而可能压垮数据源。 比如&#xff1a;用一个不存在的用户ID 获取用户信息&#xff0c;不论缓存还是数据库都没有&…

基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP

最近我在 International Journal of Digital Earth &#xff08;《国际数字地球学报》&#xff09;发表了一篇森林生物量模型构建的文章&#xff1a;Evaluation of machine learning methods and multi-source remote sensing data combinations to construct forest above-gro…

[概述] 获取点云数据的仪器

这里所说的获取点云的仪器指的是可以获取场景中物体距离信息的相关设备&#xff0c;下面分别从测距原理以及适用场景来进行介绍。 一、三角测距法 三角测距原理 就是利用三角形的几何关系来测量物体的距离。想象一下&#xff0c;你站在一个地方&#xff0c;你的朋友站在另一…

vue(32) : win10创建vue2基础前端框架

vue2element-uiaxios 1.创建vue2项目 开发工具为HBuilderX 3.7.3 1.1.新建项目 1.2.普通项目-vue项目(2.6.10) 等待创建项目 2.安装element-ui组件 2.1右键左下角开始图标 2.2.cd进入项目目录,执行安装element-ui npm i element-ui -S 2.3.main.js引入配置 import {Paginat…

人工智能基础_机器学习013_三种梯度下降对比_线性回归梯度下降更新公式_对梯度下降函数求偏导数_得到---人工智能工作笔记0053

这里批量梯度下降,就是用准备的所有样本数据进行梯度下降计算. 然后小批量梯度下降就是使用比如我一共有500个样本,那么我从中拿出50个样本进行梯度下降计算. 然后随机梯度下降,更厉害, 从一共有500个样本中,随机的取一个样本进行梯度下降计算, 首先我们看批量梯度下降,使用…

【Linux学习笔记】进程概念(中)

1. 操作系统的进程状态2. Linux操作系统的进程状态3. 僵尸进程4. 孤儿进程5. 进程优先级5.1. 优先级是什么和为什么要有优先级5.2. Linux中的进程优先级 6. 进程切换7. 环境变量7.1. 环境变量的认识7.2. 环境变量相关的命令7.3. 环境变量和本地变量7.4. 命令行参数7.5. 获取环境…
最新文章