A video image splicing method, device, readable storage medium and terminal equipment

By calculating the optimal stitching seam in the overlapping area of ​​video images and updating it according to the degree of image change, the problem of large computational load and long processing time in video image stitching is solved, and real-time processing of video images is realized.

CN115409708BActive Publication Date: 2026-11-27杭州普联系统技术有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211034641.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-26
Publication Date
2026-11-27
Estimated Expiration
2042-08-26

Smart Images

  • Figure CN115409708B_ABST
    Figure CN115409708B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of image processing, and particularly relates to a video image splicing method and device, a computer readable storage medium and a terminal device. The method comprises the following steps: acquiring a first video image and a second video image to be spliced; if the first video image and the second video image are the first frame in a video sequence, calculating an overlapping area of the first video image and the second video image; calculating an optimal splicing seam of the overlapping area; splicing the first video image and the second video image according to the optimal splicing seam to obtain a spliced video image; if the first video image and the second video image are not the first frame in the video sequence, determining a picture change degree of the overlapping area; updating the optimal splicing seam according to the picture change degree; and splicing the first video image and the second video image according to the updated optimal splicing seam to obtain a spliced video image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing technology, and in particular relates to a video image stitching method, apparatus, computer-readable storage medium and terminal device. Background Technology

[0002] In the field of surveillance, a wider field of view and image clarity are often contradictory. This is because a wider field of view usually results in fewer pixels in a given area, while a larger number of pixels in a given area typically leads to a smaller field of view. In practice, to achieve both a wider field of view and better image clarity simultaneously, image stitching technology is required. Image stitching typically involves using multiple cameras to capture images, then employing an image stitching algorithm to combine the images captured by each camera, ultimately resulting in a single image with a wide field of view and high image clarity.

[0003] Existing image stitching methods are mainly for single-frame images. When stitching video images, the processing method for single-frame images is still applied. That is, each frame is stitched according to the processing method for single-frame images. Although this method can stitch video images, the amount of computation is huge and the time consumption is long, making it difficult to process video images in real time. Summary of the Invention

[0004] In view of this, embodiments of this application provide a video image stitching method, apparatus, computer-readable storage medium, and terminal device to solve the problems of large computational load, long time consumption, and difficulty in real-time processing in the prior art when performing video image stitching.

[0005] A first aspect of this application provides a video image stitching method, which may include:

[0006] Obtain the first and second video images to be stitched together;

[0007] If the first video image and the second video image are the first frame in a video sequence, then calculate the overlapping area of ​​the first video image and the second video image;

[0008] Calculate the optimal seam for the overlapping area;

[0009] The first video image and the second video image are stitched together according to the optimal stitching seam to obtain a stitched video image;

[0010] If the first video image and the second video image are not the first frame in the video sequence, then determine the degree of image change in the overlapping area;

[0011] The optimal seam is updated based on the degree of change in the image.

[0012] The first video image and the second video image are stitched together according to the updated optimal stitching seam to obtain a stitched video image.

[0013] In one specific implementation of the first aspect, updating the optimal stitching seam based on the degree of image change may include:

[0014] When the degree of change in the image meets the first preset condition, the optimal splicing seam will not be updated.

[0015] When the degree of change in the image meets the second preset condition, all of the optimal splicing seams are updated.

[0016] When the degree of change in the image meets the third preset condition, the optimal splicing seam is locally updated.

[0017] In one specific implementation of the first aspect, determining the degree of image change in the overlapping area may include:

[0018] The background modeling foreground pixels in the overlapping region are determined using a preset background modeling algorithm;

[0019] The frame difference foreground pixels in the overlapping region are determined using a preset frame difference algorithm;

[0020] The first number of foreground pixels in the background modeling and the second number of foreground pixels in the frame difference are counted respectively.

[0021] The degree of change in the image is determined based on the first number and the second number.

[0022] In one specific implementation of the first aspect, determining the degree of image change based on the first number and the second number may include:

[0023] If both the first number and the second number are 0, then it is determined that the degree of change in the image meets the first preset condition;

[0024] If either the first number or the second number is 0, then the degree of change in the image is determined to meet the second preset condition;

[0025] If neither the first number nor the second number is 0, then the third number of foreground pixels in the background modeling on the optimal stitching seam is counted, and the degree of change in the image is determined based on the third number.

[0026] In one specific implementation of the first aspect, determining the degree of image change based on the third number may include:

[0027] If the third number is less than a preset number threshold, then the degree of change in the image is determined to meet the third preset condition;

[0028] If the third number is greater than or equal to the number threshold, then the degree of change in the image is determined to meet the first preset condition.

[0029] In one specific implementation of the first aspect, calculating the overlapping region of the first video image and the second video image may include:

[0030] Calculate the homography matrix between the first video image and the second video image;

[0031] The second video image is mapped according to the homography matrix to obtain a mapped image;

[0032] The region consisting of overlapping pixels in the first video image and the mapped image is defined as the overlapping region.

[0033] In one specific implementation of the first aspect, calculating the optimal seam of the overlapping region may include:

[0034] Calculate the brightness difference value and gradient difference value of each pixel in the overlapping region in the first video image and the mapped image, respectively;

[0035] The cost value of each pixel in the overlapping region is calculated based on the brightness difference value and the gradient difference value, respectively.

[0036] Based on the cost of each pixel in the overlapping region, the seam with the minimum total cost is selected from the overlapping region as the optimal seam.

[0037] In one specific implementation of the first aspect, the step of stitching the first video image and the second video image according to the optimal stitching seam to obtain a stitched video image may include:

[0038] Calculate the fusion width of each row in the overlapping area based on the optimal seam.

[0039] The feathering fusion coefficient of each pixel in the overlapping region is calculated based on the fusion width.

[0040] The first video image and the mapped image are feathered and blended according to the feathering blending coefficient to obtain the stitched video image.

[0041] In one specific implementation of the first aspect, calculating the fusion width of each row in the overlapping region based on the optimal seam may include:

