Obstacle recognition method, device and computer readable storage medium

By constructing a height gradient matrix of the obstacle pixel map and using a breadth-first search algorithm, the problem of imprecise obstacle contour recognition in existing technologies is solved, enabling accurate recognition of obstacles with slopes and supporting the intelligent arrangement of photovoltaic modules.

CN117274842BActive Publication Date: 2026-11-06HEFEI SUNGROW RENEWABLE ENERGY SCI & TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311251510.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-26
Publication Date
2026-11-06
Estimated Expiration
2043-09-26

AI Technical Summary

Technical Problem

In the existing technology, image recognition of the acquired two-dimensional images can only initially identify the outline of obstacles, and cannot perform fine-grained identification of the outline of obstacles, nor can it identify the outline of obstacles with slopes.

Method used

By acquiring the elevation information map of the target area, a pixel map of the target area and a pixel map of the obstacle are constructed. Based on preset rules, a height gradient matrix of each pixel is constructed. The height gradient matrix is ​​traversed to determine the outline of the obstacle. A breadth-first search algorithm is used to fit the boundary points of the obstacle to identify the outline of the obstacle on the slope.

Benefits of technology

It achieves refined recognition of obstacle contours, improves the recognition accuracy of obstacle contours, and can identify obstacle contours under different slopes, supporting the intelligent and digital arrangement of photovoltaic modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117274842B_ABST
    Figure CN117274842B_ABST
Patent Text Reader

Abstract

The application discloses an obstacle recognition method and device and a computer readable storage medium. The method comprises the following steps: obtaining an elevation information map of a target region, constructing a target region pixel map according to the elevation information map of the target region, and constructing an obstacle pixel map according to the target region pixel map; for each pixel point in each obstacle pixel map, a height gradient matrix of the pixel point is constructed based on a preset rule, wherein the height gradient matrix is used to represent the height difference and gradient of the pixel point and adjacent pixel points; each obstacle pixel map is traversed, and the height gradient matrix of the pixel point is used to determine the contour of each obstacle in the target region. The recognition accuracy of the obstacle contour is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power plant construction technology, and in particular to an obstacle identification method, device and computer-readable storage medium. Background Technology

[0002] Driven by digital and intelligent technologies, the demand for intelligent photovoltaic (PV) exploration is becoming increasingly urgent. Among these demands, the most pressing is obstacle identification to facilitate the intelligent and digital arrangement of PV modules. Therefore, there is a pressing need for obstacle identification methods. Current technologies involve image recognition of acquired two-dimensional images to obtain obstacle outlines. However, this method can only provide a preliminary identification of obstacle outlines and cannot achieve refined recognition, resulting in low accuracy. Summary of the Invention

[0003] This application provides an obstacle recognition method, device, and computer-readable storage medium, aiming to improve the recognition accuracy of obstacle contours.

[0004] This application provides an obstacle recognition method, which includes: Obtain an elevation information map of the target area, construct a pixel map of the target area based on the elevation information map of the target area, and construct an obstacle pixel map based on the pixel map of the target area; For each pixel in the pixel map of each obstacle, a height gradient matrix is ​​constructed based on a preset rule, wherein the height gradient matrix is ​​used to characterize the height difference and gradient between the pixel and its neighboring pixels; The pixel map of each obstacle is traversed, and the contour of each obstacle within the target area is determined based on the height gradient matrix of the pixel.

[0005] Optionally, the step of constructing an obstacle pixel map based on the target region pixel map includes: Obtain the height and pixel coordinates of each pixel in the pixel image of the target region; Obtain the coordinates of the highest point of the roof and the roof coordinates; The obstacle pixel map is constructed based on the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map.

[0006] Optionally, the step of constructing the obstacle pixel map based on the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map includes: Based on the height and coordinates of each pixel in the pixel image of the target region, generate the three-dimensional coordinates of each pixel. Determine the coordinate difference between the coordinates of the highest point of the roof and the coordinates of the roof. The obstacle pixel map is constructed based on the ratio of the three-dimensional coordinates of each pixel to the coordinate difference.

[0007] Optionally, the step of constructing the height gradient matrix of each pixel in each obstacle pixel map based on a preset rule includes: For each obstacle pixel map, select any pixel in the obstacle pixel map as the target pixel, and regard the pixels adjacent to the target pixel as other pixels; Obtain the first pixel coordinates and first height of the target pixel, and obtain the second pixel coordinates and second height of each of the other pixels; Based on the coordinates of the first pixel, the first height, the coordinates of the second pixel, and the second height, determine the height difference and gradient between the target pixel and each of the other pixels; Based on the height differences and gradients, construct the height gradient matrix of the target pixel.

[0008] Optionally, the step of traversing the pixel map of each obstacle and determining the contour of each obstacle within the target area based on the height gradient matrix of the pixels includes: For each obstacle pixel map, select an initial point from the obstacle pixel map; Starting from the initial point, traverse every pixel in the obstacle pixel map; Determine the obstacle boundary points based on the height gradient matrix; Fit all obstacle boundary points to generate obstacle contours.

