Projection keystone correction method for efficiently solving maximum inscribed axis alignment rectangle
By obtaining the vertex coordinates of the projected distorted image, calculating the equation of the inner half-plane, and performing a binary search, combined with the polygon clipping method, the problems of slow solution speed and poor stability of the maximum inscribed rectangle in projected trapezoidal correction are solved, achieving efficient and stable projected correction results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-03-27
AI Technical Summary
Existing projection trapezoidal correction methods suffer from slow calculation speed, small area, and instability under complex orientations, making it difficult to satisfy geometric inscribed constraints.
By obtaining the coordinates of the four vertices of the distorted image, calculating the equation of the inner half-plane, determining the vertices of the bounding box, initializing the rectangle scaling factor, using binary search and polygon clipping methods to find the feasible region of the rectangle center, and gradually adjusting the scaling factor to approximate the maximum inscribed rectangle.
It enables fast and stable solving of the maximum inscribed axis-aligned rectangle under any orientation, improving solution efficiency and stability, and is suitable for real-time keystone correction of projectors.
Smart Images

Figure CN121746253A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of projection technology, and more specifically to an efficient method for calculating the projection trapezoidal correction of the largest inscribed axis aligned rectangle. Background Technology
[0002] During projection, because the projector is not always perfectly aligned with the projection screen, when the projector deviates in pitch, yaw, or roll angles, the projected image often deviates from a standard rectangle and exhibits trapezoidal distortion, a phenomenon known as trapezoidal distortion. To ensure viewing quality, geometric transformation is typically used to correct the image, a process known as keystone correction. Existing keystone correction methods mostly employ digital correction technology, which uses image processing to geometrically map the distorted projected image, transforming the trapezoidal areas caused by projector placement angles or installation position deviations back into standard rectangles, thus achieving a visually "straightened" effect.
[0003] In existing projection keystone correction technologies, one of the core tasks is to determine the effective area within the distorted quadrilateral that can be used for projection display. Because the projected image typically presents a convex quadrilateral shape on the projection plane when the projector's pitch, yaw, or roll angles change, it is necessary to select a rectangular area from this quadrilateral that is both usable for display and maximizes its utilization. To ensure the final projected image's visual effect and geometric consistency, this effective area must simultaneously meet four conditions: First, the rectangle's aspect ratio must be consistent with the preset display ratio to avoid stretching or compression issues; second, the four vertices of the rectangle must fall precisely within the distorted quadrilateral to ensure the corrected image is entirely within the projection area without content truncation; third, the rectangle needs to maintain axis alignment, with its sides parallel to the horizontal or vertical axis; fourth, provided the aforementioned conditions are met, the rectangle's area should be as large as possible to maximize the effective display area and improve the utilization rate of the projected image. Therefore, this crucial step can essentially be summarized as solving a problem of finding the largest inscribed, proportionally aligned rectangle (a rectangle within a given graphic that satisfies a preset aspect ratio, has edges aligned with the coordinate axes, and has the largest area). The accuracy and efficiency of solving this problem directly affect the quality and real-time performance of trapezoidal correction, and it is one of the core technologies for achieving high-quality projection correction.
[0004] Currently, most methods for determining the maximum inscribed rectangle in projected trapezoidal correction rely on exhaustive search. For example, CN112689135A iterates through the longest side of the projected image and discrete points on its adjacent sides, using these points as potential rectangle vertices. Corresponding rectangles are then generated within the quadrilateral, and the largest area among all candidate rectangles is selected as the final result. A similar exhaustive approach is found in CN110336987A. Furthermore, CN108200417A proposes a fixed-vertex method. This method selects a reference vertex based on the pose and deflection direction of the projection unit and uses the geometric relationship between this vertex and other vertices or sides of the quadrilateral to construct equations, thereby obtaining the size of the maximum inscribed rectangle.
[0005] The exhaustive search method is computationally intensive and slow because it requires traversing all possible rectangle positions and sizes within the quadrilateral with a fixed step size. Furthermore, since the calculation result depends on the accuracy of the step size, it's difficult to balance accuracy and speed. Choosing a large step size cannot guarantee that the result is the largest inscribed rectangle in the strictest sense. Therefore, the exhaustive search method is unsuitable for applications with high real-time requirements, such as projectors. While the fixed vertex method is faster, it is typically only applicable when the projector has yaw or pitch angle shifts. When the projector rolls, all four vertices of the projected image rotate as a whole, making it impossible to stably select a reference vertex, thus rendering the fixed vertex method ineffective and failing to yield correct results.
[0006] To address the problems of high computational cost of existing exhaustive methods and the failure of fixed-vertex methods under complex poses, this invention proposes a projection trapezoidal correction method capable of rapidly solving for the maximum inscribed axis-aligned rectangle under arbitrary pose conditions. This method is not only computationally efficient but also independent of specific vertex assumptions, thereby improving the trapezoidal correction effect in projectors. Summary of the Invention
[0007] This invention aims to solve the problems of slow solution speed, small area, instability under complex attitude angle conditions, and difficulty in strictly satisfying geometric inscribed constraints in existing projection trapezoidal correction methods. It proposes an efficient projection trapezoidal correction method for solving the maximum inscribed axis aligned rectangle.
[0008] An efficient method for solving the projected trapezoidal correction of the largest inscribed axis-aligned rectangle includes:
[0009] Step 1: Obtain the coordinates of the four vertices of the distorted image generated by the projection, and determine the corresponding distorted quadrilateral;
[0010] Step 2: Calculate the equations of the inner half-planes of each side of the distorted image;
[0011] Step 3: Determine the vertex coordinates of the bounding box of the distorted image to provide a clear initial iteration region for the subsequent binary search rectangle center feasible region;
[0012] Step 4: Initialize the maximum and minimum scaling factors of the rectangle to be tested, providing clear upper and lower bounds for the subsequent binary search;
[0013] Step 5: Calculate the intermediate scaling factor based on the maximum and minimum scaling factors, and use the intermediate scaling factor as the scaling factor of the rectangle to be tested in each binary search to start the binary search process; calculate the maximum feasible scaling factor in the binary search so that the rectangle to be tested is completely inscribed in the distorted image and the area of the rectangle is maximized.
[0014] Step 6: Determine the feasible region of the center position of the rectangle to be measured;
[0015] Step 7: Determine whether a feasible region exists at the center position based on the number of coordinates in the point set of the feasible region at the center position of the rectangle to be tested;
[0016] Step 8: Based on the preset precision threshold, determine whether the maximum scaling factor and the minimum scaling factor have converged. If they have not converged, return to step 5 to continue iterating. If they have converged, exit the binary search.
[0017] Step 9: Determine the center coordinates of the rectangle to be measured. Based on the maximum feasible scaling factor and the unit width and unit height, calculate the width and height of the maximum inscribed axis aligned rectangle, and determine the coordinates of the four vertices of the maximum inscribed axis aligned rectangle.
[0018] Step 10: Map the distorted quadrilateral region corresponding to the distorted image into the maximum inscribed axis aligned rectangle to achieve the final geometric correction of the projected trapezoid.
[0019] Furthermore, the calculation process of the inner half-plane equation in step 2 further includes: defining the edge vectors of each side, calculating the inner normal vector of each side, and generating the inner half-plane formula for each side based on the inner normal vectors and the starting coordinates of each side. The inner half-plane formula represents the equation of the inner half-plane for any point. If the calculation result is greater than or equal to 0, then the point is in the half-plane, that is, inside the distorted quadrilateral; if it is less than 0, then the point is outside the half-plane, that is, outside the distorted quadrilateral.
[0020] Furthermore, the determination of the vertex coordinates of the bounding box of the distorted image in step 3 further includes: calculating the maximum and minimum values of the distorted image on the X-axis and Y-axis respectively based on the coordinates of the four vertices of the distorted image, and obtaining the coordinates of the four vertices of the bounding box based on the maximum and minimum values.
[0021] Furthermore, the initialization in step 4 further includes: defining the basic shape and scaling factor of the rectangle to be tested, determining the maximum scaling factor based on the bounding box range of the distorted image boundary and the aspect ratio of the target rectangle, so that the scaled rectangle to be tested can be completely contained within the bounding box, and setting the minimum scaling factor to 0.
[0022] Furthermore, the size of the rectangle to be measured is determined by a scaling factor S, with a width of... Gao Wei ,in and These are the unit width and unit height of the unit rectangle, respectively. It is the aspect ratio of the target rectangle, which is consistent with the preset display ratio.
[0023] Furthermore, the process of obtaining the feasible region in step 6 further includes: for any center coordinates of the rectangle to be tested, calculating the vertex coordinates of the rectangle to be tested based on the intermediate scaling factor and the unit half width and unit half height; inputting the vertex coordinates of the rectangle to be tested into the half-plane constraints of each side of the distorted image to generate constraints on the center coordinates of the rectangle to be tested; using the strictest constraint as the judgment condition, ensuring that all four vertices of the rectangle to be tested satisfy the inscribed constraint; based on the current constraint of the center of the rectangle to be tested, using the bounding box region of the distorted image in step 3 as the starting polygon, gradually reducing the region using polygon clipping processing, and calculating the feasible region of the center of the rectangle to be tested.
[0024] Furthermore, the polygon cropping process further includes taking the coordinates of two vertices of each edge of the bounding box of the distorted image or the polygon obtained by cropping in the previous step and substituting them into the current constraint of the center of the rectangle to be tested. Based on the positional relationship of the two vertices relative to the current constraint boundary line, different vertices or the intersection points of the current edge and the current constraint boundary line are retained to the feasible region point set, thereby generating the feasible region of the center of the rectangle to be tested at the current scaling factor.
[0025] Furthermore, the determination of whether the feasible region of the center position exists in step 7 further includes: if the point set is not empty, it indicates that there is a feasible center point of the rectangle under the current intermediate scaling factor, and the intermediate scaling factor is assigned to the minimum scaling factor and the maximum feasible scaling factor; if the point set is empty, it indicates that the vertex coordinates of the rectangle to be tested have exceeded the range of the distorted quadrilateral under the current scaling factor, and the intermediate scaling factor is assigned to the maximum scaling factor.
[0026] Furthermore, step 10 further includes: constructing the correspondence between the vertices of the distorted quadrilateral in step 1 and the vertices of the maximum inscribed axis aligned rectangle calculated in step 9; calculating the perspective transformation parameters describing the positional relationship between the distorted quadrilateral and the maximum inscribed axis aligned rectangle; performing remapping on the distorted image; and outputting the corrected image.
[0027] The present invention has the following beneficial effects:
[0028] 1. This invention transforms the traditional method of determining the inscribedness of a rectangle based on its four vertices into a problem of finding the feasible region based on the rectangle's center. It constructs constraints on the inner half-plane of a quadrilateral and uses a polygon trimming method to obtain the feasible region, then combines this with a binary search to determine the maximum rectangle size. This method avoids the large number of discrete samples required by exhaustive search and the resulting accuracy dependency, achieving higher solution efficiency and real-time performance.
[0029] 2. This method does not rely on the fixed vertex assumption and can be applied to complex distortion scenarios where the projector has arbitrary attitudes such as yaw angle, pitch angle and roll angle, and has stronger robustness and versatility. Attached Figure Description
[0030] Figure 1 This is a flowchart of the projection trapezoid correction process of the present invention;
[0031] Figure 2 This is a flowchart of the present invention that uses binary search to gradually approximate the maximum feasible scaling factor;
[0032] Figure 3 These are the four determination cases of the polygon clipping algorithm of this invention;
[0033] Figure 4 This refers to the deformation of the projection area of the present invention under different attitude angles and the calculated result of the maximum inscribed axis aligned rectangle;
[0034] Figure 5 This is a schematic diagram showing the trapezoidal distortion of the projected image when the projection device is not directly facing the projection surface.
[0035] Figure 6 This invention is for Figure 5 The image shows the result after trapezoidal correction of the distorted image. Detailed Implementation
[0036] When the projector is not directly facing the projection plane, trapezoidal distortion occurs in the projected image, resulting in an irregular convex quadrilateral shape. To obtain a corrected image with accurate proportions and complete content, an effective display area needs to be selected within the distorted quadrilateral, and the original image needs to be mapped onto this area. Typically, this effective display area should be the axis-aligned rectangle with the largest area within the distorted quadrilateral and the same output ratio as the projector. Given the problems in solving for the largest inscribed axis-aligned rectangle in existing projection trapezoidal correction methods, this invention proposes a new solution and correction process. First, this invention obtains the coordinates of the four vertices of the distorted image projected by the projector; then, using an efficient geometric solution method, a strictly inscribed axis-aligned rectangle with the largest area that satisfies a preset aspect ratio is determined within the distorted region; finally, the distorted image is mapped onto the area of this largest inscribed rectangle according to perspective transformation, thereby completing the projection trapezoidal correction. This implementation combines the precise solution of the largest inscribed rectangle with geometric correction operations, achieving fast, stable, and rigorous trapezoidal distortion correction under different orientation angles. To solve for the maximum inscribed axis-aligned rectangle, this invention employs the following technical approach: The inscribed constraint of the four vertices of the rectangle is equivalently transformed into solving for the feasible region of the rectangle's center. Specifically, by constructing inner half-plane constraints corresponding to each side of the quadrilateral, the allowed area at the rectangle's center is limited, and the feasible region at the center is obtained using a polygon clipping method. Based on this, a binary search is used to progressively adjust the rectangle's scaling factor, determining whether the feasible region is empty, thereby approximating the size of the maximum inscribed rectangle that satisfies the aspect ratio constraint. This solution approach ensures the strictness of the geometric constraints and significantly improves the solution efficiency and stability.
[0037] The main steps of this invention can be summarized as follows: obtaining the coordinates of the four vertices of the distorted image generated by projection, determining the distorted quadrilateral corresponding to the distorted image; calculating the equations of the inner half-planes of each side of the distorted image; determining the vertex coordinates of the bounding box of the distorted image; initializing the maximum and minimum scaling factors of the rectangle to be tested; calculating the intermediate scaling factor of the rectangle to be tested; obtaining the feasible region of the center position of the rectangle to be tested; determining whether the feasible region of the center position exists; determining whether the maximum and minimum scaling factors have converged; outputting the vertex coordinates of the largest inscribed axis-aligned rectangle; and finally mapping the distorted image to the target rectangle. The steps from "calculating the intermediate scaling factor of the rectangle to be tested" to "determining whether the maximum and minimum scaling factors have converged" constitute an iterative process of binary search. The following is combined with... Figure 1 and Figure 2 Each step is explained in detail.
[0038] Step 1: Obtain the coordinates of the four vertices of the distorted image generated by the projection, and determine the distorted quadrilateral corresponding to the distorted image.
[0039] When the projector yaws, tilts, or rolls, the effective display area projected onto the screen or wall is no longer a regular rectangle, but rather a convex quadrilateral. For example... Figure 5 This demonstrates that when the projector's pitch angle is shifted downwards, the projected image becomes a distorted trapezoid. To accurately model this distorted region geometrically, it is first necessary to obtain the coordinates of the four vertices of the distorted image on the display plane. This invention can obtain the positions of the four vertices in various ways depending on different system hardware configurations, including but not limited to the following methods:
[0040] A calculation method based on a six-axis attitude sensor: Projectors often integrate a six-axis IMU (accelerometer and gyroscope) to acquire the projector's spatial attitude information (yaw angle, pitch angle, roll angle) in real time. Combining the known projection optical path model and the projector's imaging geometry parameters, the coordinates of the four vertices on the projection plane can be calculated based on the attitude angles, achieving vertex localization without the need for additional camera equipment.
[0041] Image detection method based on camera: If the projector is equipped with a camera, the four vertices of the projection boundary can be directly extracted from the image through image detection. This method can employ various image processing algorithms such as edge detection, corner detection, and checkerboard reflection calibration to obtain the accurate coordinates of the distorted quadrilateral. Any of the above methods can be used to obtain the coordinates of the four vertices of the distorted image. This invention does not limit the specific acquisition method, as long as it ensures that the coordinates of the four vertices of the distorted image can be obtained, providing the basic input for subsequent construction of the inner half-plane equation and solution of the rectangle aligned with the maximum inscribed axis.
[0042] Step 2: Calculate the equations of the inner half-planes of each side of the distorted image.
[0043] In step 1, the coordinates of the four vertices of the distorted image were obtained. The distorted image is a quadrilateral, and we need to calculate the equation of the inner half-plane for each side of this quadrilateral. The calculation process for the inner half-plane equation is as follows:
[0044] Step 2.1, Define edge vectors: for each edge edge vectors Determined by its adjacent vertices, where:
[0045]
[0046] It uses the modulo operation to perform a loop traversal of vertices.
[0047] Step 2.2, Calculate the inner normal vector: (This refers to the boundary vectors...) Rotate 90° to obtain the inner normal vector of this edge:
[0048]
[0049] It is a boundary vector The components in a two-dimensional coordinate system correspond to the projection values of the edge vectors in the x-axis and y-axis directions.
[0050] Step 2.3: Determine the formula for the inner half-plane: based on the inner normal vector. and the starting coordinates of each edge The formula for the inner half-plane of each edge is calculated as follows:
[0051]
[0052] in
[0053] This formula for the inner half-plane means that for any point... If the calculation result is greater than or equal to 0, then the point is in the half-plane, that is, inside the quadrilateral of the distorted image; if it is less than 0, then the point is outside the half-plane, that is, outside the quadrilateral of the distorted image.
[0054] Step 3: Determine the vertex coordinates of the bounding box of the distorted image to provide a clear initial iteration region for the subsequent binary search rectangle center feasible region.
[0055] Given the coordinates of the four vertices of the distorted image Calculate the maximum and minimum values of the distorted image on the X and Y axes respectively:
[0056]
[0057]
[0058]
[0059]
[0060] Then, based on these maximum and minimum values, the coordinates of the four vertices of the bounding box are obtained.
[0061]
[0062]
[0063] Step 4: Initialize the maximum and minimum scaling factors of the rectangle to be tested.
[0064] Initialize scaling factor Maximum scaling factor and minimum scaling factor This provides a clear upper and lower bound for subsequent binary search.
[0065] Step 4.1, Define the basic shape and scaling factor: The aspect ratio of the target rectangle is consistent with the preset display ratio, denoted as . .make and These are respectively used as the unit width and unit height of the unit rectangle. During the binary search process, this invention defines a variable test object, namely the rectangle to be tested. The size of this rectangle is determined by a scaling factor. Decision. Its actual width is The actual height is .
[0066] Step 4.2: Determine the maximum scaling factor The maximum scaling factor is the bounding box range of the distorted image calculated in step 3. and The scaling factor is determined by both the aspect ratio of the target rectangle and the scaling factor of the target rectangle. It takes the smaller of the maximum possible scaling factors in the two axes to ensure that the scaled rectangle can be completely contained within the bounding box.
[0067]
[0068] Step 4.3: Determine the minimum scaling factor Minimum scaling factor It is usually set to 0.
[0069] Step 5: Calculate the intermediate scaling factor of the scaling factor of the rectangle to be tested.
[0070] Based on maximum scaling factor and minimum scaling factor Calculate the intermediate scaling factor And use it as the scaling factor of the rectangle to be tested in each binary search. This process is the initial step of a binary search. The goal of a binary search is to find the answer within the interval [missing information]. and In this process, it continuously tests whether the rectangle to be tested, determined by the current scaling factor, can be completely inscribed within the distorted image, thereby gradually approximating the scaling factor that maximizes the area of the rectangle while satisfying inscription. The final scaling factor obtained is the maximum feasible scaling factor. .
[0071] Step 6: Determine the feasible region of the center position of the rectangle to be tested.
[0072] The feasible region is the set of variable values that satisfy all constraints in an optimization problem.
[0073] Step 6.1: Calculate the vertex coordinates of the rectangle to be measured: In step 5 above, the intermediate scaling factor has already been calculated. Let the center coordinates of any rectangle to be measured be... unit half width for half height per unit for Therefore, the coordinates of the four vertices of the scaled rectangle to be measured can be represented as:
[0074] ,
[0075] ,
[0076] ,
[0077]
[0078] Step 6.2, Transformation Constraints: To ensure that the rectangle under the current scaling factor is completely inscribed within the distorted image, the coordinates of all four vertices of the rectangle under the measurement must satisfy all the inner half-plane constraint formulas of the distorted image. However, due to the center coordinates of the rectangle to be measured... The center position can be any value. If we directly calculate each of the four vertices for different center positions and verify each point to see if all constraints are satisfied, it will inevitably lead to a discretized exhaustive search for the center position. This point-based determination is discrete and verifies each point individually, making it difficult to directly determine a continuous solution space. Therefore, the computational cost is not significantly different from other exhaustive search methods. This invention, through algebraic derivation, transforms the constraints for the four vertices into a set of linear inequalities for the center of the rectangle. These inequalities enclose a closed polygonal region, namely the "feasible region of the center position." By solving this feasible region, the algorithm no longer needs to try different center coordinates. Instead of using a predefined rectangle for testing, this algorithm directly determines the set of all feasible solutions in one go through a polygon clipping algorithm. As long as this feasible region exists (the point set is not empty), it means that a rectangle for testing exists that satisfies the current conditions. This significantly reduces computational complexity and improves solution speed.
[0079] Specifically, the coordinates of the vertices of the rectangle to be measured are substituted into the half-plane constraint formula for each side of the distorted image. (in (Representing four sides), after unfolding, the center of the rectangle to be tested can be obtained. Constraint inequalities:
[0080]
[0081]
[0082]
[0083]
[0084] in: , represents a set of four sets (four sides) of half-plane constraint formulas, each set of formulas containing four constraint inequalities for the vertices of the rectangle.
[0085] In each set of formulas, the four inequalities, due to and Appearing at the four vertices in the form of ± signs, the right-hand side terms of these four inequalities will take four different values; among them It is the largest (and most stringent) constraint among the four cases. Therefore, by judging this most stringent condition, we can ensure that all four vertices satisfy the inline constraint at the same time, without having to judge them one by one, thus improving the calculation speed.
[0086] Step 6.3, Calculation and trimming of feasible region: After obtaining the center of the rectangle to be measured... After determining the constraint equations, the initial bounding box region (i.e., the "distorted image boundary bounding box" in step 3) can be used as the starting polygon, and the region can be gradually reduced using a polygon clipping algorithm to find the feasible region of the center of the rectangle to be measured. The clipping method used in this scheme draws on the idea of the Sutherland-Hodgman polygon clipping algorithm.
[0087] It should be noted that each equation constraining the center of the rectangle to be measured corresponds to a half-plane inequality, and its equality part... A straight line is drawn on the plane, which becomes the current constraint boundary line. This boundary line divides the plane into regions that satisfy the constraints (inside the half-plane) and regions that do not satisfy the constraints (outside the half-plane), and is used to trim the feasible region of the current polygon.
[0088] In practice, for each edge of the initial bounding box or the polygon obtained from the previous clipping step, take the coordinates of its two vertices A and B and substitute them into the center constraint equation of the current rectangle to be measured. If The calculation result is greater than or equal to If the result is less than 0, it means the corresponding vertex is inside the half-plane; if the calculated result is less than 0, it means the vertex is inside the half-plane. If , it means that the vertex is outside the half-plane.
[0089] like Figure 3 As shown, based on the positional relationship between two vertices A and B relative to the current constraint boundary line, polygon clipping can be divided into four cases. In each case, different vertices or boundaries will be retained, and the intersection points of these vertices or boundaries with the current constraint boundary line will be preserved to the feasible region point set. middle:
[0090] (1) Both A and B are in the half-plane: keep vertex B.
[0091] (2) A is in the half-plane and B is not: calculate the intersection point I of edge AB and the current constraint boundary line, and only retain the intersection point I.
[0092] (3) A is outside the half-plane and B is inside the half-plane: calculate the intersection point I, and keep the intersection point I and vertex B.
[0093] (4) Neither A nor B is in the half-plane: No points are retained.
[0094] By applying the clipping rules to each edge of the initial bounding box region in sequence, the clipped polygon point set is finally obtained. This is the current scaling factor. The feasible region of the center of the rectangle to be tested is determined. This method strictly guarantees that the polygonal region formed by the center of the rectangle to be tested satisfies all half-plane constraints, thereby ensuring that all corresponding rectangle vertices are located inside the distorted image.
[0095] Step 7: Determine if a feasible region exists at the center location.
[0096] After obtaining the point set F of the feasible region at the center of the rectangle to be tested, it is necessary to determine the number of coordinates in the point set.
[0097] If the point set is not empty: This indicates that at the current intermediate scaling factor... Below, there exists a feasible center point for the rectangle, therefore the current size is reachable. At this point, the intermediate scaling factor is assigned to the minimum scaling factor. Meanwhile, let the maximum feasible scaling factor be ;
[0098] If the point set is empty: this proves the current scaling factor is... The value is too large, causing the vertex coordinates of the rectangle being tested to exceed the range of the distorted quadrilateral corresponding to the distorted image. In this case, the intermediate scaling factor is assigned to the maximum scaling factor. .
[0099] Step 8: Determine whether the maximum and minimum scaling factors have converged.
[0100] This step is used to determine whether the binary search has converged, and it is the termination condition for the entire binary search process. As described in step 5, each iteration reduces the range of values for the scaling factor by half, making the maximum scaling factor... With minimum scaling factor The difference between them gradually approaches the optimal solution. Specifically, if... and The difference is still large (e.g., greater than the preset precision threshold). If the difference is small enough (e.g., ...), then jump back to the initial step of the binary search (step 5) and continue iterating. If the result is 0, then the binary search process is considered to have converged and the process is exited.
[0101] Step 9: Output the coordinates of the four vertices of the largest inscribed axis-aligned rectangle.
[0102] After exiting the binary search, To obtain the maximum feasible scaling factor, this step will be based on the maximum feasible scaling factor and the unit width. and unit high To obtain the coordinates of the four vertices of the target rectangle.
[0103] Step 9.1: Determine the coordinates of the center of the rectangle to be measured: First, it is necessary to determine the coordinates of the point set of the feasible region of the center of the rectangle to be measured. To calculate the center coordinates You can choose any point in the set of points as the center coordinates.
[0104] Step 9.2: Calculate the target rectangle size: based on the maximum feasible scaling factor. Given the unit dimensions, calculate the width of the final target rectangle. and high :
[0105]
[0106]
[0107] Step 9.3: Output the coordinates of the four vertices of the target rectangle: based on the center coordinates. 、and width ,high The four vertices of the target rectangle can be calculated using the following formula:
[0108] ,
[0109] ,
[0110] ,
[0111]
[0112] like Figure 4 As shown, the deformation of the projection area under different attitude angles and the result of the maximum inner axis aligned rectangle (target rectangle) calculated by the present invention are shown. Among them, (1) the pitch angle deflects, (2) the yaw angle shifts, (3) the roll angle shifts, and (4) all three angles shift.
[0113] Step 10: Map the distorted image onto the target region.
[0114] In step 9, the coordinates of the four vertices of the maximum inscribed axis aligned rectangle (target region) have been determined. This step uses these four vertex coordinates to map the quadrilateral region in the distorted image into the target rectangle, achieving the final geometric correction. Specifically, step 10 includes the following processing:
[0115] Step 10.1: Establish the correspondence between the source region and the target region. Use the four vertices of the distorted quadrilateral obtained in Step 1 as the vertices of the "source region," and the four vertices of the rectangle with the largest inscribed axis aligned to the target region calculated in Step 9 as the vertices of the "target region." Construct a one-to-one mapping relationship between the four points for subsequent geometric transformation calculations.
[0116] Step 10.2: Determine the perspective transformation relationship from the source region to the target region. Based on the four-point correspondence established in Step 10.1, calculate the perspective transformation parameters describing the positional relationship between the source quadrilateral and the target rectangle. This matrix can be obtained through existing perspective transformation solving methods, and this invention is not limited to it.
[0117] Step 10.3: Perform remapping on the distorted image. Using the perspective transformation matrix obtained in Step 10.2, reproject all pixels in the distorted image that fall within the source quadrilateral region to the target rectangle position. This process can be accomplished using existing image resampling methods (such as nearest neighbor interpolation, bilinear interpolation, etc.) to calculate the pixel value of the corrected image.
[0118] Step 10.4: Output the corrected image. After remapping, the image content is strictly mapped to the target rectangular area, maintaining the original aspect ratio and maximizing the display area, thus completing the entire projection keystone correction process. For example... Figure 6 As shown, this invention demonstrates... Figure 5 The image shown is the result of trapezoidal correction after correcting the distorted image.
[0119] This invention proposes a computationally efficient projection trapezoidal correction scheme that can quickly solve for the maximum inscribed rectangle under complex projection distortion conditions, significantly improving the real-time performance and stability of image correction. Traditional trapezoidal correction methods typically use an exhaustive search to find the maximum inscribed rectangle, the computational load of which depends on the sampling point density. For example, in common implementations, if 300 points are sampled in the horizontal and 300 points in the vertical directions respectively, approximately 300 × 300 = 90,000 inscribed rectangle checks are required, resulting in a massive computational load and accuracy limited by the sampling resolution, making it difficult to meet real-time processing requirements. In contrast, this invention requires only a maximum of 40 binary search operations, with each binary search requiring only 4 inscribed rectangle checks, totaling approximately 160 inscribed rectangle checks to converge to the global optimum. Compared to the exhaustive search method, this scheme can improve speed by approximately [missing information]. The speed is increased by a factor of 1 (depending on the specific implementation and parameter settings), significantly enhancing the real-time performance of the system. It is evident that this invention's method for efficiently solving for the maximum inscribed axis-aligned rectangle avoids the massive computational load and accuracy dependency issues of the exhaustive method, greatly improving computational speed and real-time performance, and effectively eliminating trapezoidal distortion during projection. Furthermore, this scheme does not rely on the "fixed vertex" assumption and can be applied to complex distortion scenarios caused by arbitrary projector attitudes such as yaw, pitch, and roll angles, demonstrating good robustness and versatility across various projection environments.
Claims
1. An efficient method for solving the projected trapezoidal correction of the largest inscribed axis-aligned rectangle, comprising: Step 1: Obtain the coordinates of the four vertices of the distorted image generated by the projection, and determine the corresponding distorted quadrilateral; Step 2: Calculate the equations of the inner half-planes of each side of the distorted image; Step 3: Determine the vertex coordinates of the bounding box of the distorted image to provide a clear initial iteration region for the subsequent binary search rectangle center feasible region; Step 4: Initialize the maximum and minimum scaling factors of the rectangle to be tested, providing clear upper and lower bounds for the subsequent binary search; Step 5: Calculate the intermediate scaling factor based on the maximum and minimum scaling factors, and use the intermediate scaling factor as the scaling factor of the rectangle to be tested in each binary search to start the binary search process; calculate the maximum feasible scaling factor in the binary search so that the rectangle to be tested is completely inscribed in the distorted image and the area of the rectangle is maximized. Step 6: Determine the feasible region of the center position of the rectangle to be measured; Step 7: Determine whether a feasible region exists at the center position based on the number of coordinates in the point set of the feasible region at the center position of the rectangle to be tested; Step 8: Based on the preset precision threshold, determine whether the maximum scaling factor and the minimum scaling factor have converged. If they have not converged, return to step 5 to continue iterating. If they have converged, exit the binary search. Step 9: Determine the center coordinates of the rectangle to be measured. Based on the maximum feasible scaling factor and the unit width and unit height, calculate the width and height of the maximum inscribed axis aligned rectangle, and determine the coordinates of the four vertices of the maximum inscribed axis aligned rectangle. Step 10: Map the distorted quadrilateral region corresponding to the distorted image into the maximum inscribed axis aligned rectangle to achieve the final geometric correction of the projected trapezoid.
2. The efficient method for solving the projected trapezoidal correction of the largest inscribed axis-aligned rectangle as described in claim 1, wherein the calculation process of the inner half-plane equation in step 2 further includes: Define the edge vectors for each edge, calculate the inner normal vector for each edge, and generate the inner half-plane formula for each edge based on the inner normal vectors and the starting coordinates of each edge. The inner half-plane formula represents the expression for any point... If the calculation result is greater than or equal to 0, then the point is in the half-plane, that is, inside the distorted quadrilateral; if it is less than 0, then the point is outside the half-plane, that is, outside the distorted quadrilateral.
3. The efficient method for solving the projection trapezoidal correction of the largest inscribed axis-aligned rectangle as described in claim 1, wherein step 3, determining the vertex coordinates of the bounding box of the distorted image, further includes: Based on the coordinates of the four vertices of the distorted image, calculate the maximum and minimum values of the distorted image on the X and Y axes respectively, and obtain the coordinates of the four vertices of the bounding box based on the maximum and minimum values.
4. The efficient method for solving the projected trapezoidal correction of the maximum inscribed axis aligned rectangle as described in claim 1, wherein the initialization in step 4 further includes: Define the basic shape and scaling factor of the rectangle to be tested. Determine the maximum scaling factor based on the bounding box range of the distorted image and the aspect ratio of the target rectangle, so that the scaled rectangle to be tested can be completely contained within the bounding box. Set the minimum scaling factor to 0.
5. The efficient method for calculating the projected trapezoidal correction of the largest inscribed axis-aligned rectangle as described in claim 4, wherein the size of the rectangle to be measured is determined by a scaling factor S, and the width is... Gao Wei ,in and These are the unit width and unit height of the unit rectangle, respectively. It is the aspect ratio of the target rectangle, which is consistent with the preset display ratio.
6. The efficient method for solving the projected trapezoidal correction of the largest inscribed axis-aligned rectangle as described in claim 1, wherein the process of obtaining the feasible region in step 6 further includes: For any center coordinate of the rectangle to be tested, the vertex coordinates of the rectangle to be tested are calculated based on the intermediate scaling factor and the unit half width and unit half height. The vertex coordinates of the rectangle to be tested are input into the half-plane constraints of each side of the distorted image to generate constraints on the center coordinates of the rectangle to be tested. The strictest constraint is used as the judgment condition, so that all four vertices of the rectangle to be tested satisfy the inscribed constraint. Based on the current constraint of the center of the rectangle to be tested, the bounding box region of the distorted image in step 3 is used as the starting polygon. The region is gradually reduced by using polygon clipping processing to calculate the feasible region of the center of the rectangle to be tested.
7. The efficient method for solving the projection trapezoidal correction of the largest inscribed axis aligned rectangle as described in claim 6, wherein the polygon clipping process further includes, for each edge of the bounding box of the distorted image or the polygon obtained by clipping in the previous step, taking the coordinates of its two vertices and substituting them into the current constraint of the center of the rectangle to be measured, and according to the positional relationship of the two vertices relative to the current constraint boundary line, retaining different vertices or the intersection points of the current edge and the current constraint boundary line into the feasible region point set, and generating the feasible region of the center of the rectangle to be measured under the current scaling factor.
8. The efficient method for solving the projection trapezoidal correction of the largest inscribed axis aligned rectangle as described in claim 1, wherein the determination of whether the feasible region of the center position exists in step 7 further includes: if the point set is not empty, it indicates that there is a feasible center point of the rectangle under the current intermediate scaling factor, and the intermediate scaling factor is assigned to the minimum scaling factor and the maximum feasible scaling factor; if the point set is empty, it indicates that the vertex coordinates of the rectangle to be tested have exceeded the range of the distorted quadrilateral under the current scaling factor, and the intermediate scaling factor is assigned to the maximum scaling factor.
9. The efficient method for solving the projected trapezoidal correction of the largest inscribed axis-aligned rectangle as described in claim 1, wherein step 10 further includes: Construct the correspondence between the vertices of the distorted quadrilateral in step 1 and the vertices of the maximum inscribed axis-aligned rectangle calculated in step 9. Calculate the perspective transformation parameters that describe the positional relationship between the distorted quadrilateral and the maximum inscribed axis-aligned rectangle. Perform remapping on the distorted image and output the corrected image.
Citation Information
Patent Citations
Method for obtaining maximum rectangular projection image in projection unit trapezoidal correction
CN108200417A
Projector distortion correction method and device and projector
CN110336987A
Projection correction method and device, storage medium and electronic equipment
CN112689135A