[0042] Determine the pixel intersection of the optimal seam and the target row; wherein the target row is any row in the overlapping region;

[0043] Determine whether the cost values ​​of the two pixels to the left and right of the intersection pixel in the target row, which are d pixels away from the intersection pixel, are both less than a preset cost threshold; where the initial value of d is 1.

[0044] If the cost values ​​of the left and right pixels are both less than the cost threshold, then determine whether 2d+1 is equal to the preset fusion width threshold.

[0045] If 2d+1 equals the fusion width threshold, then the fusion width of the target row is determined to be the fusion width threshold.

[0046] If 2d+1 is not equal to the fusion width threshold, then d is incremented by one counting unit, and the process returns to the step of determining whether the cost values ​​of the two pixels on the left and right of the intersection pixel in the target row that are d pixels away from the intersection pixel are both less than the preset cost threshold and subsequent steps.

[0047] If the cost value of either the left or right pixel is greater than or equal to the cost threshold, then the fusion width of the target row is determined to be 2d+1.

[0048] In one specific implementation of the first aspect, updating all the optimal seams may include:

[0049] The cost of each pixel in the overlapping region is calculated based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the overlapping region, the gradient difference value, and whether it is a foreground pixel.

[0050] Based on the cost of each pixel in the overlapping region, select the seam with the minimum total cost from the overlapping region as the optimal seam after all updates.

[0051] In one specific implementation of the first aspect, the local update of the optimal seam may include:

[0052] Determine the range of rows to be updated locally;

[0053] The cost of each pixel in the row range is calculated based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the row range, the gradient difference value, and whether it is a foreground pixel.

[0054] Based on the cost value of each pixel in the row range, a stitching seam with the minimum total cost value from the start pixel to the end pixel is selected as the locally updated stitching seam; wherein, the start pixel is the intersection pixel of the optimal stitching seam and the start row of the row range, and the end pixel is the intersection pixel of the optimal stitching seam and the end row of the row range.

[0055] Replace a portion of the optimal seam within the row range with the locally updated seam.

[0056] A second aspect of this application provides a video image stitching apparatus, which may include:

[0057] The first video image and second video image acquisition module is used to acquire the first video image and the second video image to be stitched together.

[0058] The overlapping region calculation module is used to calculate the overlapping region of the first video image and the second video image if the first video image and the second video image are the first frame in a video sequence.

[0059] The optimal seam calculation module is used to calculate the optimal seam in the overlapping area;

[0060] The first image stitching module is used to stitch the first video image and the second video image according to the optimal stitching seam to obtain a stitched video image;

[0061] The image change degree determination module is used to determine the image change degree of the overlapping area if the first video image and the second video image are not the first frame in the video sequence.

[0062] The optimal seam update module is used to update the optimal seam according to the degree of change in the image.

[0063] The second image stitching module is used to stitch the first video image and the second video image according to the updated optimal stitching seam to obtain a stitched video image.

[0064] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the video image stitching methods described above.

[0065] A fourth aspect of this application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the video image stitching methods described above.

[0066] The fifth aspect of this application provides a computer program product that, when run on a terminal device, causes the terminal device to execute the steps of any of the above-described video image stitching methods.

[0067] The beneficial effects of this application embodiment compared with the prior art are as follows: This application embodiment obtains a first video image and a second video image to be stitched; if the first video image and the second video image are the first frame in a video sequence, then the overlapping area of ​​the first video image and the second video image is calculated; the optimal stitching seam of the overlapping area is calculated; the first video image and the second video image are stitched together according to the optimal stitching seam to obtain a stitched video image; if the first video image and the second video image are not the first frame in a video sequence, then the degree of image change in the overlapping area is determined; the optimal stitching seam is updated according to the degree of image change; the first video image and the second video image are stitched together according to the updated optimal stitching seam to obtain a stitched video image. In this application embodiment, only the first frame video image is stitched together according to the processing method of a single frame image. In the processing of subsequent frames, the calculation information such as the optimal stitching seam in the previous frame can be reused, and it is only necessary to update it according to the degree of image change in the overlapping area, which greatly reduces the amount of calculation and shortens the calculation time, and enables real-time processing of video images. Attached Figure Description

[0068] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0069] Figure 1 This is a flowchart of one embodiment of a video image stitching method in this application.

[0070] Figure 2 A schematic flowchart for calculating the overlapping region of the first video image and the second video image;

[0071] Figure 3 A schematic flowchart for calculating the optimal seam in the overlapping area;

[0072] Figure 4 This is a schematic flowchart illustrating the stitching of the first and second video images according to the optimal stitching seam.

[0073] Figure 5 This is a schematic flowchart illustrating the feathering and fusion process for the first video image and the mapped image;

[0074] Figure 6 A flowchart illustrating the process of determining the degree of image change in overlapping areas;

[0075] Figure 7 A flowchart illustrating the process of updating all optimal seams;

[0076] Figure 8 A flowchart illustrating the local update of the optimal seam.

[0077] Figure 9 This is a structural diagram of one embodiment of a video image stitching device according to the present application.

[0078] Figure 10 This is a schematic block diagram of a terminal device in an embodiment of this application. Detailed Implementation

[0079] To make the inventive objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0080] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0081] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0082] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0083] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0084] Furthermore, in the description of this application, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0085] In this embodiment, only the first frame of video image can be stitched together using the single-frame image processing method. In the processing of subsequent frames, the optimal stitching seam and other calculated information from the previous frame can be reused. Updates only need to be made based on the degree of change in the overlapping area, greatly reducing the computational load and shortening the computation time, enabling real-time processing of video images. The execution subject of this embodiment can be any type of terminal device, including but not limited to mobile phones, tablets, desktop computers, laptops, and PDAs. This embodiment does not specifically limit the type of terminal device.

[0086] Please see Figure 1 One embodiment of a video image stitching method in this application may include:

[0087] Step S101: Obtain the first video image and the second video image to be stitched together.