[0009] Optionally, the step of determining the obstacle boundary points based on the height gradient matrix includes: Obtain the height gradient matrix of the pixel; If there is a height difference in the height gradient matrix that is greater than a first preset value, and the gradient corresponding to the height difference is greater than a second preset value, then that pixel is selected as the obstacle boundary point. Optionally, before the step of obtaining the elevation information map of the target area, the method further includes: Acquire two-dimensional images collected by the UAV and generate an initial elevation information map of the two-dimensional images; The target region in the two-dimensional image is identified by a pre-trained target detection model; The initial elevation information map is scaled up based on a preset scaling factor to generate an elevation information map of the target area.

[0010] Optionally, after the step of traversing the pixel map of each obstacle and determining the contour of each obstacle within the target area based on the height gradient matrix of the pixels, the method further includes: Based on the outline of the obstacle and the target area, determine the area where photovoltaic modules can be installed; Based on the area where photovoltaic modules can be installed, the arrangement of the photovoltaic modules is determined; The photovoltaic modules are arranged according to the aforementioned arrangement method.

[0011] Optionally, the obstacle recognition method further includes: Cluster analysis is performed on each obstacle pixel image to obtain the obstacle category corresponding to each obstacle pixel image; Select any obstacle category, traverse the pixel map of each obstacle in that category, and determine the outline of each obstacle in that category based on the height gradient matrix of the pixels.

[0012] In addition, to achieve the above objectives, the present invention also provides an obstacle recognition device comprising: a memory, a processor, and an obstacle recognition program stored in the memory and executable on the processor, wherein the obstacle recognition program, when executed by the processor, implements the steps of the obstacle recognition method described above.

[0013] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing an obstacle recognition program, which, when executed by a processor, implements the steps of the obstacle recognition method described above.

[0014] This application provides a technical solution for obstacle recognition, including a method, device, and computer-readable storage medium. The method involves acquiring an elevation information map of a target area, constructing a target area pixel map based on the elevation information map, and then constructing an obstacle pixel map based on the target area pixel map. Next, for each pixel in each obstacle pixel map, a height gradient matrix is ​​constructed corresponding to each pixel. Each obstacle pixel map is traversed, and the height gradient matrix of the pixels is combined to determine the contour of each obstacle within the target area. Since the height gradient matrix can represent the height difference and gradient between a pixel and its neighboring pixels, traversing the height gradient matrix to find obstacle boundary points results in a more accurate obstacle contour. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating the first embodiment of the obstacle recognition method of the present invention; Figure 2 This is a flowchart illustrating the third embodiment of the obstacle recognition method of the present invention; Figure 3 This is a schematic diagram of the obstacle recognition device according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the obstacle pixel map of the present invention; Figure 5 This is a schematic diagram of the height gradient matrix of the present invention; Figure 6 This is a flowchart illustrating the fifth embodiment of the obstacle recognition method of the present invention.

[0016] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. The accompanying drawings are only one embodiment and not the entirety of the invention. Detailed Implementation

[0017] Currently, obstacle recognition methods mainly obtain obstacle outlines by performing image recognition on acquired two-dimensional images. However, this method can only identify approximate obstacle outlines and cannot perform fine-grained recognition of obstacle outlines, resulting in low recognition accuracy.

[0018] Based on the aforementioned technical problems, this application proposes an obstacle recognition method. The main technical solution includes: acquiring an elevation information map of a target area; constructing a target area pixel map based on the elevation information map; constructing an obstacle pixel map based on the target area pixel map; for each pixel in each obstacle pixel map, constructing a height gradient matrix for that pixel based on preset rules, wherein the height gradient matrix is ​​used to characterize the height difference and gradient between that pixel and its neighboring pixels; traversing each obstacle pixel map, and determining the contour of each obstacle within the target area based on the height gradient matrix of the pixel. Because the height gradient matrix can characterize the height difference and gradient between a pixel and its neighboring pixels, and by traversing the height gradient matrix to find obstacle boundary points, a more accurate obstacle contour can be obtained.

[0019] Furthermore, existing obstacle recognition methods can only identify obstacle contours without slopes, and cannot identify obstacle contours with slopes, meaning they cannot identify obstacle contours that meet different slope conditions. This application determines the contour of each obstacle within the target area based on the height gradient matrix of pixels. Since the height gradient matrix can characterize the height difference and gradient between a pixel and its neighboring pixels, it can achieve the recognition of obstacle contours under different slope conditions.

[0020] To better understand the above technical solutions, exemplary embodiments of this disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of this disclosure to those skilled in the art.

