In-pipe detection method, device, electronic equipment and medium based on binocular matching
Through the in-pipe detection method based on binocular matching, using the image cost algorithm and depth calculation formula, the problem of low accuracy of in-pipe depth detection in the existing technology is solved, and higher detection precision and accuracy are achieved.
Patent Information
- Application Number
- CN202210752142.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-06-29
AI Technical Summary
In the existing technology, the depth detection accuracy in the tube is low, especially because the Sobel X operator edge detection in the SGBM algorithm has a high mismatch rate and poor grayscale absolute difference matching accuracy, and is easily affected by ambient lighting.
An in-tube detection method based on binocular matching is adopted. By obtaining the internal and external parameters of the binocular camera, the image cost algorithm (gradient cost and Hamming distance cost) is used to determine the image pair matching disparity map, and the depth calculation formula is used to generate the in-tube image depth. Figure, reduce the impact of lighting and noise, and improve detection accuracy.
It effectively improves the precision and accuracy of image depth detection in the tube, reduces the impact of noise, and enhances the effectiveness of the detection results.
Smart Images

Figure CN115100153B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to an in-pipe detection method, device, electronic equipment and medium based on binocular matching. Background Art
[0002] As the size of cities continues to expand, various pipelines such as industrial, sewage, and domestic pipelines are laid in the urban pipeline network and are closely related to urban life. The task of pipeline inspection and maintenance is becoming more and more important and has become an important task that cannot be ignored.
[0003] At present, pipeline inspection can be divided into two categories according to the location of the inspection equipment: external inspection and internal inspection. External inspection is to place the inspection equipment outside the pipeline to inspect the pipeline, and internal inspection is to place the detector inside the pipeline for inspection. Internal inspection usually uses binocular stereo vision to determine the location of pipeline defects, and the semi-global algorithm in binocular stereo vision uses the SGBM algorithm. However, the SGBM matching method in the SGBM algorithm uses the Sobel X operator for edge detection, which has a certain mismatch rate; the cost calculation in the SGBM algorithm is mainly the gray absolute difference (SAD), the matching accuracy is poor, and it is easily affected by factors such as ambient light, making it difficult to obtain more accurate depth information inside the pipeline.
[0004] Therefore, in the process of in-pipe detection, the prior art has the problem of low detection accuracy of the depth in the pipe. Summary of the invention
[0005] In view of this, it is necessary to provide a method, device, electronic equipment and medium for in-pipe detection based on binocular matching to solve the problem of low in-pipe depth detection accuracy in the prior art.
[0006] In order to solve the above problems, the present invention provides a method for in-pipe detection based on binocular matching, comprising:
[0007] Acquire internal parameters and external parameters of the binocular camera and a binocular image pair taken by the binocular camera, and determine a left image set and a right image set based on the internal parameters and the external parameters;
[0008] According to the left image set and the right image set, a matching disparity map of the image pair is determined by using an image cost algorithm;
[0009] According to the disparity map matched by the image pair, the depth map of the image inside the tube is determined using the depth calculation formula.
[0010] Furthermore, the internal and external parameters of the binocular camera are obtained, including:
[0011] The internal and external parameters of the binocular camera are determined according to Zhang Zhengyou's chessboard calibration method.
[0012] Further, based on the internal parameters and the external parameters, determining the left image set and the right image set includes:
[0013] Obtain a binocular image pair taken by a binocular camera, and correct the binocular image pair according to internal parameters and external parameters to obtain a horizontally consistent image pair;
[0014] Grayscale the image pairs with consistent levels to obtain grayscale image pairs;
[0015] Classify grayscale image pairs and determine the left image set and the right image set.
[0016] Furthermore, the image cost algorithm includes a gradient cost algorithm and a Hamming distance cost algorithm. The image cost algorithm is used to determine the matching disparity map of the image pair, including:
[0017] According to the left image set and the right image set, based on the gradient cost algorithm, the gradient cost of the image in the tube is determined;
[0018] Based on the Hamming distance cost algorithm, determine the Hamming distance cost of the image in the tube;
[0019] Based on the gradient cost and the Hamming distance cost, the matching disparity map of the image pair is determined according to the path aggregation function.
[0020] Furthermore, based on the gradient cost algorithm, the gradient cost of the image in the tube is determined, including:
[0021] The left image set and the right image set are processed respectively by using bilateral filtering to remove outliers, and the target left image set and the target right image set are obtained;
[0022] According to the Canny algorithm, edge detection is performed on the target left image set and the target right image set respectively to determine the gradient feature map of the image in the tube;
[0023] Perform Census transformation on the gradient feature map to determine the gradient cost of the image in the tube.
[0024] Furthermore, based on the Hamming distance cost algorithm, the Hamming distance cost of the image in the tube is determined, including:
[0025] Obtain the cost calculation areas of the left image set and the right image set respectively;
[0026] Filter the cost calculation area to obtain a median filter, and replace the center value of the cost calculation area with the median filter;
[0027] Census transformation is performed on the left image set and the right image set to determine the Hamming distance cost of the image in the tube.
[0028] Further, according to the path aggregation function, the image pair matching disparity map is determined, including:
[0029] According to the dynamic programming method with adjustment parameters, the penalty parameters corresponding to the gradient cost and the Hamming distance cost are adjusted to determine the optimal path aggregation function;
[0030] According to the optimal path aggregation function, the matching disparity map of the image pair is determined.
[0031] In order to solve the above problems, the present invention also provides an in-pipe detection device based on binocular matching, comprising:
[0032] An image set acquisition module is used to acquire internal parameters and external parameters of the binocular camera and a binocular image pair taken by the binocular camera, and determine a left image set and a right image set based on the internal parameters and the external parameters;
[0033] An image pair matching disparity map acquisition module is used to determine an image pair matching disparity map based on a left image set and a right image set using an image cost algorithm;
[0034] The in-tube depth map determination module is used to determine the in-tube depth map according to the image pair matching disparity map and using the depth calculation formula.
[0035] In order to solve the above problems, the present invention also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the in-tube detection method based on binocular matching as described above is implemented.
[0036] In order to solve the above problems, the present invention also provides a computer-readable storage medium, which stores computer program instructions. When the computer program instructions are executed by a computer, the computer executes the in-tube detection method based on binocular matching as described above.
[0037] The beneficial effect of adopting the above technical solution is: the present invention provides a method, device, electronic device and medium for in-pipe detection based on binocular matching, the method comprising: first, collecting in-pipe images through a binocular camera, using two cameras to collect images at the same time, and realizing stereo matching image data; then, using an image cost algorithm to determine the image pair matching disparity map, which not only reduces the influence of external lighting conditions, but also can effectively suppress noise and improve the effectiveness of the in-pipe image; finally, using a depth calculation formula to process the in-pipe image data, balancing the influence of noise in cost aggregation. In this application, the image cost algorithm is used to extract data information from the binocular image pair, which can effectively improve the accuracy of the image data; because the image is obtained through a binocular camera, the information in the tube can be observed from multiple angles, and a stereo image can be generated, thereby reducing the accuracy impact caused by low-dimensional information and improving the detection accuracy of the depth of the in-pipe image; finally, based on the depth calculation, the depth map of the image is obtained in a targeted manner, which improves the detection accuracy of the depth in the tube. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of a flow chart of an embodiment of an in-tube detection method based on binocular matching provided by the present invention;
[0039] Figure 2 A schematic diagram of a flow chart of an embodiment of determining a left image set and a right image set provided by the present invention;
[0040] Figure 3 The present invention provides a method for determining the matching disparity of an image pair. Figure 1 Schematic diagram of the process of the embodiment;
[0041] Figure 4 A schematic diagram of a flow chart of an embodiment of determining the gradient cost of an in-tube image provided by the present invention;
[0042] Figure 5 A schematic diagram of a flow chart of an embodiment of determining the Hamming distance cost of an image in a tube provided by the present invention;
[0043] Figure 6 This is a diagram of path aggregation. Figure 1 An angled view of an embodiment;
[0044] Figure 7 is the image depth inside the tube Figure 1 Result diagram of the embodiment;
[0045] Figure 8 A schematic diagram of the structure of the in-pipe detection device based on binocular matching provided by the present invention;
[0046] Fig. 9 This is a structural block diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0047] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0048] Before describing the embodiments, the in-tube detection is first described:
[0049] In-pipe inspection refers to using the pipeline medium to drive the detector to run in the pipeline, real-time detection and recording of pipeline deformation, corrosion and other damage conditions, and accurate positioning. Through the detection results of the detector in the pipeline, combined with computer and other data analysis equipment, the detection results are analyzed and judged to understand the condition of the pipeline. It can usually be used to detect pipeline deformation, corrosion and defects.
[0050] Furthermore, after the deformation, corrosion and defects of the pipeline are detected by the in-pipe inspection method, in order to facilitate the subsequent maintenance and protection of the pipeline, it is also necessary to locate the problematic part in the pipeline. Generally, the distance between the problematic part and the camera is determined by the in-pipe depth inspection method.
[0051] At present, binocular stereo vision is generally used to determine the location of pipeline defects, that is, binocular stereo vision is used to determine the location of pipeline defects. However, the binocular stereo vision method has the problems of low matching rate and poor matching accuracy, which leads to the problem of low detection accuracy of the depth in the pipe in the prior art.
[0052] In order to solve the problem of low detection accuracy of pipe depth in the prior art, the present invention provides a pipe detection method, device, electronic equipment and medium based on binocular matching, which are described in detail below.
[0053] like Figure 1 As shown, Figure 1 The flowchart of an embodiment of the in-tube detection method based on binocular matching provided by the present invention includes:
[0054] Step S101: acquiring internal parameters and external parameters of a binocular camera and a binocular image pair taken by the binocular camera, and determining a left image set and a right image set based on the internal parameters and the external parameters.
[0055] Step S102: Determine the image pair matching disparity map using an image cost algorithm according to the left image set and the right image set.
[0056] Step S103: According to the image pair matching disparity map, a depth calculation formula is used to determine the depth map of the image in the tube.
[0057] In this embodiment, first, the binocular camera includes two cameras with exactly the same properties, and the internal parameters and external parameters of the binocular camera are determined according to the positions of the two cameras; then, the binocular camera is used to shoot images in the tube to obtain a binocular image pair, and the images shot by different shooting cameras are grouped to determine a left image set and a right image set; next, the image cost algorithm is used to process the left image set and the right image set respectively to obtain their corresponding gradient costs and Hamming distance costs, and then the gradient cost and the Hamming distance cost are combined to determine the image pair matching disparity map; finally, the depth calculation formula is used to perform data processing on the image pair matching disparity map to determine the depth map of the image in the tube.
[0058] It can be understood that in the above embodiment, by collecting the in-tube image through the binocular camera, the in-tube image can be better positioned, and by using the image cost algorithm to determine the image pair matching disparity map, a high-precision cost value can be obtained, thereby improving the positioning accuracy of the in-tube image.
[0059] As a preferred embodiment, in step S101, in order to determine the internal parameters and external parameters of the binocular camera, the Zhang Zhengyou chessboard calibration method is used for calculation.
[0060] In a specific embodiment, a black and white chessboard with a size of 9*9 and a side length of 25 mm is used as a calibration plate, 25 groups of binocular images of the calibration plate in different postures are taken within the working distance of the binocular camera, and the captured binocular images are calibrated using MATLAB Camera Calibrator.
[0061] In a specific embodiment, the resolution of the image captured by the binocular camera is 800*800.
[0062] In a specific embodiment, the internal parameters of the binocular camera include: how many length units a pixel occupies in the x direction, denoted as dx; how many length units a pixel occupies in the y direction, denoted as dy; the number of horizontal pixels that differ between the central pixel coordinates of the image and the pixel coordinates of the image origin, denoted as u0; the number of vertical pixels that differ between the central pixel coordinates of the image and the pixel coordinates of the image origin, denoted as v0; and the focal length of the camera, denoted as f.
[0063] Among them, dx and dy are the key to realize the conversion between the image physical coordinate system and the pixel coordinate system.
[0064] The external parameters of the binocular camera include: the rotation parameters of the three axes, denoted as ω, δ, θ; the translation parameters of the three axes, denoted as Tx, Ty, Tz.
[0065] Among them, the 3*3 rotation matrices of each axis are combined, that is, the matrices are multiplied to obtain the rotation information of the three axes, denoted as R, and its size is still 3*3; then R is combined with the translation parameters of the three axes to obtain a 3*4 matrix, which is the key to converting to the calibration paper coordinates.
[0066] In other embodiments, calibration plates of other specifications may be selected, and binocular images of other numbers of calibration plates may be captured; in addition, the resolution of the images captured by the binocular camera may be adjusted according to actual needs.
[0067] As a preferred embodiment, in step S101, in order to determine the left image set and the right image set according to the binocular image pair taken by the binocular camera, such as Figure 2 As shown, Figure 2 A schematic diagram of a flow chart of an embodiment of determining a left image set and a right image set provided by the present invention includes:
[0068] Step S111: obtaining a binocular image pair taken by a binocular camera, and correcting the binocular image pair according to internal parameters and external parameters to obtain a horizontally consistent image pair.
[0069] Step S112: grayscale the horizontally consistent image pair to obtain a grayscale image pair.
[0070] Step S113: classify the grayscale image pairs to determine a left image set and a right image set.
[0071] In this embodiment, in order to obtain a binocular image pair, a calibrated binocular camera is used to shoot the situation inside the tube. Since the binocular camera includes two cameras, the images inside the tube can be obtained in pairs, that is, the binocular image pair.
[0072] In step S111, the binocular image pair is corrected according to the internal and external parameters of the binocular camera. On the one hand, the distortion of the binocular image caused by the influence of the camera is eliminated; on the other hand, epipolar correction is performed so that the image content in each pair of binocular images can be kept consistent in the horizontal position, that is, a horizontally consistent image pair is obtained.
[0073] In step S112, the horizontally consistent image pair is grayscaled so that the image data in the RGB space is converted to the grayscale space, thereby obtaining a grayscale image pair.
[0074] In step S113, the grayscale image pairs are classified according to the different shooting cameras to determine the left image set and the right image set.
[0075] In this embodiment, by correcting the binocular image pair taken by the binocular camera, the external influence caused by the binocular camera shooting is eliminated; then, the binocular image pair is grayed to highlight the characteristics of the binocular image pair, and the target data can be acquired more specifically according to the grayscale image pair; finally, the binocular image pairs are grouped, which is conducive to the subsequent orderly processing of the binocular image data.
[0076] As a preferred embodiment, in step S102, after obtaining the left image set and the right image set, an image cost algorithm is required to determine the matching disparity map of the image pair, such as Figure 3 As shown, Figure 3 The present invention provides a method for determining the matching disparity of an image pair. Figure 1 The schematic diagram of the process of the embodiment includes:
[0077] Step S121: Determine the gradient cost of the image in the tube based on the left image set and the right image set and based on the gradient cost algorithm.
[0078] Step S122: Determine the Hamming distance cost of the image in the tube based on the Hamming distance cost algorithm.
[0079] Step S123: determining a matching disparity map of the image pair based on the gradient cost and the Hamming distance cost and according to the path aggregation function.
[0080] In this embodiment, first, the data of the left image set and the right image set are merged through the gradient cost algorithm to determine the gradient cost of the image in the tube; then, the Hamming distance cost of the image in the tube is determined through the Hamming distance cost algorithm; finally, the gradient cost and the Hamming distance cost are integrated through the path aggregation function to determine the image pair matching disparity map. The data of the left image set and the right image set are integrated to finally determine the pair matching disparity map of the image in the tube for subsequent processing.
[0081] As a preferred embodiment, Figure 4 As shown, Figure 4 A schematic diagram of a flow chart of an embodiment of determining the gradient cost of an in-tube image provided by the present invention includes:
[0082] Step S1211: Use bilateral filtering to process the left image set and the right image set respectively, remove outliers, and obtain a target left image set and a target right image set.
[0083] Step S1212: Perform edge detection on the target left image set and the target right image set respectively according to the Canny algorithm to determine the gradient feature map of the image in the tube.
[0084] Step S1213: Perform Census transformation on the gradient feature map to determine the gradient cost of the image in the tube.
[0085] In this embodiment, first, a threshold interval of image data is set according to actual needs, and bilateral filtering is used to remove outliers in the left image set and the right image set according to the threshold interval to obtain a target left image set and a target right image set; then, the Canny algorithm is used to perform edge detection on the target left image set and the target right image set, so that the target left image set and the target right image set become smooth, and then the smoothed target left image set and the target right image set are combined together to extract gradient features, thereby determining a gradient feature map of the image in the tube; finally, according to the Census transformation, the gradient feature map of the image in the tube is converted into a gradient cost, thereby determining the gradient cost of the image in the tube.
[0086] In this embodiment, on the one hand, bilateral filtering is used to remove outliers, thereby realizing the extraction of required image data from multiple aspects and reducing the difficulty of subsequent calculations; on the other hand, the Canny algorithm is used to smooth the image and determine the gradient feature map, thereby optimizing the gradient features of the image data and effectively extracting the gradient cost of the in-tube image, thereby realizing the quantitative calculation of the in-tube image.
[0087] In a specific embodiment, the calculation formula of the pixel output value of the bilateral filter is:
[0088]
[0089] Among them, P(i,j) is the pixel output value; f(k,l) is the pixel input value; ω(i,j,k,l) is the weighting coefficient.
[0090] As a preferred embodiment, Figure 5 As shown, Figure 5 A schematic diagram of a flow chart of an embodiment of determining the Hamming distance cost of an image in a tube provided by the present invention includes:
[0091] Step S1221: Obtain the cost calculation areas of the left image set and the right image set respectively.
[0092] Step S1222: Filter the cost calculation area to obtain a median filter, and replace the center value of the cost calculation area with the median filter.
[0093] Step S1223: Perform Census transformation on the left image set and the right image set to determine the Hamming distance cost of the image in the tube.
[0094] In this embodiment, first, the left image set and the right image set are divided into regions to determine their cost calculation regions; then, the cost calculation regions are filtered in turn to obtain the median filter of each cost calculation region, and further, the center value of the cost calculation region is replaced by the median filter; finally, the Census transform is used to determine the Hamming distance cost of the image in the tube.
[0095] In this embodiment, by replacing the central value of the cost calculation area with a median filter, noise is effectively suppressed and the processing accuracy of the in-tube image is improved.
[0096] In a specific embodiment, a square cost calculation area of a 5×5 window is selected as a filtering window, and median filtering is performed on the pixels in the filtering window to obtain the center pixel value; then, the center pixel value is used to fill the center pixel of the area; finally, the Census transform is used to obtain the transformation code of the image in the tube, thereby determining the Hamming distance cost of the image in the tube.
[0097] In this embodiment, the noise points of the central pixel points can be effectively removed by filtering through the filter window, thereby reducing noise interference.
[0098] In a specific embodiment, when encountering noise near the center value, using traditional transformation will obtain completely different transformation codes, while after adding filtering, the difference between the result and the result not affected by noise is only 1, thus achieving effective noise suppression.
[0099] Furthermore, in step S103, after the gradient cost and the Hamming distance cost of the in-tube image are obtained, the matching disparity map of the image pair is determined according to the path aggregation function.
[0100] Firstly, according to a dynamic programming method with adjustment parameters, the penalty parameters corresponding to the gradient cost and the Hamming distance cost are adjusted to determine the optimal path aggregation function; then, according to the optimal path aggregation function, the matching disparity map of the image pair is determined.
[0101] Specifically, when using the dynamic programming method to smooth each path, two penalty parameters are involved. These two penalty parameters play an important role in the smoothing term, directly affecting the aggregation result of each path and affecting the final disparity map.
[0102] In this embodiment, in order to avoid low accuracy of the final result due to incorrect selection of the two penalty parameters, an adjustment parameter is added based on the two penalty parameters. By adjusting the penalty function, the accuracy of the penalty parameter is improved, and a smoother path and a clearer boundary are achieved.
[0103] In one embodiment, the adjustment parameter P N The calculation formula is:
[0104] P N =(1cosθ)*t
[0105] Among them, θ is the vector angle between pr and p+r, t is a constant term, and P is set N The upper threshold of , usually 1.
[0106] like Figure 6 As shown, Figure 6 This is a diagram of path aggregation. Figure 1 An angled view of an embodiment.
[0107] In a specific embodiment, after the adjustment parameters are determined, the calculation formula of the path aggregation function is:
[0108] L r (p,d)=C(p,d)+min(L r (pr,d),
[0109] L r (pr,d-1)+P 1 +P N ,
[0110] L r (pr,d+1)+P 1 +P N ,
[0111]
[0112] Among them, P 1 , P 2 is a constant, and P is specified 1 The constant term must be less than P 2 The constant term of .
[0113] In particular, when the parallax changes greatly, P 2 Punishment, when P 2 If the setting is too large, the boundary will be blurred. N The parameters will adjust the penalty function to reduce P 2 The effect is to smooth the path and clarify the boundaries.
[0114] In a specific embodiment, the matching cost is processed based on the WTA algorithm. During the processing, the Euclidean distance of the original algorithm is replaced with the standard Euclidean distance to eliminate the influence of the unbalanced gradient of the image data, and finally the matching disparity map of the image pair is output.
[0115] As a preferred embodiment, in step S104, the depth map of the image in the tube is determined according to the disparity map of the image pair matching, wherein the depth calculation formula is:
[0116]
[0117] d = X l -X r
[0118] Among them, Z represents the image depth, d represents the left and right disparity, f can be obtained through calibration, and T is the optical center distance of the binocular camera.
[0119] In a specific embodiment, if Figure 7 As shown, Figure 7 is the image depth inside the tube Figure 1 Result diagram of the embodiment.
[0120] Through the above method, the image pair matching disparity map of the binocular image pair is determined according to the gradient cost calculation and the Hamming distance cost calculation, and then the depth map of the image in the tube is determined according to the image pair matching disparity map. Since the gradient cost calculation and the Hamming distance cost calculation can better smooth the noise of the image in the tube, the processing accuracy of the image in the tube is improved, so as to obtain a higher accuracy depth map of the image in the tube.
[0121] In order to test the effect of this technical solution, a comparative experiment was carried out.
[0122] In the comparative test, on a PC, the binocular matching algorithm and the SGBM matching algorithm described in the present invention are performed on the standard image pairs provided by the Middlebury data set. The test environment is Ubantu20.04, C++ is implemented with CUDA and OpenCV programming, the hardware is Intel corei9-10980XE 3.0GHz, and the memory space is 128G. The processing results are shown in the following two tables:
[0123] %
[0124]
[0125] Table 1. Algorithm mismatch rate
[0126] s
[0127]
[0128] Table 2 Algorithm matching time
[0129] From the results of the above comparative tests, it can be seen that compared with the SGBM method, the present invention has a lower mismatch rate and a shorter matching time. In other words, the present technical solution can not only improve the detection accuracy of the depth in the pipe, but also improve the detection speed.
[0130] In order to solve the above problems, the present invention also provides a tube detection device based on binocular matching, such as Figure 8 As shown, Figure 8 The schematic diagram of the structure of the in-pipe detection device based on binocular matching provided by the present invention is as follows. The in-pipe detection device based on binocular matching 800 includes:
[0131] The image set acquisition module 801 is used to acquire the internal parameters and external parameters of the binocular camera and the binocular image pair taken by the binocular camera, and determine the left image set and the right image set based on the internal parameters and the external parameters;
[0132] An image pair matching disparity map acquisition module 802 is used to determine an image pair matching disparity map using an image cost algorithm according to a left image set and a right image set;
[0133] The in-tube depth map determination module 803 is used to determine the in-tube depth map according to the image pair matching disparity map and using the depth calculation formula.
[0134] In a specific embodiment, since there is insufficient light in the tube, when photographing the situation in the tube, it is necessary to perform fill light operation according to the actual situation, that is, the image set acquisition module 801 also includes a fill light module.
[0135] The present invention also provides an electronic device, such as Fig. 9 As shown, Fig. 9 This is a structural block diagram of an embodiment of an electronic device provided by the present invention. The electronic device 900 can be a computing device such as a mobile terminal, a desktop computer, a notebook, a PDA, and a server. The electronic device 900 includes a processor 901 and a memory 902, wherein the memory 902 stores a binocular matching-based in-pipe detection program 903.
[0136] In some embodiments, the memory 902 may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory 902 may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory 902 may also include both an internal storage unit of the computer device and an external storage device. The memory 902 is used to store application software and various types of data installed in the computer device, such as program codes for installing the computer device. The memory 902 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the in-pipe detection program 903 based on binocular matching may be executed by the processor 901, thereby realizing the in-pipe detection method based on binocular matching of each embodiment of the present invention.
[0137] In some embodiments, the processor 901 can be a central processing unit (CPU), a microprocessor or other data processing chip, which is used to run the program code or process data stored in the memory 902, such as executing an in-tube detection program based on binocular matching.
[0138] This embodiment also provides a computer-readable storage medium, on which a binocular matching-based in-tube detection program is stored. When the computer program is executed by a processor, the binocular matching-based in-tube detection method as described in any of the above technical solutions is implemented.
[0139] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0140] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for in-tube detection based on binocular matching, characterized in that: include: Acquire internal parameters and external parameters of a binocular camera and a binocular image pair taken by the binocular camera, and determine a left image set and a right image set based on the internal parameters and the external parameters; Determine, according to the left image set and the right image set, a disparity map of image pair matching using an image cost algorithm; According to the image pair matching disparity map, a depth map of the image in the tube is determined using a depth calculation formula; The image cost algorithm includes a gradient cost algorithm and a Hamming distance cost algorithm. The method of using the image cost algorithm to determine the matching disparity map of the image pair includes: Determining the gradient cost of the in-tube image based on the left image set and the right image set and the gradient cost algorithm; Determining the Hamming distance cost of the in-tube image based on the Hamming distance cost algorithm; Based on the gradient cost and the Hamming distance cost, determining a matching disparity map of the image pair according to a path aggregation function; The depth calculation formula is: Among them, Z represents the image depth, d represents the left and right disparity, f is obtained through calibration, and T is the optical center distance of the binocular camera.
2. The method for in-pipe detection based on binocular matching according to claim 1, characterized in that: Get the internal and external parameters of the binocular camera, including: The internal and external parameters of the binocular camera are determined by calculation according to Zhang Zhengyou's chessboard calibration method.
3. The method for in-pipe detection based on binocular matching according to claim 1, characterized in that: The determining of the left image set and the right image set based on the internal parameters and the external parameters comprises: Acquire a binocular image pair taken by the binocular camera, and correct the binocular image pair according to the internal parameters and the external parameters to obtain a horizontally consistent image pair; grayscale the image pair with the same level to obtain a grayscale image pair; The grayscale image pairs are classified to determine a left image set and a right image set.
4. The method for in-pipe detection based on binocular matching according to claim 1, characterized in that: Determining the gradient cost of the image in the tube based on the gradient cost algorithm includes: The left image set and the right image set are processed respectively by using bilateral filtering to remove outliers, thereby obtaining a target left image set and a target right image set; Performing edge detection on the target left image set and the target right image set respectively according to the Canny algorithm to determine the gradient feature map of the image in the tube; Perform Census transformation on the gradient feature map to determine the gradient cost of the in-tube image.
5. The method for in-pipe detection based on binocular matching according to claim 4, characterized in that: The determining the Hamming distance cost of the in-tube image based on the Hamming distance cost algorithm includes: Respectively obtaining cost calculation areas of the left image set and the right image set; Filtering the cost calculation area to obtain a median filter, and replacing the center value of the cost calculation area with the median filter; Census transformation is performed on the left image set and the right image set to determine the Hamming distance cost of the image in the tube.
6. The method for in-pipe detection based on binocular matching according to claim 5, characterized in that: The step of determining the image pair matching disparity map according to the path aggregation function includes: According to a dynamic programming method with adjustment parameters, the penalty parameters corresponding to the gradient cost and the Hamming distance cost are adjusted to determine an optimal path aggregation function; According to the optimal path aggregation function, a matching disparity map of the image pair is determined.
7. An in-pipe inspection device based on binocular matching, characterized in that: include: An image set acquisition module, used to acquire internal parameters and external parameters of a binocular camera and a binocular image pair taken by the binocular camera, and determine a left image set and a right image set based on the internal parameters and the external parameters; An image pair matching disparity map acquisition module is used to determine an image pair matching disparity map using an image cost algorithm according to the left image set and the right image set; An in-tube depth map determination module, used to determine the in-tube depth map using a depth calculation formula according to the image pair matching disparity map; The image cost algorithm includes a gradient cost algorithm and a Hamming distance cost algorithm. The method of using the image cost algorithm to determine the matching disparity map of the image pair includes: Determining the gradient cost of the in-tube image based on the left image set and the right image set and the gradient cost algorithm; Determining the Hamming distance cost of the in-tube image based on the Hamming distance cost algorithm; Based on the gradient cost and the Hamming distance cost, determining a matching disparity map of the image pair according to a path aggregation function; The depth calculation formula is: Among them, Z represents the image depth, d represents the left and right disparity, f is obtained through calibration, and T is the optical center distance of the binocular camera.
8. An electronic device, characterized in that: It includes a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the in-pipe detection method based on binocular matching as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The storage medium stores computer program instructions, and when the computer program instructions are executed by a computer, the computer executes the in-pipe detection method based on binocular matching as described in any one of claims 1 to 6.