[0088] The first video image and the second video image are acquired at the same time. The first video image (denoted as A) is a video image acquired by a preset first lens, and the second video image (denoted as B) is a video image acquired by a preset second lens. The first lens and the second lens can be two adjacent lenses in the same multi-view camera. The multi-view camera can be a binocular camera, a tri-lens camera, a quad-lens camera, etc., and the type of multi-view camera can be a spherical eagle-eye camera, a bowl-shaped eagle-eye camera, a panoramic camera, etc.

[0089] Specifically, a multi-view camera can include multiple lenses. Two adjacent lenses can be designated as the first view lens and the second view lens, respectively. For example, the left lens can be the first view lens and the right lens the second view lens, or the right lens can be the first view lens and the left lens the second view lens. Unless otherwise specified, in this embodiment, the first view lens is on the left and the second view lens is on the right.

[0090] In practical applications, when using a multi-view camera for video image acquisition, if the acquired video image has no image distortion, the video image acquired by the first lens can be directly used as the first video image, and the video image acquired by the second lens can be used as the second video image. If the acquired video image has image distortion, the distortion of the video image acquired by the first lens can be corrected first, and the corrected video image can be used as the first video image. Similarly, the distortion of the video image acquired by the second lens can be corrected, and the corrected video image can be used as the second video image. Since the first and second lenses are adjacent to each other, and the orientation of each lens in a multi-view camera is usually the same, there will often be overlapping areas in the first and second video images.

[0091] Step S102: Determine whether the first video image and the second video image are the first frame in the video sequence.

[0092] In this embodiment, the first and second video images obtained by the terminal device each time it starts executing the video image stitching method can be recorded as the first frame in the video sequence, and the first and second video images obtained subsequently can be recorded as the second frame, the third frame, ..., and so on.

[0093] If the first video image and the second video image are the first frame in the video sequence, then step S103 and subsequent steps are executed; if the first video image and the second video image are not the first frame in the video sequence, then step S106 and subsequent steps are executed.

[0094] Step S103: Calculate the overlapping area of ​​the first video image and the second video image.

[0095] like Figure 2 As shown, step S103 may specifically include the following process:

[0096] Step S1031: Calculate the homography matrix between the first video image and the second video image.

[0097] After obtaining the first and second video images, image feature points can be extracted from both images. The specific type of image feature points to be extracted can be set according to the actual situation; for example, it can be at least one of the following types: SIFT, SURF, ORB, HOG, and LBP.

[0098] Based on the extracted image feature points, the Random Sample Consensus (RANSAC) method can be used to match corresponding image feature points in two images, obtaining matching point pairs in the two images. The homography matrix is ​​then determined based on the matching point pairs, as shown in the following formula:

[0099]

[0100] Where (u′,v′) are the pixel coordinates of the matching point in the first video image, and the corresponding homogeneous expression is (u′,v′,1). (u,v) are the pixel coordinates of the matching point in the second video image, and the corresponding homogeneous expression is (u,v,1). The matching point in the first video image and the matching point in the second video image form a matching point pair. H is the homography matrix.

[0101] Step S1032: Map the second video image according to the homography matrix to obtain the mapped image.

[0102] After determining the homography matrix, the second image to be stitched can be mapped according to the homography matrix to obtain the mapped image (denoted as B1), as shown in the following formula:

[0103] p B1 =H·p B

[0104] Where, p B p is the homogeneous expression for the pixel position of the second video image. B1 This is a homogeneous expression for the pixel positions of the mapped image. By mapping each pixel in the second video image one by one using this expression, the mapped image can be obtained.

[0105] Step S1033: The region consisting of overlapping pixels in the first video image and the mapped image is taken as the overlapping region.

[0106] A pixel is considered an overlapping pixel when it has corresponding pixel locations in both the first video image A and the mapped image B1. The area formed by all overlapping pixels is the overlapping region of the first and second video images.

[0107] Step S104: Calculate the optimal seam for the overlapping area.

[0108] like Figure 3 As shown, step S104 may specifically include the following process:

[0109] Step S1041: Calculate the brightness difference value and gradient difference value of each pixel in the overlapping region in the first video image and the mapped image, respectively.

[0110] Taking the pixel (u,v) at row v and column u in the overlapping region as an example, its brightness difference value in the first video image and the mapped image can be calculated according to the following formula:

[0111] z(u, v) = |z A (u, v)-z B1(u, v)|

[0112] Among them, z A (u, v) and z B1 (u, v) are the brightness values ​​of pixel (u, v) in the first video image and the mapped image, respectively, and z(u, v) is the brightness difference value of pixel (u, v) in the first video image and the mapped image.

[0113] The gradient difference between the first video image and the mapped image can be calculated using the following formula:

[0114]

[0115] in, These are the gradient values ​​of pixels (u, v) in the first video image and the mapped image, respectively, which can be calculated using Sobel, Laplacian, or other gradient operators. Let (u, v) be the gradient difference value of pixel (u, v) in the first video image and the mapped image.

[0116] Step S1042: Calculate the cost of each pixel in the overlapping area based on the brightness difference value and the gradient difference value.

[0117] The cost of pixel (u, v) can be calculated using the following formula:

[0118]

[0119] Wherein, F(u, v) is the cost of pixel (u, v), ω1 is the preset brightness weight, and ω2 is the preset gradient weight. The specific values ​​of the two can be set according to the actual situation. For example, ω1 can be set to 0.1 and ω2 to 0.9. Of course, the two can also be set to other values. This application embodiment does not specifically limit this.

[0120] Step S1043: Select the seam with the minimum total cost from the overlapping area based on the cost of each pixel in the overlapping area as the optimal seam.

[0121] Taking left-right splicing as an example, an optimal splice seam can be selected from the overlapping area through the following process:

[0122] Step S1043a: Initialize the splice seam.

[0123] For each pixel in the first row of the overlapping region, a corresponding stitching seam is initialized. Each stitching seam initially includes only one corresponding pixel, and its total cost value is the cost value of the corresponding pixel.

[0124] Step S1043b: Extend the seam.