[0021] like Figure 1 As shown, in the first embodiment of this application, the obstacle recognition method is applied to an obstacle recognition device. The obstacle recognition device can be a smart terminal device such as a mobile phone or computer, or other devices with obstacle recognition functionality. The obstacle recognition method includes the following steps: Step S110: Obtain the elevation information map of the target area, construct a pixel map of the target area based on the elevation information map of the target area, and construct an obstacle pixel map based on the pixel map of the target area.

[0022] In this embodiment, as the demand for photovoltaic (PV) power plants increases, the construction requirements for PV power plants also become more stringent. The construction scenario for PV power plants can be set according to actual needs, such as on flat ground, rooftops, or mountaintops, to meet different energy usage requirements. Regardless of the location, the construction of a PV power plant must avoid obstructed areas to improve its usability. Therefore, the outline of obstacles needs to be determined before construction. By identifying the outline of obstacles in a target area, the areas within that target area suitable for installing PV modules and those unsuitable for installation can be determined. This allows for the arrangement of PV modules in the suitable installation areas, thereby enabling the construction of the power plant.

[0023] In this embodiment, the target area can be a roof, flat ground, or a mountaintop. The target area can be set according to the development needs of different scenarios to accommodate the recognition of obstacle contours in different scenarios. This application takes a roof as an example as the target area. By recognizing the obstacle contours in the roof, the area of ​​the roof that can be used to install photovoltaic modules is determined, and then photovoltaic modules are installed in the area of ​​the roof that can be used to install photovoltaic modules.

[0024] In this embodiment, an elevation information map is a map that displays terrain elevation and terrain details within a specific area. It typically uses contour lines and shading or coloring techniques to represent ground elevation, allowing users to intuitively understand changes in the surrounding terrain. In practical use, analyzing obstacle contours using elevation information maps reduces the need for image processing, improving the efficiency and accuracy of obstacle contour recognition within the target area. The elevation information map of the target area can be obtained directly or converted; the conversion process is described in subsequent embodiments and will not be repeated here.

[0025] In this embodiment, after obtaining the elevation information map of the target area, a pixel map of the target area is constructed based on the elevation information map, and an obstacle pixel map based on the roof is constructed based on the target area pixel map. The target area pixel map is formed by all pixels within the target area, and there may be multiple obstacles in the target area pixel map, with each obstacle corresponding to an obstacle pixel map.

[0026] Step S120: For each pixel in the pixel map of each obstacle, construct the height gradient matrix of the pixel based on a preset rule, wherein the height gradient matrix is ​​used to characterize the height difference and gradient between the pixel and its neighboring pixels.

[0027] In this embodiment, since the constructed obstacle pixel map is initially identified based on the captured image, its accuracy is low and it cannot accurately identify the obstacle contour. Therefore, to improve the accuracy of obstacle contour recognition, this application constructs a height gradient matrix. Since the height gradient matrix can characterize the height difference and gradient between a pixel and its neighboring pixels, by traversing the height gradient matrix to obtain the obstacle boundary points, a more accurate obstacle contour can be obtained.

[0028] In this embodiment, each obstacle pixel map consists of multiple pixels. For each pixel in the obstacle pixel map, the height difference and gradient between the pixel and its neighboring pixels can be constructed based on preset rules. Then, a height gradient matrix is ​​generated based on the height difference and gradient corresponding to the pixel. Each pixel corresponds to a height gradient matrix, which includes the height difference and gradient between the pixel and its neighboring pixels.

[0029] A height gradient matrix is ​​a gradient information matrix calculated based on the height values ​​at different locations in a two-dimensional or three-dimensional space. It describes the trend and degree of height variation between different locations within a certain area. Height gradient matrices are commonly used to describe the steepness, slope, and aspect of a terrain surface or terrain. It can be represented by calculating the difference between the height of a point and the heights of its adjacent points, and then dividing by the distance between the two points. Specifically, for a height gradient matrix in two-dimensional space, the value of each element represents the magnitude of the height gradient at that location; for a height gradient matrix in three-dimensional space, the gradient on the XY plane and the gradient along the Z-axis can be calculated separately. This application constructs a height gradient matrix to represent the height variation trend of each pixel in an obstacle pixel map.

[0030] Optionally, the preset rule can be the finite difference method or the gradient ascent method.

[0031] Example 1: Calculating the height gradient using the finite difference method. The finite difference method is a numerical method that approximates the solution of a differential equation by calculating the differences of a function at discrete points on a grid. When calculating the height gradient, different differencing methods can be used, such as the central difference method or the forward / backward differencing method. The specific method can be chosen based on the actual problem.

[0032] Example 2: Using gradient ascent to iteratively solve for the height gradient. Gradient ascent is an optimization algorithm used to maximize a function. When calculating the height gradient, this problem can be viewed as maximizing an objective function, and then gradient ascent can be used iteratively to find the maximum value; the resulting gradient is the height gradient.

[0033] Regardless of the method used, the terrain or other elevation data must first be discretized and represented as a matrix. Then, the elevation gradient can be calculated using the methods described above, resulting in a new matrix where each element represents the magnitude of the elevation gradient at the corresponding location.

