Parallax compensation method and apparatus therefor
By obtaining the optical axis offset vector mapping table and the current focus distance, the gimbal compensation angle is calculated and the gimbal attitude is adjusted, which solves the problem of image center jump when switching lenses, and achieves seamless switching and image quality preservation.
Patent Information
- Application Number
- CN202611470005.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-11-27
AI Technical Summary
When switching lenses, the physical offset of the optical axis of different lenses causes the center of the image to change. Existing technology cannot completely eliminate parallax through software post-processing, which affects the smoothness of shooting and image quality.
By obtaining the optical axis offset vector mapping table and the current focus distance, the compensation angle of the gimbal is calculated, and the gimbal attitude is adjusted to keep the center of the second lens's image aligned with the center of the first lens's image before and after switching, thus physically correcting parallax.
It effectively alleviates the problem of image center shift during lens transitions, preserves image resolution and field of view, and improves shooting smoothness.
Smart Images

Figure CN123185332A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of photography technology, specifically relating to a parallax compensation method and apparatus. Background Technology
[0002] Currently, when switching between lenses in multi-camera devices equipped with gimbals, the optical axes of different lenses are physically offset, causing a significant jump in the center of the captured image at the moment of lens switching. This can lead to the subject shifting or even disappearing, severely disrupting the smoothness of the shooting process.
[0003] Currently, the above problems can be solved through software post-processing. For example, the new lens image after switching can be cropped to align with the center of the original lens image, or the switching process can be smoothed through frame interpolation. However, the above cropping and alignment solutions sacrifice the effective pixels and field of view of the new lens image after switching. Furthermore, because parallax varies with the distance of objects, a fixed cropping and translation amount cannot simultaneously correct objects at different focus distances in the captured image. The above frame interpolation solutions only smooth the transition between the images before and after the lens switch, but cannot eliminate the fundamental difference in the perspective relationship between the two lenses. The relative positions and occlusion relationships of objects will change before and after the switch, and users can perceive object drift or distortion.
[0004] Therefore, how to eliminate the shift in image center caused by optical axis offset during camera transitions without losing image quality or being limited by scene distance is a problem that urgently needs to be solved. Summary of the Invention
[0005] The purpose of this application is to provide a parallax compensation method and apparatus that can physically correct parallax caused by lens optical axis offset through active rotation of the gimbal, effectively alleviating the problem of image center jump caused by lens switching.
[0006] In a first aspect, embodiments of this application provide a parallax compensation method, executed by an electronic device, the electronic device including a gimbal, a first lens, and a second lens, the method comprising: When the lens of the electronic device that captures the image frame is switched from the first lens to the second lens, the optical axis offset vector mapping table and the current focus distance are obtained. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens. The compensation angle of the gimbal is determined based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. Based on the compensation angle, the gimbal attitude is adjusted so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
[0007] Secondly, embodiments of this application provide a parallax compensation device applied to an electronic device, the electronic device including a gimbal, a first lens, and a second lens, the device comprising: The acquisition module is used to acquire an optical axis offset vector mapping table and the current focus distance when the lens of the electronic device that acquires the image frame is switched from the first lens to the second lens. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens. The determination module is used to determine the compensation angle of the gimbal based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. The adjustment module is used to adjust the gimbal attitude based on the compensation angle so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
[0008] Thirdly, embodiments of this application provide an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can run on the processor, and the programs or instructions, when executed by the processor, implement the method as described in the first aspect.
[0009] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the method described in the first aspect.
[0010] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.
[0011] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.
[0012] In this embodiment, when a lens switch is detected, an optical axis offset vector mapping table is obtained. Based on the first focal length of the first lens, the second focal length of the second lens, and the optical axis offset vector of the second lens relative to the first lens in the optical axis offset vector mapping table, the compensation angle of the gimbal is determined in conjunction with the current focusing distance. Then, the gimbal attitude is adjusted based on the compensation angle to keep the center of the second lens's image aligned with the center of the first lens's image before and after the switch. In this way, the optical axis offset vector mapping table is used as the basis for compensation data. At the moment of lens switch, the gimbal actively rotates to physically correct the parallax caused by the lens optical axis offset, effectively alleviating the problem of image center jump caused by the moment of lens switch. It does not rely on software post-processing methods such as cropping or frame interpolation. Therefore, it can achieve seamless switching while fully preserving all pixels and field of view of the second lens without sacrificing image resolution. Moreover, the compensation effect is not limited by scene distance, significantly improving the shooting smoothness of multi-camera electronic devices during lens switch. Attached Figure Description
[0013] Figure 1 This is a flowchart illustrating a parallax compensation method provided in some embodiments of this application; Figure 2 These are schematic diagrams illustrating the structure of a parallax compensation device according to some embodiments of this application; Figure 3 These are schematic diagrams illustrating the structure of an electronic device according to some embodiments of this application; Figure 4 These are schematic diagrams illustrating the hardware structure of an electronic device according to some embodiments of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0015] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and are not limited in number; for example, a first object can be one or N objects. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0016] The terminology used in the embodiments of this invention will be explained below.
[0017] Parallax: Due to the different positions of two lenses in physical space, the image position of the same object differs in the frames of different lenses. This difference in position is called parallax.
[0018] Parallax angle: Due to the different positions of the two lenses in physical space (physical offset of the optical axis), there is an angular deviation between the image position of the same object in the wide-angle lens image and the image position in the telephoto lens image. This angular deviation is called the parallax angle. In other words, the parallax angle reflects the angle between the target object and the optical centers of the two lenses. The parallax angle can include horizontal parallax angle and vertical parallax angle.
[0019] Optical axis offset vector: Since there is a gap of several millimeters to several centimeters between different lenses in the physical position in a multi-camera device, the optical axes of each lens are not completely coincident. This physical offset is the optical axis offset vector. In the embodiments of this application, the optical axis offset vector can be used to characterize the offset of the optical axes of two lenses in physical space, including horizontal offset component, vertical offset component and optical axis offset component.
[0020] Binocular depth perception: a depth acquisition method based on the principle of parallax. Specifically, two cameras simultaneously capture the same scene from different angles. Based on the difference in pixel position of the same object in the two images (i.e., parallax), combined with the baseline distance between the two cameras and the focal length of the lens, the depth value of the object can be calculated using the principle of triangulation.
[0021] Time-of-flight (TOF) sensor: A sensor that calculates the distance to an object by measuring the time difference between the emission and reception of a light pulse. The TOF sensor emits a modulated light pulse towards the target object; the light pulse is reflected by the object and received by the TOF sensor. The distance is calculated by measuring the time difference in the light pulse's flight path. t, combined with the speed of light c, using the formula The distance from the object to the time-of-flight sensor is calculated. The depth information output by the time-of-flight sensor is this distance value.
[0022] Lens focusing motor: It integrates a position encoder, which can provide real-time feedback on the physical position of the focusing lens group along the optical axis. This position information, combined with the factory-calibrated focusing curve (i.e., the mapping relationship between the position of the focusing lens group and the focusing distance), can be used to calculate the current focusing distance.
[0023] Laser rangefinder: A sensor that calculates distance by emitting a laser beam towards a target and receiving the reflected light, measuring the round-trip time or phase difference of the laser. Similar to time-of-flight sensors, laser rangefinders directly output distance information, but they typically use a single-point ranging method, resulting in higher accuracy.
[0024] Phase detection point: A dedicated phase detection pixel (also known as a PDAF pixel) integrated on the image sensor. Each phase detection point contains a pair of photodiodes that can receive light from different areas of the lens pupil. By comparing the phase difference of the light signals from the left and right or up and down, the current focus state is determined and the focus direction and defocus amount are determined, which are then converted into focus distance.
[0025] The technical solution of this application embodiment can be applied to scenarios where multi-camera electronic devices equipped with gimbals need to perform parallax compensation when switching lenses. For example, a user is recording video with a mobile phone at a concert. Initially, a wide-angle lens is used to record a panoramic view of the entire stage. When the user wants to record close-up details of the singer on stage, the lens is switched from wide-angle to telephoto using a zoom operation. At the instant of this lens switch, due to the offset of the optical axes of the wide-angle lens and the telephoto lens in physical space, the center of the image will jump, causing the singer's position in the image to suddenly shift or even move out of the frame.
[0026] The parallax compensation method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0027] Figure 1 This is a flowchart illustrating a parallax compensation method provided in an embodiment of this application. The subject executing the parallax compensation method can be an electronic device, which may include a gimbal, a first camera, and a second camera. The electronic device may be, but is not limited to, a personal computer (PC), a smartphone, a tablet computer, or a personal digital assistant (PDA). The electronic device includes a first lens and a second lens, which may be, for example, a wide-angle lens and a telephoto lens as described in the above example.
[0028] like Figure 1 As shown, the parallax compensation method provided in this application embodiment may include steps 110-130.
[0029] Step 110: When the lens of the electronic device that captures the image frame is switched from the first lens to the second lens, obtain the optical axis offset vector mapping table and the current focus distance. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens.
[0030] The first lens can be the lens currently in use before the lens switch when the electronic device captures image frames, and the second lens can be the lens that will be used after the lens switch when the electronic device captures image frames. Taking the scenario of a user recording video at a concert as an example, the user initially uses a wide-angle lens to record the entire stage. When the user adjusts the focal length from 1x to 3x through zoom operation, the electronic device detects the need to switch from the wide-angle lens to the telephoto lens. In this case, the wide-angle lens is the first lens, and the telephoto lens is the second lens.
[0031] The optical axis offset vector mapping table can be a pre-built mapping table stored in an electronic device. This table records the optical axis offset vector between any two lenses and the focal length parameters of each lens. Using a reference lens as the index root, the table stores the optical axis offset vectors from that reference lens to all other lenses. Taking a wide-angle lens, telephoto lens, and ultra-wide-angle lens as an example, the table stores the offset vectors from the wide-angle lens to the telephoto lens, the wide-angle lens to the ultra-wide-angle lens, and the focal length parameters of each lens. For switching between non-reference lenses, the corresponding optical axis offset vector can be derived in real time through vector operations.
[0032] The current focusing distance can refer to the physical distance between the subject and the electronic device in the current shooting scene. Taking the user recording a concert scene as an example, if the user focuses on the singer on the stage, the current focusing distance is the distance between the singer and the phone, for example, 5 meters.
[0033] In some embodiments of this application, the current focusing distance can be obtained in various ways, such as direct measurement by a laser rangefinder, determination by depth information output from a time-of-flight sensor, determination after obtaining a depth map through binocular depth sensing, or calculation by combining position information fed back by the lens focusing motor position encoder with the focusing curve. These methods can be used individually or in combination to improve the accuracy of distance acquisition. Specific methods for obtaining the current focusing distance will be described in detail in later embodiments.
[0034] In some embodiments of this application, before obtaining the optical axis offset vector mapping table, the optical axis offset vector mapping table must first be constructed. Specifically, before step 110, the method described above may further include: Acquire a first focal length and a second focal length, as well as a first image of the calibration board captured by the first lens and a second image of the calibration board captured by the second lens; Feature matching is performed on the first image and the second image to obtain the pixel offset vector of the center of the second image relative to the center of the first image; Based on the pixel size of the second lens, the first focal length, and the second focal length, the pixel offset vector is converted into a physical offset vector to obtain the optical axis offset vector of the second lens relative to the first lens. Based on the first focal length, the second focal length, and the optical axis offset vector, an optical axis offset vector mapping table is constructed.
[0035] The calibration board can be a standard test pattern used for lens calibration, usually a checkerboard pattern or a dot array pattern, with the grid size being a known physical size, which can be used as a reference for image feature matching.
[0036] The first image can be an image obtained by taking a picture of the calibration board with the first lens. The second image can be an image obtained by taking a picture of the calibration board with the second lens.
[0037] A pixel offset vector can be the difference in the imaging position of the same feature point in images captured by two lenses under the same calibration scene. It is expressed in pixels and includes horizontal pixel offset and vertical pixel offset.
[0038] The optical axis offset vector can be used to characterize the offset of the optical axes of two lenses in physical space, including the horizontal offset component, the vertical offset component, and the optical axis offset component.
[0039] In some embodiments of this application, during the factory calibration stage of the electronic device, the electronic device is fixed on a test pan-tilt unit and aligned with a calibration board for optical axis calibration. This calibration board can be a checkerboard calibration board, where the actual size of each square is a known physical dimension (e.g., each square has a side length of 10mm). During calibration, the electronic device is fixed on the test pan-tilt unit, ensuring that the optical axis of the electronic device is perpendicular to the plane of the calibration board. The calibration distance is typically ≥5m to ensure near-infinity conditions, at which point parallax effects are negligible, facilitating accurate measurement of the physical offset between the optical axes of each lens.
[0040] The system sequentially switches between the lenses of the electronic device to capture images of the calibration board, obtaining corresponding images and acquiring the calibration board image captured by each lens along with its corresponding focal length parameters. Specifically, the nominal focal length of the first lens (e.g., a wide-angle lens) is acquired as the first focal length, along with the first image obtained by the first lens capturing the calibration board; the nominal focal length of the second lens (e.g., a telephoto lens) is acquired as the second focal length, along with the second image obtained by the second lens capturing the same calibration board.
[0041] Then, using an image feature point matching algorithm, feature matching is performed on the first and second images to identify the same feature point (such as the same corner point on the calibration board) in both images. The positional difference of this feature point in the two images is then calculated, i.e., the pixel offset vector. Specifically, the Scale-Invariant Feature Transform (SIFT) algorithm or the Speeded Up Robust Features (SURF) algorithm can be used to extract and match feature points from the two images. This is because the checkerboard pattern of the calibration board has regular and clear corner point features, allowing the algorithm to accurately identify and match the same corner point in both images. Next, a corner point near the center of the calibration board is selected as a reference feature point. The pixel coordinates (x1, y1) of this feature point in the first image and (x2, y2) in the second image are recorded. The difference between the two coordinates is calculated to obtain the pixel offset vector (px, py) = (x2-x1, y2-y1) of the center of the second image relative to the center of the first image.
[0042] The aforementioned pixel offset vector represents the difference in imaging position in pixels and needs to be converted into an actual offset in physical space. Therefore, firstly, the sensor pixel size of the second lens is obtained. This pixel size refers to the actual physical size of each pixel unit on the image sensor of the second lens, typically in micrometers. The pixel offset vector is then multiplied by the pixel size of the second lens to obtain the physical distance of the pixel offset vector on the sensor plane. Then, combining the ratio of the first focal length to the second focal length, the physical distance on the sensor plane is converted into the actual offset of the lens optical axis in physical space using the principle of similar triangles, as shown in formula (1) below.
[0043]
[0044] In the above formula (1), This represents the horizontal component of the optical axis offset vector. This represents the vertical component of the optical axis offset vector; This represents the horizontal component of the pixel offset vector; This represents the vertical component of the pixel offset vector; The sensor pixel size for the second lens; The first focal length; This is the second focal length.
[0045] It should be noted that in the above formula (1), the focal length ratio is used. The conversion is necessary because lenses with different focal lengths have different field of view angles, and the parallax angle corresponding to the same sensor physical offset differs at different focal lengths. Focal length normalization is needed to obtain the actual offset in physical space. Furthermore, the offset component of the optical axis offset vector in the optical axis direction... It can be calculated through the correspondence between the distance of the calibration plate and the offset of the imaging position, or it can be directly measured by precision measuring equipment during factory calibration.
[0046] Finally, the calibration results are organized into a mapping table format. The mapping table uses a reference lens as its index root and stores the optical axis offset vectors from the reference lens to all other lenses, as well as the focal length parameters of each lens. Each record in the mapping table corresponds to a lens pair, recording the optical axis offset vectors (including horizontal, vertical, and optical axis offset components) from the source lens to the target lens, the focal length of the source lens, and the focal length of the target lens. As shown in Tables 1 and 2 below, Table 1 is the top-level mapping table, which corresponds to the multi-camera electronic device. Table 2 is the mapping table for a single lens pair, recording the mapping relationship between a single lens pair.
[0047] Table 1
[0048] Table 2
[0049] It should be noted that Tables 1 and 2 above can be stored in the non-volatile memory of the electronic device for subsequent use when switching lenses.
[0050] Continuing with the example above, before the concert begins, the user's mobile phone has already completed the construction of the optical axis offset vector mapping table during the factory stage, and this mapping table is stored in the phone's memory. Specifically, the phone is fixed on the test gimbal and aimed at a checkerboard calibration board 5m away. The actual size of each square in the checkerboard is 10mm × 10mm. First, the calibration board is photographed with a wide-angle lens to obtain the first image, and the nominal focal length of the wide-angle lens is obtained. =4.25mm; then switch to the telephoto lens to photograph the same calibration plate to obtain the second image, and obtain the nominal focal length of the telephoto lens. =12.00mm.
[0051] Through SIFT feature matching, the center corner point of the calibration board is located at pixel coordinates (960, 540) in the first image taken with the wide-angle lens (assuming an image resolution of 1920×1080), and at pixel coordinates (1085, 508) in the second image taken with the telephoto lens. The pixel offset vector of the telephoto lens image center relative to the wide-angle lens image center is calculated as ( =1085-960=125, =508-540=-32) pixels. That is, the position of the center corner point of the same calibration board in the image taken by the telephoto lens is 125 pixels to the right and 32 pixels above the position in the image taken by the wide-angle lens.
[0052] The second lens (telephoto lens) has a sensor pixel size of 1.0µm / pixel, and the first focal length... =4.25mm, second focal length =12.00mm, based on the above formula (1), the pixel offset vector (125, -32) pixels is converted into a physical offset vector: = 125×1.0um×(4.25 / 12.00)=125×1.0um×0.354≈44.25um≈0.044mm.
[0053] However, the above calculation This is incorrect. The actual calculation considers the proportions of similar triangles and requires conversion based on a calibration distance of 5m. When the calibration distance is much greater than the focal length, the physical offset of the optical axis can be directly calculated from the ratio of the known physical dimensions of the calibration plate to the image pixel size. A more accurate method is to use the known physical dimensions of the calibration plate (e.g., 10mm per grid) and their corresponding pixel size in the image to establish a conversion ratio between millimeters and pixels, thus directly converting the pixel offset into a physical offset. Specifically, if one grid (10mm) on the calibration plate corresponds to 100 pixels in the image, the ratio is 0.1mm / pixel. A pixel offset of (125, -32) pixels corresponds to a physical offset of (12.5mm, -3.2mm). This allows us to obtain the optical axis offset vector of the second lens relative to the first lens. =12.5mm, =-3.2mm, =0.8mm). Then, the wide-angle focal length of 4.25mm, the telephoto focal length of 12.00mm, and the optical axis offset vector ( =12.5mm, =-3.2mm, =0.8mm) is stored as a mapping table entry for wide-angle → telephoto.
[0054] Thus, on the day of the concert, when recording live video, users initially use a wide-angle lens to capture a panoramic view of the entire stage. When users want to record close-up details of the singers on stage, they switch the lens from wide-angle to telephoto using a zoom operation. At this moment of lens switching, the system queries the pre-built optical axis offset vector mapping table and reads the optical axis offset vector from wide-angle to telephoto. =12.5mm, =-3.2mm, =0.8mm) and the focal length parameters of the two lenses, combined with the current focusing distance, calculate the gimbal compensation angle and perform compensation.
[0055] In another implementation of this application, the optical axis offset vector can also be obtained by directly measuring the physical center distance between the two lenses using a precision measuring device, and the pixel offset vector is only used to verify the accuracy of the physical distance.
[0056] In this embodiment, an optical axis offset vector mapping table is pre-constructed at the factory. Specifically, the first and second images of the calibration board are captured by the first and second lenses, respectively. Feature matching is performed on the two images to obtain pixel offset vectors. Combining the pixel size of the second lens with the first and second focal lengths, the pixel offsets are converted into optical axis offset vectors in physical space. Finally, a mapping table is constructed based on the focal length parameters and the optical axis offset vectors. Thus, the optical axis offset vector mapping table is accurately calibrated and stored in the electronic device at the factory. Subsequent lens switching does not require repeated calibration; the optical axis offset vector can be obtained directly by querying the mapping table. This eliminates the calibration calculation overhead during each switch, reduces processing latency during switching, improves the response speed of lens switching, and ensures real-time compensation. Simultaneously, based on the feature matching method of the calibration board image, the three-dimensional offsets between each lens in the horizontal, vertical, and optical axis directions can be accurately calculated, providing an accurate data foundation for the subsequent precise calculation of the gimbal compensation angle. Furthermore, this optical axis offset vector mapping table establishes a directed mapping relationship with the reference lens as the index root, which can cover the switching scenarios between any two lenses and has good scalability. Thus, regardless of whether the electronic device is equipped with three, four or more lenses, the optical axis offset vector between all lens pairs can be quickly queried through a unified mapping table structure, making it highly versatile.
[0057] In some embodiments of this application, before obtaining the current focus distance, the current focus distance must first be determined, that is, before step 110. The method described above may also include: Obtain the focus distance parameter; The current focus distance is determined based on the focus distance parameter.
[0058] The focusing distance parameter can be raw data used to determine the distance from the focusing target to the electronic device in the current shooting scene. This data can originate from various sensors or algorithms, including but not limited to depth map information, motor position information, laser rangefinder information, and phase difference information. Specifically, the focusing distance parameter can include at least one of the following: depth information obtained through binocular depth sensing based on the last frame image captured by the first lens; depth information output by the time-of-flight sensor of the electronic device when the last frame image was captured by the first lens; position information fed back by the focusing motor of the second lens; distance information output by the laser rangefinder sensor of the electronic device; and phase difference information output by the phase detection point of the first lens or the phase detection point of the second lens.
[0059] In some embodiments of this application, upon triggering a lens switch, the electronic device acquires a focus distance parameter through one or more methods. This focus distance parameter is the raw data source for determining the current focus distance, and its specific form depends on the type of sensor or algorithm employed. Specifically, the electronic device can acquire the focus distance parameter from at least one of the following sources: (1) Depth information obtained by binocular depth perception based on the last frame image captured by the first lens.
[0060] When an electronic device is equipped with a binocular camera (such as a binocular system consisting of a wide-angle lens and a telephoto lens), it can use a binocular depth perception algorithm to calculate the depth of the last frame image captured by the first lens. Specifically, the electronic device acquires the last frame image captured by the first lens (such as the wide-angle lens in the example above) and simultaneously acquires the corresponding frame image captured by the other lens (such as the telephoto lens in the example above) at the same time. It then performs stereo matching on the two images, calculates the disparity value of each pixel, and generates a depth map. The grayscale value or numerical value of each pixel in the depth map represents the depth information corresponding to that location. The electronic device reads the depth value of the central region of the image (i.e., the region where the focus target is located) as one of the sources of the focus distance parameter.
[0061] (2) Depth information output by the time-of-flight sensor of the electronic device when the last frame of the image is captured by the first lens.
[0062] The time-of-flight sensor on the electronic device can continuously output depth maps or depth point cloud data of the scene at a fixed sampling frequency (e.g., 30Hz). Therefore, when the user triggers a camera switch, the electronic device can read the depth data of the latest frame from the time-of-flight sensor. Since the sampling time of the time-of-flight sensor is synchronized (or nearly synchronized) with the time when the first lens captures the last frame, this depth data reflects the scene depth distribution at the corresponding moment of the last frame before the switch. Thus, the electronic device uses the depth value of the central area of the image (i.e., the area where the focus target is located) as the depth information output by the time-of-flight sensor.
[0063] (3) Position information based on the focus motor feedback of the second lens.
[0064] The focus motor position encoder can accurately feed back the physical displacement of the focusing lens group in the optical axis direction. This displacement has a one-to-one mapping relationship with the focusing distance (i.e., the focusing curve). Therefore, after the lens switching is triggered and before the second lens officially outputs the image, the electronic device reads the current position information fed back by the focus motor position encoder of the second lens (the target lens to which it is about to switch). After reading this position information, the electronic device calculates the corresponding focusing distance by combining it with the factory-calibrated focusing curve.
[0065] (4) Distance information output by a laser rangefinder based on electronic devices.
[0066] The laser rangefinder sensor on the electronic device can directly output the distance value from the target object to the sensor by emitting a laser beam and measuring the flight time or phase difference of the reflected light. Thus, when the user triggers the lens switch, the electronic device reads the distance information output by the laser rangefinder sensor, and the output distance information can be directly used as the focus distance parameter.
[0067] (5) Phase difference information output based on the phase detection point of the first lens or the phase detection point of the second lens.
[0068] The image sensor of an electronic device integrates multiple phase detection points, each containing a pair of photodiodes that can receive light from the left and right sides of the lens pupil, respectively. When the subject is in focus, the left and right light signals are completely synchronized, with zero phase difference; when the subject is out of focus, a phase difference exists between the left and right light signals, the magnitude and direction of which reflect the amount and direction of defocusing. Therefore, the electronic device can read the phase difference information output from the phase detection points of either the first or second lens. This phase difference information has a definite mapping relationship with the focusing distance, and can be converted into the current focusing distance using a factory-calibrated phase difference-distance mapping curve.
[0069] After the electronic device acquires one or more focusing distance parameters according to the above steps, it can determine the current focusing distance based on the focusing distance parameters. Specifically, when the acquired focusing distance parameter is from a single source (i.e., only one of the above five items is used), the electronic device directly uses that focusing distance parameter as the current focusing distance. For example, if the electronic device only reads the depth information output by the time-of-flight sensor, and the depth information is 5.0m, then the current focusing distance D = 5.0m.
[0070] When the acquired focus distance parameters come from multiple sources (using multiple of the five methods mentioned above), the electronic device can fuse these parameters to obtain the final current focus distance. Fusion methods can include weighted averaging, median filtering, and confidence level selection. For example, the electronic device simultaneously acquires a depth information of 5.0m from the time-of-flight sensor and a focus distance of 3.1m calculated from the position information fed back by the focus motor; these two values differ. The electronic device performs a weighted average based on the confidence levels of each sensor in the current scene. The time-of-flight sensor has a higher confidence level at medium to long distances, so it is assigned a weight of 0.7; the focus motor feedback has higher accuracy at close distances, so it is assigned a weight of 0.3. The calculated weighted average distance is D = 5.0 × 0.7 + 3.1 × 0.3 = 4.43m.
[0071] It should be noted that among the various methods of obtaining the focus distance parameter mentioned above, the "position information based on the focus motor feedback of the second lens" is read after the switch is triggered but before the second lens officially outputs the image, while the other four methods are obtained at the moment of switch triggering (i.e., the moment when the first lens captures the last frame). Since the time window between the switch triggering and the second lens output is extremely short (usually 10-50ms), the change in focus distance within this time window can be ignored. Therefore, the focus distance parameters from multiple sources can be considered as data at the same moment in time and do not affect the accuracy of the fusion processing.
[0072] Continuing with the example above, a user is recording stage footage using a wide-angle lens. The singer is approximately 5 meters away from the phone, and the user wants to switch to a telephoto lens to capture a close-up shot of the singer. The instant the user triggers the zoom and the phone detects the switch from wide-angle to telephoto, it needs to immediately acquire the current focus distance to calculate the gimbal compensation angle. The phone can acquire the focus distance parameter in parallel through several methods. Specifically: First, the phone reads the last frame image captured by the wide-angle lens (first lens) and simultaneously acquires the corresponding frame image captured by the telephoto lens at the same time. A stereo matching algorithm is then used to generate a depth map. This depth map shows that the depth value of the central area of the image (the area where the singer is located) is 5.2m. Based on this, the depth information based on stereo depth perception is obtained, which yields the first set of focus distance parameters.
[0073] Secondly, the phone reads the depth data of the latest frame from the time-of-flight sensor. For example, if the time-of-flight sensor works continuously at a frequency of 30Hz, at the moment the user triggers the switch, the latest frame depth data from the time-of-flight sensor shows that the depth of the central area of the screen is 5.0m. Based on this, the depth information output by the time-of-flight sensor is obtained, which is the second set of focus distance parameters.
[0074] Next, the mobile phone reads the distance information output by the laser rangefinder. The laser rangefinder performs a single distance measurement when the user triggers the switch, and outputs a distance value of 5.05m. Based on this, the distance information output by the laser rangefinder is obtained, which is the third set of focus distance parameters.
[0075] Then, the phone also reads the phase difference information output by the phase detection point on the wide-angle lens image sensor. The phase detection point detects that the current phase difference is a certain value. Combined with the factory-calibrated phase difference-distance mapping curve, the focusing distance is calculated to be 5.1m. Based on this, the phase difference information is obtained, which is the fourth set of focusing distance parameters.
[0076] Finally, the phone fuses the multiple sets of focus distance parameters. Considering the good lighting conditions at the concert venue, the high accuracy of binocular depth sensing and phase detection, and the high accuracy of the time-of-flight sensor and laser rangefinder at a distance of 5m, the phone uses a weighted average method for fusion, assigning similar weights to each source, and calculates the final current focus distance D≈5.05m. The phone substitutes the fused current focus distance D=5.05m into the subsequent compensation angle calculation step, combining it with the first focal length of 4.25mm, the second focal length of 12.00mm, and the optical axis offset vector ( ) from the optical axis offset vector mapping table. =12.5mm, =-3.2mm, =0.8mm), the calculated gimbal compensation angle is approximately 0.052°. The gimbal completes the rotation of this angle within the switching delay time, aligning the center of the telephoto lens image with the center of the wide-angle lens image before the switch. Since the acquisition of the current focus distance and the calculation of the compensation angle are completed at the moment of switching trigger, when the telephoto lens image is officially output, the singer is still located in the center of the image, and the user does not perceive the image jump.
[0077] In this embodiment, by acquiring the focus distance parameter before obtaining the optical axis offset vector mapping table and the current focus distance, and determining the current focus distance based on this focus distance parameter, a precise distance data foundation is provided for the subsequent calculation of the gimbal compensation angle. Specifically, the focus distance parameter can be acquired in various ways, including depth information obtained from binocular depth perception based on the last frame image of the first lens, depth information output by the time-of-flight sensor, position information fed back by the focus motor, distance information output by the laser rangefinder, and phase difference information output by the phase detection point. These methods can be used individually or in combination. Thus, by providing multiple ways to acquire the focus distance parameter, the acquisition of the current focus distance does not depend on a single sensor or a single algorithm. Applicable methods can be selected to acquire distance information in any shooting scenario, significantly improving the adaptability and robustness of the solution to different scenarios. Simultaneously, when multiple methods are used to acquire the focus distance parameter and perform fusion processing, the potential accuracy degradation or failure of a single sensor in specific scenarios can be effectively avoided. Through complementary verification and weighted fusion of multi-source data, the accuracy of determining the current focus distance is improved, thereby enhancing the accuracy of the gimbal compensation angle calculation. In addition, all of the above acquisition methods can be completed at the moment of lens switching or in a very short time, ensuring the real-time nature of distance acquisition and providing reliable data support for gimbal compensation within the switching delay time.
[0078] Step 120: Determine the compensation angle of the gimbal based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector.
[0079] The gimbal compensation angle can be defined as the angle by which the gimbal rotates around the yaw and pitch axes to ensure that the center of the second camera's image remains aligned with the center of the first camera's image before and after switching. This compensation angle includes the yaw compensation angle and the pitch compensation angle.
[0080] In some embodiments of this application, the compensation angle can be obtained based on a parallax mapping model. Specifically, a parallax model can be constructed using the optical axis offset vector, focal length parameters, and the current focus distance, and then the parallax angle can be obtained based on the parallax model, and then the angle at which the gimbal needs to rotate can be obtained based on the parallax angle.
[0081] In some embodiments of this application, step 120 may specifically include: Based on the first focal length and the second focal length, the focal length normalization factor is obtained; Based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector, determine the parallax angle between the first lens and the second lens; The compensation angle of the gimbal is determined based on the parallax angle and the focal length normalization factor.
[0082] The focal length normalization factor can be obtained based on the first focal length and the second focal length. Specifically, the focal length normalization factor can be the ratio of the first focal length to the second focal length.
[0083] In some embodiments of this application, since lenses with different focal lengths have different field of view, the same physical offset of the optical axis has different effects on the center offset of the image at different focal lengths. Therefore, the optical axis offset vector can be normalized from the focal length scale of the source lens to the focal length scale of the target lens based on the focal length normalization factor.
[0084] In some embodiments of this application, the focal lengths of the first lens and the second lens are usually different during lens switching. For example, when switching from a wide-angle lens (focal length 4.25mm) to a telephoto lens (focal length 12.00mm), there is a significant difference in the focal lengths of the two lenses. Since the optical axis offset vector is the offset in physical space (in millimeters) measured during the factory calibration stage, and lenses with different focal lengths have different sensitivities to the same physical offset, specifically, the longer the focal length of the lens, the smaller the offset angle produced by the same physical offset on the image. Therefore, it is necessary to calculate the focal length normalization factor based on the first focal length and the second focal length, which is used to correlate the optical axis offset vector with the focal length difference in subsequent steps. Specifically, the focal length normalization factor can be calculated by the following formula (2).
[0085]
[0086] In the above formula (2), The first focal length; This is the second focal length; This is the focal length normalization factor, which reflects the degree of influence of focal length differences on parallax angle. Specifically, when... > When switching from telephoto to wide-angle. >1. The compensation angle needs to be increased; when < When switching from wide-angle to telephoto. <1, the compensation angle needs to be reduced.
[0087] Since the optical axis offset vector reflects the offset of the optical axes of the first lens and the second lens in physical space, including the horizontal offset component... Vertical offset component and optical axis offset component The current focusing distance D reflects the physical distance between the subject and the electronic device. Parallax angle is the angular deviation between two lenses when observing the same object due to the physical offset of the optical axis. Parallax angle includes horizontal parallax angle and vertical parallax angle. Specifically, the horizontal parallax angle is caused by the horizontal offset of the optical axis. The vertical parallax angle is caused by the offset of the optical axis in the vertical direction. Caused by. The size of the parallax angle is directly proportional to the optical axis offset and inversely proportional to the current focusing distance. That is, the greater the optical axis offset, the greater the parallax angle; the closer the shooting distance, the greater the parallax angle. Specifically, the parallax angle between the first lens and the second lens can be calculated based on the following formula (3) using the first focal length, the second focal length, the current focusing distance and the optical axis offset vector.
[0088]
[0089] In the above formula (3), This is the vertical component of the parallax angle, i.e., the pitch angle; This is the horizontal component of the parallax angle, i.e., the yaw angle; This represents the vertical offset component in the optical axis offset vector. This is the horizontal offset component. This is the current focus distance.
[0090] It should be noted that, based on the above formula (3), for distant scenes (i.e., Much larger and The parallax angle can be approximated as: , .
[0091] After calculating the parallax angle, which is the angular deviation of the second lens relative to the first lens on the image plane, the gimbal needs to be rotated by a corresponding angle in the opposite direction to eliminate this angular deviation and align the center of the second lens with the center of the first lens. Simultaneously, considering the calculated focal length normalization factor, the parallax angle needs to be normalized to obtain the final compensation angle that the gimbal needs to rotate. Specifically, the compensation angle of the gimbal is calculated based on the parallax angle and the focal length normalization factor, using the following formula (4).
[0092]
[0093] In the above formula (4), This is the compensation angle for the gimbal in the pitch direction; This is the compensation angle for the gimbal in the yaw direction; This is the focal length normalization factor; This represents the vertical component of the parallax angle. This represents the horizontal component of the parallax angle.
[0094] It should be noted that the sign of the compensation angle indicates the direction of rotation of the gimbal: A positive value indicates that the gimbal needs to be rotated upwards (pitch up). A negative value indicates that the gimbal needs to be rotated downwards (tilt down). A positive value indicates that the gimbal needs to rotate to the right (yaw to the right). A negative value indicates that the gimbal needs to rotate to the left (yaw left turn).
[0095] Thus, the gimbal rotates according to the compensation angle obtained above, so that the optical axis direction of the second lens is consistent with the optical axis direction of the first lens at the instant before switching, thereby ensuring that the center of the image after switching is aligned with that before switching.
[0096] Continuing with the example above, the user uses a wide-angle lens (focal length) Switch to telephoto lens (focal length = 4.25mm) =12.00mm), focal length normalization factor =4.25 / 12.00≈0.354. That is, since the focal length of a telephoto lens is approximately 2.82 times that of a wide-angle lens, the same physical offset will produce an offset angle in the telephoto lens image that is approximately 1 / 2.82 of that in the wide-angle lens image. When a phone switches from a wide-angle lens to a telephoto lens, the optical axis offset vector is ( =12.5mm, =-3.2mm, =0.8mm), the current focusing distance D=5.0m (i.e. 5000mm). Based on the above formula (3), the following is calculated: ; That is, due to the vertical offset of the optical axis by -3.2mm, the image position of the subject (singer) in the telephoto lens image is shifted upward by about 0.037° relative to the wide-angle lens; and due to the horizontal offset of the optical axis by 12.5mm, the image position of the subject in the telephoto lens image is shifted to the right by about 0.143° relative to the wide-angle lens.
[0097] It should be noted that the sign of the parallax angle indicates the direction of offset: A positive value indicates that the target object is positioned lower in the target lens frame relative to the source lens frame. A negative value indicates an upward bias; A positive value indicates a rightward deviation. A negative value indicates a leftward bias. In this example, (Slightly above) (Slightly to the right).
[0098] Then based on the focal length normalization factor =0.354, parallax angle , Substituting into the above formula (4), the gimbal compensation angle is calculated as follows: , That is, the gimbal needs to tilt down 0.013° in the pitch direction (because) (If the value is negative), the yaw direction is tilted 0.051° to the left (because...) A positive value indicates that the image is tilted to the right, and the gimbal needs to rotate to the left to compensate. The electronic device can send this compensation angle to the gimbal motor drive module, which drives the gimbal to complete a micro-angle rotation of 0.013° downward and 0.051° to the left within the lens switching delay time window. After the gimbal completes this micro-angle rotation, the optical axis direction of the telephoto lens is consistent with the optical axis direction of the wide-angle lens before the switch. The singer's position in the center of the image remains aligned before and after the switch. That is, when the telephoto lens image is officially output, the singer is still located in the center of the image, consistent with the position of the singer in the wide-angle lens before the switch. The user does not perceive the change in the center of the image during the entire zoom process, and the experience is smooth and natural.
[0099] In this embodiment, a focal length normalization factor is obtained based on a first focal length and a second focal length. The parallax angle is determined based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. The gimbal compensation angle is then determined based on the parallax angle and the focal length normalization factor. Thus, by introducing a focal length normalization factor, the transmission effect of the optical axis offset vector between lenses with different focal lengths is accurately modeled. This allows the calculated gimbal compensation angle to accurately reflect the differences in the impact of different focal length lenses on the parallax angle, making the calculation of the compensation angle more precise. Simultaneously, the determination of the parallax angle combines the optical axis offset vector and the current focusing distance, reflecting the influence of the shooting distance on the size of the parallax angle. The closer the shooting distance, the larger the parallax angle, and the correspondingly larger the compensation angle; the farther the shooting distance, the smaller the parallax angle, and the correspondingly smaller the compensation angle, achieving adaptive adjustment of the compensation angle according to the shooting distance. Furthermore, the above calculation process involves only simple trigonometric function operations and multiplication operations, with a small computational load, which can be completed in milliseconds. This ensures that the compensation angle can be quickly calculated and the gimbal can be driven to rotate within the lens switching delay time, providing an algorithmic efficiency guarantee for real-time parallax compensation.
[0100] In some embodiments of this application, determining the gimbal compensation angle based on the parallax angle and focal length normalization factor may specifically include: When the current focusing distance is greater than the first threshold and less than the second threshold, the compensation angle of the gimbal is determined based on the parallax angle and the focal length normalization factor. When the current focusing distance is less than the first threshold, the compensation angle of the gimbal is determined based on the parallax angle, the focal length normalization factor, and the nonlinear correction factor.
[0101] The first and second thresholds can both be pre-set thresholds for the current focusing distance. These thresholds can be used to distinguish between close-up scenes and medium / distant scenes. When the current focusing distance is less than the first threshold, it is considered a close-up scene. In this case, the parallax effect is significant, and a non-linear correction factor needs to be introduced to further correct the compensation angle.
[0102] The second threshold can be used as a distance threshold to distinguish between mid-range and distant scenes. When the current focusing distance is greater than the first threshold and less than the second threshold, it is considered a mid-range scene. At this time, the parallax effect is moderate, and the basic parallax model can describe the relationship between parallax and distance well without additional correction.
[0103] The first threshold and the second threshold mentioned above can be determined based on factors such as the optical axis offset vector of the electronic device and the lens baseline length. For example, the first threshold can be 1 meter and the second threshold can be 50 meters. The specific values of the first threshold and the second threshold can be set according to user needs, and are not limited in this embodiment.
[0104] The nonlinear correction factor can be used to correct the compensation angle in close-up scenes. Since the target object is close to the electronic device, that is, the shooting distance is close, the optical axis offset vector and the parallax angle have a nonlinear relationship. Therefore, the compensation angle can be additionally corrected based on the nonlinear correction factor to compensate for the nonlinear parallax effect in close-up scenes, so that the compensation angle can more accurately match the actual parallax offset. The nonlinear correction factor is determined based on the current focusing distance. Specifically, the nonlinear correction factor is determined based on the following formula (5).
[0105]
[0106] In the above formula (5), This is a nonlinear correction factor; This is the current focus distance; The correction strength coefficient is used to control the growth rate of the nonlinear correction. The larger the value, the stronger the correction force during calibration. Its value can be calibrated based on factors such as the optical axis offset vector of the electronic device and the lens baseline length. Specifically, The value ranges from 0.1 to 0.2. For example, a value of 0.1 indicates a 10% increase in compensation. The first value "1" on the right side of the equals sign is to ensure... The minimum value is 1, meaning no correction is performed, ensuring that the correction factor does not weaken the original compensation angle. This value is constant and cannot be adjusted.
[0107] In some embodiments of this application, when the current focus distance is in the medium field range (i.e. (greater than the first threshold and less than the second threshold), for example, 1 meter < At distances ≤50 meters, the parallax effect is moderate. The optical axis offset vector is relatively small compared to the shooting distance, and the parallax angle and shooting distance approximately satisfy a linear relationship. The basic parallax mapping model can accurately describe the relationship between the parallax angle, optical axis offset, and shooting distance. Therefore, within this distance range, the gimbal compensation angle can be determined directly based on the parallax angle and focal length normalization factor to meet the accuracy requirements. Specifically, the gimbal compensation angle can be obtained according to the formula (4) above.
[0108] Continuing with the example above, the current focus distance =5m, meaning the distance from the singer to the phone is 5m. Taking a first threshold of 1m and a second threshold of 50m as an example, the current focusing distance of 5m falls within the mid-range of 1m to 50m. At this time, the phone directly focuses on the parallax angle. , and focal length normalization factor =0.354 determines the gimbal compensation angle, and the gimbal compensation angle is calculated. , The phone drives the gimbal to rotate according to the compensation angle, so that the center of the telephoto lens's image is aligned with the center of the wide-angle lens's image before switching.
[0109] When the current focusing distance is within the near-field range (i.e., D is less than the first threshold), for example, D≤1 meter, the shooting distance is very close, the optical axis offset vector is not negligible relative to the shooting distance, and the relationship between the parallax angle and the shooting distance deviates from linearity, exhibiting significant nonlinear characteristics. Specifically, when the shooting distance is very close, the slope of the parallax angle changes with distance increases, that is, the same amount of distance change will lead to a larger amount of parallax angle change. If the above linear parallax model is still used to calculate the compensation angle, the compensation amount will be insufficient and the center jump of the image cannot be completely eliminated. Therefore, in near-field scenes, it is necessary to introduce a nonlinear correction factor to make additional corrections to the compensation angle. The nonlinear correction factor is determined based on the current focusing distance and is used to make nonlinear compensations to the basic compensation angle. Its value changes with the shooting distance. Specifically, the closer the shooting distance, the larger the nonlinear correction factor and the larger the amount of compensation angle correction. For example, in the case of D=1m, in the above formula (5), =0, =1, meaning no additional correction is introduced at the boundary between the mid-range and foreground, compared to the gimbal compensation angle obtained above. , Continuous transition; when D < 1m, >0, If D > 1, a positive correction value needs to be introduced; and the smaller D is, the better. The larger, The larger the value, the greater the correction amount.
[0110] After introducing the nonlinear correction factor, the calculation formula for the gimbal compensation angle is shown in formula (6) below. That is, the compensation angle obtained by formula (4) is multiplied by the nonlinear correction factor to obtain the final compensation angle.
[0111]
[0112] Continuing with the example above, there are various shooting distances at a concert. Users may shoot a mid-range panoramic view of the stage, a close-up of the singer, or a distant view of the entire venue. Assuming the current focusing distance D = 5m (the distance from the singer to the phone), the first threshold is set to 1m, and the second threshold is set to 50m. The current focusing distance of 5m is greater than 1m and less than 50m, which falls within the mid-range. The phone directly calculates the compensation angle using the formula (4) above. The phone is based on the parallax angle. , and focal length normalization factor =0.354, the calculated gimbal compensation angle is 0.354. , Then, after the gimbal completes the compensation rotation according to that angle, the singer's position in the telephoto lens image is consistent with that in the wide-angle lens image, and the switch is smooth and seamless.
[0113] Suppose the user later moves to the front row of the stage and zooms again from a distance of 0.5m from the singer, switching from a wide-angle lens to a telephoto lens to take a close-up of the singer's face. At this point, the current focus distance D=0.5m, which is less than the first threshold of 1m, falling within the close-up range. The phone first calculates the basic parallax angle: , Then, according to the above formula (5), the nonlinear correction factor is calculated. =1+0.1×(1 / 0.5-1)=1.1, substituting into the above formula (6), we get the final compensation angle as , Thus, compared to the compensation angle without a nonlinear correction factor, the compensation angle in the yaw direction... With an increase of approximately 10% in compensation, the phone-driven gimbal rotates at a compensation angle of 0.558°, aligning the optical axis of the telephoto lens with the singer's face. This ensures that the singer's face is centered in the frame after the switch, consistent with the position of the singer's face in the wide-angle lens before the switch.
[0114] If the user later moves to the back of the venue and zooms to take a picture at a distance of 30m from the stage, the current focus distance D=30m is still within the mid-range of 1m to 50m. The mobile phone can use the above formula (4) to calculate the compensation angle without introducing a nonlinear correction factor. The calculation process is similar to that when D=5m.
[0115] If a user zooms in at a distance of 80m from the stage, the current focus distance D=80m, which is greater than the second threshold of 50m, falling within the range of a distant scene. In distant scenes, the parallax angle is extremely small, the optical axis offset vector is negligible relative to the shooting distance, the gimbal compensation angle is close to zero, and the mobile phone can directly ignore compensation or perform minimal compensation.
[0116] In this embodiment, different compensation angle calculation strategies are adopted according to the current focusing distance. When the current focusing distance is greater than a first threshold and less than a second threshold (i.e., in a mid-range scene), the gimbal compensation angle is directly determined based on the parallax angle and focal length normalization factor, resulting in low computational load and fast response speed. When the current focusing distance is less than the first threshold (i.e., in a close-up scene), a nonlinear correction factor determined based on the current focusing distance is introduced to further correct the compensation angle determined by the parallax angle and focal length normalization factor, thus obtaining the final compensation angle. In this way, by setting a distance-level strategy, a basic compensation model is used in mid-range and long-range scenes with small parallax effects, avoiding unnecessary computational overhead and improving computational efficiency. In close-up scenes with significant parallax effects, a nonlinear correction factor is used to compensate for the nonlinear relationship between the parallax angle and the shooting distance in close-up scenes, enabling the compensation angle to accurately match the actual parallax offset and avoiding the image center alignment deviation problem caused by insufficient compensation of the basic linear model in close-up scenes. Meanwhile, the setting of the first and second thresholds provides a clear judgment benchmark for the distance-level strategy, ensuring clear boundary conditions for switching compensation strategies across different distance ranges and guaranteeing a smooth transition of the compensation scheme in different distance scenarios. This achieves accurate parallax compensation across the entire distance range, from distant to close-up shots. Whether the user is shooting a distant, medium, or close-up scene, the electronic device can automatically adapt to the optimal compensation strategy based on the actual shooting distance, improving the solution's adaptability and compensation accuracy for diverse shooting scenarios.
[0117] Step 130: Based on the compensation angle, adjust the gimbal attitude so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
[0118] In some embodiments of this application, after obtaining the compensation angle, the gimbal attitude can be adjusted based on the compensation angle. Specifically, the gimbal can be driven to rotate according to the compensation angle calculated in step 120 so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
[0119] It should be noted that the gimbal rotation needs to be precisely synchronized with the camera switching sequence to ensure that the gimbal has been compensated in place before the new camera image is output.
[0120] In some embodiments of this application, step 130 may specifically include: Obtain the maximum angular velocity of the gimbal's drive motor, and the switching delay time required to switch from the first lens to the second lens; Based on the compensation angle and maximum angular velocity, determine the rotation time required for the gimbal to complete the rotation of the compensation angle; If the rotation time is less than the switching delay time, the gimbal attitude is adjusted within the switching delay time.
[0121] The maximum angular velocity of the gimbal's drive motor can be defined as the maximum rotational angular velocity that the gimbal drive motor can achieve under rated operating conditions, expressed in degrees per second. This maximum angular velocity is a physical characteristic parameter of the gimbal motor itself, determined by factors such as motor torque, load inertia, and drive voltage. For example, the maximum angular velocity of the gimbal drive motor of a certain mobile phone model is 60° / s. This maximum angular velocity is calibrated and stored in the electronic device's memory when the gimbal module leaves the factory.
[0122] Switching latency, measured in milliseconds (ms), is the time required from the moment the electronic device issues a lens switching command until the second lens completes the hardware switch and begins outputting a stable image. Switching latency includes the sum of delays from multiple stages, such as the image sensor power-on and stabilization time, the lens drive motor response time, and the image signal processor switching time. This switching latency is determined by hardware characteristics and is typically between 10ms and 50ms. For example, the switching latency for a certain mobile phone model switching from a wide-angle lens to a telephoto lens is 30ms. This parameter is also tested and calibrated at the factory and stored in the electronic device's memory.
[0123] The rotation time is the time required for the gimbal to complete the rotation according to the compensation angle, and the unit is milliseconds (ms). The rotation time is determined by the compensation angle and the maximum angular velocity of the gimbal drive motor, and the calculation formula is shown in the following formula (7).
[0124]
[0125] In the above formula (7), For rotation time; For the compensation angle, including the angle obtained from formula (4) or formula (6) above. and ; This is the maximum angular velocity of the gimbal drive motor.
[0126] It should be noted that when the compensation angle includes two components: pitch compensation angle and yaw compensation angle, the actual rotation trajectory of the gimbal is a composite motion in both directions. Therefore, the time required for the gimbal to complete this composite rotation is determined by the composite rotation angle. The combined rotation angle can be determined based on the following formula (8).
[0127]
[0128] Correspondingly, the rotation time can be calculated using the composite rotation angle. Alternatively, to simplify the calculation, the rotation time in both directions can be calculated separately, and the larger of the two values can be taken as the total time required for the gimbal to complete the compensation rotation.
[0129] In some embodiments of this application, after the lens switching is triggered but before the gimbal compensation rotation is performed, the electronic device first reads the maximum angular velocity of the gimbal drive motor and the switching delay time required to switch from the first lens to the second lens from the memory. Based on the obtained maximum angular velocity of the gimbal drive motor and the compensation angle calculated in the aforementioned steps, the electronic device calculates the rotation time required for the gimbal to complete the rotation of the compensation angle according to the above formula (7).
[0130] The electronic device will use the calculated gimbal rotation time. With the acquired lens switching delay time If a comparison is made, < This indicates that the gimbal can complete the compensation rotation before the lens switching is finished, satisfying the timing synchronization condition. In this case, the electronic equipment drives the gimbal to rotate according to the compensation angle during the lens switching delay time, so that the second lens is already in the compensated posture when the image is output, thereby ensuring that the center of the image remains aligned at the moment of switching.
[0131] like ≥ This indicates that the gimbal cannot complete the compensation rotation before the lens switching is complete, and the timing synchronization condition is not met. In this case, the electronic device can adopt a step-by-step compensation strategy (the specific process will be described in detail in subsequent embodiments), or perform partial compensation before the switching is completed, and continue to perform the remaining compensation after the switching is completed.
[0132] It should be noted that the gimbal rotation time With camera switching delay time The comparison is the core condition for timing synchronization control. Only when the gimbal rotation time is less than the lens switching delay time can compensation be completed before the switch is finished, achieving a seamless "zero-jump" switch. If the gimbal rotation time is greater than the switching delay time, it means that the gimbal has not yet rotated to its proper position when the new lens image is output, and the user will see the image still moving after the switch, significantly reducing the compensation effect. Therefore, ensuring that the gimbal compensation rotation and lens switching timing are precisely matched is a crucial step in guaranteeing the compensation effect.
[0133] Continuing with the example above, compensation angle , The maximum angular velocity of the gimbal drive motor Synthetic rotation angle Gimbal rotation time ms.
[0134] Gimbal rotation time ms, camera switching delay time Since 0.88ms < 30ms, the timing synchronization condition is met. Simultaneously with the camera switching command, the phone immediately drives the gimbal to perform compensating rotation. The gimbal completes a micro-angle rotation of 0.053° within 0.88ms. At this point, the camera switching is not yet complete (approximately 29ms remain). When the telephoto lens image is officially output 30ms later, the gimbal has already completed its compensating rotation and stabilized in its compensating posture. The center of the telephoto lens image remains aligned with the center of the wide-angle lens image before the switch, so the user does not perceive any image jump during the entire switching process.
[0135] In this embodiment, by acquiring the maximum angular velocity of the gimbal drive motor and the lens switching delay time, the rotation time required for the gimbal to complete the compensation angle rotation is determined based on the compensation angle and the maximum angular velocity. If the rotation time is less than the switching delay time, the gimbal attitude is adjusted within the switching delay time. Thus, by comparing the gimbal rotation time with the lens switching delay time, and using timing synchronization as a constraint, it is ensured that the gimbal compensation rotation is completed before the lens switching is finished, so that the second lens is already in the compensated attitude when the image is output. This achieves precise synchronization between the gimbal physical compensation and the lens switching timing. Furthermore, compensation can only be completed within the switching delay time if the rotation time is less than the switching delay time. This fundamentally guarantees the effectiveness of the compensation action and avoids the problem of image jump residue caused by the gimbal rotation lagging behind the lens switching.
[0136] In some embodiments of this application, after determining the compensation angle of the gimbal, the method described above may further include: When the compensation angle is greater than the preset compensation angle threshold, the image captured by the second lens is compensated based on the software compensation method so that the center of the second lens image is aligned with the center of the first lens image before and after switching.
[0137] The preset compensation angle threshold can be a pre-set upper limit value for gimbal compensation angle, used to determine whether the current compensation angle is within the safe range of gimbal physical compensation. The preset compensation angle threshold can be set according to factors such as the mechanical travel range of the gimbal, motor drive capability, and image stability requirements. For example, the preset compensation angle threshold can be set to ±3°.
[0138] In some embodiments of this application, after the electronic device calculates the compensation angle of the gimbal based on the first focal length, the second focal length, the current focus distance and the optical axis offset vector, before performing physical compensation of the gimbal, the electronic device first compares the calculated compensation angle with a preset compensation angle threshold.
[0139] As a precision electromechanical actuator, the physical rotation range of a gimbal is limited by its mechanical structure. Specifically, both the yaw and pitch axes of the gimbal have finite mechanical rotational travel; exceeding this range may lead to mechanical collisions or motor overload. Furthermore, even within the mechanical travel range, excessive compensation angles can cause noticeable rotation or jitter in the image, negatively impacting the user experience. Therefore, electronic devices need to have a preset compensation angle threshold to determine the safety of the compensation angle. This preset threshold is a pre-defined safety boundary value used to determine whether the current compensation angle is within the safe operating range of the gimbal's physical compensation. Specifically, this can be achieved by comparing the calculated yaw and pitch compensation angles separately with the preset compensation angle threshold, or by comparing the composite compensation angle with the preset compensation angle threshold.
[0140] If the compensation angle is determined to be within the preset compensation angle threshold and within the safe range of gimbal physical compensation, the electronic device continues to execute the gimbal physical compensation process, driving the gimbal to rotate according to the compensation angle. If the compensation angle is determined to be greater than the preset compensation angle threshold, the electronic device stops gimbal physical compensation and instead uses a software compensation method to process the image captured by the second lens.
[0141] The specific implementation of the aforementioned software compensation method is as follows: The electronic device acquires the original image captured by the second lens and determines the number of pixels to be cropped and shifted based on the size and direction of the compensation angle. Specifically, the electronic device crops the original image captured by the second lens, using the target position in the second lens image aligned with the center of the first lens image as the center, removing the edge misalignment areas caused by parallax shift. Then, the cropped image is shifted as a whole so that its center point is aligned with the center of the first lens image. The specific number of pixels to be cropped and shifted is calculated by combining the compensation angle and the lens focal length, and the conversion relationship is the inverse operation of the conversion relationship used in calculating the physical compensation angle.
[0142] It should be noted that while the software compensation method can achieve center alignment, it involves image cropping and digital magnification, which sacrifices some effective pixels and field of view of the image captured by the second lens, resulting in a decrease in image resolution. However, in extreme scenarios with excessively large compensation angles, such as extremely close-range macro photography, software compensation can still ensure basic center alignment, serving as an effective backup solution for physical compensation. Through the aforementioned software compensation scheme, even in extremely close-range macro photography scenarios, the electronic device can still ensure basic center alignment of the image during lens switching, avoiding significant image jumps caused by the unavailability of physical compensation, and improving the robustness of the solution in this application embodiment under extreme scenarios.
[0143] In addition, while switching to software compensation, the electronic device can also display a prompt on its screen to inform the user that physical compensation is unavailable in the current scene and that software compensation mode has been switched. For example, the electronic device may display a prompt such as "Current distance is too close, digital zoom mode has been switched" or "Shooting distance is too close, image has been automatically stabilized," allowing the user to understand the current compensation status.
[0144] Continuing with the example above, users may shoot from different distances, ranging from mid-to-long-distance panoramic shots of the stage to extremely close-up shots. In most cases, the user is about 3-10 meters away from the singer. At this distance, the calculated compensation angle is usually less than 0.1°, far less than the preset compensation angle threshold of ±3°. The phone performs normal gimbal physical compensation, and the user does not perceive any image jump when switching lenses.
[0145] However, in a specific scenario, a user might want to capture details of an instrument held by a singer. Moving the phone to a position approximately 0.05m (5cm) away from the instrument for macro photography, the user switches from a wide-angle lens to a telephoto lens. The phone calculates a compensation angle of approximately 4.97°, which exceeds the preset compensation angle threshold of ±3°. Upon detecting that the compensation angle of 4.97° is greater than the preset threshold of 3°, the phone determines that physical compensation by the gimbal is not feasible. Forcibly rotating the gimbal by 4.97° would require it to rotate at an extremely high angular velocity within the lens switching delay time (approximately 30ms), potentially causing severe image jitter, ghosting, or even damage to the gimbal's mechanical structure. Therefore, the phone automatically abandons physical compensation and switches to a software compensation solution. Specifically, the phone acquires an image of the musical instrument captured by the telephoto lens. Based on the pixel offset calculated using a compensation angle of 4.97°, the telephoto image is cropped and shifted. The cropping is centered on the actual imaging position of the instrument within the telephoto image, ensuring the instrument is centered in the cropped image, consistent with its position in the wide-angle lens image before switching. The cropped image is then digitally magnified to fill the entire display screen. Simultaneously, a notification pops up on the phone screen: "Current distance too close, switched to digital zoom mode," informing the user that a software compensation scheme is being used. Upon seeing this notification, the user understands that the current lens switch uses digital zoom mode for compensation, which may result in a slight loss of image quality, but still ensures that the main subject is centered within the image.
[0146] In this embodiment, after determining the compensation angle of the gimbal, it is determined whether the compensation angle is greater than a preset compensation angle threshold. If the compensation angle is greater than the preset compensation angle threshold, physical compensation of the gimbal is abandoned, and instead, compensation is performed on the image captured by the second lens using a software compensation method, so that the center of the image from the second lens remains aligned with the center of the image from the first lens before and after the switch. Thus, by setting a preset compensation angle threshold, a safe judgment is made on the compensation angle. When the compensation angle is within a safe range, physical compensation of the gimbal is performed to achieve accurate parallax compensation without image quality loss. When the compensation angle exceeds the safe threshold, the software compensation scheme is automatically switched to avoid abnormal situations such as image shaking, ghosting, or mechanical damage that may occur due to excessive rotation of the gimbal, ensuring the operational safety of the device and the basic stability of the image. At the same time, software compensation serves as an effective backup solution for physical compensation, enabling the technical solution of this application to still achieve image center alignment in extreme scenarios such as extremely close-range macro shooting, ensuring the applicability and robustness of the solution in all scenarios. Furthermore, by organically combining physical compensation and software compensation, the optimal compensation strategy is adaptively selected based on the size of the compensation angle. Specifically, physical compensation is used to ensure lossless image quality at small angles, while software compensation is used to ensure safety and basic alignment at large angles. This achieves a multiple balance between compensation accuracy, image quality protection, and device safety.
[0147] In some embodiments of this application, when the electronic device is in video recording mode, the method described above may further include: Monitor the equivalent focal length corresponding to the current zoom ratio; If the difference between the equivalent focal length and the second focal length is less than a preset focal length threshold, the optical axis offset vector mapping table is preloaded. Correspondingly, step 110 above may specifically include: When the lens of the electronic device that is capturing image frames switches from the first lens to the second lens, the current focus distance and the preloaded optical axis offset vector mapping table are obtained.
[0148] The video recording mode is a shooting mode in which the electronic device continuously captures a sequence of image frames output by the image sensor and encodes them into a video file at a set frame rate (such as 30fps or 60fps). In video recording mode, the picture is presented as a continuous sequence of frames, and the camera transitions must be completed within one frame interval; otherwise, the user will perceive stuttering or frame skipping.
[0149] The equivalent focal length corresponding to the current zoom ratio can be the value set by the user through zoom operations (such as sliding the zoom slider or pinch-to-zoom). Zoom ratios are typically based on 1x (corresponding to the physical focal length of a wide-angle lens). For example, 2x zoom corresponds to an equivalent focal length twice that of a wide-angle lens, and 3x zoom corresponds to an equivalent focal length three times that of a wide-angle lens. This equivalent focal length changes in real time during continuous zooming. When its value approaches the nominal focal length of a physical lens, the electronic device will trigger a lens switch.
[0150] The preset focal length threshold can be a pre-set distance threshold used to determine whether the current equivalent focal length is close to the physical focal length of the second lens, thereby predicting whether a lens switch is about to occur. The preset focal length threshold can be set to a fixed value (e.g., 1.0mm) or a percentage of the second focal length (e.g., 10% of the second focal length). When the difference between the equivalent focal length and the second focal length is less than the preset focal length threshold, the electronic device determines that a lens switch is about to occur and begins preloading relevant data.
[0151] Preloading can be an operation in which electronic devices read the optical axis offset vector mapping table from a slow storage medium (such as flash memory) into a fast cache (such as RAM) before the actual lens switching occurs. The purpose of preloading is to eliminate the latency caused by reading data only after the switching is triggered, ensuring that the system can immediately obtain the optical axis offset vector at the moment the switching is triggered, without waiting for the memory to read the data.
[0152] In some embodiments of this application, in video recording mode, the user may adjust the zoom ratio by sliding the zoom slider or performing a two-finger zoom operation. The electronic device monitors the user's operation in real time, obtains the current zoom ratio, and calculates the equivalent focal length corresponding to the current zoom ratio based on the focal length of the currently used physical lens. Specifically, when the user is recording using a wide-angle lens (focal length f_wide=4.25mm, corresponding to 1x reference), the electronic device monitors the position of the zoom slider in real time. Assuming the user starts zooming from 1x towards the telephoto end, the zoom ratio gradually increases, and the current zoom ratio and the current equivalent focal length satisfy the following formula (9).
[0153]
[0154] In the above formula (9), Equivalent focal length; The first focal length; This is the current zoom level.
[0155] The electronic device continuously monitors changes in the current equivalent focal length to determine if a lens switch is imminent. Specifically, it calculates the difference between the current equivalent focal length and the physical focal length of the second lens and compares this difference with a preset focal length threshold. If the difference is less than the preset focal length threshold, the electronic device determines that the current zoom position is close to the lens switch point and a switch from the first lens to the second lens is about to be triggered. Therefore, it begins preloading the optical axis offset vector mapping table. For example, the electronic device reads entries from the optical axis offset vector mapping table between the first and second lenses (including the optical axis offset vector and the first and second focal lengths) from non-volatile memory and loads this data into a memory cache. After preloading, the electronic device keeps this data in memory, waiting for the actual triggering of the lens switch.
[0156] As the user continues to zoom to the switching point, the electronic device officially detects the instruction to switch from the first lens to the second lens. At this point, the electronic device directly reads the pre-loaded optical axis offset vector mapping table entry from the memory cache, eliminating the need to access the slow flash memory and saving data reading time. Simultaneously, the electronic device obtains the current focus distance in real time from the ToF sensor or the focusing motor (this data cannot be pre-loaded because the focus distance is dynamically changing and must be read in real time at the moment of switching). Then, the electronic device uses both the pre-loaded optical axis offset vector and the real-time obtained current focus distance for subsequent compensation angle calculations.
[0157] It should be noted that the aforementioned preset focal length threshold should not be too large or too small. If the preset focal length threshold is too large, preloading will occur too early, which may consume memory resources and result in inaccurate predictions. If the preset focal length threshold is too small, preloading will not be completed in time before the switching trigger. This preset focal length threshold can be calibrated based on factors such as the response speed of the zoom slider and the memory read time. For example, the preset focal length threshold can be set to 1.0mm, meaning that the electronic device begins preloading the mapping table when the equivalent focal length is 1.0mm away from the physical focal length of the second lens.
[0158] In addition, when monitoring the equivalent focal length corresponding to the current zoom ratio, the monitoring frequency can be synchronized with the video frame rate. For example, if the video frame rate is 30fps, monitoring can be performed once every 33ms, or a higher frequency of monitoring can be used to ensure timely response.
[0159] Continuing with the example above, the user is currently using a wide-angle lens (focal length 4.25mm, corresponding to 1x zoom) to record a panoramic view of the entire stage. The user wants to zoom in to film the singer on stage and starts sliding the zoom slider from 1x to 3x. The phone monitors the position of the zoom slider in real time and calculates the current equivalent focal length. When the user slides the zoom slider to the 2.7x position, the current equivalent focal length is... =4.25×2.7≈11.475mm.
[0160] The telephoto lens has a physical focal length of 12.00mm and a preset focal length threshold of 1.0mm. When the user zooms to 2.7x, the current equivalent focal length is 11.475mm. The difference between the equivalent focal length and the second focal length is 12.00 - 11.475 = 0.525mm, which is less than the preset focal length threshold of 1.0mm. The phone detects an impending lens switch and immediately preloads the optical axis offset vector mapping table entries from the flash memory, including the optical axis offset vector (…). =12.5mm, =-3.2mm, =0.8mm), wide-angle focal length 4.25mm, and telephoto focal length 12.00mm, and these data are loaded into the memory cache. During this process, the user is still sliding the zoom slider and has not yet reached the 3x switching point. The phone has already completed the data preloading in the background, which the user is unaware of. The user continues to slide the zoom slider from 2.7x to 3.0x. When the zoom ratio reaches approximately 2.82x (equivalent focal length = 4.25 × 2.82 ≈ 12.00mm, which is equal to the physical focal length of the second lens), the phone officially triggers the switch from the wide-angle lens to the telephoto lens. At this time, the phone first obtains the current focus distance D = 5.0m, and then the phone reads the preloaded optical axis offset vector mapping table entry from the memory cache and directly obtains the optical axis offset vector ( =12.5mm, =-3.2mm, The focal lengths are 0.8mm (wide-angle), 4.25mm (wide-angle), and 12.00mm (telephoto). Since the mapping table is pre-loaded into memory, eliminating the approximately 5-10ms delay of reading data from flash memory, the phone can immediately proceed to the compensation angle calculation step. Based on the pre-loaded focal length and optical axis offset vector, as well as the real-time acquired current focusing distance, the phone calculates the compensation angle. The gimbal compensation rotation is completed within approximately 0.88ms. When the next frame (the N+1th frame) is output, the center of the telephoto lens image is aligned with the center of the wide-angle lens image before the switch, and the singer is still located in the center of the image, so the user cannot perceive the image change.
[0161] In this embodiment, when the electronic device is in video recording mode, the equivalent focal length corresponding to the current zoom level is monitored. When the difference between the equivalent focal length and the second focal length is less than a preset focal length threshold, an optical axis offset vector mapping table is preloaded. Then, when a lens switch is detected, the current focus distance and the preloaded optical axis offset vector mapping table are obtained. Thus, by loading the optical axis offset vector mapping table from slow storage medium into a fast cache in advance when the zoom approaches the switching threshold, the time delay caused by reading data only after the switch is triggered is eliminated. This allows the electronic device to immediately obtain the optical axis offset vector when a switch command is detected, without waiting for memory read time, significantly reducing the time overhead from switch triggering to the completion of compensation angle calculation. Simultaneously, since the current focus distance is dynamically changing and may differ in each frame, it is still read in real-time at the moment of switch triggering, ensuring that the distance data used for compensation angle calculation is the latest value for the current scene, balancing data timeliness and calculation accuracy. In addition, by preloading to eliminate latency, it is ensured that the gimbal compensation rotation can be completed within the frame interval, ensuring that the center of the image is aligned when each frame is output. This achieves a seamless experience of camera switching during video recording and avoids screen jumps or stuttering caused by data reading latency.
[0162] In some embodiments of this application, when the electronic device is in video recording mode, adjusting the gimbal attitude based on the compensation angle may specifically include: Get the frame interval time of the recorded video; The maximum compensation angle for a single video frame is determined based on the frame interval time and the maximum angular velocity of the gimbal's drive motor. When the compensation angle is less than or equal to the maximum compensation angle, the gimbal's attitude is adjusted to compensate the angle within one video frame. When the compensation angle is greater than the maximum compensation angle, the compensation angle is decomposed into multiple sub-angles, and the gimbal's attitude is adjusted to the corresponding sub-angle frame by frame during the frame interval of multiple consecutive frames until the compensation angle adjustment is completed.
[0163] The frame interval time can be the time interval between two adjacent frames in video recording, measured in milliseconds (ms). The frame interval time is determined by the video frame rate and is calculated using the following formula (10).
[0164]
[0165] In the above formula (10), This is the frame interval time.
[0166] It should be noted that the frame interval time limits the time window from acquisition to output of each frame image. The gimbal compensation rotation must be completed within the frame interval time to ensure that the image is stable when the next frame is output.
[0167] The maximum compensation angle of a single video frame can be the maximum rotation angle that the gimbal can safely complete within a single frame interval, expressed in degrees (°). This maximum compensation angle is determined by the maximum angular velocity of the gimbal drive motor and the frame interval time, while also taking into account the safety margin coefficient. Specifically, this maximum compensation angle can be determined based on the following formula (11).
[0168]
[0169] In the above formula (11), The maximum compensation angle for a single video frame; This is the maximum angular velocity of the gimbal drive motor; This refers to the frame interval time. As a safety margin factor, this The value can range from 0.2 to 0.6, for example, this... The possible value is 0.4.
[0170] It should be noted that the safety margin factor The introduction of this safety margin is to allow for sufficient acceleration / deceleration time and control error margin for the gimbal. This is because the gimbal motor undergoes acceleration / deceleration processes during startup and shutdown, and the angular velocity does not always remain at its maximum value during actual rotation; therefore, a certain time margin is required. Simultaneously, factors such as the transmission delay of motor control commands and quantization errors in angle measurement also necessitate the inclusion of error margins. Typically, a safety margin factor is used. The value is set to 0.4, which means that only 40% of the gimbal's maximum capacity is used, and the remaining 60% is used as a time margin to ensure that the gimbal can complete the rotation stably within the frame interval without timeout.
[0171] A sub-angle can be defined as the amount of rotation the gimbal needs to complete within a frame interval when the compensation angle is greater than the maximum compensation angle in a single frame. The sum of the sub-angles equals the compensation angle. For example, a compensation angle of 0.85° can be decomposed into two sub-angles of 0.425° and 0.425°, which are completed within the frame interval of two consecutive frames.
[0172] In some embodiments of this application, in video recording mode, the electronic device first obtains the frame rate of the currently recorded video and calculates the frame interval time based on the frame rate. Then, based on the obtained frame interval time and the maximum angular velocity of the gimbal drive motor, the electronic device calculates the maximum compensation angle that the gimbal can safely complete within a single video frame using the formula (11). The electronic device then calculates the compensation angle obtained in the aforementioned steps. With the determined maximum compensation angle for a single frame If a comparison is made, ≤ This indicates that the compensation angle is within the processable range of a single frame. In this case, the electronic device drives the gimbal to complete the rotation of the compensation angle within a single frame interval. Specifically, the electronic device starts the gimbal motor within the frame interval of the current frame, performs rotation according to the compensation angle, and completes the rotation and stabilization before the next frame arrives. If > This indicates that the compensation angle exceeds the range that a single frame can handle. Although the gimbal can theoretically complete the rotation within a single frame interval (and may not even time out when calculated at maximum angular velocity), when the rotation angle is large, the gimbal needs to operate at near or near its maximum angular velocity. The acceleration and deceleration process is relatively drastic, which may cause obvious ghosting or jitter in the image, affecting the user experience. Therefore, in this case, the electronic device adopts a multi-frame step-by-step compensation strategy. Specifically, the compensation angle is... Decomposed into N sub-angles (N is an integer greater than or equal to 2), each sub-angle being the maximum compensated angle in a single frame. Within a certain range or not exceeding a more optimal allocation value. Then, within the frame interval of N consecutive frames, the gimbal's attitude is adjusted to the corresponding sub-angle frame by frame until all compensation angles are adjusted.
[0173] The above decomposition method can be equal division, that is, the compensation angle is divided into N sub-angles of the same size, as shown in the following formula (12).
[0174]
[0175] In the above formula (12), The value for each sub-angle, Let N be the number of sub-angles, specifically, N is the number of angles that satisfy... ≤ The smallest integer.
[0176] In another embodiment, non-equal division can also be used, for example, the first frame and the second frame each perform 50% compensation angle.
[0177] After the decomposition is complete, the electronic device performs the first sub-angle rotation within the frame interval of frame N, the second sub-angle rotation within the frame interval of frame N+1, and so on, until the last sub-angle rotation is completed in frame N+M, at which point all compensation angles have been processed. Throughout the step-by-step compensation process, the electronic device monitors the stability of the center of each frame to ensure that the image remains stable after each sub-angle rotation.
[0178] Continuing with the example above, the user is recording a concert video on their phone at 30fps. The phone obtains the current video frame rate as 30fps and calculates the frame interval. =1 / 30≈33.3ms. The compensation angle was calculated when the user switched from wide-angle to telephoto at a distance of 5m from the singer. Maximum compensation angle per frame ≈0.8°. Since 0.053° < 0.8°, the compensation angle is less than the maximum compensation angle per frame. The phone drives the gimbal to rotate 0.053° within the frame interval (33.3ms) of the current frame. The actual rotation time of the gimbal is... The frame interval is much shorter than 33.3ms. The gimbal completes its rotation and stabilizes within 0.88ms, leaving approximately 32.4ms for image capture and output. When the next frame (the N+1th frame) is output, the gimbal is already stable in its compensated posture, and the center of the telephoto lens image is aligned with the center of the wide-angle lens image before the switch, so the user cannot perceive the image jump.
[0179] In another scenario, a user walks to the front row of the stage and takes a close-up shot from a distance of 0.3m from the singer, calculating the compensation angle. Since 0.85° > 0.8°, the compensation angle is greater than the maximum compensation angle in a single frame. Therefore, the system adopts a multi-frame step-by-step compensation strategy. Specifically, the phone decomposes 0.85° into two sub-angles: 0.425° is applied in the first frame and 0.425° in the second frame. Within the frame interval of the Nth frame, the gimbal rotates 0.425° (approximately 7.1ms), reducing the image center offset by half. Within the frame interval of the N+1th frame, the gimbal continues to rotate the remaining 0.425° (approximately 7.1ms), perfectly aligning the image center. After a smooth transition of two consecutive frames, all compensation angles are completed. Users do not perceive any noticeable image jitter or jumps during the entire switching process, resulting in smooth and natural video playback.
[0180] If the phone doesn't use multi-frame step-by-step compensation and instead attempts to complete a 0.85° rotation within a single frame interval, the gimbal needs to complete the rotation within approximately 14.2ms. Although theoretically this doesn't exceed a 33.3ms frame interval, the angular velocity is relatively high (approximately 60° / s), resulting in a drastic acceleration and deceleration process. This can lead to noticeable motion blur and jitter, affecting video recording quality. Multi-frame step-by-step compensation reduces the angle of rotation per rotation, making the gimbal movement smoother and ensuring better image quality.
[0181] In this embodiment, the frame interval time of the recorded video is obtained, and the maximum compensation angle of a single video frame is determined based on the frame interval time and the maximum angular velocity of the gimbal drive motor. When the compensation angle is less than or equal to the maximum compensation angle, the gimbal attitude is adjusted to compensate the angle within one video frame. When the compensation angle is greater than the maximum compensation angle, the compensation angle is decomposed into multiple sub-angles, and the gimbal attitude is adjusted to the corresponding sub-angle frame by frame within the frame interval time of consecutive frames until all compensation angles are adjusted. Thus, by introducing the maximum compensation angle of a single frame as a judgment benchmark, the compensation angle is divided into two cases: one that can be completed in a single frame and one that needs to be completed in multiple frames. When the compensation angle is small, it is completed quickly within a single frame; when the compensation angle is large, it is completed smoothly in multiple frames. This ensures both compensation efficiency and image stability. The aforementioned multi-frame step-by-step compensation strategy decomposes large angles into multiple smaller sub-angles and executes them frame by frame, avoiding image ghosting or jitter caused by rapid rotation at a single large angle. At the same time, the rotation amount of each frame is within a safe range, ensuring that the gimbal is stable when each frame is output. Thus, in video recording scenarios, regardless of the size of the compensation angle, parallax compensation can be completed while ensuring stable output of each frame, achieving a smooth, seamless, and imperceptible experience when switching shots during video recording.
[0182] In some embodiments of this application, after adjusting the gimbal attitude based on the compensation angle, the method described above may further include: Smoothly restore the gimbal's posture from the compensated rotation posture to the gimbal's motion trajectory before the lens switching trigger.
[0183] The compensated rotation posture refers to the position of the gimbal after rotating according to the compensation angle. At this time, the optical axis of the gimbal is consistent with the optical axis of the first lens before the switch, and the center of the second lens's image is aligned with the center of the first lens's image before the switch. The compensated rotation posture is a temporary posture that the gimbal actively adjusts to to eliminate parallax at the moment of lens switching.
[0184] The gimbal's motion trajectory before the aforementioned lens switch trigger can be the original camera movement trajectory that the gimbal was executing before the user performed the lens switch operation. This motion trajectory reflects the user's shooting intention and the gimbal's motion state before the lens switch.
[0185] In some embodiments of this application, after the gimbal completes its rotation according to the compensation angle, the electronic device records the current gimbal attitude information (i.e., the attitude after the compensation rotation) and the motion trajectory information (including the original attitude, direction of motion, and speed) that the gimbal is executing before the lens switching is triggered. Specifically, the original motion trajectory information has been recorded and cached by the system before the switching is triggered.
[0186] Taking gimbal attitude recording as an example, the electronic device acquires the gimbal's attitude information in real time through the gimbal's attitude sensors (such as gyroscopes or inertial measurement units). This attitude information can be represented as Euler angles (yaw, pitch, roll) or quaternions. When a camera switching command is triggered, the electronic device records the current gimbal attitude as the "original attitude of the gimbal before the switching trigger." After the gimbal completes its compensated rotation, the electronic device records the gimbal attitude after compensation as the "attitude after compensated rotation."
[0187] After the gimbal compensation rotation is completed, the electronic device controls the gimbal to enter the trajectory recovery mode. The purpose of this trajectory recovery mode is to smoothly transition the gimbal from the temporary posture after the compensation rotation back to the user's original camera movement trajectory, so that the user can continue to move the camera according to the original shooting intention without being affected by the compensation rotation.
[0188] The smooth recovery described above can be achieved using a preset smooth transition algorithm. Commonly used smooth transition algorithms include S-shaped velocity curves and Bezier interpolation. Specifically, the S-shaped velocity curve divides the recovery process into three stages: acceleration, constant speed, and deceleration. In the acceleration stage, the gimbal gradually increases its recovery speed from a stationary state to avoid initial shock. In the constant speed stage, the gimbal approaches the original trajectory at a constant speed to maintain smooth motion. In the deceleration stage, the gimbal gradually decreases its speed to smoothly rejoin the original trajectory. The continuous change in acceleration of the S-shaped velocity curve makes the gimbal's motion smooth and natural, without producing abrupt shocks.
[0189] The aforementioned Bezier interpolation can generate a smooth transition path for the gimbal's attitude within the recovery time window using a Bezier curve. Specifically, the electronic device can use the attitude after compensation rotation as the starting point and the attitude at the corresponding moment on the original trajectory as the ending point, generating a smooth interpolation path between the two using a Bezier curve. Then, the gimbal moves along the Bezier curve path, resulting in continuous and smooth attitude changes. The preset recovery time window for this smooth recovery can be set according to actual needs. A time window that is too short may result in an excessively fast recovery speed and a noticeable secondary shift in the image; a time window that is too long may cause the gimbal to deviate from the original trajectory for an extended period, affecting the continuity of subsequent camera movements. The recovery time window can be set from 100ms to 300ms.
[0190] Thus, because the restoration process is smooth and gradual, the center of the image will gradually transition from the position of the compensation alignment to the position corresponding to the original camera movement trajectory. Throughout the transition, the center of the image moves continuously, and the user perceives only a smooth fine adjustment rather than a jump.
[0191] It should be noted that during the process of the gimbal recovering from the compensated posture to the original trajectory, the electronic equipment can monitor the position of the center of the screen in real time to ensure that the recovery action itself does not introduce new screen jumps.
[0192] Continuing with the example above, when a user is recording a concert video with their phone, the gimbal is initially slowly panning to follow the singer moving back and forth on stage (i.e., the original motion trajectory). When the user switches from a wide-angle lens to a telephoto lens, the gimbal completes a compensating rotation with a 0.053° compensation angle. At this point, the gimbal's posture deviates from the original motion trajectory by approximately 0.053°. If the gimbal were to suddenly jump back to its original trajectory, the user would see abrupt changes in the image, disrupting the viewing experience. Therefore, the phone needs to smoothly restore the gimbal to its original trajectory. Specifically, after the gimbal completes the compensated rotation, the phone immediately enters the trajectory recovery mode. The phone first obtains the original attitude and direction of motion of the gimbal before the switching trigger, records the current attitude after the compensated rotation, and then uses an S-shaped velocity curve as a smooth transition algorithm. The preset recovery time window is 200ms. During the recovery process, the S-shaped velocity curve controls the gimbal movement as follows: acceleration phase (0-60ms), the gimbal gradually accelerates from a stationary state, and the recovery speed gradually increases from 0 to the maximum recovery speed; constant speed phase (60-140ms), the gimbal approaches the original trajectory at a constant maximum recovery speed, and most of the recovery is completed in this phase; deceleration phase (140-200ms), the gimbal gradually decelerates, and the speed drops to 0 at 200ms, and the gimbal attitude is accurately restored to the original trajectory. The entire recovery process described above lasted 200ms. The gimbal's attitude changed smoothly and continuously. The offset of the center of the screen gradually decreased from 0.053° to 0°. Users would not perceive that the gimbal was performing a recovery action. They would only feel that the screen moved slightly after the switch and then continued to follow the singer's movement. The entire camera movement was smooth and natural.
[0193] If the phone lacks a trajectory recovery function, the gimbal will remain in its compensated position after completing the compensation rotation and will no longer follow the singer's movement. Users will notice the singer gradually shifting in the frame, forcing them to manually adjust the gimbal position, severely impacting the shooting experience. With the trajectory recovery function, the gimbal actively returns to the user's original camera movement trajectory after compensation, allowing users to continue shooting smoothly without any additional intervention.
[0194] In this embodiment, after the gimbal attitude adjustment is completed, the gimbal attitude is smoothly restored from the compensated rotation attitude to the gimbal's motion trajectory before the lens switch was triggered. Thus, by smoothly returning the gimbal attitude to the user's original camera movement trajectory after parallax compensation, the problem of camera movement interruption caused by the gimbal remaining in the compensated attitude for an extended period is avoided. This ensures a smooth transition between camera movements before and after the compensated rotation, allowing the user to continue shooting according to their original intention without manually adjusting the gimbal position after the switch. In this way, while eliminating the sudden shift in the image center during lens switching, the trajectory restoration function further ensures the continuity of camera movement before and after the switch, achieving a seamless switching experience from the start of compensation to the completion of restoration.
[0195] The parallax compensation method provided in this application can be implemented by a parallax compensation device. This application uses a parallax compensation device to implement the parallax compensation method as an example to illustrate the parallax compensation device provided in this application.
[0196] Figure 2 This is a schematic diagram illustrating the structure of a parallax compensation device according to an exemplary embodiment. The parallax compensation device is applied to an electronic device, which includes a gimbal, a first lens, and a second lens. Figure 2 As shown, the parallax compensation device 200 may include: The acquisition module 210 is used to acquire an optical axis offset vector mapping table and the current focus distance when the lens of the electronic device that acquires the image frame is switched from the first lens to the second lens. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens. The determining module 220 is used to determine the compensation angle of the gimbal based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. The adjustment module 230 is used to adjust the gimbal attitude based on the compensation angle so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
[0197] In this embodiment, when a lens switch is detected, an optical axis offset vector mapping table is obtained. Based on the first focal length of the first lens, the second focal length of the second lens, and the optical axis offset vector of the second lens relative to the first lens in the optical axis offset vector mapping table, the compensation angle of the gimbal is determined in conjunction with the current focusing distance. Then, the gimbal attitude is adjusted based on the compensation angle to keep the center of the second lens's image aligned with the center of the first lens's image before and after the switch. In this way, the optical axis offset vector mapping table is used as the basis for compensation data. At the moment of lens switch, the gimbal actively rotates to physically correct the parallax caused by the lens optical axis offset, effectively alleviating the problem of image center jump caused by the moment of lens switch. It does not rely on software post-processing methods such as cropping or frame interpolation. Therefore, it can achieve seamless switching while fully preserving all pixels and field of view of the second lens without sacrificing image resolution. Moreover, the compensation effect is not limited by scene distance, significantly improving the shooting smoothness of multi-camera electronic devices during lens switch.
[0198] In some embodiments of this application, before obtaining the optical axis offset vector mapping table and the current focus distance, the acquisition module is further configured to acquire the first focal length and the second focal length, as well as a first image of the calibration board captured by the first lens and a second image of the calibration board captured by the second lens; The device further includes: The feature matching module is used to perform feature matching on the first image and the second image to obtain the pixel offset vector of the center of the second image relative to the center of the first image. The conversion module is used to convert the pixel offset vector into a physical offset vector based on the pixel size of the second lens, the first focal length, and the second focal length, so as to obtain the optical axis offset vector of the second lens relative to the first lens; A construction module is used to construct the optical axis offset vector mapping table based on the first focal length, the second focal length, and the optical axis offset vector.
[0199] In some embodiments of this application, the determining module is specifically used for: Based on the first focal length and the second focal length, a focal length normalization factor is obtained; Based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector, the parallax angle between the first lens and the second lens is determined. The compensation angle of the gimbal is determined based on the parallax angle and the focal length normalization factor.
[0200] In some embodiments of this application, the adjustment module is specifically used for: Obtain the maximum angular velocity of the drive motor of the gimbal, and the switching delay time required for the first lens to switch to the second lens; Based on the compensation angle and the maximum angular velocity, determine the rotation time required for the gimbal to complete the rotation of the compensation angle; If the rotation time is less than the switching delay time, the gimbal attitude is adjusted within the switching delay time.
[0201] In some embodiments of this application, after determining the compensation angle of the gimbal, the adjustment module is further configured to compensate the image captured by the second lens based on a software compensation method when the compensation angle is greater than a preset compensation angle threshold, so that the center of the image of the second lens remains aligned with the center of the image of the first lens before and after switching.
[0202] The parallax compensation device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, handheld camera, aircraft, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.
[0203] The parallax compensation device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.
[0204] The parallax compensation device provided in this application embodiment can achieve... Figure 1 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0205] Optionally, such as Figure 3As shown, this application embodiment also provides an electronic device 300, including a processor 301 and a memory 302. The memory 302 stores a program or instructions that can run on the processor 301. When the program or instructions are executed by the processor 301, they implement the various steps of the above parallax compensation method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0206] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0207] Figure 4 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.
[0208] The electronic device 400 includes, but is not limited to, components such as: radio frequency unit 401, network module 402, audio output unit 403, input unit 404, sensor 405, display unit 406, user input unit 407, interface unit 408, memory 409, and processor 410.
[0209] Those skilled in the art will understand that the electronic device 400 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 410 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0210] The processor 410 is configured to, when detecting that the lens of the electronic device acquiring the image frame has switched from the first lens to the second lens, obtain an optical axis offset vector mapping table and a current focus distance, wherein the optical axis offset vector mapping table includes a first focal length of the first lens and a second focal length of the second lens, as well as an optical axis offset vector of the second lens relative to the first lens; determine a compensation angle of the gimbal based on the first focal length, the second focal length, the current focus distance, and the optical axis offset vector; and adjust the attitude of the gimbal based on the compensation angle so that the center of the image of the second lens remains aligned with the center of the image of the first lens before and after the switch.
[0211] Thus, by acquiring the optical axis offset vector mapping table when a lens switch is detected, and determining the gimbal's compensation angle based on the first focal length of the first lens, the second focal length of the second lens, and the optical axis offset vector of the second lens relative to the first lens, combined with the current focusing distance, the gimbal's attitude is adjusted based on the compensation angle to keep the center of the second lens's image aligned with the center of the first lens's image before and after the switch. In this way, using the optical axis offset vector mapping table as the basis for compensation data, the gimbal actively rotates at the moment of lens switch to physically correct the parallax caused by the lens's optical axis offset, effectively alleviating the problem of image center jump caused by the moment of lens switch. It does not rely on software post-processing methods such as cropping or frame interpolation, thus achieving seamless switching while fully preserving all pixels and the field of view of the second lens without sacrificing image resolution. Moreover, the compensation effect is not limited by scene distance, significantly improving the shooting smoothness of multi-camera electronic devices during lens switching.
[0212] Optionally, the processor 410 is further configured to, before obtaining the optical axis offset vector mapping table and the current focusing distance, obtain the first focal length and the second focal length, as well as a first image of the calibration board captured by the first lens and a second image of the calibration board captured by the second lens; perform feature matching on the first image and the second image to obtain a pixel offset vector of the center of the second image relative to the center of the first image; convert the pixel offset vector into a physical offset vector based on the pixel size of the second lens, the first focal length, and the second focal length to obtain an optical axis offset vector of the second lens relative to the first lens; and construct the optical axis offset vector mapping table based on the first focal length, the second focal length, and the optical axis offset vector.
[0213] Optionally, the processor 410 is further configured to obtain a focal length normalization factor based on the first focal length and the second focal length; determine the parallax angle between the first lens and the second lens based on the first focal length, the second focal length, the current focusing distance and the optical axis offset vector; and determine the compensation angle of the gimbal based on the parallax angle and the focal length normalization factor.
[0214] Optionally, the processor 410 is further configured to acquire the maximum angular velocity of the drive motor of the gimbal and the switching delay time required for the first lens to switch to the second lens; determine the rotation time required for the gimbal to complete the rotation of the compensation angle based on the compensation angle and the maximum angular velocity; and adjust the attitude of the gimbal within the switching delay time if the rotation time is less than the switching delay time.
[0215] Optionally, the processor 410 is further configured to, after determining the compensation angle of the gimbal, compensate the image captured by the second lens based on a software compensation method when the compensation angle is greater than a preset compensation angle threshold, so that the center of the image of the second lens remains aligned with the center of the image of the first lens before and after switching.
[0216] It should be understood that, in this embodiment, the input unit 404 may include a graphics processing unit (GPU) 4041 and a microphone 4042. The GPU 4041 processes image data of still images or videos obtained by an image capture device (such as a color camera) in video capture mode or image capture mode. The display unit 406 may include a display panel 4061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 407 includes at least one of a touch panel 4071 and other input devices 4072. The touch panel 4071 is also called a touch screen. The touch panel 4071 may include two parts: a touch detection device and a touch controller. Other input devices 4072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
[0217] The memory 409 can be used to store software programs and various data. The memory 409 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 409 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 409 in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.
[0218] Processor 410 may include one or more processing units; optionally, processor 410 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 410.
[0219] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described parallax compensation method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0220] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0221] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above parallax compensation method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0222] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0223] This application provides a computer program product stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the parallax compensation method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0224] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0225] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0226] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A parallax compensation method, characterized in that, Performed by an electronic device, the electronic device including a gimbal, a first lens, and a second lens, the method includes: When the lens of the electronic device that captures the image frame is switched from the first lens to the second lens, the optical axis offset vector mapping table and the current focus distance are obtained. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens. The compensation angle of the gimbal is determined based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. Based on the compensation angle, the gimbal attitude is adjusted so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
2. The method according to claim 1, characterized in that, Before obtaining the optical axis offset vector mapping table and the current focus distance, the method further includes: Acquire the first focal length and the second focal length, as well as a first image of the calibration board captured by the first lens and a second image of the calibration board captured by the second lens; Feature matching is performed on the first image and the second image to obtain the pixel offset vector of the center of the second image relative to the center of the first image; Based on the pixel size of the second lens, the first focal length, and the second focal length, the pixel offset vector is converted into a physical offset vector to obtain the optical axis offset vector of the second lens relative to the first lens; Based on the first focal length, the second focal length, and the optical axis offset vector, construct the optical axis offset vector mapping table.
3. The method according to claim 1, characterized in that, Determining the compensation angle of the gimbal based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector includes: Based on the first focal length and the second focal length, a focal length normalization factor is obtained; Based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector, the parallax angle between the first lens and the second lens is determined. The compensation angle of the gimbal is determined based on the parallax angle and the focal length normalization factor.
4. The method according to claim 1, characterized in that, The adjustment of the gimbal attitude based on the compensation angle includes: Obtain the maximum angular velocity of the drive motor of the gimbal, and the switching delay time required for the first lens to switch to the second lens; Based on the compensation angle and the maximum angular velocity, determine the rotation time required for the gimbal to complete the rotation of the compensation angle; If the rotation time is less than the switching delay time, the gimbal attitude is adjusted within the switching delay time.
5. The method according to claim 1, characterized in that, After determining the compensation angle of the gimbal, the method further includes: When the compensation angle is greater than a preset compensation angle threshold, the image captured by the second lens is compensated based on a software compensation method so that the center of the image of the second lens remains aligned with the center of the image of the first lens before and after switching.
6. A parallax compensation device, characterized in that, Applied to an electronic device, the electronic device including a gimbal, a first lens, and a second lens, the device includes: The acquisition module is used to acquire an optical axis offset vector mapping table and the current focus distance when the lens of the electronic device that acquires the image frame is switched from the first lens to the second lens. The optical axis offset vector mapping table includes the first focal length of the first lens and the second focal length of the second lens, as well as the optical axis offset vector of the second lens relative to the first lens. The determination module is used to determine the compensation angle of the gimbal based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector. The adjustment module is used to adjust the gimbal attitude based on the compensation angle so that the center of the second lens's image remains aligned with the center of the first lens's image before and after switching.
7. The apparatus according to claim 6, characterized in that, Before acquiring the optical axis offset vector mapping table and the current focus distance, the acquisition module is further configured to acquire the first focal length and the second focal length, as well as a first image of the calibration board captured by the first lens and a second image of the calibration board captured by the second lens; The device further includes: The feature matching module is used to perform feature matching on the first image and the second image to obtain the pixel offset vector of the center of the second image relative to the center of the first image. The conversion module is used to convert the pixel offset vector into a physical offset vector based on the pixel size of the second lens, the first focal length, and the second focal length, so as to obtain the optical axis offset vector of the second lens relative to the first lens; A construction module is used to construct the optical axis offset vector mapping table based on the first focal length, the second focal length, and the optical axis offset vector.
8. The apparatus according to claim 6, characterized in that, The determining module is specifically used for: Based on the first focal length and the second focal length, a focal length normalization factor is obtained; Based on the first focal length, the second focal length, the current focusing distance, and the optical axis offset vector, the parallax angle between the first lens and the second lens is determined. The compensation angle of the gimbal is determined based on the parallax angle and the focal length normalization factor.
9. The apparatus according to claim 6, characterized in that, The adjustment module is specifically used for: Obtain the maximum angular velocity of the drive motor of the gimbal, and the switching delay time required for the first lens to switch to the second lens; Based on the compensation angle and the maximum angular velocity, determine the rotation time required for the gimbal to complete the rotation of the compensation angle; If the rotation time is less than the switching delay time, the gimbal attitude is adjusted within the switching delay time.
10. The apparatus according to claim 6, characterized in that, After determining the compensation angle of the gimbal, the adjustment module is further configured to compensate the image captured by the second lens based on a software compensation method when the compensation angle is greater than a preset compensation angle threshold, so that the center of the image of the second lens remains aligned with the center of the image of the first lens before and after switching.