[0125] Starting from the second row of the overlapping region, select the optimal stitching seam for each pixel in the previous row. Taking pixel (u, v) as an example, compare the total cost of the stitching seams corresponding to the three adjacent pixels in the previous row (i.e., the three adjacent pixels directly above, to the upper left, and to the upper right). Select the stitching seam corresponding to the minimum value and extend it to pixel (u, v). The total cost of the extended stitching seam is:

[0126] M(u,v)=F(u,v)+min(M(u-1,v-1),M(u,v-1),M(u+1,v-1))

[0127] Where M(u,v) is the total cost after the stitching seam is extended to pixel (u,v).

[0128] Step S1043c: Determine whether the last row of the overlapping area has been calculated.

[0129] If the last row of the overlapping region has not yet been calculated, return to step S1043b, that is, select an optimal seam in the previous row for each pixel in the new row, extend it to the current pixel, and calculate the total cost of the extended seam. If the last row of the overlapping region has been calculated, proceed to step S1043d.

[0130] Step S1043d: Determine the optimal splice seam.

[0131] After calculating the last row of the overlapping region, each pixel in the last row corresponds to a stitching seam. The stitching seam with the minimum total value can be selected as the optimal stitching seam.

[0132] Step S105: The first video image and the second video image are stitched together according to the optimal stitching seam to obtain a stitched video image.

[0133] like Figure 4 As shown, step S105 may specifically include the following process:

[0134] Step S1051: Calculate the fusion width of each row in the overlapping area according to the optimal splicing seam.

[0135] Taking any row in the overlapping area (denoted as the target row) as an example, its merge width can be calculated using the following process:

[0136] Step S1051a: Determine the intersection pixel of the optimal seam and the target row.

[0137] The intersection pixel is denoted as the pixel at the intersection of the optimal stitching seam and the target row. This pixel belongs to both the optimal stitching seam and the target row.

[0138] Step S1051b: Determine whether the cost values ​​of the two pixels to the left and right of the intersection pixel in the target row, which are d pixels away from the intersection pixel, are both less than the preset cost threshold.

[0139] The initial value of d is 1. The specific value of the cost threshold can be set according to the actual situation, and this application embodiment does not impose specific limitations on it.

[0140] If the cost value of both the left and right pixels is less than the cost threshold, then step S1051c and subsequent steps are executed; if the cost value of either of the left and right pixels is greater than or equal to the cost threshold, then step S1051f is executed.

[0141] Step S1051c: Determine whether 2d+1 is equal to the preset fusion width threshold.

[0142] The fusion width threshold is an odd number, and its specific value can be set according to the actual situation. This application embodiment does not impose specific limitations on it.

[0143] If 2d+1 equals the fusion width threshold, then proceed to step S1051d; if 2d+1 does not equal the fusion width threshold, then proceed to step S1051e and subsequent steps.

[0144] Step S1051d: Determine the fusion width of the target row as the fusion width threshold.

[0145] Step S1051e: Increase d by one counting unit.

[0146] That is, execute: d = d + 1, and then return to execute step S1051b and its subsequent steps.

[0147] Step S1051f: Determine the fusion width of the target row as 2d+1.

[0148] In one specific implementation of this application, the calculated fusion width of each row in the overlapping region can be used directly. In another specific implementation of this application, after calculating the fusion width of each row in the overlapping region, these fusion width data can be smoothed. For example, these fusion widths can be smoothed in intervals, and for two adjacent fusion widths that are not at the fusion width threshold, mean filtering is used to smooth the fusion width, thereby obtaining the smoothed fusion width.

[0149] Step S1052: Calculate the feathering fusion coefficient of each pixel in the overlapping area according to the fusion width.

[0150] In this embodiment, the feathering fusion coefficient corresponding to the first video image can be denoted as the first feathering fusion coefficient, and the feathering fusion coefficient corresponding to the mapped image can be denoted as the second feathering fusion coefficient. For each pixel in the overlapping region, the sum of its first feathering fusion coefficient and second feathering fusion coefficient is 1.

[0151] Taking any row in the overlapping region as an example, the first feathering blending coefficient of pixels to the left of the blending width is 1; the first feathering blending coefficient of pixels to the right of the blending width is 0; within the blending width, the first feathering blending coefficient of each pixel decreases linearly from 1 to 0 from left to right, decreasing each time... Among them, WP i This is the width of the merged line.

[0152] Correspondingly, the second feathering fusion coefficient of pixels located to the left of the fusion width is 0; the second feathering fusion coefficient of pixels located to the right of the fusion width is 1; within the fusion width range, the second feathering fusion coefficient of each pixel increases linearly from 0 to 1 from left to right, with each increment...

[0153] Step S1053: Perform feathering fusion processing on the first video image and the mapped image according to the feathering fusion coefficient to obtain the stitched video image.

[0154] In the embodiments of this application, such as Figure 5 As shown, the image in the first video image that does not belong to the overlapping region can be identified as the first boundary image, the image in the first video image that belongs to the overlapping region can be identified as the first overlapping image, the image in the mapped image that does not belong to the overlapping region can be identified as the second boundary image, and the image in the mapped image that belongs to the overlapping region can be identified as the second overlapping image. Each pixel in the first overlapping image and the second overlapping image is in one-to-one correspondence. Taking any pair of corresponding pixels as an example, the pixel in the first overlapping image can be denoted as the first pixel, and the pixel in the second overlapping image can be denoted as the second pixel.

[0155] After determining the first and second feathering blending coefficients, we can calculate the first product of the pixel value of the first pixel and the first feathering blending coefficient, and the second product of the pixel value of the second pixel and the second feathering blending coefficient. The sum of the first and second products is then used to determine the pixel value of the merged pixel, which is the pixel obtained by merging the first and second pixels. By iterating through each pair of corresponding pixels in the first and second overlapping images and calculating the corresponding merged pixel, we can obtain the overlapping region merged image. Finally, by sequentially concatenating the first boundary image, the overlapping region merged image, and the second boundary image, we can obtain the final stitched video image.

