Parallax calculation method and device for binocular spliced lens
By calculating the disparity value sequence of binocular lenses for image stitching, the misalignment and jumping problems in traditional lens stitching algorithms are solved, high-quality video stitching effect is achieved, and the dependence on the hardware structure of the lens module is reduced.
Patent Information
- Application Number
- CN202510029149.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-05-13
AI Technical Summary
Traditional lens stitching algorithms have problems of misalignment, ghosting and obvious positional jumps at the stitching of stitching images in video scenes, and the dynamic stitching scheme has high requirements for the center of the lens module, resulting in poor splicing effect.
By obtaining the overlapping area image of the binocular lens, calculating the initial parallax map and dividing the blocks, adjusting the parallax change parameters, using the parallax value sequence for image splicing, decoupling the dependence on the hardware structure of the lens module, and reducing the sense of slit jump.
It achieves the accuracy and continuity of the splicing visual effect without adjusting the splicing, reduces the jumping feeling of the splicing, and provides good image splicing quality.
Smart Images

Figure CN119991430A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image stitching, and in particular to a method and device for calculating the parallax of a binocular stitching lens. Background Art
[0002] The application of traditional shot stitching algorithms in video scenes has obvious problems such as misalignment at the stitching of stitched images, ghosting at the stitching of stitched images, and obvious position jumps between the previous and next frames of the video content. For this reason, researchers in this field have further conceived a dynamic stitching solution, which is achieved by dynamically adjusting the stitching position in the picture in real time.
[0003] However, the dynamic stitching solution has high requirements on the visual center distance of the lens module itself. Specifically, it is strictly required that the maximum parallax value corresponding to the lens module must be within a specific range, such as 20 pixels, in order to meet the subjective experience of stitching. Otherwise, the larger parallax will cause the stitching effect to have an obvious sense of stitching jumps, and the visual effect will be poor. Summary of the invention
[0004] The present application provides a method and device for calculating the parallax of a binocular stitching lens, which can decouple the dependence on the hardware structure of the lens module, reduce the sense of seam jump, and achieve a good stitching visual effect.
[0005] In a first aspect, an embodiment of the present application provides a method for calculating the parallax of a binocular stitching lens, comprising:
[0006] Acquire a first image and a second image having an overlapping area; use the overlapping area in the first image as a first initial image; and use the overlapping area in the second image as a second initial image;
[0007] Inputting the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map;
[0008] Divide the initial disparity map according to a preset pixel range to obtain multiple blocks;
[0009] Calculate the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map;
[0010] Determine whether the parallax change parameter is greater than a preset repetition threshold;
[0011] If yes, the minimum disparity value in the corresponding block is used as the disparity value of each pixel in the block;
[0012] The disparity averages of the left pixel points and the right pixel points of the preset seam are calculated to obtain a disparity value sequence.
[0013] Furthermore, the method also includes:
[0014] Before inputting the disparity calculation function, the first initial image and the second initial image are respectively downsampled to a first preset size; and then the first initial image and the second initial image are respectively padded to a second preset size.
[0015] Furthermore, the above-mentioned calculation of the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map includes:
[0016] Pixels with the same disparity value in the block are classified as one category to obtain multiple disparity value classifications;
[0017] Calculate the difference between any two disparity value categories to obtain multiple difference values;
[0018] The number of difference values less than a preset distribution threshold is used as a parallax change parameter.
[0019] Furthermore, the method also includes:
[0020] Before calculating the average disparity, the pixel variance value in each block is calculated;
[0021] If the pixel variance value is less than the preset featureless threshold, the corresponding block is regarded as an untrustworthy block;
[0022] Obtaining a first block and a second block that are closest to the untrusted block and are not untrusted blocks;
[0023] Linear interpolation is performed on the disparity values of the first block and the second block to obtain a disparity value of the unreliable block.
[0024] Furthermore, the method also includes:
[0025] Before calculating the average disparity value, obtaining historical disparity maps corresponding to a preset number of historical frames of the current frame;
[0026] Calculate the historical variance value of the block and the corresponding historical block in each historical disparity map;
[0027] Determine whether the historical variance value is greater than or equal to the preset stability threshold;
[0028] If yes, the historical block in the historical disparity map corresponding to the adjacent historical frame is used as the block of the current frame.
[0029] Furthermore, the method also includes:
[0030] Obtaining an upper adjacent block and a lower adjacent block of the block; calculating a first average disparity value of the block, a second average disparity value of the upper adjacent block, and a third average disparity value of the lower adjacent block;
[0031] Determining whether the first average disparity value is between the second average disparity value and the third average disparity value;
[0032] If not, the block corresponding to the first average disparity value is regarded as an untrustworthy block.
[0033] Furthermore, the method also includes:
[0034] Obtain the first coordinate of a pixel point in the map data within a preset adjustment range of a preset seam;
[0035] Adjust each first coordinate according to the disparity value sequence to obtain a second coordinate;
[0036] Obtaining the frame sequence number of the current frame corresponding to the first image and the second image;
[0037] Obtain the current stitching coordinates according to the frame sequence number, the first coordinate and the second coordinate;
[0038] Configure the current stitching coordinates to the map data.
[0039] In a second aspect, an embodiment of the present application provides a disparity calculation device for a binocular stitching lens, comprising:
[0040] An acquisition module, used for acquiring a first image and a second image having an overlapping area; taking the overlapping area in the first image as a first initial image; taking the overlapping area in the second image as a second initial image;
[0041] A disparity module, used for inputting the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map;
[0042] A division module, used for dividing the initial disparity map according to a preset pixel range to obtain multiple blocks;
[0043] A calculation module, used for calculating the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map;
[0044] A judging module, used to judge whether the parallax variation parameter is greater than a preset repetition threshold;
[0045] An updating module, used for taking the minimum disparity value in the corresponding block as the disparity value of each pixel in the block;
[0046] The sequence module is used to calculate the average disparity of the left pixel point and the right pixel point of the preset stitching seam to obtain a disparity value sequence.
[0047] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of a method for calculating the parallax of a binocular stitching lens as in any of the above embodiments are performed.
[0048] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a method for calculating the parallax of a binocular stitching lens as in any of the above embodiments are implemented.
[0049] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:
[0050] The embodiment of the present application provides a method for calculating the disparity of a binocular stitching lens. First, two overlapping images of a first image and a second image are collected, and then the initial disparity map of the first initial image and the second initial image is calculated by a disparity calculation function. Then, the disparity value in the initial disparity map is adjusted based on the disparity change parameter, which makes up for the calculation deviation of the disparity calculation function itself and ensures the accuracy of the disparity value. Finally, a disparity value sequence for image stitching is obtained based on a fixed preset seam. The above method does not require adjusting the seam, thereby decoupling the dependence on the hardware structure of the lens module and reducing the sense of seam jumping. A good stitching visual effect can be achieved by directly using the disparity value sequence of the present application for image stitching. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A flowchart of a method for calculating the parallax of a binocular stitching lens is provided as an exemplary embodiment of the present application.
[0052] Figure 2 A structural diagram of a parallax calculation device for a binocular stitching lens provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0053] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0054] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.
[0055] See also Figure 1 The present application embodiment provides a method for calculating the parallax of a binocular stitching lens, comprising:
[0056] Step S11, acquiring a first image and a second image having overlapping areas; taking the overlapping area in the first image as a first initial image; and taking the overlapping area in the second image as a second initial image.
[0057] Specifically, there is an overlapping area in the images captured by the two lenses, and the overlapping area in the first image is used as the first initial image I0, and the overlapping area in the second image is used as the second initial image I1.
[0058] Step S12: input the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map.
[0059] The disparity calculation function is the SGBM disparity calculation function, and the disparity value of each pixel in the output initial disparity map P0 represents the horizontal distance between the corresponding pixel in I0 and the best matching pixel in I1.
[0060] Step S13, dividing the initial disparity map according to a preset pixel range to obtain a plurality of blocks.
[0061] The preset pixel range is obtained by dividing the height of the entire initial disparity map by 32 pixels. For example, if the height of the initial disparity map is 2688, it will be divided into 84 blocks.
[0062] Step S14, calculating the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map.
[0063] Specifically, before executing S14 to calculate the disparity change parameters, because the initial disparity map P0 has holes in some areas, the initial disparity map P0 can be filled first. Assuming that P(x, y) is a hole (that is, the value is -2), take the point P(x, y) as the center point and search in the area of 3*3 pixels around it. Set the maximum disparity value of the 3*3 pixels to the disparity value of the current hole point. After filling the disparities of all the hole pixels, the filled initial disparity map is obtained.
[0064] Step S15, determining whether the parallax change parameter is greater than a preset repetition threshold.
[0065] Among them, the preset repetition threshold can be 2 or 3; specifically, the inspection change parameter is the distribution of disparity values in the corresponding block. If it is greater than the preset repetition threshold, it means that the corresponding block has an obvious multi-peak trend, that is, an obvious repetitive feature.
[0066] Step S16: If yes, the minimum disparity value in the corresponding block is used as the disparity value of each pixel in the block.
[0067] Specifically, since the calculation results of the SGBM disparity calculation function for repeated features have obvious deviations, it is necessary to adjust the disparity values of the areas with repeated features to ensure the accuracy of the disparity values.
[0068] Step S17, calculating the average disparity of the left pixel point and the right pixel point of the preset seam to obtain a disparity value sequence.
[0069] Specifically, in the present application, the preset seam is a straight line with unchanged position and shape, and its position is the position of the center line.
[0070] The above steps are to average the disparity values of the two pixels on the left and right sides of the seam to obtain a disparity value sequence from top to bottom.
[0071] The above embodiment provides a method for calculating the disparity of a binocular stitching lens. First, two overlapping images of a first image and a second image are collected, and then the initial disparity map of the first initial image and the second initial image is calculated by a disparity calculation function. Then, the disparity value in the initial disparity map is adjusted based on the disparity change parameter, which makes up for the calculation deviation of the disparity calculation function itself and ensures the accuracy of the disparity value. Finally, a disparity value sequence for image stitching is obtained based on a fixed preset seam. The above method does not require adjusting the seam, thereby decoupling the dependence on the hardware structure of the lens module and reducing the sense of seam jumping. A good stitching visual effect can be achieved by directly using the disparity value sequence of the present application for image stitching.
[0072] In some embodiments, the method further comprises:
[0073] Before inputting the disparity calculation function, the first initial image and the second initial image are respectively downsampled to a first preset size; and then the first initial image and the second initial image are respectively padded to a second preset size.
[0074] Among them, the first preset size is 256*340; when filling the initial image, 128 pixels are filled on the left side of the two initial images; specifically, since the results calculated by the SGBM disparity calculation function are invalid values in the left half of the picture, in order to obtain the valid disparity value of the entire image, this application forcibly adds a black area of 128 pixels on the left side of the initial image to obtain the valid disparity value of the overlapping area that needs to be calculated.
[0075] In some embodiments, the above-mentioned calculation of the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map may specifically include the following steps:
[0076] In step S141 , pixels with the same disparity value in the block are classified into one category to obtain a plurality of disparity value categories.
[0077] Step S142 , calculating the difference between any two disparity value categories to obtain a plurality of difference values.
[0078] Step S143: taking the number of difference values less than a preset distribution threshold as a parallax change parameter.
[0079] Among them, the preset distribution threshold can be 2; the above-mentioned difference refers to the difference in quantity, for example, there are 20 pixels in a block, there are 8 pixels in a disparity value category, and the disparity values are all 5; there are 7 pixels in a disparity value category, and the disparity values are all 4, and there is only 1 pixel in the remaining 5 disparity value categories, then only the difference in the number of pixels corresponding to the disparity value 5 and the disparity value 4 is 1, and the difference in the number of pixels in the remaining 5 disparity value categories and the number of pixels corresponding to the disparity values of 5 and 4 are both 7 and 6, that is, the number of differences less than the preset distribution threshold is only 1, and the disparity change parameter is 1.
[0080] The above embodiment classifies the pixels in the block based on the disparity value and determines the number of pixels in the category. If the difference is less than the preset distribution threshold, it means that the distribution proportions of the disparity values of the corresponding two categories are close. If the proportions are close and exceed the preset repetition threshold, it means that there are obvious repetitive features in the block and the disparity value needs to be adjusted.
[0081] In some embodiments, the method further comprises:
[0082] Step S21 , before calculating the average disparity value, calculate the pixel variance value in each block.
[0083] Step S22: if the pixel variance value is less than a preset featureless threshold, the corresponding block is regarded as an untrustworthy block.
[0084] Among them, the preset featureless threshold can be set to 4.
[0085] Step S23, obtaining a first block and a second block which are closest to the untrusted block and are not the untrusted block.
[0086] Step S24 , performing linear interpolation on the disparity values of the first block and the second block to obtain a disparity value of the unreliable block.
[0087] Specifically, before executing step S14, the pixel variance value of the pixel points in each block is calculated. If the pixel variance value in the area is less than 4, the corresponding block is considered to be a featureless block, that is, an unreliable block.
[0088] At this time, it is necessary to obtain valid blocks above and below the untrusted block. From the block division step in the above embodiment, it can be seen that the divided blocks have only one column, the preset pixel range only stipulates the height of the block, and the width of the block is the width of the initial disparity map. Therefore, the first block and the second block are the non-untrusted blocks closest to the top and bottom of the untrusted block, respectively.
[0089] Because the number of pixels in each block is the same, the disparity values of the pixels at the same coordinates in the first block and the second block can be extracted, and then the values of the pixels at the same coordinates in the unreliable block can be obtained according to the nearest interpolation method.
[0090] The above embodiment selects featureless blocks by calculating variance and updates the disparity values therein, which further compensates for the obvious deviation of the calculation results of the featureless blocks by the SGBM algorithm and ensures the accuracy of the disparity values.
[0091] In some embodiments, the method further comprises:
[0092] Step S31 : before calculating the average disparity value, obtaining historical disparity maps corresponding to a preset number of historical frames of the current frame.
[0093] The current frame is the frame where the first image and the second image are located, and the historical frame may specifically be the first 4 frames of the current frame. Then, an initial disparity map calculated when each historical frame is stitched is obtained as the historical disparity map.
[0094] Step S32 , calculating the historical variance value between the block and the corresponding historical blocks in each historical disparity map.
[0095] Specifically, after executing step S16 and before executing step S17, the disparity value of the current frame may be adjusted for stability according to the historical frames; because the size of the overlapping area of the binocular stitching lens remains unchanged, the size of the disparity map obtained for each frame will not change, and the corresponding divided blocks may also correspond one to one.
[0096] The above step S32 is to calculate the variance of the disparity value between the current block of the current frame and the corresponding blocks in each historical frame.
[0097] Step S33, determining whether the historical variance value is greater than or equal to a preset stability threshold.
[0098] Step S34: If yes, the historical block in the historical disparity map corresponding to the adjacent historical frame is used as the block of the current frame.
[0099] Among them, the preset stability threshold can be 3. If the historical variance value is greater than 3, it is considered that the current block is not stable enough, so the corresponding block in the previous frame is used as the current block. Otherwise, it is considered that the parallax value of the current block is stable and does not need to be adjusted.
[0100] The above embodiment adjusts the disparity value of the current block in combination with historical frame data, thereby solving the problem that the disparity data result of a single frame is greatly affected by environmental factors, resulting in possible sudden changes in the disparity value, and further improving the accuracy of the disparity value.
[0101] In some embodiments, the method further comprises:
[0102] Step S41, obtaining an upper adjacent block and a lower adjacent block of the block; calculating a first average disparity value of the block, a second average disparity value of the upper adjacent block, and a third average disparity value of the lower adjacent block.
[0103] Among them, the upper adjacent block is the block adjacent to the upper side of the block, and the lower adjacent block is the block adjacent to the lower side of the end block.
[0104] Specifically, the steps of this embodiment may be performed after step S34 is performed and before step S17 is performed.
[0105] Step S42: determining whether the first average disparity value is between the second average disparity value and the third average disparity value.
[0106] Step S43: if not, the block corresponding to the first average disparity value is regarded as an untrustworthy block.
[0107] Specifically, the maximum disparity value and the minimum disparity value in the upper adjacent block and the lower adjacent block can also be taken to determine whether the disparity values of the middle block are between the maximum disparity value and the minimum disparity value. If so, the middle block is a credible block, otherwise it is an untrustworthy block. After being determined to be an untrustworthy block, steps S23 and S24 of the above embodiment are executed on it.
[0108] The above embodiment performs validity judgment based on upper and lower adjacent blocks, and can find mutations in blocks, further eliminate the influence of environmental factors on single-frame disparity data, and improve the accuracy of disparity values.
[0109] In some embodiments, the method further comprises:
[0110] Step S51, obtaining the first coordinates of the pixel points in the map data within the preset adjustment range of the preset seam.
[0111] Step S52: adjusting each first coordinate according to the disparity value sequence to obtain a second coordinate.
[0112] Specifically, the conventional method of applying the disparity value sequence in image stitching is: read the map data, obtain the coordinates near the seam as Q(x,y), the disparity value to be adjusted is d, the disparity adjustment range is 2w, and the adjusted coordinates are Q'(x,y):
[0113] Q ′ (x,y)=Q(x,y)-d
[0114]
[0115] …
[0116] Q′ (xw,y)=Q(xw,y)
[0117] Each coordinate point in the original map data is adjusted as above to obtain adjusted map data M1.
[0118] Wherein, d is a value in the disparity value sequence, and the adjustment method is to take the d value at each position for adjustment, and w is a preset adjustment range, which can be specifically 1 / 4 of the image width of the overlapping area, which is approximately 370, that is, d=370.
[0119] Step S53, obtaining the frame sequence numbers of the current frames corresponding to the first image and the second image.
[0120] Step S54, obtaining the current stitching coordinates according to the frame sequence number, the first coordinates and the second coordinates.
[0121] Step S55, configuring the current splicing coordinates into the map data.
[0122] However, directly adjusting according to the disparity value sequence may cause obvious changes in the stitched image. In order to achieve a better stitching effect, the present application adds a gradient adjustment algorithm, that is, the gradient map is adjusted through n frames (the value of n can be dynamically configured by the disparity value to be adjusted. Assuming that the required disparity value is 15, then n=15), the difference between the first coordinate M0 adjusted last time and the second coordinate M1 after adjustment is made, and then the difference is evenly divided into n steps to achieve the gradient process. For details, please refer to the following formula, where N represents the map configured each time, and the subscript of N is the frame number:
[0123] N0=M0
[0124]
[0125] …
[0126] N n =M1
[0127] The above embodiment achieves a continuous transition of the splicing effect by gradually adjusting the coordinates, further reducing the jumpiness of the splicing.
[0128] See also Figure 2 Another embodiment of the present application provides a disparity calculation device for a binocular stitching lens, comprising:
[0129] The acquisition module 101 is used to acquire a first image and a second image having overlapping areas; use the overlapping areas in the first image as a first initial image; and use the overlapping areas in the second image as a second initial image.
[0130] The disparity module 102 is used to input the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map.
[0131] The division module 103 is used to divide the initial disparity map according to a preset pixel range to obtain a plurality of blocks.
[0132] The calculation module 104 is used to calculate the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map.
[0133] The determination module 105 is used to determine whether the parallax change parameter is greater than a preset repetition threshold.
[0134] The updating module 106 is configured to use the minimum disparity value in the corresponding block as the disparity value of each pixel in the block.
[0135] The sequence module 107 is used to calculate the average disparity of the left pixel point and the right pixel point of the preset seam to obtain a disparity value sequence.
[0136] In some embodiments, the apparatus further comprises:
[0137] The preprocessing module is used to downsample the first initial image and the second initial image to a first preset size before inputting the disparity calculation function; and then fill the first initial image and the second initial image to a second preset size.
[0138] Furthermore, the method also includes:
[0139] The variance calculation module is used to calculate the pixel variance value in each block before calculating the disparity average value.
[0140] The untrusted marking module is used to mark the corresponding block as an untrusted block when the pixel variance value is less than a preset featureless threshold.
[0141] The effective acquisition module is used to acquire a first block and a second block which are closest to the untrusted block and are not untrusted blocks.
[0142] The interpolation module is used to perform linear interpolation on the disparity values of the first block and the second block to obtain a disparity value of the unreliable block.
[0143] In some embodiments, the apparatus further comprises:
[0144] A history acquisition module, used to acquire a history disparity map corresponding to a preset number of history frames of the current frame;
[0145] The historical variance module is used to calculate the historical variance value of the block and the corresponding historical block in each historical disparity map.
[0146] The historical judgment module is used to judge whether the historical variance value is greater than or equal to a preset stability threshold.
[0147] The block update module is used to use the historical blocks in the historical disparity map corresponding to the adjacent historical frames as the blocks of the current frame.
[0148] The specific definition of the parallax calculation device for a binocular stitching lens provided in this embodiment can be found in the embodiment of the parallax calculation method for a binocular stitching lens described above, and will not be repeated here. Each module in the above-mentioned parallax calculation device for a binocular stitching lens can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0149] The embodiment of the present application provides a computer device, which may include a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the processor executes the steps of a method for calculating the parallax of a binocular stitching lens as in any of the above embodiments.
[0150] The working process, working details and technical effects of the computer device provided in this embodiment can be found in the above embodiment of a method for calculating the parallax of a binocular stitching lens, which will not be described in detail here.
[0151] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of a method for calculating the parallax of a binocular stitching lens as in any of the above embodiments are implemented. Wherein, the computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive and / or a memory stick (Memory Stick), etc., and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The working process, working details and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment of a method for calculating the parallax of a binocular stitching lens, and will not be repeated here.
[0152] 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. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present 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).
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for calculating the parallax of a binocular stitching lens, characterized in that: include: Acquire a first image and a second image having an overlapping area; taking the overlapping area in the first image as a first initial image; using the overlapping area in the second image as a second initial image; Inputting the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map; Divide the initial disparity map according to a preset pixel range to obtain a plurality of blocks; Calculating the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map; Determining whether the parallax change parameter is greater than a preset repetition threshold; If yes, the minimum disparity value in the corresponding block is used as the disparity value of each pixel in the block; The disparity averages of the left pixel points and the right pixel points of the preset seam are calculated to obtain a disparity value sequence.
2. The parallax calculation method of binocular stitching lens according to claim 1, characterized in that: Also includes: Before inputting the disparity calculation function, downsampling the first initial image and the second initial image to a first preset size respectively; Then, the first initial image and the second initial image are filled to a second preset size respectively.
3. The parallax calculation method of binocular stitching lens according to claim 1, characterized in that: The calculating the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map includes: Pixels with the same disparity value in the block are classified as one category to obtain multiple disparity value categories; Calculate the difference between any two disparity value categories to obtain multiple difference values; The number of the difference values that are smaller than a preset distribution threshold is used as the parallax change parameter.
4. The parallax calculation method of binocular stitching lens according to claim 1, characterized in that: Also includes: Before calculating the disparity average value, calculating the pixel variance value in each of the blocks; If the pixel variance value is less than a preset featureless threshold, the corresponding block is regarded as an untrustworthy block; Obtaining a first block and a second block which are closest to the untrusted block and are not untrusted blocks; Linear interpolation is performed on the disparity values of the first block and the second block to obtain a disparity value of the unreliable block.
5. The parallax calculation method of binocular stitching lens according to claim 1, characterized in that: Also includes: Before calculating the disparity average value, obtaining historical disparity maps corresponding to a preset number of historical frames of the current frame; Calculate the historical variance value of the block and the historical blocks corresponding to each historical disparity map; Determine whether the historical variance value is greater than or equal to a preset stability threshold; If yes, the historical block in the historical disparity map corresponding to the adjacent historical frame is used as the block of the current frame.
6. The parallax calculation method of binocular stitching lens according to claim 4, characterized in that: Also includes: Obtaining an upper adjacent block and a lower adjacent block of the block; Calculating a first average disparity value of the block, a second average disparity value of the upper adjacent block, and a third average disparity value of the lower adjacent block; determining whether the first average disparity value is between the second average disparity value and the third average disparity value; If not, the block corresponding to the first average disparity value is used as the untrustworthy block.
7. The parallax calculation method of binocular stitching lens according to claim 1, characterized in that: Also includes: Obtaining first coordinates of pixel points in the map data within a preset adjustment range of the preset seam; Adjust each of the first coordinates according to the disparity value sequence to obtain a second coordinate; Obtaining the frame sequence number of the current frame corresponding to the first image and the second image; Obtaining a current stitching coordinate according to the frame sequence number, the first coordinate, and the second coordinate; The current stitching coordinates are configured into the map data.
8. A parallax calculation device for binocular stitching lens, characterized in that: include: An acquisition module, used for acquiring a first image and a second image having an overlapping area; taking the overlapping area in the first image as a first initial image; using the overlapping area in the second image as a second initial image; A disparity module, used for inputting the first initial image and the second initial image into a disparity calculation function to obtain an initial disparity map; A division module, used for dividing the initial disparity map according to a preset pixel range to obtain a plurality of blocks; A calculation module, used for calculating the disparity change parameter of each block according to the disparity value of each pixel point in the initial disparity map; A judging module, used for judging whether the parallax variation parameter is greater than a preset repetition threshold; An updating module, configured to use the minimum disparity value in the corresponding block as the disparity value of each pixel in the block; The sequence module is used to calculate the average disparity of the left pixel point and the right pixel point of the preset stitching seam to obtain a disparity value sequence.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for calculating the parallax of the binocular stitching lens as claimed in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for calculating the parallax of a binocular stitching lens as claimed in any one of claims 1 to 7 are implemented.