[0034] Step S130: Traverse the pixel map of each obstacle and determine the outline of each obstacle within the target area based on the height gradient matrix of the pixel.

[0035] In this embodiment, the pixel map of each obstacle is traversed or a breadth-first search is performed, and the obstacle outline is determined by combining the height gradient matrix corresponding to the pixel.

[0036] In other embodiments, during image acquisition and transmission, noise may be generated due to interference. Noise is an erroneous signal that interferes with normal signals, causing image roughness. Therefore, after obtaining the obstacle contour, it is necessary to further smooth the obstacle contour to improve its clarity. Optionally, an image smoothing algorithm can be used to smooth the obstacle contour to obtain a clearer obstacle contour. The image smoothing algorithm includes, but is not limited to, one of the following: neighborhood averaging, neighborhood weighted averaging, selective masking, and median filtering.

[0037] According to the above technical solution, this embodiment obtains an elevation information map of the target area, constructs a target area pixel map based on the elevation information map, and constructs an obstacle pixel map based on the target area pixel map. Then, for each pixel in each obstacle pixel map, a height gradient matrix is ​​constructed for each pixel. Each obstacle pixel map is traversed, and the height gradient matrix of the pixels is combined to determine the contour of each obstacle within the target area. Since the height gradient matrix can represent the height difference and gradient between a pixel and its neighboring pixels, traversing the height gradient matrix to find obstacle boundary points results in a more accurate obstacle contour.

[0038] Furthermore, based on the first embodiment, in the second embodiment of this application, step S110 includes the following steps: Step S111: Acquire the two-dimensional image collected by the UAV and generate the initial elevation information map of the two-dimensional image; Step S112: Identify the target region in the two-dimensional image using a pre-trained target detection model; Step S113: Scale the initial elevation information map based on a preset scaling factor to generate an elevation information map of the target area.

[0039] In this embodiment, the pixel size of the initial elevation information map is different from that of the elevation information map. In actual use, it is necessary to change the pixel size of the initial elevation information map to obtain the elevation information map. The elevation information map is then used to analyze the contours of obstacles with slopes. The specific method of changing the pixel size is described in subsequent implementation methods and will not be repeated here.

[0040] In this embodiment, a two-dimensional image collected by a drone can be acquired, and a pre-trained target detection model can be used to identify the target region in the two-dimensional image.

[0041] Because 2D images captured by UAVs may contain other interfering regions besides the target area, processing is necessary to improve obstacle contour recognition accuracy. Only the target area needs to be retained for subsequent obstacle contour analysis and recognition. Specifically, an object detection model is used to identify and extract the target area from the UAV-captured 2D images. This model can be one of the following: a recurrent convolutional neural network (R-CNN), a single-stage object detection model (SSD), a single-stage real-time object detection model (YOLO), or an FPN object detection model. The appropriate model can be selected based on the specific circumstances and image characteristics.

[0042] The drone is equipped with an image acquisition device. Acquiring two-dimensional images from the drone includes controlling the drone to fly directly above the target area and then acquiring two-dimensional images. The drone can also be controlled to fly to different positions above the target area to acquire images from various angles, which are then stitched together to obtain a two-dimensional image. Besides identifying the target area in the two-dimensional image using a target detection model, the location of the target area can be determined from a remote sensing map, and the corresponding area contour can be extracted as the two-dimensional image of the target area. Furthermore, two-dimensional images associated with the target area can be obtained from a database. This database pre-stores two-dimensional images corresponding to each area, and these stored images can be historically acquired images. During actual use, the corresponding two-dimensional images are retrieved from this database for analysis. This application enriches the methods for acquiring two-dimensional images through the above approaches.

[0043] In this embodiment, a preset scaling factor is used to convert the pixel size between the initial elevation information map and the elevation information map of the target area. Since each pixel in the initial elevation information map includes an x-coordinate and a y-coordinate, where the x-coordinate represents the pixel's length and the y-coordinate represents its width, the preset scaling factor includes a preset length factor and a preset width factor. The preset scaling factor can be fixed or dynamically determined based on the pixel's size.

[0044] For example: when the preset scaling factor is fixed, that is, when the preset width factor and preset length factor are fixed, the coordinates of each pixel in the initial elevation information map can be scaled based on the fixed preset length factor and preset width factor to obtain the elevation information map.

[0045] For example: when the preset scaling factor changes dynamically according to the size of the pixel, that is, when the preset width factor and preset length factor corresponding to each pixel are different, the coordinates of each pixel in the initial elevation information map can be scaled based on the preset width factor and preset length factor respectively, so as to obtain the elevation information map, which can dynamically adapt to different pixels.

[0046] Optionally, the abscissa of the pixel in the elevation information map is determined based on the abscissa of the pixel in the initial elevation information map and a preset length factor; the ordinate of the pixel in the elevation information map is determined based on the ordinate of the pixel in the initial elevation information map and a preset width factor; and the elevation information map is obtained by combining the abscissa of each pixel in the elevation information map and the ordinate of each pixel in the elevation information map.