[0156] Step S106: Determine the degree of image change in the overlapping area.

[0157] In this embodiment, it is assumed that the relative position between the first eye lens and the second eye lens remains unchanged. Therefore, the overlapping area of ​​each subsequent frame with the first frame is the same, and the overlapping area calculated in the first frame can be directly reused.

[0158] like Figure 6 As shown, step S106 may specifically include the following process:

[0159] Step S1061: Use a preset background modeling algorithm to determine the background modeling foreground pixels in the overlapping area.

[0160] In this embodiment, a Gaussian mixture model (MOG) or other background modeling algorithms can be selected to determine the foreground pixels of the first video image and the foreground pixels of the mapped image in the overlapping region, respectively, based on the actual situation. For any pixel position in the overlapping region, if it is a foreground pixel of either the first video image or the mapped image, it can be determined as a foreground pixel for background modeling.

[0161] Step S1062: Use a preset frame difference algorithm to determine the frame difference foreground pixels in the overlapping area.

[0162] In this embodiment, the inter-frame difference method can be used to determine the foreground pixels of the first video image and the mapped image in the overlapping region, respectively. For any pixel position in the overlapping region, if it is a foreground pixel of either the first video image or the mapped image, it can be determined as an inter-frame difference foreground pixel.

[0163] Step S1063: Count the first number of foreground pixels in background modeling and the second number of foreground pixels in frame difference.

[0164] Step S1064: Determine the degree of change in the image based on the first number and the second number.

[0165] If both the first and second numbers are 0, then it can be determined that the degree of change in the image meets the first preset condition.

[0166] If either the first or second number is 0, then it can be determined that the degree of change in the image meets the second preset condition.

[0167] If both the first and second numbers are not zero, a third number of foreground pixels in the background modeling on the optimal stitching seam can be counted, and the degree of image change can be determined based on the third number. Specifically, if the third number is less than a preset threshold, the degree of image change can be determined to meet the third preset condition; if the third number is greater than or equal to the threshold, the degree of image change can be determined to meet the first preset condition. The specific value of the threshold can be set according to the actual situation, and this application embodiment does not specifically limit it.

[0168] Step S107: Update the optimal seam according to the degree of change in the image.

[0169] When the degree of change in the image meets the first preset condition, the optimal stitching seam is not updated, and the optimal stitching seam of the previous frame can be reused directly.

[0170] When the degree of change in the image meets the second preset condition, then it can be based on Figure 7 The process shown updates the optimal seam completely:

[0171] Step S1071: Calculate the cost of each pixel in the overlapping area based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the overlapping area, the gradient difference value, and whether it is a foreground pixel.

[0172] Taking the pixel (u, v) at row v and column u in the overlapping region as an example, its cost can be calculated using the following formula:

[0173]

[0174]

[0175] Among them, S p (v) represents the position of the optimal stitching seam in row v of the previous frame, |uS p (v) represents the distance between pixel (u, v) and the optimal stitching seam. FG(u, v) indicates whether pixel (u, v) is a foreground pixel. If pixel (u, v) is a foreground pixel in background modeling, then FG(u, v) is 1; otherwise, FG(u, v) is 0. fg (u, v) represents the cost of the foreground and background of pixel (u, v). If FG(u, v) is 1, then E fg If (u, v) is 128, and FG(u, v) is 0, then E fg (u, v) is 0. α1, α2 and α3 are preset weights, and their specific values ​​can be set according to the actual situation. For example, they can be set to 0.25, 0.5 and 0.25 respectively. Of course, they can also be set to other values. This application embodiment does not specifically limit this.

[0176] Step S1072: Select the stitching seam with the minimum total cost value from the overlapping area based on the cost value of each pixel in the overlapping area as the optimal stitching seam after all updates.

[0177] The process of step S1072 is the same as that of step S1043. For details, please refer to the detailed description in step S1043. It will not be repeated here.

[0178] When the degree of change in the image meets the third preset condition, then it can be based on Figure 8 The process shown involves locally updating the optimal seam:

[0179] Step S1073: Determine the row range for the partial update.

[0180] Let v be the first row containing the foreground pixels in the background modeling. m The last line containing it is denoted as v. n Expanding outwards by r rows both upwards and downwards, we can obtain the row range for the local update. The starting row of the row range is v. m -r, the termination behavior for the line range. n +r. Specifically, if the row range exceeds the overlapping area, the excess portion can be removed. The specific value of r can be set according to the actual situation; for example, it can be set to 1, 2, or other values. This application embodiment does not specifically limit this.

[0181] Step S1074: Calculate the cost of each pixel in the row range based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the row range, the gradient difference value, and whether it is a foreground pixel.

[0182] The specific calculation process of the substitution value can be found in the detailed description in step S1071, and will not be repeated here.

[0183] Step S1075: Select a stitching seam from the row range with the minimum total cost from the starting pixel to the ending pixel as the local update stitching seam based on the cost value of each pixel in the row range.

[0184] Wherein, the starting pixel is the intersection point pixel of the optimal stitching seam of the previous frame and the starting row of the row range, and its position coordinates are (S p (v m -r), v m -r), the terminating pixel is the pixel at the intersection of the optimal stitching seam of the previous frame and the terminating row of the row range, and its position coordinates are (S p (v n +r), v n +r).

[0185] Specifically, a local update seam can be selected from the row range using the following procedure:

[0186] Step S1075a: Initialize the splice seam.

[0187] For each pixel in the first row of the row range, initialize a corresponding seam. Each seam initially includes only one corresponding pixel. For the starting pixel (S) p (v m -r), v m For the pixel with the prefix "-r"), the total cost of the seam is the cost of the starting pixel. For other pixels, the total cost of the seam is set to the preset maximum cost value MAX_VALUE. The specific value of the maximum cost value can be set according to the actual situation. For example, it can be set to (v n -v m +1)*255 or other values ​​are not specifically limited in this application embodiment.

[0188] Step S1075b: Extend the seam.

