Water pipe thickness identification method and device, electronic equipment and storage medium
The target camera and semantic segmentation model are used to identify the outline and skeleton of the water pipe, and calculate the thickness of the water pipe, which solves the problem of difficulty in identifying water pipes when the unmanned sweeper is driving, and improves safety and driving efficiency.
Patent Information
- Application Number
- CN202410777194.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-17
AI Technical Summary
When the unmanned sweeper is driving, it is difficult to accurately identify and calculate the thickness of the water pipe, causing the chassis of the sweeper to easily become entangled in the water pipe, causing damage to the motor or dragging.
Obtain the target image of the water pipe through the target camera, use the preset semantic segmentation model to segment the water pipe, extract the water pipe outline and perform skeleton extraction, traverse the center point on the contour center line, and search for the contour point closest to the center point. Based on the target camera The calibration parameters are processed to obtain the physical distance between the center point and the contour point in the world coordinate system, and the thickness of the water pipe is calculated.
It achieves accurate identification of the thickness of water pipes, improves the ability of the unmanned sweeper to safely identify and avoid water pipes during driving, and avoids motor damage and dragging problems caused by entangled water pipes.
Smart Images

Figure CN118657941A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, device, electronic equipment and storage medium for identifying the thickness of a water pipe. Background Art
[0002] At present, in the field of unmanned sweepers, it is necessary to perform semantic segmentation of the surrounding environment during driving, especially when it involves safety issues. For example, when unmanned sweepers are used in campuses, parks and other scenes, water pipes are often encountered. Due to the low chassis of the sweeper, it is easy to put the water pipe into the wheel and burn the motor. Therefore, the segmentation and recognition of water pipes is very important. Considering the driving efficiency of unmanned sweepers, thin water pipes can be directly retracted and pressed over, while thick water pipes will cause dragging, so they need to be avoided. In this case, it is necessary to calculate the thickness of the water pipe. Summary of the invention
[0003] The main purpose of the embodiments of the present invention is to provide a method, device, electronic device and storage medium for identifying the thickness of a water pipe, in order to solve at least one problem of the prior art. The present invention can accurately identify the thickness of a water pipe.
[0004] To achieve the above purpose, one aspect of an embodiment of the present invention provides a method for identifying the thickness of a water pipe, the method comprising:
[0005] Acquire a target image of the water pipe to be identified through a target camera;
[0006] Input the target image into the preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be identified;
[0007] Perform skeleton extraction based on the water pipe outline to obtain the center line of the water pipe outline;
[0008] Traverse the center point on the contour centerline and search for the contour point closest to the center point on the water pipe contour;
[0009] The physical distance between the center point and the contour point in the world coordinate system is obtained based on the calibration parameter processing of the target camera; the thickness and size of the water pipe to be identified are determined based on twice the physical distance.
[0010] In some embodiments, the method further comprises the following steps:
[0011] The pre-configured Unet model is trained using water pipe images with their outer contours labeled to obtain a semantic segmentation model.
[0012] In some embodiments, training a preconfigured Unet model using a water pipe image with annotated outer contours to obtain a semantic segmentation model includes the following steps:
[0013] Input the water pipe image into the preconfigured Unet model for segmentation processing to obtain the segmentation result;
[0014] The loss is calculated according to the outer contour and segmentation results, and the parameters of the Unet model are feedback-adjusted based on the loss calculation results to obtain a semantic segmentation model.
[0015] In some embodiments, skeleton extraction is performed according to the water pipe contour to obtain the contour center line of the water pipe contour, including the following steps:
[0016] The outer contour boundary is obtained according to the water pipe contour extraction, and the water pipe contour is filled with white based on the outer contour boundary to obtain a white target object;
[0017] According to the white target object, the contour centerline of the water pipe contour is obtained through the thinning algorithm.
[0018] In some embodiments, searching for the contour point closest to the center point on the water pipe contour includes the following steps:
[0019] Based on the center point, a distance range search is performed on the water pipe contour using the nearest neighbor algorithm;
[0020] The contour point corresponding to the center point on the water pipe contour is determined according to the minimum distance result of the distance range search.
[0021] In some embodiments, obtaining the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera includes the following steps:
[0022] Obtaining image coordinates of the center point and the contour point in the target image; the image coordinates include a first image coordinate of the center point and a second image coordinate of the contour point;
[0023] The image coordinates are converted from the image coordinate system of the target image to the world coordinate system according to the calibration parameters to obtain the world coordinates; the world coordinates include the center point world coordinates corresponding to the center point and the contour point world coordinates corresponding to the contour point;
[0024] The Euclidean distance is calculated based on the world coordinates of the center point and the world coordinates of the contour point to obtain the physical distance between the center point and the contour point in the world coordinate system.
[0025] In some embodiments, the calibration parameters include an intrinsic parameter matrix and an extrinsic parameter matrix, and the extrinsic parameter matrix includes a translation vector; converting the image coordinates from the image coordinate system of the target image to the world coordinate system according to the calibration parameters to obtain the world coordinates includes the following steps:
[0026] Obtaining a first conversion parameter according to the product of the inverse of the internal parameter matrix and the inverse of the external parameter matrix;
[0027] Based on the product of the first conversion parameter and the image coordinates, the image coordinates are converted from the image coordinate system to the camera coordinate system of the target camera to obtain the camera coordinates;
[0028] Obtaining a second conversion parameter according to the product of the inverse of the extrinsic parameter matrix and the translation vector;
[0029] obtaining a ratio parameter based on a ratio of the second conversion parameter to the first conversion parameter;
[0030] The world coordinates are obtained by subtracting the second transformation parameter from the product of the camera coordinates and the scale parameter.
[0031] To achieve the above object, another aspect of an embodiment of the present invention provides a water pipe thickness identification device, the device comprising:
[0032] The first module is used to obtain a target image of the water pipe to be identified through a target camera;
[0033] The second module is used to input the target image into a preset semantic segmentation model to perform water pipe segmentation and obtain the water pipe contour of the water pipe to be identified;
[0034] The third module is used to extract the skeleton according to the water pipe outline to obtain the contour center line of the water pipe outline;
[0035] The fourth module is used to traverse the center point on the contour center line and search for the contour point closest to the center point on the water pipe contour;
[0036] The fifth module is used to obtain the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determine the thickness and size of the water pipe to be identified based on twice the physical distance.
[0037] In some embodiments, the apparatus further comprises:
[0038] The sixth module is used to train the preconfigured Unet model using the water pipe image with the outer contour annotated to obtain a semantic segmentation model.
[0039] To achieve the above objective, another aspect of an embodiment of the present invention provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above method when executing the computer program.
[0040] To achieve the above objective, another aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0041] The embodiments of the present invention include at least the following beneficial effects: the present invention provides a method, device, electronic device and storage medium for identifying the thickness of a water pipe. The scheme acquires a target image of a water pipe to be identified through a target camera; inputs the target image into a preset semantic segmentation model for water pipe segmentation to obtain the water pipe contour of the water pipe to be identified; extracts the skeleton according to the water pipe contour to obtain the contour centerline of the water pipe contour; traverses the center point on the contour centerline, and searches for the contour point closest to the center point on the water pipe contour; obtains the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determines the thickness size of the water pipe to be identified according to twice the physical distance. The embodiment of the present invention first identifies the water pipe contour by identifying the image of the water pipe, extracts the center line of the skeleton based on the water pipe contour, and then searches for the nearest relative points of the water pipe contour and the center line on the image, and then converts the points on the image into the world coordinate system to accurately realize the physical distance measurement; based on the axial symmetry of the water pipe, the embodiment of the present invention can accurately identify the radius of the water pipe through the center line and contour of the skeleton, and then deduce the size of the water pipe. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 This is a schematic diagram of an implementation environment for water pipe thickness identification provided by an embodiment of the present invention;
[0043] Figure 2 is a schematic diagram of a flow chart of a water pipe thickness identification method provided by an embodiment of the present invention;
[0044] Figure 3 It is a schematic diagram of the training process of compressing the Unet+++ network using the channel branch subtraction method provided by an embodiment of the present invention;
[0045] Figure 4 is an exemplary diagram of a water pipe and its skeleton provided by an embodiment of the present invention;
[0046] Figure 5 is an example diagram of a center point and its corresponding contour points provided by an embodiment of the present invention;
[0047] Figure 6 The embodiment of the present invention provides Figure 5 A partial enlarged view of
[0048] Figure 7 It is a schematic diagram of the overall process of the water pipe thickness identification method provided by an embodiment of the present invention;
[0049] Figure 8 It is a schematic diagram of the process principle of the water pipe thickness identification method provided by an embodiment of the present invention;
[0050] Fig. 9 is a schematic diagram of the structure of a water pipe thickness identification device provided by an embodiment of the present invention;
[0051] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present invention. They are only examples of devices and methods consistent with some aspects of the embodiments of the present invention as detailed in the attached claims.
[0053] It is understood that the terms "first", "second", etc. used in the present invention may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0054] The terms "at least one", "multiple", "each", "any", etc. used in the present invention, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein are only for the purpose of describing the embodiments of the present invention and are not intended to limit the present invention.
[0056] It should be noted that, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first / S100", "second / S200", etc. in the specification, claims and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0057] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0058] It is understandable that the water pipe thickness identification method provided in the embodiment of the present invention can be applied to any computer device with data processing and computing capabilities, and this computer device can be various terminals or servers. When the computer device in the embodiment is a server, the server is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Optionally, the terminal is a smart phone, tablet computer, laptop computer, desktop computer, etc., but is not limited to this.
[0059] like Figure 1 FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the invention. Figure 1 The implementation environment includes at least one terminal 102 and a server 101. The terminal 102 and the server 101 can be connected to a network wirelessly or wired to complete data transmission and exchange.
[0060] Server 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0061] In addition, the server 101 can also be a node server in the blockchain network. Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm.
[0062] The terminal 102 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal 102 and the server 101 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiment of the present invention.
[0063] Based on the example Figure 1 In the implementation environment shown, an embodiment of the present invention provides a method for identifying the thickness of a water pipe. The following is an example of the method for identifying the thickness of a water pipe being applied in a server 101 . It can be understood that the method for identifying the thickness of a water pipe can also be applied in a terminal 102 .
[0064] Reference Figure 2 , Figure 2 This is a flow chart of a method for identifying the thickness of a water pipe applied to a server provided in an embodiment of the present invention. The execution subject of the method for identifying the thickness of a water pipe may be any of the aforementioned computer devices (including a server or a terminal). Figure 2 The method includes but is not limited to steps S100 to S500.
[0065] S100, acquiring a target image of a water pipe to be identified through a target camera;
[0066] It should be noted that, with the development of unmanned driving technology, intelligent driving technology has been applied to various fields, such as catering delivery, medical antivirus, intelligent cleaning, etc. The embodiments of the present invention can be applied in the field of safety of unmanned sweepers, to segment and identify water pipes on the road surface when the unmanned sweeper is driving, and to calculate the thickness of the water pipes. Considering the low chassis of the sweeper, water pipes with a thickness of less than 5 cm are brushed and passed, and water pipes with a thickness of more than 5 cm are safely avoided by the unmanned sweeper. For example, in some specific implementations, the image of the water pipes on the subsequent path of the unmanned sweeper can be collected by a camera set on the unmanned sweeper.
[0067] S200, inputting the target image into a preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be identified;
[0068] It should be noted that, in some embodiments, the method may further include the following steps: training a preconfigured Unet model using a water pipe image with annotated outer contours to obtain a semantic segmentation model.
[0069] In some embodiments, a preconfigured Unet model is trained by using a water pipe image with annotated outer contours to obtain a semantic segmentation model, which may include the following steps: inputting the water pipe image into a preconfigured Unet model for segmentation processing to obtain a segmentation result; calculating the loss based on the outer contour and the segmentation result, and performing feedback adjustment on the parameters of the Unet model based on the loss calculation result to obtain a semantic segmentation model.
[0070] Exemplarily, in some specific implementations, Unet is an excellent semantic segmentation model, and its main execution process is similar to other semantic segmentation models. The difference from the image-level classification of conventional semantic segmentation models is that Unet is a pixel-level classification, and its output is the category of each pixel point, which is applied to the coarse and fine recognition of the embodiment of the present invention, and can accurately identify the size. Among them, the main parts of the Unet loss function (used to calculate the loss) are: softmax activation function, weighted cross entropy loss function and weight calculation function.
[0071] In order to further improve the recognition accuracy, in some preferred implementations, the Unet model can use a branch-reduced Unet+++ network to segment the water pipe. Figure 3 As shown, Unet+++ can use channel branch subtraction to compress the Unet+++ network and then segment the water pipe.
[0072] S300, extracting a skeleton according to the water pipe outline to obtain a center line of the water pipe outline;
[0073] It should be noted that, in some embodiments, step S300 may include: extracting an outer contour boundary based on the water pipe contour, filling the water pipe contour with white based on the outer contour boundary to obtain a white target object; and obtaining the contour centerline of the water pipe contour through a refinement algorithm based on the white target object.
[0074] For example, in some specific implementations, the outer contour boundary is extracted by the mask (water pipe contour) segmented previously, and then filled with white, and the edge of the white target object in the image is refined by using the Zhang-Suen algorithm as a refinement algorithm, such as Figure 4 As shown, a skeleton (ie, the center line of the contour) with a width of one pixel is finally obtained.
[0075] Among them, the implementation principle of the Zhang-Suen algorithm is as follows:
[0076] Initial conditions: The input is a binary image, where zero represents the background and non-zero represents the foreground. The goal of the algorithm is to refine the edges of foreground objects.
[0077] Iteration conditions: The Zhang-Suen algorithm consists of two iterative steps, which are usually performed alternately until no more changes occur.
[0078] The two steps are:
[0079] In the first step, the algorithm will traverse each pixel of the image and check whether the foreground color meets the following conditions.
[0080] The current pixel is white;
[0081] There is at least one black pixel in the 8-neighborhood (upper, lower, left, right, upper left, lower left, upper right, lower right) of the current pixel P;
[0082] In the 8-neighborhood of the current pixel, the number of white pixels is between 2 and 6;
[0083] If all the above conditions are met, the current pixel is marked as black.
[0084] In the second step, the algorithm again iterates over each pixel of the image and checks whether the foreground color satisfies the following conditions:
[0085] The current pixel is white;
[0086] Among the 8 neighbors of the current pixel, at least one is black;
[0087] In the 8-neighborhood of the current pixel, the number of white pixels is between 2 and 6;
[0088] The black pixels in the 8-neighborhood of the current pixel are not connected (i.e., not a connected component);
[0089] If all the above conditions are met, the current pixel is marked as black (background).
[0090] Iteration termination condition: Iteration steps 1 and 2 will be executed alternately until no more pixels can be deleted. If no pixels are deleted after one round of iteration, the algorithm terminates, otherwise it continues to the next round of iteration.
[0091] Results: After multiple iterations, the Zhang-Suen algorithm will refine the edges of the white target object in the image and eventually obtain a skeleton with a width of one pixel.
[0092] S400, traversing the center point on the contour center line, searching for the contour point closest to the center point on the water pipe contour;
[0093] It should be noted that, in some embodiments, searching for the contour point closest to the center point on the water pipe contour may include the following steps: based on the center point, performing a distance range search on the water pipe contour using a nearest neighbor algorithm; and determining the contour point corresponding to the center point on the water pipe contour based on the minimum distance result of the distance range search.
[0094] It should be understood that the purpose of traversing the center point on the contour center line is to facilitate the subsequent search to find the contour point corresponding to the center point on all points of the contour center line. Then, in the subsequent steps, the indoor distance obtained based on the center point and contour point processing is the radius of the water pipe at the corresponding center point. Due to the axial symmetry of the water pipe, the thickness and size of the corresponding point can be determined by the radius. In addition, in practical applications, the size of a section of water pipe at each point is usually constant, so the thickness and size of the entire section of water pipe can be calculated only by the center point and contour point corresponding to one point. In extreme cases, the size of each position of the entire section of water pipe can be calculated by the contour point corresponding to the center point on all points of the traversed contour center line.
[0095] For example, in some specific implementations, the outer contour points of the segmented mask are placed in a kd-tree, and the kd-tree is used to accelerate the traversal of the outer contour search. A point on the skeleton can quickly find its shortest distance point on the contour (such as Figure 5 and Figure 6 , Figure 6 for Figure 5 A local enlarged image of the image, where blue is the center point and green is its corresponding contour point).
[0096] Among them, the k-dimension tree is a data structure used for searching key data in multidimensional space, mainly used for nearest neighbor search and distance range search.
[0097] The kd tree can realize efficient nearest neighbor search by recursively dividing the k-dimensional data space into multiple subspaces. Its construction process is based on the divide-and-conquer strategy, which selects the dimension with the largest variance as the dividing dimension and the median as the dividing point on this dimension to divide the data space into two left and right subspaces. This process is recursively performed until each subspace contains only one data point or no data point.
[0098] The embodiment of the present invention uses a kd tree to perform a distance range search, that is, to find all points that meet a specific distance condition. This search method is similar to a nearest neighbor search, but all points that meet the condition need to be put into a result set.
[0099] S500, obtaining the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determining the thickness and size of the water pipe to be identified according to twice the physical distance.
[0100] It should be noted that, in some embodiments, obtaining the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera may include the following steps: obtaining the image coordinates of the center point and the contour point in the target image; the image coordinates include the first image coordinates of the center point and the second image coordinates of the contour point; converting the image coordinates from the image coordinate system of the target image to the world coordinate system according to the calibration parameters to obtain the world coordinates; the world coordinates include the center point world coordinates corresponding to the center point and the contour point world coordinates corresponding to the contour point; performing Euclidean distance calculation based on the center point world coordinates and the contour point world coordinates to obtain the physical distance between the center point and the contour point in the world coordinate system.
[0101] For example, in some specific implementations, the center point and the contour are respectively calculated using the calibrated internal and external parameters of the camera to calculate their physical distance points in the vehicle coordinate system (world coordinate system), and then the Euclidean distance between the two points is calculated. Double the distance is the thickness of the water pipe.
[0102] In some embodiments, the calibration parameters include an intrinsic parameter matrix and an extrinsic parameter matrix, the extrinsic parameter matrix includes a translation vector; according to the calibration parameters, the image coordinates are converted from the image coordinate system of the target image to the world coordinate system to obtain the world coordinates, including the following steps: obtaining a first conversion parameter according to the product of the inverse of the intrinsic parameter matrix and the inverse of the extrinsic parameter matrix; based on the product of the first conversion parameter and the image coordinates, converting the image coordinates from the image coordinate system to the camera coordinate system of the target camera to obtain the camera coordinates; obtaining a second conversion parameter according to the product of the inverse of the extrinsic parameter matrix and the translation vector; obtaining a scale parameter based on the ratio of the second conversion parameter to the first conversion parameter; and obtaining the world coordinates based on the product of the camera coordinates and the scale parameter minus the second conversion parameter.
[0103] For example, in some specific implementations, the specific calculation is as follows:
[0104] For example, the center point (skeleton point) a(x1,y1) is searched to obtain the corresponding contour point b(x2,y2), which is calculated by the camera intrinsic parameter matrix IntrinsicR, the extrinsic parameter matrix InverseR, and the translation vector T respectively:
[0105] The following is the process of converting skeleton points to world coordinate points:
[0106] exToinMat=InverseR^(-1)*IntrinsicR^(-1);
[0107] pixelToCamera=exToinMat*a;
[0108] pixelToCameraInverse=InverseR^(-1)*T;
[0109] scale=(pixelToCameraInverse(2,0)) / pixelToCamera(2,0);
[0110] Ya=pixelToCamera*scale–pixelToCameraInverse;
[0111] exToinMat is the first conversion parameter; pixelToCamera represents the camera coordinates obtained by converting the image coordinate system to the camera coordinate system of the target camera; pixelToCameraInverse represents the second conversion parameter of converting the image coordinate system to the world coordinate system; scale represents the scale parameter; Ya represents the world coordinates of the center point converted from the image coordinate system of the target image to the world coordinate system; similarly, Yb of the corresponding contour point can be calculated;
[0112] Therefore, it can be concluded that the thickness of the water pipe is d=2*|Yb-Ya|.
[0113] In order to explain the principle of the technical solution of the present invention in detail, the overall process of the present invention is described below in combination with some specific embodiments. It is easy to understand that the following is an explanation of the technical principle of the present invention and cannot be regarded as a limitation of the present invention.
[0114] First of all, it should be noted that it is necessary to perform semantic segmentation of the surrounding environment during driving in the field of unmanned sweepers, especially when it comes to safety issues. For example, when unmanned sweepers are used in parks and other scenes, water pipes are often encountered. Due to the low chassis of the sweeper, it is easy to put the water pipe into the wheel and burn the motor. Therefore, the segmentation and recognition of water pipes is very important. Considering the driving efficiency of unmanned sweepers, thin water pipes can be directly retracted and pressed over, while thick water pipes will cause dragging, so they need to be avoided. In this case, it is necessary to calculate the thickness of the water pipe.
[0115] The environmental perception of unmanned road sweepers on the market is mainly target-level segmentation and panoramic segmentation. The present invention compresses the Unet+++ segmentation algorithm network to suit the operation of edge computing devices, segments the specific locations of water pipes encountered by unmanned road sweepers during driving, and calculates the thickness of the water pipes.
[0116] like Figure 7 and Figure 8As shown, in some specific implementation modes, the present invention can be implemented through the following process principles:
[0117] Step 1: For the water pipe image captured by the camera of the unmanned sweeper, use the branch reduction based Unet+++ to segment the water pipe and obtain the water pipe contour mask.
[0118] like Figure 3 As shown, the Unet+++ network can be compressed using channel branch subtraction and then the water pipes can be segmented.
[0119] Step 2: Skeleton extraction.
[0120] The outer contour boundary is extracted through the mask segmented in step 1, and then filled with white. The edge of the white target object in the image is refined through the Zhang-Suen algorithm, and finally a skeleton with a width of one pixel is obtained.
[0121] Step 3: Distance calculation.
[0122] The outer contour points of the mask segmented in step 1 are placed in a kd-tree. The kd-tree is used to accelerate the traversal of the outer contour retrieval. A point on the skeleton can quickly find its shortest distance point on the contour (such as Figure 6 ), the physical distance between these two points in the vehicle coordinate system (world coordinate system) is calculated through the calibrated camera external parameters, and then the Euclidean distance between the two points is calculated. The twice distance is the thickness of the water pipe.
[0123] The specific calculation is as follows:
[0124] The skeleton point a(x1,y1) and the found contour point b(x2,y2) are calculated by the camera intrinsic parameter matrix IntrinsicR, the extrinsic parameter matrix InverseR, and the translation vector T respectively:
[0125] The following is the process of converting skeleton points to world coordinate points:
[0126] exToinMat=InverseR^(-1)*IntrinsicR^(-1);
[0127] pixelToCamera=exToinMat*a;
[0128] pixelToCameraInverse=InverseR^(-1)*T;
[0129] scale=(pixelToCameraInverse(2,0)) / pixelToCamera(2,0);
[0130] Ya=pixelToCamera*scale–pixelToCameraInverse;
[0131] Similarly, the Yb of the corresponding contour point can be calculated;
[0132] Therefore, it can be concluded that the thickness of the water pipe is d=2*|Yb-Ya|.
[0133] Through the above calculation, the water pipe has a series of sizes. As long as they are all smaller than a certain set value, the sweeper can retract its brush and pass through. As long as there is a point where the distance is greater than the set value, the sweeper needs to bypass the position to avoid passing.
[0134] See also Fig. 9 The embodiment of the present invention further provides a water pipe thickness identification device 900, which can implement the above-mentioned water pipe thickness identification method, and the device includes:
[0135] The first module 910 is used to obtain a target image of a water pipe to be identified through a target camera;
[0136] The second module 920 is used to input the target image into a preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be identified;
[0137] The third module 930 is used to extract the skeleton according to the water pipe outline to obtain the outline center line of the water pipe outline;
[0138] The fourth module 940 is used to traverse the center point on the contour center line and search for the contour point closest to the center point on the water pipe contour;
[0139] The fifth module 950 is used to obtain the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determine the thickness and size of the water pipe to be identified according to twice the physical distance.
[0140] In some embodiments, the apparatus may further include:
[0141] The sixth module is used to send a preset prompt message to the client or play the preset prompt message through a preset audio device when the instruction text is not matched and parsed to the intent keyword and / or entity keyword.
[0142] In some embodiments, the instruction data is transmitted to the client based on a preset communication connection, and the device may further include:
[0143] The sixth module is used to train the preconfigured Unet model using the water pipe image with the outer contour annotated to obtain a semantic segmentation model.
[0144] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0145] The embodiment of the present invention further provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned water pipe thickness identification method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0146] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0147] See also Fig.10 , Fig.10 The hardware structure of an electronic device 1000 of another embodiment is illustrated. The electronic device includes:
[0148] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;
[0149] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the water pipe thickness identification method of the embodiment of the present invention;
[0150] Input / output interface 1003, used to implement information input and output;
[0151] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0152] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );
[0153] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .
[0154] An embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the water pipe thickness identification method is implemented.
[0155] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0156] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0157] The water pipe thickness recognition method, water pipe thickness recognition device, electronic device and storage medium provided by the embodiment of the present invention obtain the target image of the water pipe to be recognized through the target camera; input the target image into the preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be recognized; perform skeleton extraction according to the water pipe contour to obtain the contour centerline of the water pipe contour; traverse the center point on the contour centerline, and search for the contour point closest to the center point on the water pipe contour; obtain the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determine the thickness size of the water pipe to be recognized according to twice the physical distance. The embodiment of the present invention first recognizes the water pipe contour by recognizing the image of the water pipe, and extracts the center line of the skeleton based on the water pipe contour, and then searches for the nearest relative points of the water pipe contour and the center line on the image, and then converts the points on the image into the world coordinate system to accurately realize the physical distance measurement; based on the axial symmetry of the water pipe, the embodiment of the present invention can accurately identify the radius of the water pipe through the center line and contour of the skeleton, and then deduce the size of the water pipe.
[0158] The embodiments described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention, and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. Those skilled in the art can appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0159] Those skilled in the art will appreciate that the technical solutions shown in the figures do not limit the embodiments of the present invention and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0160] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0161] Those skilled in the art will appreciate that all or some of the steps, devices, and functional modules / units in the above disclosed methods may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0162] The terms "first", "second", "third", "fourth", etc. (if any) in the description of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0163] It should be understood that in the present invention, "at least one (item)" refers to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can represent: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0164] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0165] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0166] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0167] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including multiple instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store programs.
[0168] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the embodiments of the present invention is not limited thereby. Any modification, equivalent substitution and improvement made by those skilled in the art without departing from the scope and essence of the embodiments of the present invention shall be within the scope of the rights of the embodiments of the present invention.
Claims
1. A method for identifying the thickness of a water pipe. It is characterized in that The method comprises the following steps: Acquire a target image of the water pipe to be identified through a target camera; Inputting the target image into a preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be identified; Perform skeleton extraction according to the water pipe outline to obtain the outline center line of the water pipe outline; Traversing the center point on the center line of the contour, searching for the contour point closest to the center point on the water pipe contour; The physical distance between the center point and the contour point in the world coordinate system is obtained based on the calibration parameter processing of the target camera; and the thickness and size of the water pipe to be identified are determined according to twice the physical distance.
2. The method according to claim 1, It is characterized in that The method further comprises the following steps: The semantic segmentation model is obtained by training the preconfigured Unet model using the water pipe image with the outer contour marked.
3. The method according to claim 2, It is characterized in that The pre-configured Unet model is trained by using the water pipe image with the outer contour marked to obtain the semantic segmentation model, including the following steps: Input the water pipe image into the preconfigured Unet model for segmentation processing to obtain a segmentation result; The loss is calculated according to the outer contour and the segmentation result, and the parameters of the Unet model are feedback-adjusted based on the loss calculation result to obtain the semantic segmentation model.
4. The method according to claim 1, It is characterized in that The skeleton extraction is performed according to the water pipe outline to obtain the outline center line of the water pipe outline, including the following steps: Extracting an outer contour boundary according to the water pipe contour, and filling the water pipe contour with white based on the outer contour boundary to obtain a white target object; According to the white target object, the contour center line of the water pipe contour is obtained by thinning algorithm processing.
5. The method according to claim 1, It is characterized in that The step of searching for the contour point closest to the center point on the water pipe contour comprises the following steps: Based on the center point, a distance range search is performed on the water pipe contour by a nearest neighbor algorithm; The contour point corresponding to the center point on the water pipe contour is determined according to the minimum distance result of the distance range search.
6. The method according to claim 1, It is characterized in that The obtaining of the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera comprises the following steps: Acquire the image coordinates of the center point and the contour point in the target image; the image coordinates include the first image coordinates of the center point and the second image coordinates of the contour point; The image coordinates are converted from the image coordinate system of the target image to the world coordinate system according to the calibration parameters to obtain world coordinates; the world coordinates include the center point world coordinates corresponding to the center point and the contour point world coordinates corresponding to the contour point; The Euclidean distance calculation is performed based on the world coordinates of the center point and the world coordinates of the contour point to obtain the physical distance between the center point and the contour point in the world coordinate system.
7. The method according to claim 6, It is characterized in that The calibration parameters include an intrinsic parameter matrix and an extrinsic parameter matrix, wherein the extrinsic parameter matrix includes a translation vector; and the image coordinates are converted from the image coordinate system of the target image to the world coordinate system according to the calibration parameters to obtain the world coordinates, comprising the following steps: Obtaining a first conversion parameter according to the product of the inverse of the internal parameter matrix and the inverse of the external parameter matrix; Based on the product of the first conversion parameter and the image coordinates, convert the image coordinates from the image coordinate system to the camera coordinate system of the target camera to obtain camera coordinates; Obtaining a second conversion parameter according to the product of the inverse of the extrinsic parameter matrix and the translation vector; obtaining a proportional parameter based on a ratio of the second conversion parameter to the first conversion parameter; The world coordinates are obtained based on the product of the camera coordinates and the scale parameter minus the second conversion parameter.
8. A water pipe thickness identification device, It is characterized in that The device comprises: The first module is used to obtain a target image of the water pipe to be identified through a target camera; The second module is used to input the target image into a preset semantic segmentation model to perform water pipe segmentation to obtain the water pipe contour of the water pipe to be identified; The third module is used to extract the skeleton according to the water pipe outline to obtain the outline center line of the water pipe outline; A fourth module is used to traverse the center point on the center line of the contour and search for the contour point closest to the center point on the water pipe contour; The fifth module is used to obtain the physical distance between the center point and the contour point in the world coordinate system based on the calibration parameter processing of the target camera; and determine the thickness and size of the water pipe to be identified according to twice the physical distance.
9. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Vessel segmentation method and device
CN108537802A
Endoscope target object size calculating method and analysis system
CN109730683A
Target blood vessel extraction method and device and computer readable storage medium
CN112652011A
Two-dimensional pixel-level three-dimensional positioning system and method
CN113674345A
Laser welding seam feature point identification method and device based on deep learning
CN114140439A