[0047] Specifically, the abscissa of a pixel in the initial elevation information map can be determined by multiplying its abscissa in the initial elevation information map by a preset length factor. Similarly, the ordinate of a pixel in the initial elevation information map can be determined by multiplying its ordinate in the initial elevation information map by a preset width factor.

[0048] According to the above technical solution, this embodiment uses a preset width factor and a preset length factor to scale the pixel coordinates in the initial elevation information map to obtain the elevation information map of the target area, thus realizing the pixel conversion between the initial elevation information map and the elevation information map.

[0049] Furthermore, referring to Figure 2 Based on any of the embodiments in the first-second embodiments, in the third embodiment of this application, the step S110 of constructing an obstacle pixel map based on the elevation information map of the target area includes the following steps: Step S121: Obtain the height and pixel coordinates of each pixel in the pixel image of the target region.

[0050] In this embodiment, the height of each pixel in the target area pixel image is obtained by traversing the pixels in the elevation information map, and a height matrix is ​​generated based on the height of each pixel. Thus, the pixel coordinates and heights corresponding to each pixel in the target area pixel image are obtained.

[0051] Step S122: Obtain the coordinates of the highest point of the roof and the roof coordinates.

[0052] Step S123: Construct the obstacle pixel map based on the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map.

[0053] In this embodiment, after obtaining the height and coordinates of each pixel in the target area pixel map, the pixels corresponding to the height below the roof and the maximum height on the roof can be filtered out by traversal, thereby constructing the obstacle pixel map.

[0054] Optionally, constructing the obstacle pixel map based on the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map includes: determining a three-dimensional matrix based on the height and coordinates of each pixel in the target area pixel map; determining the height difference between the highest point of the roof and the roof based on the coordinates of the highest point of the roof and the roof coordinates; and determining the obstacle pixel map based on the ratio between the three-dimensional matrix and the height difference. The obstacle pixel map is determined using the following formula: The pixel R, G, B of the obstacle pixel map = height matrix [2D X coordinate][2D Y coordinate] / (coordinates of the highest point of the roof - roof coordinates).

[0055] Wherein, the two-dimensional X-coordinate represents the horizontal coordinate of a pixel in the target region pixel image, and the two-dimensional Y-coordinate represents the vertical coordinate of a pixel in the target region pixel image. The height matrix [two-dimensional X-coordinate][two-dimensional Y-coordinate] represents a three-dimensional matrix.

[0056] According to the above technical solution, this embodiment constructs an obstacle pixel map based on the roof using the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map. This improves the accuracy of obstacle contour recognition when performing obstacle analysis based on the obstacle pixel map.

[0057] Furthermore, based on the first embodiment, in the fourth embodiment of this application, step S120 includes the following steps: Step S121: For each obstacle pixel map, select any pixel in the obstacle pixel map as the target pixel, and regard the pixels adjacent to the target pixel as other pixels.

[0058] In this embodiment, after obtaining the coordinates and height of each pixel in the obstacle pixel image, a height gradient matrix is ​​constructed based on the coordinates and height of each pixel in the obstacle pixel image. Specifically, a height gradient matrix based on height variation is constructed using a line parallel to the roof slope as a baseline. For each pixel, the gradient is constant if there are no obstacles. If the roof has no slope, a gradient matrix based on height variation is constructed using any line parallel to the roof slope as a baseline.

[0059] In this embodiment, as Figure 4As shown, the center point A in the obstacle pixel map can be determined as the target pixel. Assuming that the center point is point A, then the pixels adjacent to point A include a1-a9, that is, a1-a9 are other pixels.

[0060] Step S122: Obtain the first pixel coordinates and first height of the target pixel, and obtain the second pixel coordinates and second height of each of the other pixels.

[0061] In this embodiment, the coordinates of the first pixel, the first height, the coordinates of the second pixel, and the second height have been determined above and can be obtained directly.

[0062] Step S123: Determine the height difference and gradient between the target pixel and each of the other pixels based on the coordinates of the first pixel, the first height, the coordinates of the second pixel, and the second height.

[0063] Step S124: Construct the height gradient matrix of the target pixel based on each height difference and each gradient.

[0064] In this embodiment, the first pixel coordinates include a first horizontal coordinate and a first vertical coordinate, and the second pixel coordinates include a second horizontal coordinate and a second vertical coordinate.

[0065] Optionally, determining the gradient between the target pixel and each other pixel based on the first pixel coordinates and first height of the target pixel, and the second pixel coordinates and second height of each other pixel specifically includes: determining the difference between the second height and the first height, and using the difference as the numerator; determining the first squared value of the difference between the second horizontal coordinate and the first horizontal coordinate, and determining the second squared value of the difference between the second vertical coordinate and the first vertical coordinate; using the square root of the sum of the first squared value and the second squared value as the denominator, and then obtaining the gradient between the target pixel and each other pixel based on the numerator and denominator. The gradient of each pixel can be calculated using the above gradient calculation method.