[0189] Starting from the second row of the row range, select the optimal stitching seam for each pixel in the previous row. Taking pixel (u, v) as an example, compare the total cost of the stitching seams corresponding to the three adjacent pixels in the previous row (i.e., the three adjacent pixels directly above, to the upper left, and to the upper right). Select the stitching seam corresponding to the minimum value and extend the selected stitching seam to pixel (u, v). The total cost of the extended stitching seam is:

[0190] M(u,v)=F(u,v)+min(M(u-1,v-1),M(u,v-1),M(u+1,v-1))

[0191] Where M(u,v) is the total cost after the stitching seam is extended to pixel (u,v).

[0192] Step S1075c: Determine whether the last row of the row range has been calculated.

[0193] If the last row of the row range has not yet been calculated, return to step S1075b, that is, select an optimal seam in the previous row for each pixel in the new row, extend it to the current pixel, and calculate the total cost of the extended seam. If the last row of the row range has been calculated, proceed to step S1075d.

[0194] Step S1075d: Determine the local update seam.

[0195] After calculating the last row of the row range, the stitching seam with the minimum total value from the starting pixel to the ending pixel can be selected as the local update stitching seam.

[0196] Step S1076: Replace the portion of the optimal seam within the row range with a locally updated seam.

[0197] That is, only the portion of the optimal seam within the row range is updated, while the other portions remain unchanged, thus obtaining the updated optimal seam.

[0198] Step S108: The first video image and the second video image are stitched together according to the updated optimal stitching seam to obtain a stitched video image.

[0199] The process of step S108 is the same as that of step S105, and can be found in the detailed description of step S105, which will not be repeated here. It should be noted that if the update method is no update, the blend width and feathering blend coefficient in the previous frame can be directly reused without recalculation; if the update method is partial update, only the blend width and feathering blend coefficient within the row range can be calculated, while the blend width and feathering blend coefficient in the previous frame can be directly reused for other rows without recalculation; if the update method is full update, the blend width and feathering blend coefficient in the entire overlapping area need to be recalculated.

[0200] In summary, this application embodiment obtains a first video image and a second video image to be stitched together; if the first video image and the second video image are the first frame in a video sequence, the overlapping area of ​​the first video image and the second video image is calculated; the optimal stitching seam of the overlapping area is calculated; the first video image and the second video image are stitched together according to the optimal stitching seam to obtain a stitched video image; if the first video image and the second video image are not the first frame in a video sequence, the degree of image change in the overlapping area is determined; the optimal stitching seam is updated according to the degree of image change; the first video image and the second video image are stitched together according to the updated optimal stitching seam to obtain a stitched video image. In this application embodiment, only the first frame video image is stitched together according to the processing method of a single frame image. In the processing of subsequent frames, the calculation information such as the optimal stitching seam in the previous frame can be reused, and it is only necessary to update it according to the degree of image change in the overlapping area, which greatly reduces the amount of calculation and shortens the calculation time, and enables real-time processing of video images.

[0201] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0202] Corresponding to the video image stitching method described in the above embodiments, Figure 9This diagram illustrates a structural diagram of an embodiment of a video image stitching device provided in this application.

[0203] In this embodiment, a video image stitching device may include:

[0204] The video image acquisition module 901 is used to acquire the first video image and the second video image to be stitched together.

[0205] The overlapping region calculation module 902 is used to calculate the overlapping region of the first video image and the second video image if the first video image and the second video image are the first frame in a video sequence.

[0206] The optimal seam calculation module 903 is used to calculate the optimal seam in the overlapping area;

[0207] The first image stitching module 904 is used to stitch the first video image and the second video image according to the optimal stitching seam to obtain a stitched video image;

[0208] The image change degree determination module 905 is used to determine the image change degree of the overlapping area if the first video image and the second video image are not the first frame in the video sequence.

[0209] The optimal seam update module 906 is used to update the optimal seam according to the degree of change in the image.

[0210] The second image stitching module 907 is used to stitch the first video image and the second video image according to the updated optimal stitching seam to obtain a stitched video image.

[0211] In one specific implementation of this application embodiment, the optimal seam update module may include:

[0212] The first update submodule is used to not update the optimal stitching seam when the degree of change in the image meets the first preset condition;

[0213] The second update submodule updates all the optimal splicing seams when the degree of change in the image meets the second preset condition.

[0214] The third update submodule performs a local update on the optimal splicing seam when the degree of change in the image meets the third preset condition.

[0215] In one specific implementation of this application embodiment, the image change degree determination module may include:

[0216] The background modeling foreground pixel determination submodule is used to determine the background modeling foreground pixels in the overlapping area using a preset background modeling algorithm;

[0217] The frame difference foreground pixel determination submodule is used to determine the frame difference foreground pixels in the overlapping region using a preset frame difference algorithm;

[0218] The foreground pixel statistics submodule is used to count the first number of foreground pixels in the background modeling and the second number of foreground pixels in the frame difference, respectively.

[0219] The image change degree determination submodule is used to determine the image change degree based on the first number and the second number.

[0220] In one specific implementation of this application embodiment, the submodule for determining the degree of image change may include:

[0221] The first screen change degree determination unit is used to determine that the screen change degree meets the first preset condition if both the first number and the second number are 0.

[0222] The second screen change degree determination unit is used to determine that the screen change degree meets the second preset condition if either the first number or the second number is 0.

[0223] The third image change degree determination unit is used to count the third number of background modeling foreground pixels on the optimal stitching seam if the first number and the second number are not both 0, and to determine the image change degree based on the third number.

[0224] In one specific implementation of this application embodiment, the third screen change degree determination unit can be specifically used to: if the third number is less than a preset number threshold, then determine that the screen change degree meets the third preset condition; if the third number is greater than or equal to the number threshold, then determine that the screen change degree meets the first preset condition.

[0225] In one specific implementation of this application embodiment, the overlapping region calculation module may include:

[0226] The homography matrix calculation submodule is used to calculate the homography matrix between the first video image and the second video image;

