A method and system for stitching panoramic pictures and videos
By dividing the 360-degree panoramic image into multiple areas, selecting and intercepting the corresponding parts, and splicing, the problem of the existing technology being difficult to directly reorganize certain areas of panoramic images or videos is solved, and flexible area reorganization and efficient splicing effect are achieved. .
Patent Information
- Application Number
- CN202210695883.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-20
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2042-06-20
AI Technical Summary
The existing panoramic picture and video stitching technology is difficult to directly reorganize multiple panoramic pictures or certain areas of videos according to needs, and cannot meet the needs of regional reorganization in scene needs.
By defining a circle that represents a 360-degree panoramic image, divide it into several parts, set the starting angle and the end angle of each area, select the panoramic image or video of each area and capture the corresponding parts, and finally splice these parts , forming new panoramic pictures or video frames.
It realizes direct splicing of certain areas of panoramic pictures or videos according to needs, meeting the needs of regional reorganization in scene needs, and improving the flexibility and efficiency of splicing.
Smart Images

Figure CN115103207B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image and video stitching, and in particular to a method and system for stitching panoramic pictures and videos. Background Art
[0002] Panoramic images are 360-degree panoramic images taken by professional panoramic cameras, and panoramic videos can be regarded as sequence frames of panoramic images. In some application scenarios, two or more panoramic images or panoramic videos need to be cut and stitched into a new panoramic image or panoramic video. For example, take a scene with lighting effects, the lights are placed in front of and behind the camera, and take a panoramic image for each. If the final panoramic image hopes to have brighter lighting effects in the front and back, then what needs to be done is to stitch the first half of the first panoramic image with the second half of the second panoramic image to form a new panoramic image. For another example, there are panoramic images of several scenes, but you want to show part of each scene in one panoramic image, so you need to stitch the existing panoramic images.
[0003] The existing panoramic image or video stitching technologies are all based on the recognition and matching of image features. The corresponding points in different panoramic images are found, and the relative position relationship of the cameras is estimated through the relative position relationship of the corresponding points. Finally, the photos taken by other cameras are projected onto the photos of one of the cameras, and the result is a stitched panoramic image. Generally, an object in a scene in multiple panoramic images or videos is identified, and the parts of the object in multiple panoramic images are extracted and stitched together to form the overall outline of an object and minimize distortion. These panoramic stitching technologies do not match the scene requirements, because the scene requirements are generally to reorganize certain areas of multiple panoramic images, and do not require precise matching of objects, so a more direct stitching method is needed. Summary of the invention
[0004] In order to solve the technical problems existing in the prior art, the present invention provides a method and system for stitching panoramic pictures and videos. By giving a number of panoramic pictures or panoramic videos, a part of each panoramic picture or panoramic video frame is intercepted according to needs, and then the intercepted partial pictures or video frames are stitched to form a new panoramic picture or panoramic video frame.
[0005] The method of the present invention is implemented by the following technical solution: A method for stitching panoramic pictures and videos, comprising the following steps:
[0006] S1. Define a circle to represent a 360° panoramic image;
[0007] S2. Divide the circle into several parts. Set a starting angle and an ending angle for each area. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle. Each area represents a part of a panoramic picture or a panoramic video.
[0008] S3, selecting a panoramic picture or a panoramic video for each divided area, and intercepting a portion of the picture and video of the area corresponding to the panoramic picture or the panoramic video;
[0009] S4. Splicing the partial panoramic images cut out from the various panoramic images or panoramic video frames to form a new panoramic image or panoramic video frame.
[0010] The system of the present invention adopts the following technical solutions to achieve: a panoramic picture and video stitching system, including:
[0011] Definition module: used to define a circle, representing a 360-degree panoramic image;
[0012] Division module: used to divide a circle into several parts. Each area is set with a starting angle and an ending angle. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle. Each area represents a part of a panoramic picture or panoramic video.
[0013] Panoramic picture or video capture module: used to select a panoramic picture or panoramic video for each divided area, and capture part of the picture and video of the area corresponding to the panoramic picture or panoramic video;
[0014] Panoramic picture or video stitching module: used to stitch partial panoramic pictures cut out from various panoramic pictures or panoramic video frames to form new panoramic pictures or panoramic video frames.
[0015] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0016] 1. The present invention is given a number of panoramic pictures or panoramic videos, and according to the needs, a part of each panoramic picture or panoramic video frame is intercepted, and then the intercepted partial pictures or video frames are spliced to form a new panoramic picture or panoramic video frame. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of the method of the present invention;
[0018] Figure 2 is a circular schematic diagram defined in this embodiment;
[0019] Figure 3 is a schematic diagram of the area division definition of this embodiment;
[0020] Figure 4 is a schematic diagram of virtual rectangle definition in this embodiment;
[0021] Figure 5 It is a schematic diagram of capturing a panoramic picture in this embodiment. DETAILED DESCRIPTION
[0022] The present invention is further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.
[0023] Example
[0024] like Figure 1 As shown, the present embodiment provides a method and system for stitching panoramic pictures and videos, comprising the following steps:
[0025] S1. Define a circle to represent a 360-degree panoramic image;
[0026] S2, divide the circle into several parts, such as Figure 2 As shown, each area sets a starting angle and an ending angle. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle size. Each area represents a part of a panoramic picture or panoramic video.
[0027] S3, selecting a panoramic picture or a panoramic video for each divided area, and intercepting a portion of the picture and video of the area corresponding to the panoramic picture or the panoramic video;
[0028] S4. Splicing the partial panoramic images cut out from the various panoramic images or panoramic video frames to form a new panoramic image or panoramic video frame.
[0029] In this embodiment, the specific process of capturing a portion of the image or video corresponding to the area of the panoramic image or panoramic video in step S3 is as follows:
[0030] S31, such as Figure 3 As shown, each divided area is defined using a starting angle stangle and an ending angle endangle;
[0031] S32, such as Figure 4 As shown, according to the width and height of each frame of the panoramic picture or panoramic video, a virtual rectangle is defined, and the left side coordinate is marked as 0° and the right side coordinate is marked as 360°;
[0032] S33, the angle of the calculated area is angle = endangle - stangle, corresponding to the width of the partial image intercepted from the panoramic image resultWidth = width*(angle / 360.0);
[0033] for Figure 2 For the special case of area 1 in the figure, since the starting angle stangle is 330° and the ending angle endangle is 60°, the starting angle stangle is greater than the ending angle endangle, so the calculation method is: angle = endangle + (360 – stangle), and then endangle is defined as stangle + angle;
[0034] S34, normalize the starting angle stangle and the ending angle endangle, add 180 degrees to the starting angle stangle and the ending angle endangle of the divided area respectively, if the result is greater than 360 degrees, then subtract 360 degrees from the result, so that the starting angle stangle and the ending angle endangle are both within the range of 0 to 360 degrees; the specific process is as follows:
[0035] The camera is placed at the center of the panoramic image, and then a complete panoramic image is formed by shooting 180° on the left and right sides, that is, 0° in the circle defined in step S1 corresponds to the center line 180° of the panoramic image; the semicircular area from 0° to 180° corresponds to the right half of the center line of the image, that is, the range of 180° to 360°; the semicircular area from 180° to 360° corresponds to the left half of the center line of the image, that is, 0° to 180°; specifically, the start angle stangle and the end angle endangle of each divided area need to be calculated. For the part that should be in the picture, the starting angle stangle and the ending angle endangle are shifted 180° to the right as a whole. For the semicircular area from 0° to 180°, after adding 180°, it is in the range of 180° to 360°, corresponding to the right half of the panoramic picture; and for the semicircular area from 180° to 360°, after adding 180°, it will be in the range of 360° to 540°, and then subtract 360° to make it in the range of 0° to 180°, which just corresponds to the left half of the panoramic picture;
[0036] Specifically, Figure 2 The area stangle in is 330°, and edangle is calculated to be 420° after step S3. According to the standardized implementation, stangle+180° is equal to 510°, and edangle+180° is equal to 600°, both of which are greater than 360°. Subtracting 360° respectively, stangle is equal to 150°, and edangle is equal to 240°. The rectangular range formed by stangle and edangle is between 150° and 240°, which is 30° to the left and 60° to the right of the center line in the panoramic picture, which is consistent with the theoretical result.
[0037] S35, using the standardized starting angle stangle and ending angle endangle; if the starting angle stangle is smaller than the ending angle endangle, then intercepting from the panoramic image, the intercepted left coordinate left = (stangle / 360) * width, the intercepted right coordinate right = left + resultWidth, the interception result is as follows Figure 5 As shown; if the starting angle stangle is greater than the ending angle endangle, the original starting angle stangle and the ending angle endangle include 180°, and this area includes the left and right sides of the panoramic image, such as Figure 5 As shown, two parts need to be cut out from the panoramic image, namely the rectangular part from left1 to right1 and the rectangular part from left2 to right2. The calculation formulas for each coordinate are:
[0038] left1=0
[0039] right1=(endangle / 360)*width
[0040] left2=(stangle / 360)*width
[0041] right2 = width;
[0042] In this embodiment, each sector-shaped area corresponds to a panoramic image portion, and each panoramic image portion needs to record a left coordinate, and then these panoramic image portions are spliced according to certain rules.
[0043] In this embodiment, the specific process of step S4 is as follows:
[0044] S41, sorting the cropped panoramic images according to the left coordinates to form a sequence, recorded as X0, X1, ..., Xn;
[0045] S42: Connect the panoramic picture sequence end to end to form a new panoramic picture.
[0046] Based on the same inventive concept, the present invention proposes a panoramic picture and video stitching system, comprising:
[0047] Definition module: used to define a circle, representing a 360-degree panoramic image;
[0048] Division module: used to divide a circle into several parts. Each area is set with a starting angle and an ending angle. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle. Each area represents a part of a panoramic picture or panoramic video.
[0049] Panoramic picture or video capture module: used to select a panoramic picture or panoramic video for each divided area, and capture part of the picture and video of the area corresponding to the panoramic picture or panoramic video;
[0050] Panoramic picture or video stitching module: used to stitch partial panoramic pictures cut out from various panoramic pictures or panoramic video frames to form new panoramic pictures or panoramic video frames.
[0051] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A method for stitching panoramic images and videos, characterized in that: The following steps are involved: S1. Define a circle to represent a 360° panoramic image; S2. Divide the circle into several parts. Set a starting angle and an ending angle for each area. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle. Each area represents a part of a panoramic picture or a panoramic video. S3, selecting a panoramic picture or a panoramic video for each divided area, and intercepting a portion of the picture and video of the area corresponding to the panoramic picture or the panoramic video; S4, stitching the partial panoramic pictures cut out from the various panoramic pictures or panoramic video frames to form a new panoramic picture or panoramic video frame; The specific process of capturing a portion of the image or video corresponding to the area of the panoramic image or panoramic video in step S3 is as follows: S31, defining each divided area using a starting angle stangle and an ending angle endangle; S32, defining a virtual rectangle according to the width and height of each frame of the panoramic image or panoramic video, marking the left side coordinate as 0° and the right side coordinate as 360°; S33, the angle of the calculated area is angle = endangle - stangle, corresponding to the width of the partial picture intercepted from the panoramic picture resultWidth = width*(angle / 360.0), if the starting angle stangle is greater than the ending angle endangle, the calculation method is: angle = endangle + (360 - stangle); S34, normalizing the starting angle stangle and the ending angle endangle, adding 180° to the starting angle stangle and the ending angle endangle of the divided area, and if the result is greater than 360°, subtracting 360°, so that the starting angle stangle and the ending angle endangle are both within the range of 0 to 360°; S35, using the standardized starting angle stangle and ending angle endangle; if the starting angle stangle is smaller than the ending angle endangle, intercepting from the panoramic image, the intercepted left coordinate left = (stangle / 360) * width, the intercepted right coordinate right = left + resultWidth; if the starting angle stangle is larger than the ending angle endangle, the original starting angle stangle and the ending angle endangle contain 180°, and this area includes the left and right sides of the panoramic image, then intercepting two parts from the panoramic image, namely the rectangular part from left1 to right1 and the rectangular part from left2 to right2, and the calculation formula of each coordinate is: left1=0 right1=(endangle / 360)*width left2=(stangle / 360)*width right2=width.
2. A method for stitching panoramic pictures and videos according to claim 1, characterized in that: The specific process of step S34 is as follows: S341, placing the camera at the center of the panoramic picture, and then shooting 180° on the left and right to form a complete panoramic picture, that is, 0° in the circle defined in step S1 corresponds to 180°, the center line of the panoramic picture; S342, the semicircular area from 0° to 180° corresponds to the right half of the center line of the image, that is, the range from 180° to 360°; the semicircular area from 180° to 360° corresponds to the left half of the center line of the image, that is, 0° to 180°; S343, calculate the starting angle stangle and the ending angle endangle of each divided area corresponding to the part in the picture, and shift the starting angle stangle and the ending angle endangle to the right by 180° as a whole. For the semicircular area from 0° to 180°, after adding 180°, it is in the range of 180° to 360°, which corresponds to the right half of the panoramic picture; for the semicircular area from 180° to 360°, after adding 180°, it is in the range of 360° to 540°, and then subtract 360° to make it in the range of 0° to 180°, which corresponds to the left half of the panoramic picture.
3. The method for stitching panoramic pictures and videos according to claim 1, characterized in that: The specific process of step S4 is as follows: S41, sorting the cropped panoramic images according to the left coordinates to form a sequence, recorded as X0, X1, ..., Xn; S42: Connect the panoramic picture sequence end to end to form a new panoramic picture.
4. A stitching system based on the method for stitching panoramic pictures and videos according to claim 1, characterized in that: include: Definition module: used to define a circle, representing a 360-degree panoramic image; Division module: used to divide a circle into several parts. Each area is set with a starting angle and an ending angle. The ending angle minus the starting angle is the angle size of the area. The areas are arranged clockwise according to the starting angle. Each area represents a part of a panoramic picture or panoramic video. Panoramic picture or video capture module: used to select a panoramic picture or panoramic video for each divided area, and capture part of the picture and video of the area corresponding to the panoramic picture or panoramic video; Panoramic picture or video stitching module: used to stitch partial panoramic pictures cut out from various panoramic pictures or panoramic video frames to form new panoramic pictures or panoramic video frames.
Citation Information
Patent Citations
Panorama generating method and device
CN107563959A
Panoramic camera device and panoramic picture generation method
WO2017206198A1