[0066] like Figure 4 As shown, the height gradient matrix formed based on the pixel gradients from pixel A to pixels a1-a9 is as follows: Figure 5 The calculation formula is as follows: .

[0067] Wherein, point A is the target pixel. Let A be the second height of the pixels adjacent to pixel A. It is the first elevation of point A. Let x be the second x-coordinate of the pixel adjacent to point A. Let A be the first x-coordinate of pixel A. Similarly, Let A be the first ordinate. Let y be the second ordinate of the pixel adjacent to point A. This represents the height difference between the target pixel and its adjacent pixels.

[0068] According to the above technical solution, this embodiment constructs a height gradient matrix and uses height and gradient to identify roof obstacles. The advantage of this algorithm is that it can identify obstacles on sloping roofs with high accuracy.

[0069] Furthermore, referring to Figure 6 Based on the first embodiment, in the fifth embodiment of this application, step S130 includes the following steps: Step S131: For each obstacle pixel map, select an initial point from the obstacle pixel map; Step S132: Starting from the initial point, traverse every pixel in the obstacle pixel map; Step S133: Determine the obstacle boundary points based on the height gradient matrix.

[0070] Step S134: Fit all obstacle boundary points to generate obstacle contours.

[0071] In this embodiment, a breadth-first search algorithm or a clustering algorithm can be used to extract the obstacle contour. Taking the breadth-first search algorithm as an example, an initial point can be determined first, such as the bottom left pixel in the obstacle pixel image. Then, starting from the initial point, every pixel in the obstacle pixel image is traversed to obtain the obstacle boundary points. Connecting the obtained obstacle boundary points in sequence gives the obstacle contour. The coordinate information of the obstacle contour can be determined based on the coordinates of each obstacle boundary point.

[0072] Optionally, each pixel has a height gradient matrix, which represents the height difference and gradient between the pixel and its neighboring pixels. When traversing each pixel in the obstacle pixel map, the height gradient matrix of each pixel is obtained; if there is a height difference in the height gradient matrix greater than a first preset value, and the gradient corresponding to that height difference is greater than a second preset value, then that pixel is selected as an obstacle boundary point. The first and second preset values ​​can be set according to actual conditions.

[0073] In this embodiment, a traversal or breadth-first search is performed on each obstacle pixel image, and the obstacle contour is determined by combining the height gradient matrix corresponding to the obstacle pixel image. The basic idea of ​​the breadth-first search algorithm is as follows: (1) Select a starting node and mark it as visited.

[0074] (2) Add the starting node to a queue.

[0075] (3) When the queue is not empty, perform the following: Take a node from the queue and visit the node. Iterate through all the neighboring nodes of the node. For each unvisited neighboring node, mark it as visited and add it to the queue.

[0076] Repeat (3) until the queue is empty.

[0077] The key to the breadth-first search (BFS) algorithm lies in using a queue to traverse nodes in a first-in, first-out (FIFO) order. This ensures that nodes closer to the starting node are visited first, and then the search gradually expands to nodes further away. BFS can be used for graph traversal and searching. It finds the shortest path from the starting node to the target node and can traverse all nodes in the graph. Because BFS searches hierarchically, expanding layer by layer during the search, the path found is always the shortest. It's important to note that BFS requires additional data structures during execution—a queue to store nodes to be visited, and a marker array or hash table to record the node visit status and prevent duplicate visits. Furthermore, BFS is applicable to both directed and undirected graphs. In summary, BFS uses a queue to implement breadth-first access to nodes and uses a marker array or hash table to avoid duplicate visits, thereby traversing the graph and finding the shortest path.

[0078] For example, this application uses a breadth-first search algorithm to traverse each obstacle pixel image to obtain the outline of each obstacle. Based on the principle of the breadth-first search algorithm described above, this application specifically performs the following operations for each obstacle pixel image: (1) Generate a queue of obstacle ranges based on the given range, and randomly select a pixel from the obstacle range as the starting node and put it into the queue.

[0079] (2) Initialize a two-dimensional array marker with the same range as the obstacle to mark whether the two-dimensional pixels have been traversed.

[0080] (3) If the queue is not empty and the two-dimensional array is marked as false, it means that the pixel has not been traversed yet. In this case, the divergence operation can be performed to diverge the points in the queue. If the node has not crossed the boundary, the pixel is searched from the four directions of east, west, south and north. If the height of the adjacent point is less than the preset value, such as 5 cm, the divergence continues and the pixel is marked as having been traversed. If the height difference is greater than or equal to 5 cm (first preset value) and the gradient of the surrounding pixels of the pixel is parallel to the roof slope (second preset value), it means that the pixel is an obstacle boundary point. The pixel and its height are added to the result set and the point is marked as having been traversed.