[0227] The image mapping submodule is used to map the second video image according to the homography matrix to obtain a mapped image;

[0228] The overlapping region determination submodule is used to define the region consisting of overlapping pixels in the first video image and the mapped image as the overlapping region.

[0229] In one specific implementation of this application embodiment, the optimal splice seam calculation module may include:

[0230] The difference value calculation submodule is used to calculate the brightness difference value and gradient difference value of each pixel in the overlapping region in the first video image and the mapped image, respectively.

[0231] The cost value calculation submodule is used to calculate the cost value of each pixel in the overlapping region based on the brightness difference value and the gradient difference value, respectively.

[0232] The optimal seam selection submodule is used to select the seam with the minimum total cost from the overlapping area based on the cost of each pixel in the overlapping area as the optimal seam.

[0233] In one specific implementation of this application embodiment, the first image stitching module may include:

[0234] The fusion width calculation submodule is used to calculate the fusion width of each row in the overlapping area based on the optimal seam.

[0235] The feathering blending coefficient calculation submodule is used to calculate the feathering blending coefficient of each pixel in the overlapping region according to the blending width;

[0236] The image stitching submodule is used to perform feathering fusion processing on the first video image and the mapped image according to the feathering fusion coefficient to obtain the stitched video image.

[0237] In one specific implementation of this application, the fusion width calculation submodule can be specifically used to: determine the intersection pixel of the optimal stitching seam and the target row; wherein, the target row is any row in the overlapping region; determine whether the cost value of the two pixels on the left and right of the target row that are d pixels away from the intersection pixel is less than a preset cost threshold; wherein, the initial value of d is 1; if the cost value of the two pixels on the left and right is less than the cost threshold, then determine whether 2d+1 is equal to the preset fusion width threshold; if 2d+1 is equal to the fusion width threshold, then determine the fusion width of the target row as the fusion width threshold; if 2d+1 is not equal to the fusion width threshold, then increment d by one count unit, and return to execute the step of determining whether the cost value of the two pixels on the left and right of the target row that are d pixels away from the intersection pixel is less than the preset cost threshold and its subsequent steps; if the cost value of either of the two pixels on the left and right is greater than or equal to the cost threshold, then determine the fusion width of the target row as 2d+1.

[0238] In one specific implementation of this application, the second update submodule can be used to: calculate the cost value of each pixel in the overlapping region based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the overlapping region, the gradient difference value, and whether it is a foreground pixel; and select a stitching seam with the minimum total cost value from the overlapping region based on the cost value of each pixel in the overlapping region as the optimal stitching seam after all updates.

[0239] In one specific implementation of this application, the third update submodule can be used to: determine the row range for local update; calculate the cost value of each pixel in the row range based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the row range, the gradient difference value, and whether it is a foreground pixel; select a stitching seam with the minimum total cost value from the start pixel to the end pixel in the row range as the local update stitching seam based on the cost value of each pixel in the row range; wherein, the start pixel is the intersection pixel of the optimal stitching seam and the start row of the row range, and the end pixel is the intersection pixel of the optimal stitching seam and the end row of the row range; and replace a portion of the optimal stitching seam in the row range with the local update stitching seam.

[0240] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0241] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0242] Figure 10 A schematic block diagram of a terminal device provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiment of this application are shown.

[0243] like Figure 10 As shown, the terminal device 10 of this embodiment includes: a processor 100, a memory 101, and a computer program 102 stored in the memory 101 and executable on the processor 100. When the processor 100 executes the computer program 102, it implements the steps in the various video image stitching method embodiments described above, for example... Figure 1 Steps S101 to S108 are shown. Alternatively, when the processor 100 executes the computer program 102, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 9 The functions of modules 901 to 907 are shown.

[0244] For example, the computer program 102 may be divided into one or more modules / units, which are stored in the memory 101 and executed by the processor 100 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program 102 in the terminal device 10.

[0245] The terminal device 10 can be a desktop computer, laptop, handheld computer, or other computing device. Those skilled in the art will understand that... Figure 10 This is merely an example of terminal device 10 and does not constitute a limitation on terminal device 10. It may include more or fewer components than shown, or combine certain components, or different components. For example, terminal device 10 may also include input / output devices, network access devices, buses, etc.

[0246] The processor 100 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0247] The memory 101 can be an internal storage unit of the terminal device 10, such as a hard disk or memory of the terminal device 10. The memory 101 can also be an external storage device of the terminal device 10, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the terminal device 10. Furthermore, the memory 101 can include both internal and external storage units of the terminal device 10. The memory 101 is used to store the computer program and other programs and data required by the terminal device 10. The memory 101 can also be used to temporarily store data that has been output or will be output.

[0248] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0249] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0250] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0251] In the embodiments provided in this application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0252] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0253] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0254] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content included in the computer-readable storage medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.

[0255] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A video image stitching method, characterized in that, include: Obtain the first and second video images to be stitched together; If the first video image and the second video image are the first frame in a video sequence, then calculate the overlapping area of ​​the first video image and the second video image; Calculate the optimal seam for the overlapping area; The first video image and the second video image are stitched together according to the optimal stitching seam to obtain a stitched video image; If the first video image and the second video image are not the first frame in the video sequence, then the degree of image change in the overlapping area is determined; and the optimal stitching seam is updated according to the degree of image change. The first video image and the second video image are stitched together according to the updated optimal stitching seam to obtain a stitched video image; The step of updating the optimal seam based on the degree of change in the image includes: When the degree of change in the image meets the third preset condition, the optimal splicing seam is locally updated; The local update of the optimal seam includes: Determine the range of rows to be updated locally; The cost of each pixel in the row range is calculated based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the row range, the gradient difference value, and whether it is a foreground pixel. Based on the cost value of each pixel in the row range, a stitching seam with the minimum total cost value from the start pixel to the end pixel is selected as the locally updated stitching seam; wherein, the start pixel is the intersection pixel of the optimal stitching seam and the start row of the row range, and the end pixel is the intersection pixel of the optimal stitching seam and the end row of the row range. Replace a portion of the optimal seam within the row range with the locally updated seam.

