System and method for accurately and synchronously realizing image stitching
Through multi-threaded processing and feature point matching technology, the quality problems caused by time deviation in multi-mesh camera video stitching are solved, accurate synchronization and efficient stitching of videos are achieved, and the splicing quality and processing efficiency are improved.
Patent Information
- Application Number
- CN202410918836.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-11-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When splicing videos with multi-mesh cameras, video time deviations caused by different machine models, machine booting lag, network delays, etc., lead to a decrease in splicing quality, resulting in phantoms, ghosts, splitting of moving targets, and disappearing moving targets. Impacts the accuracy of target tracking.
Using image preprocessing module, feature point detection and matching module, sequence coplanar module, time synchronization module and fusion smoothing module, the precise synchronization of images is achieved through multi-threading, including geometric distortion correction, noise suppression, feature point matching, and single response Matrix calculations, time deviation adjustments, and image fusion smoothing ensure video alignment in time and space.
It realizes accurate synchronization of video, improves splicing quality, reduces processing time, improves overall processing efficiency, and ensures the time and visual consistency and naturalness of the spliced video.
Smart Images

Figure CN118890423A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image stitching, and in particular relates to a system and method for realizing image stitching with precise synchronization. Background Art
[0002] With the rapid development of digital video technology and computer vision technology, video stitching technology has gradually matured and is widely used in various fields. Video stitching technology can stitch video images from multiple cameras into an image with a wide angle and a large field of view, thereby improving the ability to obtain environmental information. This helps people understand the environment more comprehensively and accurately, and provides a basis for decision-making.
[0003] In the fields of security monitoring and intelligent transportation, video stitching technology can stitch together video images from multiple surveillance cameras to form a complete surveillance picture. This helps monitoring personnel to detect abnormal situations more quickly and improve monitoring efficiency. In the fields of virtual reality, gaming and entertainment, video stitching technology can generate panoramic images or 360-degree videos to provide users with a more immersive experience. At the same time, in the field of medical imaging, video stitching technology can also help doctors diagnose diseases more accurately.
[0004] Although video splicing technology has been widely used in modern society, it still has some shortcomings. The following are the main shortcomings of video splicing technology:
[0005] In the actual application of video stitching based on multiple cameras, the videos shot by different cameras will have a certain degree of time deviation due to different machine models, machine startup freezes, network delays and other reasons. In this case, directly stitching videos with time deviations may cause virtual images, ghost images, moving target segmentation, moving target disappearance and other situations that affect the stitching quality. On this basis, when performing operations such as target tracking on the stitched video, the stitching results with many defects will have a greater negative impact on the accuracy of target tracking. Therefore, video synchronization work for multiple cameras is very necessary. Summary of the invention
[0006] In order to overcome the shortcomings and deficiencies of the above-mentioned prior art, the first purpose of the present invention is to provide a system for realizing image stitching with precise synchronization; the second purpose of the present invention is to provide a method for realizing image stitching with precise synchronization.
[0007] The first object of the present invention adopts the following technical solution:
[0008] A system for realizing image stitching with precise synchronization, comprising an image preprocessing module, a feature point detection and matching module, a sequence coplanarity module, a time synchronization module and a fusion smoothing module;
[0009] Image preprocessing module: used to read the Ai-th frame image of camera A and the Bi-th frame image of camera B and perform preprocessing, including geometric distortion correction and noise suppression;
[0010] Feature point detection and matching module: used to detect and match feature points of an image to obtain a correctly matched feature point matching pair set C;
[0011] Sequence coplanar module: used to calculate the homography matrix between the Ai-th frame image and the Bi-th frame image, and obtain the position conversion relationship between the two image planes in space;
[0012] Time synchronization module: obtain the optimal matching sequence based on the target sequence and the comparison sequence, calculate the time deviation t based on the pairing of the target sequence and the optimal matching sequence, complete the time synchronization of the two videos, and realize the alignment between the images;
[0013] Fusion smoothing module: used to stitch images after completing image matching, and smooth the stitched boundaries to make the stitching transition natural.
[0014] The second object of the present invention adopts the following technical solution:
[0015] A method for realizing image stitching accurately and synchronously, wherein the process is completed by multiple threads, including callback function threads A and B and user-defined threads 1, 2, 3, and 4;
[0016] Thread A: Get video frame data from camera A and store it in buffer1;
[0017] Thread B: Get video frame data from camera B and store it in buffer2;
[0018] Thread 1: Read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression;
[0019] Thread 2: Detect feature points on the Ai-th frame image;
[0020] Thread 3: Detect feature points on the Bi-th frame image;
[0021] Thread 4: Perform feature point matching, sequence coplanarity, time synchronization, and fusion smoothing on the Ai-th frame image and the Bi-th frame image;
[0022] The specific process is as follows:
[0023] Step 1: Initialize camera A and camera B, and set the parameters of A and B;
[0024] Step 2: read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression;
[0025] Step 3: Feature point detection and matching: feature point detection is performed on the Ai-th frame image and the Bi-th frame image, and the feature points of the two images are matched; the feature point matching pairs are screened, and the correctly matched feature point matching pairs are retained to obtain a feature point matching pair set C, where a correct match means that the similarity between the two feature points meets the set similarity threshold;
[0026] Step 4: Calculate the homography matrix H between the Ai-th frame image and the Bi-th frame image to obtain the position conversion relationship between the two image planes in space, project the two video frames taken by camera A and camera B into the same plane, and complete the coplanarity of the video sequence;
[0027] Step 5: Obtain matching sequence;
[0028] S501, performing background subtraction processing on two video sequences that are already coplanar in space, and then extracting contour sequences A1 and B1 of moving targets in the two videos respectively;
[0029] S502, scaling the contour sequence A1 and the contour sequence B1 to the same scale, and then aligning the two contours according to their center positions, and calculating the similarity of the two contours;
[0030] S503, marking the contour sequence A1 as the target sequence X, and marking the contour sequence B1 as the comparison sequence Y; finding the end frame of the matching sequence that matches the last frame of the target sequence in the comparison sequence, calculating the matching sequence according to the end frame, and adjusting the playback time of the target sequence and the comparison sequence by calculating the time deviation between the two videos, so as to achieve the time synchronization of the two videos;
[0031] Step 6: By comparing the ratio of the length of the matching sequence to the length of the target sequence, the average scaling degree of the retained matching sequence relative to the target sequence is calculated, and the matching sequence with the average scaling degree value closest to 1 is selected as the optimal matching sequence. According to the pairing of the target sequence and the optimal matching sequence, the time deviation t is calculated to complete the time synchronization;
[0032] Step 7: Image fusion and boundary smoothing.
[0033] As a preferred embodiment, the pretreatment process is as follows:
[0034] S201, correcting the image through an algorithm, performing dedistortion, cropping, and alignment processing on the captured image, ensuring that each image can be seamlessly connected when stitching, and eliminating geometric distortion caused by shooting equipment and shooting conditions;
[0035] S202: Using filter technology to reduce and eliminate noise points in the image and improve image quality.
[0036] As a preferred embodiment, the specific process of step 4 is as follows:
[0037] According to the correctly matched feature point matching pair set C obtained by screening in step 3, the transformation matrix between the Ai frame image and the Bi frame image is calculated based on the transformation formula. Assuming that the corresponding point coordinates of the points in the same plane in the Ai frame image and the Bi frame image are (xa, ya) and (xb, yb) respectively, the transformation formula between the two points is as follows:
[0038]
[0039] Among them, the H matrix is the homography matrix between the Ai-th frame image and the Bi-th frame image. It is a homogeneous matrix with 8 degrees of freedom; h1, h2, h4 and h5 are scale transformation and rotation; h3 is the horizontal displacement component; h6 is the vertical displacement component; h7 and h8 are the horizontal and vertical deformation components respectively;
[0040] By performing matrix transformation on the transformation formula, we can obtain:
[0041]
[0042] Extract 4 pairs of non-collinear matching points from the feature point matching pair set C, substitute them into the above equation, solve all variables, and you can get the homography matrix H;
[0043] Based on the homography matrix H between the Ai-th frame image and the Bi-th frame image, the spatial position relationship between the two images is obtained, and the two video frames taken by camera A and camera B are projected into the same plane to complete the coplanarity of the video sequence.
[0044] Preferably, the specific process of step S502 is as follows:
[0045] The contour sequence Al and the contour sequence Bl are respectively converted into regions in the binary image, where the pixels inside the contour are set to 1 and the pixels outside the contour are set to 0;
[0046] Calculate the intersection of two regions, where the intersection region is a set of pixels that are both 1 in the contour sequence A1 and the contour sequence B1.
[0047] Calculate the union of two regions, where the union region is a set of pixels that contain 1 in at least one region;
[0048] The similarity J(Al, Bl) is calculated by dividing the intersection area by the union area.
[0049]
[0050] J(Al, Bl) ranges from 0 to 1, where 0 indicates that the contour sequence Al has no overlap with the contour sequence Bl, and 1 indicates that the contour sequence Al has complete overlap with the contour sequence Bl.
[0051] Preferably, step S503 is specifically as follows:
[0052] Extract contour sequences from two video sequences, including target sequence X and comparison sequence Y;
[0053] For each frame xi in the target sequence X and each frame yj in the comparison sequence Y, calculate the similarity J[xi,yj] between xi and yj, where i and j are both positive integers, i = 1, 2, 3, ..., i; j = 1, 2, 3, ..., j; based on the similarity, construct a similarity matrix between the target sequence X and the comparison sequence Y;
[0054] Calculate the cumulative similarity matrix D, where D[xi,yj] represents the cumulative similarity of the optimal alignment path from X[1:xi] to Y[1:yj], where X[1:xi] represents the first frame to the i-th frame in the target sequence X; Y[1:yj] represents the first frame to the j-th frame in the comparison sequence Y;
[0055] In the last row of the cumulative similarity matrix D, all potential end points are extracted, where the potential end points correspond to the frames in the comparison sequence Y that may match the last frame of the target sequence X;
[0056] Based on the last matching frame corresponding to each potential end point, the frames of the entire matching sequence are extracted using optimal path backtracking;
[0057] The trajectory slope r of each matching sequence is calculated by comparing the ratio of the index difference between the first and last frames in the comparison sequence and the length of the target sequence. The size of |r| and the set absolute slope threshold is determined. When |r| is greater than or equal to the set absolute slope threshold, the corresponding matching sequence is discarded; when |r| is less than the set absolute slope threshold, the corresponding matching sequence is retained.
[0058] As a preferred embodiment, the specific process of step six is as follows:
[0059] The first and last frames of the matching sequence are extracted, and the time deviation t is calculated according to the pairing of the target sequence and the optimal matching sequence, as follows:
[0060] The frame index of the target sequence is it, the frame index of the best matching sequence is im, and the index difference of each pair of frames is Δi.
[0061] Δi=im-it;
[0062] Calculate the average index difference
[0063]
[0064] Where n is the number of frame pairs; Δik is the index difference of the kth pair of matching frames;
[0065] According to the average index difference Calculate the time deviation t, the calculation formula is as follows:
[0066]
[0067] Among them, FPS is frame rate;
[0068] The calculated time deviation t is used to adjust the playback time of the target sequence and the comparison sequence to achieve temporal synchronization of the two videos.
[0069] As a preferred embodiment, the specific process of step seven is as follows:
[0070] The video frame to be spliced is marked as Frame A, and the reference video frame is marked as Frame B;
[0071] Obtain the depth information of the specific area of Frame A and the overlapping area of Frame B to generate a depth map;
[0072] Using the depth map to calculate the disparity between corresponding pixels in the overlapping area;
[0073] When it is within the set disparity range, it means that the depth difference between the two frames in this area is small, and the pixels of the first frame are retained;
[0074] When the set disparity range is exceeded, it indicates that there is a large depth difference, and the pixels of the second frame are mapped to the corresponding positions of the first frame;
[0075] Map the pixels in the non-overlapping area to the target coordinate system according to their correspondence with the homography matrix;
[0076] For the specific area of Frame A and the overlapping area of Frame B, construct their Laplacian pyramids respectively. The Laplacian pyramid is constructed by Gaussian pyramid and image upsampling / downsampling, which contains detailed information of the image at different scales;
[0077] In each pyramid layer, the corresponding layers of Frame A and Frame B are fused based on the fusion rule of local contrast, and the areas with high contrast and clarity are selected for fusion;
[0078] The fused Laplacian pyramid layers are reassembled into the fused image, starting from the top layer, and each layer is upsampled and Gaussian blurred before being added to the next layer until the original image size is reached;
[0079] Merge the fused video frame with the reference video frame, and combine multiple fused frames in the correct order and position;
[0080] Adjust the brightness and contrast of the images on both sides of the seam, apply a blur effect around the seam to reduce sharp boundaries, adjust the colors of the images on both sides of the seam to ensure they are visually consistent, and smooth the pixels around the seam in the gradient domain to reduce gradient differences.
[0081] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0082] 1. The present invention realizes multi-task parallel execution by assigning each link of image processing to different threads. Threads A and B are responsible for data acquisition, threads 1, 2, and 3 are responsible for preprocessing and feature point detection respectively, and thread 4 is responsible for subsequent matching, coplanarity, synchronization, and smoothing processing. This method greatly reduces processing time and improves overall processing efficiency; multi-threaded processing can make full use of the computing power of multi-core processors and avoid performance bottlenecks caused by a single task occupying all resources. At the same time, through reasonable thread scheduling, it can ensure smooth data flow between various processing links and reduce waiting time.
[0083] 2. The present invention adopts multi-threading for feature point detection, which can identify the key feature points in the image more quickly and accurately, and construct a matching pair set C through a feature point matching algorithm. The screening mechanism enhances the feature point matching accuracy and provides a reliable basis for subsequent image stitching and spatial position conversion.
[0084] 3. The present invention obtains a high-precision matching sequence through the steps of background subtraction, contour extraction, registration and similarity calculation. Furthermore, by calculating the time deviation t and adjusting the playback time, the precise synchronization of the two videos in time is achieved. This synchronization mechanism ensures that the spliced video remains continuous and consistent in time.
[0085] 4. After completing the image stitching, the present invention uses fusion and smoothing technology to process the stitching boundary, eliminating the problem of unnatural seams and transitions. This processing makes the stitched image more natural and harmonious visually. BRIEF DESCRIPTION OF THE DRAWINGS
[0086] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0087] Figure 1 A module diagram of a system for realizing image stitching with precise synchronization according to the present invention is shown;
[0088] Figure 2 The thread synchronization and multithreading flow chart of the present invention is shown;
[0089] Figure 3 A flow chart of a method for realizing image stitching with precise synchronization according to the present invention is shown. DETAILED DESCRIPTION
[0090] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0091] Example 1
[0092] See also Figure 1 As shown, a system for realizing image stitching with precise synchronization in this embodiment includes an image preprocessing module, a feature point detection and matching module, a sequence coplanarity module, a time synchronization module and a fusion smoothing module.
[0093] Image preprocessing module: used to read the Ai-th frame image of camera A and the Bi-th frame image of camera B and perform preprocessing, including geometric distortion correction and noise suppression.
[0094] Feature point detection and matching module: used to detect and match feature points of an image to obtain a correctly matched feature point matching pair set C.
[0095] Sequence coplanar module: used to calculate the homography matrix between the Ai-th frame image and the Bi-th frame image to obtain the position conversion relationship between the two image planes in space.
[0096] Time synchronization module: The optimal matching sequence is obtained based on the target sequence and the comparison sequence. According to the pairing of the target sequence and the optimal matching sequence, the time deviation t is calculated to complete the time synchronization of the two videos and realize the alignment between the images.
[0097] Fusion smoothing module: used to stitch images after image matching is completed, and smooth the stitching boundaries to make the stitching transition naturally.
[0098] The beneficial effects of this embodiment are as follows: this embodiment achieves high-precision and high-efficiency processing of image stitching and video synchronization through the collaborative work of the image preprocessing module, feature point detection and matching module, sequence coplanarity module, time synchronization module and fusion smoothing module, bringing significant beneficial effects to the fields of image processing and video analysis.
[0099] Example 2
[0100] See also Figure 3 As shown, a method for realizing image stitching with precise synchronization in this embodiment, the process is completed by multiple threads together, including callback function threads A and B and user-defined threads 1, 2, 3, and 4;
[0101] Thread A: Get video frame data from camera A and store it in buffer1;
[0102] Thread B: Get video frame data from camera B and store it in buffer2;
[0103] Thread 1: Read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression;
[0104] Thread 2: Detect feature points on the Ai-th frame image;
[0105] Thread 3: Detect feature points on the Bi-th frame image;
[0106] Thread 4: Perform feature point matching, sequence coplanarity, time synchronization, and fusion smoothing on the Ai-th frame image and the Bi-th frame image;
[0107] See also Figure 3 As shown, a method for realizing image stitching with precise synchronization in this embodiment has the following process:
[0108] Step 1: Initialize camera A and camera B, and set the parameters of A and B to ensure that they can work normally; at the same time, create threads to control camera A and camera B respectively.
[0109] Thread A: Get video frame data from camera A and store it in buffer1.
[0110] Thread B: Gets video frame data from camera B and stores it in buffer2.
[0111] Step 2: read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression.
[0112] S201, correcting the image through an algorithm, performing dedistortion, cropping, and alignment on the captured image, ensuring that each image can be seamlessly connected when stitched, and eliminating geometric distortion caused by shooting equipment or shooting conditions.
[0113] S202: Use filter and other technologies to reduce or eliminate noise points in the image and improve image quality.
[0114] Step 3: Feature point detection and matching.
[0115] Perform feature point detection on the Ai-th frame image and the Bi-th frame image, and match the feature points of the two images;
[0116] The feature point matching pairs are screened, and the correctly matched feature point matching pairs are retained to obtain a feature point matching pair set C, where a correct match means that the similarity between the two feature points meets the set similarity threshold.
[0117] Step 4: Calculate the homography matrix between the Ai-th frame image and the Bi-th frame image to obtain the position conversion relationship between the two image planes in space.
[0118] According to the correctly matched feature point matching pair set C obtained by screening in step 3, the transformation matrix between the Ai frame image and the Bi frame image is calculated based on the transformation formula. Assuming that the corresponding point coordinates of the points in the same plane in the Ai frame image and the Bi frame image are (xa, ya) and (xb, yb) respectively, the transformation formula between the two points is as follows:
[0119]
[0120] Among them, the H matrix is the homography matrix between the Ai-th frame image and the Bi-th frame image. The homography matrix is a homogeneous matrix with a total of 8 degrees of freedom; h1, h2, h4 and h5 are scale transformation and rotation; h3 is the horizontal displacement component; h6 is the vertical displacement component; h7 and h8 are the horizontal and vertical deformation components respectively.
[0121] By performing matrix transformation on the transformation formula, we can obtain:
[0122]
[0123] Extract 4 pairs of non-collinear matching points from the feature point matching pair set C, substitute them into the above equation, solve all variables, and you can get the homography matrix H;
[0124] Based on the homography matrix H between the Ai-th frame image and the Bi-th frame image, the spatial position relationship between the two images is obtained, and the two video frames taken by camera A and camera B are projected into the same plane to complete the coplanarity of the video sequence.
[0125] Step 5: Get the matching sequence.
[0126] S501: Perform background subtraction processing on two video sequences that are already coplanar in space, and then extract contour sequences A1 and B1 of moving objects in the two videos respectively.
[0127] S502: Scale the contour sequence A1 and the contour sequence B1 to the same scale, and then align the two contours according to their center positions to calculate the similarity of the two contours.
[0128] The contour sequence Al and the contour sequence Bl are respectively converted into regions in the binary image, where the pixels inside the contour are set to 1 and the pixels outside the contour are set to 0;
[0129] Calculate the intersection of two regions, where the intersection region is a set of pixels that are both 1 in the contour sequence A1 and the contour sequence B1.
[0130] Calculate the union of two regions, where the union region is a set of pixels that contain 1 in at least one region;
[0131] The similarity J(Al, Bl) is calculated by dividing the intersection area by the union area.
[0132]
[0133] J(Al, Bl) ranges from 0 to 1, where 0 indicates that the contour sequence Al has no overlap with the contour sequence Bl, and 1 indicates that the contour sequence Al has complete overlap with the contour sequence Bl.
[0134] S503, marking the contour sequence Al as the target sequence X, and marking the contour sequence Bl as the comparison sequence Y; finding the end frame of the matching sequence that matches the last frame of the target sequence in the comparison sequence, calculating the matching sequence according to the end frame, and calculating the time deviation between the two videos. The time deviation is used to adjust the playback time of the target sequence and the comparison sequence to achieve time synchronization of the two videos.
[0135] Contour sequences are extracted from two video sequences, including a target sequence X and a comparison sequence Y.
[0136] For each frame xi in the target sequence X and each frame yj in the comparison sequence Y, calculate the similarity J[xi,yj] between xi and yj, where i and j are both positive integers, i = 1, 2, 3, ..., i; j = 1, 2, 3, ..., j; based on the similarity, construct a similarity matrix between the target sequence X and the comparison sequence Y;
[0137] Calculate the cumulative similarity matrix D, where D[xi,yj] represents the cumulative similarity of the optimal alignment path from X[1:xi] to Y[1:yj], where X[1:xi] represents the first frame to the i-th frame in the target sequence X; Y[1:yj] represents the first frame to the j-th frame in the comparison sequence Y;
[0138] In the last row of the cumulative similarity matrix D, all potential end points are extracted, where the potential end points correspond to the frames in the comparison sequence Y that may match the last frame of the target sequence X;
[0139] Based on the last matching frame corresponding to each potential end point, the frames of the entire matching sequence are extracted using optimal path backtracking;
[0140] The trajectory slope r of each matching sequence is calculated by comparing the ratio of the index difference between the first and last frames in the comparison sequence and the length of the target sequence. The size of |r| and the set absolute slope threshold is determined. When |r| is greater than or equal to the set absolute slope threshold, the corresponding matching sequence is discarded; when |r| is less than the set absolute slope threshold, the corresponding matching sequence is retained.
[0141] Step 6: Calculate the time difference and complete time synchronization.
[0142] By comparing the ratio of the length of the matching sequence to the length of the target sequence, the average scaling degree of the retained matching sequence relative to the target sequence is calculated, and the matching sequence with the average scaling degree value closest to 1 is selected as the optimal matching sequence;
[0143] The first and last frames of the matching sequence are extracted, and the time deviation t is calculated according to the pairing of the target sequence and the optimal matching sequence, as follows:
[0144] The frame index of the target sequence is it, the frame index of the best matching sequence is im, and the index difference of each pair of frames is Δi.
[0145] Δi=im-it;
[0146] Calculate the average index difference
[0147]
[0148] Where n is the number of frame pairs; Δik is the index difference between the kth pair of matching frames.
[0149] According to the average index difference Calculate the time deviation t, the calculation formula is as follows:
[0150]
[0151] Among them, FPS is the frame rate.
[0152] The calculated time deviation t is used to adjust the playback time of the target sequence and the comparison sequence to achieve temporal synchronization of the two videos.
[0153] Step 7: Image fusion and boundary smoothing.
[0154] In the overlapping area between the video frame to be stitched and the reference video frame, an image fusion algorithm is used to perform fusion processing to reduce stitching traces and make the stitched image more natural.
[0155] The fused video frames are combined with the reference video frames to reconstruct a panoramic image or a high-resolution image.
[0156] Smoothing is performed on the image stitching to eliminate stitching marks caused by differences in lighting, color, etc., making the stitched image more natural.
[0157] The specific process is as follows:
[0158] The video frame to be spliced is marked as Frame A, and the reference video frame is marked as Frame B;
[0159] Obtain the depth information of the specific area of Frame A and the overlapping area of Frame B to generate a depth map;
[0160] The depth map is used to calculate the disparity between corresponding pixels in the overlapping area.
[0161] When within the disparity range: If the disparity is within the predetermined range, it means that the depth difference between the two frames in this area is small, and the pixels of the first frame can be selected to be retained.
[0162] When the disparity range is exceeded: If the disparity exceeds the predetermined range, indicating a large depth difference, the pixels of the second frame are mapped to the corresponding positions of the first frame.
[0163] Non-overlapping area mapping: Map the pixels in the non-overlapping area to the target coordinate system according to their correspondence with the homography matrix.
[0164] For the specific area of Frame A and the overlapping area of Frame B, construct their Laplacian pyramids respectively. The Laplacian pyramid is constructed by Gaussian pyramid and image upsampling / downsampling, which contains detailed information of the image at different scales;
[0165] In each pyramid layer, the corresponding layers of Frame A and Frame B are fused based on the fusion rule of local contrast, and the areas with high contrast and clarity are selected for fusion;
[0166] The fused Laplacian pyramid layers are reassembled into the fused image, starting from the top layer, and each layer is upsampled and Gaussian blurred before being added to the next layer until the original image size is reached;
[0167] Merge the fused video frame with the reference video frame, and combine multiple fused frames in the correct order and position;
[0168] Adjust the brightness and contrast of the images on both sides of the seam, apply a blur effect around the seam to reduce sharp boundaries, adjust the colors of the images on both sides of the seam to ensure they are visually consistent, and smooth the pixels around the seam in the gradient domain to reduce gradient differences.
[0169] The beneficial effects of this embodiment are as follows: the present invention realizes multi-task parallel execution by assigning each link of image processing to different threads. This method greatly reduces the processing time and improves the overall processing efficiency; a matching pair set is constructed through a feature point matching algorithm, and a strict matching screening mechanism ensures the correctness of the matching, providing a reliable basis for subsequent image stitching and spatial position conversion; a high-precision matching sequence is obtained through steps such as background subtraction, contour extraction, registration and similarity calculation. Further, by calculating the time deviation t and adjusting the playback time, the precise synchronization of the two videos in time is achieved. This synchronization mechanism ensures that the spliced video remains continuous and consistent in time.
[0170] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
[0171] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A system for realizing image stitching with precise synchronization, characterized in that: It includes image preprocessing module, feature point detection and matching module, sequence coplanarity module, time synchronization module and fusion smoothing module; Image preprocessing module: used to read the Ai-th frame image of camera A and the Bi-th frame image of camera B and perform preprocessing, including geometric distortion correction and noise suppression; Feature point detection and matching module: used to detect and match feature points of an image to obtain a correctly matched feature point matching pair set C; Sequence coplanar module: used to calculate the homography matrix between the Ai-th frame image and the Bi-th frame image, and obtain the position conversion relationship between the two image planes in space; Time synchronization module: obtain the optimal matching sequence based on the target sequence and the comparison sequence, calculate the time deviation t based on the pairing of the target sequence and the optimal matching sequence, complete the time synchronization of the two videos, and realize the alignment between the images; Fusion smoothing module: used to stitch images after completing image matching, and smooth the stitched boundaries to make the stitching transition natural.
2. A method for realizing image stitching by precise synchronization, applied to the system for realizing image stitching by precise synchronization as claimed in claim 1, characterized in that: The specific process is as follows: Step 1: Initialize camera A and camera B, and set the parameters of A and B; Step 2: read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression; Step 3: Feature point detection and matching: feature point detection is performed on the Ai-th frame image and the Bi-th frame image, and the feature points of the two images are matched; the feature point matching pairs are screened, and the correctly matched feature point matching pairs are retained to obtain a feature point matching pair set C, where a correct match means that the similarity between the two feature points meets the set similarity threshold; Step 4: Calculate the homography matrix H between the Ai-th frame image and the Bi-th frame image to obtain the position conversion relationship between the two image planes in space, project the two video frames taken by camera A and camera B into the same plane, and complete the coplanarity of the video sequence; Step 5: Obtain matching sequence; S501, performing background subtraction processing on two video sequences that are already coplanar in space, and then extracting contour sequences A1 and B1 of moving targets in the two videos respectively; S502, scaling the contour sequence A1 and the contour sequence B1 to the same scale, and then aligning the two contours according to their center positions, and calculating the similarity of the two contours; S503, marking the contour sequence A1 as the target sequence X, and marking the contour sequence B1 as the comparison sequence Y; finding the end frame of the matching sequence that matches the last frame of the target sequence in the comparison sequence, calculating the matching sequence according to the end frame, and adjusting the playback time of the target sequence and the comparison sequence by calculating the time deviation between the two videos, so as to achieve the time synchronization of the two videos; Step 6: By comparing the ratio of the length of the matching sequence to the length of the target sequence, the average scaling degree of the retained matching sequence relative to the target sequence is calculated, and the matching sequence with the average scaling degree value closest to 1 is selected as the optimal matching sequence. According to the pairing of the target sequence and the optimal matching sequence, the time deviation t is calculated to complete the time synchronization; Step 7: Image fusion and boundary smoothing.
3. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The pre-processing process is as follows: S201, correcting the image through an algorithm, performing dedistortion, cropping, and alignment processing on the captured image, ensuring that each image can be seamlessly connected when stitching, and eliminating geometric distortion caused by shooting equipment and shooting conditions; S202: Using filter technology to reduce and eliminate noise points in the image and improve image quality.
4. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The specific process of step 4 is as follows: According to the correctly matched feature point matching pair set C obtained by screening in step 3, the transformation matrix between the Ai frame image and the Bi frame image is calculated based on the transformation formula. Assuming that the corresponding point coordinates of the points in the same plane in the Ai frame image and the Bi frame image are (xa, ya) and (xb, yb) respectively, the transformation formula between the two points is as follows: Among them, the H matrix is the homography matrix between the Ai-th frame image and the Bi-th frame image. It is a homogeneous matrix with 8 degrees of freedom; h1, h2, h4 and h5 are scale transformation and rotation; h3 is the horizontal displacement component; h6 is the vertical displacement component; h7 and h8 are the horizontal and vertical deformation components respectively; By performing matrix transformation on the transformation formula, we can obtain: Extract 4 pairs of non-collinear matching points from the feature point matching pair set C, substitute them into the above equation, solve all variables, and you can get the homography matrix H; Based on the homography matrix H between the Ai-th frame image and the Bi-th frame image, the spatial position relationship between the two images is obtained, and the two video frames taken by camera A and camera B are projected into the same plane to complete the coplanarity of the video sequence.
5. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The specific process of step S502 is as follows: The contour sequence Al and the contour sequence Bl are respectively converted into regions in the binary image, where the pixels inside the contour are set to 1 and the pixels outside the contour are set to 0; Calculate the intersection of two regions, where the intersection region is a set of pixels that are both 1 in the contour sequence A1 and the contour sequence B1. Calculate the union of two regions, where the union region is a set of pixels that contain 1 in at least one region; The similarity J(Al, Bl) is calculated by dividing the intersection area by the union area. J(Al, Bl) ranges from 0 to 1, where 0 indicates that the contour sequence Al has no overlap with the contour sequence Bl, and 1 indicates that the contour sequence Al has complete overlap with the contour sequence Bl.
6. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The step S503 is specifically as follows: Extract contour sequences from two video sequences, including target sequence X and comparison sequence Y; For each frame xi in the target sequence X and each frame yj in the comparison sequence Y, calculate the similarity J[xi,yj] between xi and yj, where i and j are both positive integers, i = 1, 2, 3, ..., i; j = 1, 2, 3, ..., j; based on the similarity, construct a similarity matrix between the target sequence X and the comparison sequence Y; Calculate the cumulative similarity matrix D, where D[xi,yj] represents the cumulative similarity of the optimal alignment path from X[1:xi] to Y[1:yj], where X[1:xi] represents the first frame to the i-th frame in the target sequence X; Y[1:yj] represents the first frame to the j-th frame in the comparison sequence Y; In the last row of the cumulative similarity matrix D, all potential end points are extracted, where the potential end points correspond to the frames in the comparison sequence Y that may match the last frame of the target sequence X; Based on the last matching frame corresponding to each potential end point, the frames of the entire matching sequence are extracted using optimal path backtracking; The trajectory slope r of each matching sequence is calculated by comparing the ratio of the index difference between the first and last frames in the comparison sequence and the length of the target sequence. The size of |r| and the set absolute slope threshold is determined. When |r| is greater than or equal to the set absolute slope threshold, the corresponding matching sequence is discarded; when |r| is less than the set absolute slope threshold, the corresponding matching sequence is retained.
7. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The specific process of step six is as follows: The first and last frames of the matching sequence are extracted, and the time deviation t is calculated according to the pairing of the target sequence and the optimal matching sequence, as follows: The frame index of the target sequence is it, the frame index of the best matching sequence is im, and the index difference of each pair of frames is Δi. Δi=im-it; Calculate the average index difference Where n is the number of frame pairs; Δik is the index difference of the kth pair of matching frames; According to the average index difference Calculate the time deviation t, the calculation formula is as follows: Among them, FPS is frame rate; The calculated time deviation t is used to adjust the playback time of the target sequence and the comparison sequence to achieve temporal synchronization of the two videos.
8. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The specific process of step seven is as follows: The video frame to be spliced is marked as Frame A, and the reference video frame is marked as Frame B; Obtain the depth information of the specific area of Frame A and the overlapping area of Frame B to generate a depth map; Using the depth map to calculate the disparity between corresponding pixels in the overlapping area; When it is within the set disparity range, it means that the depth difference between the two frames in this area is small, and the pixels of the first frame are retained; When the set disparity range is exceeded, it indicates that there is a large depth difference, and the pixels of the second frame are mapped to the corresponding positions of the first frame; Map the pixels in the non-overlapping area to the target coordinate system according to their correspondence with the homography matrix; For the specific area of Frame A and the overlapping area of Frame B, construct their Laplacian pyramids respectively; the Laplacian pyramid is constructed by Gaussian pyramid and image upsampling / downsampling, and contains detailed information of the image at different scales; In each pyramid layer, the corresponding layers of Frame A and Frame B are fused based on the fusion rule of local contrast, and the areas with high contrast and clarity are selected for fusion; The fused Laplacian pyramid layers are reassembled into the fused image, starting from the top layer, and each layer is upsampled and Gaussian blurred before being added to the next layer until the original image size is reached; Merge the fused video frame with the reference video frame, and combine multiple fused frames in the correct order and position; Adjust the brightness and contrast of the images on both sides of the seam, apply a blur effect around the seam to reduce sharp boundaries, adjust the colors of the images on both sides of the seam to ensure they are visually consistent, and smooth the pixels around the seam in the gradient domain to reduce gradient differences.
9. The method for realizing image stitching by precise synchronization according to claim 2, characterized in that: The process is completed by multiple threads, including callback function threads A and B and user-defined threads 1, 2, 3, and 4; Thread A: Get video frame data from camera A and store it in buffer1; Thread B: Get video frame data from camera B and store it in buffer2; Thread 1: Read the Ai-th frame image of camera A and the Bi-th frame image of camera B, and pre-process the video frames, including geometric distortion correction and noise suppression; Thread 2: Detect feature points on the Ai-th frame image; Thread 3: Detect feature points on the Bi-th frame image; Thread 4: Perform feature point matching, sequence coplanarity, time synchronization, and fusion smoothing on the Ai-th frame image and the Bi-th frame image.
Citation Information
Patent Citations
Image mosaic method and image mosaic device
CN101673395A
Video sequence synchronization method based on moving object timing sequence information
CN106991690A
Video image splicing device and splicing method thereof
CN107426507A
MRI / PET / CT / PET-CT panoramic video auxiliary system
CN109961394A