[0081] (4) The algorithm terminates when all the two-dimensional arrays are marked as true, indicating that all pixels have been traversed.

[0082] Optionally, after determining the obstacle boundary points, an obstacle contour is generated by fitting the data based on these points. Different fitting methods are used for the vector data of the obstacle contour recognition; for example, if the obstacle contour is longitudinal, the minimum rectangle algorithm is used for fitting, and if it is a circle, the minimum circle algorithm is used for fitting, in order to achieve the best fit for the contour.

[0083] According to the above technical solution, this embodiment improves the recognition accuracy of obstacle contours by using a breadth-first search algorithm to determine the obstacle contours.

[0084] Furthermore, based on any of the embodiments in the first to fifth embodiments, in the sixth embodiment of this application, the obstacle recognition method of this application further includes the following steps: Step S310: Determine the area where photovoltaic modules can be installed based on the outline of the obstacle and the target area; In this embodiment, after identifying the obstacle outline, the area in the target region other than the obstacle outline is determined as the area where photovoltaic modules can be installed.

[0085] Step S320: Based on the area where photovoltaic modules can be installed, determine the arrangement of the photovoltaic modules.

[0086] In this embodiment, once a region suitable for installing photovoltaic modules is obtained, the photovoltaic modules are arranged. The arrangement of the photovoltaic modules can be determined based on the shape of the region. For example, if the region has a regular shape, the photovoltaic modules are arranged at equal intervals. If the region has an irregular shape, the region is divided into multiple blocks, and the photovoltaic modules are arranged in each block.

[0087] In this embodiment, the number of photovoltaic modules can be determined based on the local electricity demand, and the arrangement of the photovoltaic modules can be determined based on the number of photovoltaic modules. The arrangement of the photovoltaic modules can be an equal-spaced arrangement or other arrangements. The arrangement of the photovoltaic modules can also be determined based on factors such as sunlight and season, so that the photovoltaic modules arranged in this way can be installed in areas that avoid obstacles and can also meet the usage needs in different scenarios.

[0088] Step S330: Arrange the photovoltaic modules according to the arrangement method of the photovoltaic modules.

[0089] This invention provides an embodiment of an obstacle recognition method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0090] Furthermore, based on any of the embodiments in the first to sixth embodiments, in the seventh embodiment of this application, the obstacle recognition method of this application further includes the following steps: Step S410: Perform cluster analysis on each obstacle pixel image to obtain the obstacle category corresponding to each obstacle pixel image.

[0091] In this embodiment, there are multiple obstacle categories. Taking roof obstacles as an example, the categories include: tree branches, cement blocks, water tanks, etc. The clustering analysis algorithm used in this application can be K-means clustering, hierarchical clustering, density clustering, etc. One of the clustering analysis algorithms can be selected according to the actual situation to perform clustering analysis and obtain the obstacle category corresponding to each obstacle pixel image.

[0092] Step S420: Select any obstacle category, traverse the pixel map of each obstacle in the obstacle category, and determine the outline of each obstacle in the obstacle category based on the height gradient matrix of the pixels.

[0093] In this embodiment, for any obstacle category, the pixel map of each obstacle in that category is analyzed to obtain the outline of each obstacle in that category. Specifically, for each obstacle pixel map of that category, each pixel in the obstacle pixel map is traversed, and the obstacle outline in the obstacle pixel map is determined based on the height gradient matrix corresponding to the pixel. By traversing each obstacle pixel map of that category, each obstacle outline in each obstacle pixel map of that category is obtained.

[0094] This application uses a clustering algorithm to perform cluster analysis on the pixel image of obstacles, thereby classifying obstacles and facilitating the identification of the outline of each obstacle in each obstacle type.

[0095] like Figure 3 As shown, Figure 3 This is a schematic diagram of the hardware operating environment of the obstacle recognition device according to an embodiment of the present invention. The obstacle recognition device can be a smart terminal device such as a mobile phone or computer, or other devices with obstacle recognition functions.

[0096] In one implementation, the obstacle recognition device includes: a processor 101, such as a CPU, a memory 102, and a communication bus 103. The communication bus 103 is used to establish communication between these components. The processor 101 is used to invoke an application program to perform control operations. The memory 102 can be a high-speed RAM or a stable memory, such as a disk storage device.

[0097] It is understood that, in one embodiment, the obstacle recognition program is stored in the memory 102 or in a computer-readable storage medium. When the processor 101 invokes the obstacle recognition program from the memory 102 or the computer-readable storage medium, it performs the following operations: Obtain an elevation information map of the target area, construct a pixel map of the target area based on the elevation information map of the target area, and construct an obstacle pixel map based on the pixel map of the target area; For each pixel in the pixel map of each obstacle, a height gradient matrix is ​​constructed based on a preset rule, wherein the height gradient matrix is ​​used to characterize the height difference and gradient between the pixel and its neighboring pixels; The pixel map of each obstacle is traversed, and the contour of each obstacle within the target area is determined based on the height gradient matrix of the pixel.