2. The video image stitching method according to claim 1, characterized in that, The step of updating the optimal seam based on the degree of change in the image includes: When the degree of change in the image meets the first preset condition, the optimal splicing seam will not be updated. When the degree of change in the image meets the second preset condition, all of the optimal splicing seams are updated.

3. The video image stitching method according to claim 1, characterized in that, Determining the degree of image change in the overlapping area includes: The background modeling foreground pixels in the overlapping region are determined using a preset background modeling algorithm; The frame difference foreground pixels in the overlapping region are determined using a preset frame difference algorithm; The first number of foreground pixels in the background modeling and the second number of foreground pixels in the frame difference are counted respectively. The degree of change in the image is determined based on the first number and the second number.

4. The video image stitching method according to claim 3, characterized in that, Determining the degree of change in the image based on the first number and the second number includes: If both the first number and the second number are 0, then it is determined that the degree of change in the image meets the first preset condition; If either the first number or the second number is 0, then the degree of change in the image is determined to meet the second preset condition; If neither the first number nor the second number is 0, then the third number of foreground pixels in the background modeling on the optimal stitching seam is counted, and the degree of change in the image is determined based on the third number.

5. The video image stitching method according to claim 4, characterized in that, Determining the degree of change in the image based on the third number includes: If the third number is less than a preset number threshold, then the degree of change in the image is determined to meet the third preset condition; If the third number is greater than or equal to the number threshold, then the degree of change in the image is determined to meet the first preset condition.

6. The video image stitching method according to claim 1, characterized in that, The calculation of the overlapping region between the first video image and the second video image includes: Calculate the homography matrix between the first video image and the second video image; The second video image is mapped according to the homography matrix to obtain a mapped image; The region consisting of overlapping pixels in the first video image and the mapped image is defined as the overlapping region.

7. The video image stitching method according to claim 6, characterized in that, The calculation of the optimal seam in the overlapping area includes: Calculate the brightness difference value and gradient difference value of each pixel in the overlapping region in the first video image and the mapped image, respectively; The cost value of each pixel in the overlapping region is calculated based on the brightness difference value and the gradient difference value, respectively. Based on the cost of each pixel in the overlapping region, the seam with the minimum total cost is selected from the overlapping region as the optimal seam.

8. The video image stitching method according to claim 7, characterized in that, The step of stitching the first video image and the second video image according to the optimal stitching seam to obtain a stitched video image includes: Calculate the fusion width of each row in the overlapping area based on the optimal seam. The feathering fusion coefficient of each pixel in the overlapping region is calculated based on the fusion width. The first video image and the mapped image are feathered and blended according to the feathering blending coefficient to obtain the stitched video image.

9. The video image stitching method according to claim 8, characterized in that, The step of calculating the fusion width of each row in the overlapping area based on the optimal seam includes: Determine the pixel intersection of the optimal seam and the target row; wherein the target row is any row in the overlapping region; Determine the distance between the target row and the intersection point pixel. Whether the cost values ​​of the two pixels to the left and right of each pixel are both less than a preset cost threshold; where, The initial value is 1; If the cost values ​​of both the left and right pixels are less than the cost threshold, then it is determined that... Is it equal to the preset fusion width threshold? like If the value is equal to the fusion width threshold, then the fusion width of the target row is determined to be the fusion width threshold. like If it is not equal to the fusion width threshold, then... Increment the count by one unit and return to the previous step, determining the distance between the target row and the pixel at the intersection point. The steps of checking whether the cost value of the left and right pixels of a pixel is less than the preset cost threshold and subsequent steps. If the cost value of either the left or right pixel is greater than or equal to the cost threshold, then the fusion width of the target row is determined to be... .

10. The video image stitching method according to any one of claims 2 to 9, characterized in that, The complete update of the optimal seam includes: The cost of each pixel in the overlapping region is calculated based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the overlapping region, the gradient difference value, and whether it is a foreground pixel. Based on the cost of each pixel in the overlapping region, select the seam with the minimum total cost from the overlapping region as the optimal seam after all updates.

11. A video image stitching device, characterized in that, include: The video image acquisition module is used to acquire the first and second video images to be stitched together. The overlapping region calculation module is used to calculate the overlapping region of the first video image and the second video image if the first video image and the second video image are the first frame in a video sequence. The optimal seam calculation module is used to calculate the optimal seam in the overlapping area; The first image stitching module is used to stitch the first video image and the second video image according to the optimal stitching seam to obtain a stitched video image; The image change degree determination module is used to determine the image change degree of the overlapping area if the first video image and the second video image are not the first frame in the video sequence. The optimal seam update module is used to update the optimal seam according to the degree of change in the image. The second image stitching module is used to stitch the first video image and the second video image according to the updated optimal stitching seam to obtain a stitched video image; The step of updating the optimal seam based on the degree of change in the image includes: When the degree of change in the image meets the third preset condition, the optimal splicing seam is locally updated; The local update of the optimal seam includes: Determine the range of rows to be updated locally; The cost of each pixel in the row range is calculated based on the optimal stitching seam of the previous frame, the brightness difference value of each pixel in the row range, the gradient difference value, and whether it is a foreground pixel. Based on the cost value of each pixel in the row range, a stitching seam with the minimum total cost value from the starting pixel to the ending pixel is selected as the locally updated stitching seam; wherein, the starting pixel is the intersection pixel of the optimal stitching seam and the starting row of the row range, and the ending pixel is the intersection pixel of the optimal stitching seam and the ending row of the row range. Replace a portion of the optimal seam within the row range with the locally updated seam.

12. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the video image stitching method as described in any one of claims 1 to 10.

13. A terminal 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, it implements the steps of the video image stitching method as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Video stitching method

    CN106412461A

  • Video stitching method based on dynamic optimal stitching line

    CN107203970A

  • Real-time video stitching method based on seam line

    CN108093221A

  • Large-view-field-angle image real-time splicing method based on calibration

    CN111047510A