A method, device and medium for generating parallax images for binocular vision equipment
By using the corresponding relationship between image feature extraction and the transformer module to determine the matching coordinates in the binocular vision device, the problem of pixel point matching in the pathological area in the binocular vision device is solved, high-precision parallax image generation is achieved, and the stereoscopic image is improved. quality.
Patent Information
- Application Number
- CN202111408110.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-11-19
AI Technical Summary
Existing technology is difficult to accurately match pixels in stereoscopic images with pathological areas such as occlusion areas, repeated textures, and reflective surfaces in binocular vision devices, resulting in poor disparity image generation effects.
By obtaining image pairs from different angles collected by binocular vision equipment, image feature extraction and segmentation are performed. The transformer module is used to establish the correspondence between feature blocks, determine the matching coordinates and parallax coordinates, and generate the final parallax image, combining different resolutions. Match and refine the characteristic image of the rate to achieve accurate matching of pixels in the pathological area.
It improves the accuracy and effect of parallax image generation, can establish pixel point matching relationships at low feature resolutions, and perform refined matching at high feature resolutions, solving the matching problem of pathological areas and generating high-quality parallax stereoscopic images. .
Smart Images

Figure CN114332188B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to a method, device and medium for generating a parallax image for a binocular vision device. Background Art
[0002] With the development of science and technology, the application scenarios of stereoscopic images are becoming more and more extensive. Stereoscopic images mainly rely on stereoscopic vision processing of images of the same object taken at different angles to obtain images with image depth features. Stereoscopic vision processing mainly establishes the correspondence between the pixels in two images at different angles, thereby generating stereoscopic images.
[0003] At present, stereo images are mainly captured by binocular vision cameras, and each pixel in the stereo image pair is matched. However, the matching of stereo image pairs achieved by the existing technology is generally carried out by matching the image pairs through the pixels with obvious distinction in the image. Due to the complex and diverse shooting angles and actual shooting environments of binocular vision cameras, it cannot be guaranteed that a clear stereo image pair with good imaging effects can be captured at all times. If relying on the existing parallax image generation technology, it is impossible to match the pixels between stereo image pairs with pathological areas such as occluded areas, repeated textures, and reflective surfaces. Summary of the invention
[0004] The embodiments of the present application provide a parallax image generation method, device and medium for a binocular vision device, which are used to match the pixels of a stereo image pair with pathological areas such as occluded areas, repeated textures, and reflective surfaces.
[0005] On the one hand, the present application provides a method for generating a disparity image for a binocular vision device, the method comprising:
[0006] Obtain an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions. The image pair to be processed includes a plurality of images corresponding to images of the same target at different angles collected by a binocular vision device. Divide the feature image pair of the first resolution into a plurality of first feature blocks. Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the correspondence between the first feature blocks. The correspondence is the correlation between any two first feature blocks in the feature image pair. Based on the coordinates to be matched, determine the matching coordinates in the feature image pair of the second resolution. And use the feature image pair corresponding to the second resolution as the image pair to be matched. The second resolution is greater than the first resolution. Determine the region pair to be matched in the image pair to be matched according to the matching coordinates in the feature image pair of the second resolution. Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate the final disparity image of the image pair to be processed based on the disparity coordinates. The feature sub-blocks are obtained by dividing the region pair to be matched.
[0007] In one implementation of the present application, a ratio of the second resolution to the first resolution is determined. The ratio is multiplied by the coordinates to be matched to determine the matching coordinates corresponding to the coordinates to be matched in the image pair to be matched. The first coordinate value in the matching coordinates corresponds to the first image to be matched in the image pair to be matched, and the second coordinate value corresponds to the second image to be matched in the image pair to be matched.
[0008] In one implementation of the present application, the pixel point corresponding to the matching coordinate is used as the center of the matching window, and the coverage area of the matching window in the image pair to be matched is determined. The size of the matching window is a preset value. According to the coverage area, the pair of regions to be matched in the image pair to be matched is determined respectively.
[0009] In one implementation of the present application, a central feature subblock corresponding to a central pixel point corresponding to a first to-be-matched region in a to-be-matched region pair is determined. Second feature subblocks corresponding to each pixel point of a second to-be-matched region in a to-be-matched region pair are determined. A feature correlation value between a vector of the central feature subblock and vectors of each second feature subblock is calculated to determine a disparity coordinate according to the feature correlation value. The feature correlation value represents a degree of correlation between a vector of the central feature subblock and vectors of each second feature subblock.
[0010] In one implementation of the present application, a disparity image generation model is trained by using sample image pairs in a preset sample library to obtain a trained disparity image generation model. The disparity image generation model is used to generate a disparity image based on the image pairs to be processed. The disparity image generation model includes any one or more of the following modules: an image feature extraction module for performing image feature extraction on the image pairs to be processed. A segmentation module for dividing a feature image pair of a first resolution into a plurality of first feature blocks. A transformer module for determining a corresponding relationship. A first matching module for determining the coordinates to be matched corresponding to the feature image pair of the first resolution. A second matching module for determining the matching coordinates in the feature image pair of the second resolution. A disparity calculation module for generating an original disparity image. A disparity refinement module for refining an original disparity image into a final disparity image.
[0011] In one implementation of the present application, the feature image pair is vector processed to generate a one-dimensional vector corresponding to the feature image pair. According to the one-dimensional vector corresponding to the feature image pair, the feature image pair is position-encoded to obtain position information corresponding to the feature image pair. According to the position information, the feature image pair of the first resolution is cut into a plurality of first feature blocks having position information.
[0012] In an implementation of the present application, the sizes of the first feature blocks are the same.
[0013] In one implementation of the present application, a stereo image pair captured by a binocular vision device is received. Alternatively, a stereo image pair in a preset scene stream data set is obtained. Each stereo image in the stereo image pair is aligned and corrected according to the epipolar lines of a preset direction. The aligned and corrected stereo image pair is used as an image pair to be processed.
[0014] On the other hand, the present application provides a parallax image generating device for a binocular vision device, the device comprising:
[0015] At least one processor; and a memory in communication with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:
[0016] Obtain an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions. The image pair to be processed includes a plurality of images corresponding to images of the same target at different angles collected by a binocular vision device. Divide the feature image pair of the first resolution into a plurality of first feature blocks. Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the correspondence between the first feature blocks. The correspondence is the correlation between any two first feature blocks in the feature image pair. Based on the coordinates to be matched, determine the matching coordinates in the feature image pair of the second resolution. And use the feature image pair corresponding to the second resolution as the image pair to be matched. The second resolution is greater than the first resolution. Determine the region pair to be matched in the image pair to be matched according to the matching coordinates in the feature image pair of the second resolution. Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate the final disparity image of the image pair to be processed based on the disparity coordinates. The feature sub-blocks are obtained by dividing the region pair to be matched.
[0017] On the other hand, the present application also provides a non-volatile computer storage medium for generating disparity images of a binocular vision device, storing computer executable instructions, and the computer executable instructions are set to:
[0018] Obtain an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions. The image pair to be processed includes a plurality of images corresponding to images of the same target at different angles collected by a binocular vision device. Divide the feature image pair of the first resolution into a plurality of first feature blocks. Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the correspondence between the first feature blocks. The correspondence is the correlation between any two first feature blocks in the feature image pair. Based on the coordinates to be matched, determine the matching coordinates in the feature image pair of the second resolution. And use the feature image pair corresponding to the second resolution as the image pair to be matched. The second resolution is greater than the first resolution. Determine the region pair to be matched in the image pair to be matched according to the matching coordinates in the feature image pair of the second resolution. Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate the final disparity image of the image pair to be processed based on the disparity coordinates. The feature sub-blocks are obtained by dividing the region pair to be matched.
[0019] Through the above scheme, the present application establishes a pixel matching relationship on an image with low feature resolution, and then establishes a refined matching relationship on an image with high feature resolution. At the same time, the function of the transformer module is utilized to match image features on the global receptive field of the image, thereby achieving accurate matching of pixels in the pathological area. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 A schematic diagram of a process of generating a parallax image for a binocular vision device in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a method for generating a disparity image for a binocular vision device in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of a method for generating a disparity image for a binocular vision device in an embodiment of the present application;
[0024] Figure 4 This is a structural schematic diagram of a parallax image generating device for a binocular vision device in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0026] Binocular stereo vision is an important form of machine vision. It is based on the principle of parallax and uses imaging equipment to obtain two images of the object under test from different positions. It calculates the position deviation between corresponding points in the images to obtain the three-dimensional geometric information of the object.
[0027] When there is a positional deviation between corresponding points in the two images of the object being measured, the matching accuracy of the corresponding points is required to be high. If the corresponding points cannot be accurately matched, the stereoscopic effect of the stereoscopic image formed by binocular stereo vision is very poor. Matching corresponding points between pathological areas such as blanks and occlusions in the two images is a technical problem in obtaining parallax images with binocular stereo vision. There is an urgent need for a technical solution that can accurately match corresponding points in pathological areas such as repeated textures and occluded areas in the image to obtain good parallax stereo images.
[0028] Based on this, the embodiments of the present application provide a method, device and medium for generating a parallax image for a binocular vision device, which are used to accurately match corresponding points of pathological areas such as repeated textures and occluded areas in the image.
[0029] The following describes in detail various embodiments of the present application in conjunction with the accompanying drawings.
[0030] The present application embodiment provides a method for generating a disparity image for a binocular vision device, such as Figure 1 As shown, the method may include steps S101-S106:
[0031] S101, the server obtains an image pair to be processed, and performs image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions.
[0032] The image pair to be processed includes multiple images corresponding to the same target at different angles acquired by a binocular vision device.
[0033] In an embodiment of the present application, the server can process images of the same target captured by a binocular vision device at different angles to obtain a pair of images to be processed.
[0034] Specifically, the server may receive a stereo image pair collected by a binocular vision device. The server may also obtain a stereo image pair in a preset scene stream data set.
[0035] Among them, the internal parameters and external parameters of the binocular vision device can be a pre-calibrated device, and the position data of the binocular vision device can be obtained through the calibrated device parameters. For example, the position of the binocular vision device is placed parallel to the horizon, or perpendicular to the horizon, etc.
[0036] The server aligns and corrects each stereo image in the stereo image pair according to the epipolar lines of the preset direction.
[0037] The position data of the binocular vision device can be used to obtain the epipolar direction of the image collected by the binocular vision device. For example, if the binocular vision device is placed horizontally, the epipolar direction is a horizontal epipolar direction. If the binocular vision device is placed at an angle of 45 degrees, the epipolar direction is at an angle of 45 degrees. Based on the epipolar direction, the server aligns and corrects the stereo images in the stereo image pair so that the epipolar directions of the stereo image pair are parallel, that is, the image pixel rows collected by each acquisition device in the binocular vision device are strictly aligned.
[0038] The server uses the aligned and rectified stereo image pair as the image pair to be processed.
[0039] In addition, in another embodiment of the present application, the server may also randomly crop the aligned and corrected stereo image pair to obtain a stereo image pair with a uniform resolution, such as a to-be-processed image pair with a resolution of (480, 640).
[0040] In the embodiment of the present application, the binocular vision device can be two pre-set video cameras or cameras, or can be a finished binocular stereo camera, and the present application does not make any specific limitation thereto.
[0041] In an embodiment of the present application, the server needs to perform image feature extraction on the image pair to be processed. The feature extraction can be performed using Feature Pyramid Networks (FPN) to obtain multiple feature image pairs with different resolutions.
[0042] It should be noted that the server, as the executor of the parallax image generation method for binocular vision devices, exists only for exemplary purposes. The executor is not limited to the server, and this application does not make any specific limitations on this.
[0043] S102: The server divides the feature image of the first resolution into a plurality of first feature blocks.
[0044] In the embodiment of the present application, the server can first flatten the feature image pair of the first resolution through the Flatten layer in the machine learning network, that is, expand the two-dimensional feature image pair into a one-dimensional vector according to each row of pixels. For example, the vector matrix form of a feature image in the feature image pair is After the Flatten layer, it becomes a one-dimensional vector (1,2,3,4). The first resolution is, for example, one eighth of the original image resolution.
[0045] Through the Flatten layer, the server can reduce the amount of computation and facilitate the position encoding of the images of the feature image pairs.
[0046] The embodiment of the present application can obtain a plurality of first feature blocks with position codes by executing the following method. Specifically:
[0047] First, the server performs vector processing on the feature image pair to generate a one-dimensional vector corresponding to the feature image pair.
[0048] The process of the server generating a one-dimensional vector from the feature image pair is the process of generating a one-dimensional vector through the Flatten layer, which will not be repeated here.
[0049] Then, the server performs position encoding on the feature image pair according to the one-dimensional vector corresponding to the feature image pair to obtain the corresponding position information of the feature image pair.
[0050] Finally, the server divides the feature image pair of the first resolution into a plurality of first feature blocks having the position information according to the position information.
[0051] In the embodiment of the present application, the first feature blocks have the same size, for example, each of the first feature blocks contains 50 pixels. If the first feature blocks are divided into different sizes, the embodiment of the present application can process the first feature blocks according to different sizes based on the number of sizes counted.
[0052] The present application divides the first feature blocks into several blocks, which can facilitate the subsequent transformer module to perform self-attention layer and cross-attention layer processing, thereby improving the disparity image generation efficiency of the disparity image generation method for binocular vision equipment.
[0053] S103: The server determines corresponding coordinates to be matched of the feature image pair of the first resolution according to the correspondence between the first feature blocks.
[0054] The corresponding relationship is the correlation between any two first feature blocks in the feature image pair.
[0055] The server can process each first feature block through a preset transformer module, and the transformer module can be a transformer model including an encoder and a decoder. The server can obtain the self-attention layer and the cross-attention layer of each first feature block through the transformer module. The self-attention layer performs image processing on the same image in the feature image pair, that is, combines the position information of the first feature block of the image on the image and the pixel value of the first feature block to determine the feature data of the first feature block on the image.
[0056] The cross attention layer processes different images in the feature image pair to determine the features of the images. For example, the feature image pair includes a first image and a second image. Combined with the position information of the first feature block A corresponding to the first image, the first feature block in the second image related to the first feature block A is determined. The server calculates the correlation between any two first feature blocks between the first image and the second image to obtain the corresponding relationship.
[0057] Then, the server determines the coordinates to be matched of the feature image pair of the first resolution according to the correspondence obtained by the transformer module. For example, in the feature image pair, the first feature block a and the second feature block b of the first image A correspond to the first feature block c and the first feature block d of the second image B, such as ad, bc. The server can determine the coordinates to be matched (a, d) (b, d). The transformer module processes the first feature block as follows: Figure 2 The system includes an image feature extraction module 201 , a segmentation module 202 , a transformer module 203 , a first matching module 204 , a second matching module 205 , a disparity calculation module 206 , and a disparity refinement module 207 .
[0058] According to the first feature block, the specific calculation process of obtaining the coordinates to be matched is as follows:
[0059] The server calculates the feature vectors of each pixel point of the first image and the second image in the feature image pair respectively. The feature vector of the first image is: F A , the feature vector of the second image is: F B The server performs self-attention layer and cross-attention layer processing on each first feature block according to the transformer module, and obtains the transformation features with position relationship and pixel value relationship: the transformation feature vector F′ of the first image A , the transformed feature vector F′ of the second image B .
[0060] The server then calculates Where S(i,j) is the transformed feature vector F′ A and the transformed eigenvector F′ B The confidence matrix between ; i is any point in the first image, j is any point in the second image; τ is a constant used to reduce the amount of calculation. The server calculates the matching probability of any two feature points according to the following formula:
[0061] p c (i,j)=softmax(S(i,·)) j softmax(S(·,j)) i
[0062] Among them, p c (i,j) represents the matching probability of coordinates (i,j), that is, the feature correlation between point i and point j. S(i,·) represents the inner product operation between point i in the first image and all points in the second image. S(·,j) represents the inner product operation between point j in the second image and all points in the first image.
[0063] Based on the obtained matching probability, the server can regard the matching probability greater than a threshold as a credible match, such as a point (x, y) with a matching probability greater than 0.8 as a credible coordinate to be matched. The coordinate to be matched can also be obtained through the mutual nearest neighbor algorithm MNN.
[0064] After the feature image pair corresponding to the first resolution completes the determination of the coordinates to be matched, the server can match the coordinates in the high-resolution image in a high-resolution image higher than the first resolution according to the coordinates to be matched. The present application implements high-resolution image matching by executing the following method.
[0065] S104: The server determines matching coordinates in a feature image pair of the second resolution based on the coordinates to be matched, and uses the feature image pair corresponding to the second resolution as an image pair to be matched.
[0066] The second resolution is greater than the first resolution.
[0067] In an embodiment of the present application, the server may correspond the coordinates to be matched to the feature image pair of the second resolution to obtain the matching coordinates.
[0068] In one embodiment of the present application, the server may obtain the matching coordinates in the feature image pair of the second resolution by executing the following method:
[0069] First, the server determines a ratio of the second resolution to the first resolution.
[0070] For example, the image with the first resolution is one eighth of the resolution of the image captured by the binocular vision device, and the second resolution is one half of the resolution of the image captured by the binocular vision device, then the ratio of the second resolution to the first resolution is 4.
[0071] Then, the server performs a product operation on the ratio and the coordinates to be matched to determine the corresponding matching coordinates of the coordinates to be matched in the pair of images to be matched.
[0072] The first coordinate value in the matching coordinates corresponds to the first image to be matched in the pair of images to be matched, and the second coordinate value corresponds to the second image to be matched in the pair of images to be matched.
[0073] For example, if the ratio is 4, and the coordinates to be matched are (0, 0), (0, 0.5), (0.5, 0.5), (0, 1), (1, 1), then the matching coordinates are the ratio multiplied by the coordinate values of the coordinates to be matched, that is, the matching coordinates are: (0, 0), (0, 2), (2, 2), (0, 4), (4, 4). In the embodiment of the present application, the horizontal coordinate and the vertical coordinate of the coordinate come from different images respectively, the horizontal coordinate comes from the first image in the image pair, and the vertical coordinate comes from the second image in the image pair.
[0074] S105: The server determines a pair of regions to be matched in the pair of images to be matched according to the matching coordinates in the pair of feature images at the second resolution.
[0075] In the embodiment of the present application, the server can determine the area pair to be matched by executing the following method, as follows:
[0076] In the embodiment of the present application, the server uses the pixel point corresponding to the matching coordinates as the center of the matching window and determines the coverage area of the matching window in the pair of images to be matched.
[0077] Among them, the size of the matching window is a preset value.
[0078] In the embodiment of the present application, the size of the matching window can be adjusted according to actual use. The preset value is, for example, a value of 3*3. The preset value can be an area value or a value including length and width.
[0079] The server determines the to-be-matched area pairs in the to-be-matched image pairs respectively according to the coverage areas.
[0080] The area pair to be matched can narrow the search area for feature matching, improve the efficiency of feature matching, and reduce the error in image matching. For example, after the feature image pair of the first resolution obtains the coordinates to be matched (o, p), feature processing is performed in the area pair to be matched corresponding to the matching coordinates (o, p) of the feature image pair of the second resolution, that is, feature processing is performed in the area centered at (o, p). Since the first resolution is smaller than the second resolution, the feature image pair of the second resolution has more pixels than the first resolution. Through the area pair to be matched, the pixel points in the feature image pair of the second resolution that are more than the feature image pair of the first resolution can be accurately processed.
[0081] The above scheme realizes sub-pixel precision matching, improves the accuracy of the final disparity image generation, and also avoids the inability to accurately match pixel corresponding points in pathological areas such as occluded areas, repeated texture areas, reflective surfaces, etc.
[0082] S106: The server determines the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate a final disparity image of the image pair to be processed based on the disparity coordinates.
[0083] The feature sub-blocks are obtained by segmenting the to-be-matched region pairs.
[0084] In the embodiment of the present application, the parallax coordinates are obtained by executing the following method, specifically:
[0085] First, the server determines the first to-be-matched area in the to-be-matched area pair and the central feature sub-block corresponding to the corresponding central pixel point.
[0086] The server can obtain several feature sub-blocks corresponding to the to-be-matched region pair by executing the above-mentioned transformer module to process the first feature block. The first to-be-matched region comes from the first to-be-matched image in the to-be-matched region image pair.
[0087] Then, the server determines a second characteristic sub-block corresponding to each pixel point of the second to-be-matched area in the to-be-matched area pair.
[0088] The second to-be-matched region comes from the second to-be-matched image in the to-be-matched region image pair.
[0089] Finally, the server calculates a feature correlation value between the vector of the central feature sub-block and the vectors of each second feature sub-block to determine the disparity coordinates according to the feature correlation value.
[0090] The feature correlation value represents the degree of correlation between the vector of the central feature sub-block and the vectors of each second feature sub-block.
[0091] In the embodiment of the present application, the way in which the server calculates the feature correlation value between the vector of the central feature sub-block and the vectors of each second feature sub-block can refer to step S103, and the feature correlation value can be calculated by the matching probability formula in step S103.
[0092] After the server obtains the feature correlation value between the vector of the central feature sub-block and the vectors of each second feature sub-block, if the center coordinates corresponding to the central feature sub-block are The center coordinates of the second feature sub-block are By calculating the feature correlation value, the server can generate a heat map, and determine the vector T in the second feature sub-block corresponding to the maximum matching probability according to the heat map, such as T is different from the center coordinate of Thus, the server can obtain the disparity coordinates as
[0093] After the server obtains the disparity coordinates, it can perform disparity calculation and disparity refinement on the image pair to be processed, thereby obtaining the final disparity image. The disparity calculation is to obtain the depth value by using the calculation formula of the disparity and depth value from the disparity coordinates, thereby generating the final disparity image.
[0094] In the embodiment of the present application, the parallax image generation method for binocular vision equipment can obtain the final parallax image through a pre-trained parallax image generation model. It is known to those skilled in the art that the above steps can also be steps for training a time difference image generation model, and the present application does not specifically limit this.
[0095] The embodiment of the present application generates a disparity image generation model for generating a final disparity image by the following method, which is as follows:
[0096] The server trains the disparity image generation model by using sample image pairs in a preset sample library to obtain a trained disparity image generation model.
[0097] The disparity image generation model is used to generate a disparity image according to the image pair to be processed.
[0098] The disparity image generation model includes any one or more of the following modules:
[0099] An image feature extraction module for extracting image features from the image pair to be processed;
[0100] A segmentation module for segmenting a feature image pair of the first resolution into a plurality of first feature blocks; a transformer module for determining a corresponding relationship;
[0101] A first matching module for determining coordinates to be matched corresponding to a feature image pair of a first resolution;
[0102] a second matching module for determining matching coordinates in a pair of feature images at a second resolution;
[0103] A disparity calculation module for generating an original disparity image;
[0104] A disparity refinement module for refining the original disparity image into a final disparity image.
[0105] In an embodiment of the present application, in order to alleviate the situation where the process of disparity regression of the original disparity map is only performed on the outer pole line, thereby lacking context information, the embodiment of the present application uses convolution to adjust the estimated value. The original disparity image is first connected along the channel dimension with the left image collected by the binocular vision device (taking the binocular vision device placed left and right as an example), and two convolution blocks are used to gather occlusion information. Then, the linear rectified function (Rectified Linear Unit, ReLU) is used to refine the disparity through the residual block 301. Before the ReLU function is activated, the residual block 301 expands the channel dimension to restore it to its original channel dimension. The original disparity and the residual block 301 are repeatedly cascaded to obtain a better adjustment effect. The final output of the residual block is added to the original disparity through a long jump connection to obtain the final disparity map. The specific schematic diagram is as follows Figure 3 shown.
[0106] After the training of the disparity image generation model is completed, the embodiment of the present application can implement transfer learning of the disparity image generation model so that the disparity image generation model can generate a final disparity image of the image pair to be tested that is different from the sample image pair.
[0107] The present application processes feature image pairs with different resolutions to obtain the coordinates to be matched of the feature image pair with a first resolution, and then determines the matching coordinates of the feature image pair with a higher resolution than the first resolution through the coordinates to be matched. The matching coordinates are used to refer to the pixel points of the first image in the feature image pair, corresponding to the pixel point positions of the second image. Based on the matching coordinates, a parallax image is generated.
[0108] This application first establishes a pixel matching relationship on an image with low feature resolution, and then establishes a refined matching relationship on an image with high feature resolution. At the same time, the function of the transformer module is utilized to match image features on the global receptive field of the image, thereby achieving accurate matching of pixels in the pathological area.
[0109] Figure 4 A structural diagram of a parallax image generating device for a binocular vision device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the device includes:
[0110] At least one processor. And a memory in communication with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:
[0111] Obtain an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions. The image pair to be processed includes a plurality of images corresponding to images of the same target at different angles collected by a binocular vision device. Divide the feature image pair of the first resolution into a plurality of first feature blocks. Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the correspondence between the first feature blocks. The correspondence is the correlation between any two first feature blocks in the feature image pair. Based on the coordinates to be matched, determine the matching coordinates in the feature image pair of the second resolution. And use the feature image pair corresponding to the second resolution as the image pair to be matched. The second resolution is greater than the first resolution. Determine the region pair to be matched in the image pair to be matched according to the matching coordinates in the feature image pair of the second resolution. Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate the final disparity image of the image pair to be processed based on the disparity coordinates. The feature sub-blocks are obtained by dividing the region pair to be matched.
[0112] The embodiment of the present application further provides a non-volatile computer storage medium for generating a disparity image of a binocular vision device, storing computer executable instructions, wherein the computer executable instructions are configured as follows:
[0113] Obtain an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions. The image pair to be processed includes a plurality of images corresponding to images of the same target at different angles collected by a binocular vision device. Divide the feature image pair of the first resolution into a plurality of first feature blocks. Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the correspondence between the first feature blocks. The correspondence is the correlation between any two first feature blocks in the feature image pair. Based on the coordinates to be matched, determine the matching coordinates in the feature image pair of the second resolution. And use the feature image pair corresponding to the second resolution as the image pair to be matched. The second resolution is greater than the first resolution. Determine the region pair to be matched in the image pair to be matched according to the matching coordinates in the feature image pair of the second resolution. Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate the final disparity image of the image pair to be processed based on the disparity coordinates. The feature sub-blocks are obtained by dividing the region pair to be matched.
[0114] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0115] The devices, media and methods provided in the embodiments of the present application correspond one to one, and therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0116] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0117] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for generating a disparity image for a binocular vision device, It is characterized in that The method comprises: Acquire an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions; wherein the image pair to be processed includes a plurality of images corresponding to images of the same target at different angles acquired by a binocular vision device; Cutting the feature image of the first resolution into a plurality of first feature blocks; Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the corresponding relationship between the first feature blocks; wherein the corresponding relationship is the correlation between any two first feature blocks in the feature image pair; Based on the coordinates to be matched, determining matching coordinates in the feature image pair of the second resolution; and taking the pair of feature images corresponding to the second resolution as a pair of images to be matched; wherein the second resolution is greater than the first resolution; Determining a pair of regions to be matched in the pair of images to be matched according to the matching coordinates in the pair of feature images at the second resolution; Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate a final disparity image of the image pair to be processed based on the disparity coordinates; the feature sub-blocks are obtained by segmenting the region pair to be matched; Wherein, determining the disparity coordinates corresponding to the pair of images to be matched based on the feature correlation values between the feature sub-blocks in the pair of regions to be matched specifically includes: Determine a central feature sub-block corresponding to a central pixel point corresponding to a first to-be-matched area in the to-be-matched area pair; Determine a second characteristic sub-block corresponding to each pixel point of a second to-be-matched area in the to-be-matched area pair; The characteristic correlation value between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks is calculated to determine the disparity coordinates according to the characteristic correlation value; wherein the characteristic correlation value represents the degree of correlation between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks.
2. The method according to claim 1, It is characterized in that Determining matching coordinates in the feature image pair of the second resolution based on the coordinates to be matched specifically includes: determining a ratio of the second resolution to the first resolution; The ratio is multiplied by the coordinates to be matched to determine the matching coordinates corresponding to the coordinates to be matched in the pair of images to be matched; wherein the first coordinate value in the matching coordinates corresponds to the first image to be matched in the pair of images to be matched, and the second coordinate value corresponds to the second image to be matched in the pair of images to be matched.
3. The method according to claim 1, It is characterized in that Determining a pair of to-be-matched regions in the pair of to-be-matched images according to the matching coordinates in the pair of feature images at the second resolution specifically includes: Taking the pixel point corresponding to the matching coordinate as the center of the matching window, determining the coverage area of the matching window in the pair of images to be matched; wherein the size of the matching window is a preset value; According to the coverage area, the to-be-matched area pairs in the to-be-matched image pairs are respectively determined.
4. The method according to claim 1, It is characterized in that Before acquiring the image pair to be processed, the method further includes: The disparity image generation model is trained by using sample image pairs in a preset sample library to obtain the trained disparity image generation model; wherein the disparity image generation model is used to generate the disparity image according to the image pairs to be processed; The disparity image generation model includes any one or more of the following modules: An image feature extraction module for extracting image features from the image pair to be processed; A segmentation module for segmenting the feature image pair of the first resolution into a plurality of first feature blocks; A transformer module for determining the corresponding relationship; A first matching module for determining coordinates to be matched corresponding to the feature image pair of the first resolution; a second matching module for determining matching coordinates in the pair of feature images at a second resolution; A disparity calculation module for generating an original disparity image; A disparity refinement module is used for refining the original disparity image into the final disparity image.
5. The method according to claim 1, It is characterized in that The feature image of the first resolution is cut into a plurality of first feature blocks, specifically comprising: Performing vector processing on the feature image pair to generate a one-dimensional vector corresponding to the feature image pair; According to the one-dimensional vector corresponding to the feature image pair, position encoding is performed on the feature image pair to obtain position information corresponding to the feature image pair; According to the position information, the feature image pair of the first resolution is divided into a plurality of the first feature blocks having the position information.
6. The method according to claim 1, It is characterized in that The first feature blocks have the same size.
7. The method according to claim 1, It is characterized in that Before acquiring the image pair to be processed, the method further includes: Receiving a stereo image pair acquired by a binocular vision device; or Obtain a stereo image pair in a preset scene flow dataset; Aligning and correcting each stereo image in the stereo image pair according to an epipolar line in a preset direction; The aligned and corrected stereo image pair is used as the image pair to be processed.
8. A parallax image generating device for a binocular vision device, It is characterized in that The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions; wherein the image pair to be processed includes a plurality of images corresponding to images of the same target at different angles acquired by a binocular vision device; Cutting the feature image of the first resolution into a plurality of first feature blocks; Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the corresponding relationship between the first feature blocks; wherein the corresponding relationship is the correlation between any two first feature blocks in the feature image pair; Based on the coordinates to be matched, determining matching coordinates in the feature image pair of the second resolution; and taking the pair of feature images corresponding to the second resolution as a pair of images to be matched; wherein the second resolution is greater than the first resolution; Determining a pair of regions to be matched in the pair of images to be matched according to the matching coordinates in the pair of feature images at the second resolution; Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate a final disparity image of the image pair to be processed based on the disparity coordinates; the feature sub-blocks are obtained by segmenting the region pair to be matched; Wherein, based on the feature correlation values between the feature sub-blocks in the pair of regions to be matched, the disparity coordinates corresponding to the pair of images to be matched are determined, and the at least one processor is specifically capable of: Determine a central feature sub-block corresponding to a central pixel point corresponding to a first to-be-matched area in the to-be-matched area pair; Determine a second characteristic sub-block corresponding to each pixel point of a second to-be-matched area in the to-be-matched area pair; The characteristic correlation value between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks is calculated to determine the disparity coordinates according to the characteristic correlation value; wherein the characteristic correlation value represents the degree of correlation between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks.
9. A non-volatile computer storage medium for generating disparity images for a binocular vision device, storing computer executable instructions, It is characterized in that The computer executable instructions are configured to: Acquire an image pair to be processed, and perform image feature extraction on the image pair to be processed to obtain a plurality of feature image pairs at different resolutions; wherein the image pair to be processed includes a plurality of images corresponding to images of the same target at different angles acquired by a binocular vision device; Cutting the feature image of the first resolution into a plurality of first feature blocks; Determine the coordinates to be matched corresponding to the feature image pair of the first resolution according to the corresponding relationship between the first feature blocks; wherein the corresponding relationship is the correlation between any two first feature blocks in the feature image pair; Based on the coordinates to be matched, determining matching coordinates in the feature image pair of the second resolution; and taking the pair of feature images corresponding to the second resolution as a pair of images to be matched; wherein the second resolution is greater than the first resolution; Determining a pair of regions to be matched in the pair of images to be matched according to the matching coordinates in the pair of feature images at the second resolution; Determine the disparity coordinates corresponding to the image pair to be matched based on the feature correlation values between the feature sub-blocks in the region pair to be matched, so as to generate a final disparity image of the image pair to be processed based on the disparity coordinates; the feature sub-blocks are obtained by segmenting the region pair to be matched; Wherein, determining the disparity coordinates corresponding to the pair of images to be matched based on the feature correlation values between the feature sub-blocks in the pair of regions to be matched specifically includes: Determine a central feature sub-block corresponding to a central pixel point corresponding to a first to-be-matched area in the to-be-matched area pair; Determine a second characteristic sub-block corresponding to each pixel point of a second area to be matched in the pair of areas to be matched; The characteristic correlation value between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks is calculated to determine the disparity coordinates according to the characteristic correlation value; wherein the characteristic correlation value represents the degree of correlation between the vector of the central characteristic sub-block and the vectors of each of the second characteristic sub-blocks.