[0098] Based on the same inventive concept, this application also provides a computer-readable storage medium storing an obstacle recognition program. When the obstacle recognition program is executed by a processor, it implements the various steps of the obstacle recognition method described above and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0099] Since the computer-readable storage medium provided in the embodiments of this application is a computer-readable storage medium used to implement the methods of the embodiments of this application, those skilled in the art can understand the specific structure and variations of the storage medium based on the methods described in the embodiments of this application, and therefore will not be repeated here. All storage media used in the methods of the embodiments of this application fall within the scope of protection of this application.

[0100] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0101] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0102] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, television, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0103] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. An obstacle recognition method, characterized in that, The obstacle recognition method includes: Obtain an elevation information map of the target area, construct a pixel map of the target area based on the elevation information map, and construct an obstacle pixel map based on the target area pixel map. This includes: determining a three-dimensional matrix based on the height and coordinates of each pixel in the target area pixel map; determining the height difference between the highest point of the roof and the roof surface based on the coordinates of the highest point of the roof and the roof surface coordinates; and determining the obstacle pixel map based on the ratio between the three-dimensional matrix and the height difference. For each pixel in the pixel map of each obstacle, a height gradient matrix is ​​constructed based on a preset rule, wherein the height gradient matrix is ​​used to characterize the height difference and gradient between the pixel and its neighboring pixels; The pixel map of each obstacle is traversed, and the contour of each obstacle in the target area is determined based on the height gradient matrix of the pixel. For each obstacle pixel map, select an initial point from the obstacle pixel map; Starting from the initial point, traverse every pixel in the obstacle pixel map; For each pixel, obtain the height gradient matrix of that pixel; If there is a height difference in the height gradient matrix that is greater than the first preset value, and the gradient corresponding to the height difference is greater than the second preset value, then the pixel is selected as the obstacle boundary point. Fit all obstacle boundary points to generate obstacle contours.

2. The obstacle recognition method as described in claim 1, characterized in that, The step of constructing an obstacle pixel map based on the target region pixel map includes: Obtain the height and pixel coordinates of each pixel in the pixel image of the target region; Obtain the coordinates of the highest point of the roof and the roof coordinates; The obstacle pixel map is constructed based on the coordinates of the highest point of the roof, the roof coordinates, and the height and coordinates of each pixel in the target area pixel map.

3. The obstacle recognition method as described in claim 1, characterized in that, The step of constructing the height gradient matrix of each pixel in each obstacle pixel map based on a preset rule includes: For each obstacle pixel map, select any pixel in the obstacle pixel map as the target pixel, and regard the pixels adjacent to the target pixel as other pixels; Obtain the first pixel coordinates and first height of the target pixel, and obtain the second pixel coordinates and second height of each of the other pixels; Based on the coordinates of the first pixel, the first height, the coordinates of the second pixel, and the second height, determine the height difference and gradient between the target pixel and each of the other pixels; Based on the height differences and gradients, construct the height gradient matrix of the target pixel.

4. The obstacle recognition method as described in claim 1, characterized in that, The steps for obtaining the elevation information map of the target area include: Acquire two-dimensional images collected by the UAV and generate an initial elevation information map of the two-dimensional images; The target region in the two-dimensional image is identified by a pre-trained target detection model; The initial elevation information map is scaled up based on a preset scaling factor to generate an elevation information map of the target area.

5. The obstacle recognition method as described in claim 1, characterized in that, After the step of traversing the pixel map of each obstacle and determining the contour of each obstacle within the target area based on the height gradient matrix of the pixels, the method further includes: Based on the outline of the obstacle and the target area, determine the area where photovoltaic modules can be installed; Based on the area where photovoltaic modules can be installed, the arrangement of the photovoltaic modules is determined; The photovoltaic modules are arranged according to the aforementioned arrangement method.

6. The obstacle recognition method as described in claim 1, characterized in that, The obstacle recognition method further includes: Cluster analysis is performed on each obstacle pixel image to obtain the obstacle category corresponding to each obstacle pixel image; Select any obstacle category, traverse the pixel map of each obstacle in that category, and determine the outline of each obstacle in that category based on the height gradient matrix of the pixels.

7. An obstacle recognition device, characterized in that, The obstacle recognition device includes: a memory, a processor, and an obstacle recognition program stored in the memory, wherein when the obstacle recognition program is executed by the processor, it implements the steps of the obstacle recognition method as described in any one of claims 1-6.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an obstacle recognition program, which, when executed by a processor, implements the steps of the obstacle recognition method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Obstacle detection method for space tether robot in capturing area

    CN104156946A

  • Image rendering method applied to haptic representation device integrating electrostatic force and air pressure film

    CN111338471A

  • Crop form detection method, device and equipment and storage medium

    CN114511520A