A method and terminal for trapezoidal correction

The projector's chessboard image and yaw angle are obtained through the camera and Tof camera, and the yaw angle between the projection plane and the projector is calculated, which solves the complexity of rectangular screen adjustment when the projector is not front projection and the simplicity of the correction angle acquisition of the smart projector. solve the problem and achieve efficient keystone correction.

CN118400503BActive Publication Date: 2024-10-15FUJIAN ELECTRONICS INFORMATION TECH CO LTD SONG AIRLINES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410841459.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-15
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

Existing projectors need to manually adjust their posture and position to achieve a rectangular screen when projecting from a non-frontal perspective, which is complex and inconvenient to operate. Moreover, the keystone correction method of smart projectors is single to obtain angles, which affects the success rate.

Method used

Use the camera to capture the chessboard image of the projector, judge the image integrity, obtain the world coordinates of the target symmetry point and light point, calculate the yaw angle, and use the Tof camera to obtain the distance, segment the chessboard image into matrix areas, and calculate the distance between the projection plane and the projector. yaw angle between them to perform image correction.

Benefits of technology

It improves the success rate and accuracy of trapezoidal correction, simplifies the calculation process, and adapts to the correction needs of different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118400503B_ABST
    Figure CN118400503B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and terminal for trapezoidal correction, wherein a first chessboard image projected by a projector is photographed by a camera to obtain a second chessboard image; whether the second chessboard image is complete is determined, and if so, symmetrical corner points are obtained as target symmetrical point pairs, and the first world coordinates of the target symmetrical point pairs and the second world coordinates of the light point of the projector are obtained; the yaw angle between the projection plane and the projector orientation is calculated according to the first world coordinates and the second world coordinates; otherwise, the distance from the light point to the left and right sides of the second chessboard image is obtained, and the yaw angle between the projection plane and the projector orientation is calculated according to the distance and the second world coordinates; an image correction form is obtained according to the yaw angle, and the image to be projected is corrected according to the image correction form before projection. The present invention can simplify the calculation process by constructing a geometric relationship between the projector and the projection plane, improve the efficiency of calibration during trapezoidal correction, and achieve low-latency trapezoidal correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of projection correction, and in particular to a trapezoidal correction method and a terminal. Background Art

[0002] When the projector is not projecting frontally, the projection area appears as an irregular quadrilateral. It is necessary to manually adjust the placement and position of the projector so that the optical axis of the projector lens is as perpendicular to the projection plane as possible to present a normal rectangular image. Alternatively, the coordinates of the four vertices of the image can be manually adjusted to achieve image distortion so that the image on the projection plane appears rectangular. Manually adjusting the placement and position of the projector is limited by the viewing angle and scene, is not convenient, and has poor effects. Manually adjusting the coordinates of the four vertices of the image is complex to operate, has a high learning cost for users, and is not easy to use.

[0003] Almost all existing smart projectors have an automatic keystone correction function. Keystone correction requires obtaining the angle between the projector and the projection plane (wall, screen). The existing solutions have a single way of obtaining the angle, which affects the success rate of keystone correction. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a trapezoidal correction method to achieve efficient trapezoidal correction.

[0005] In order to solve the above technical problems, a technical solution adopted by the present invention is:

[0006] A method for trapezoidal correction, comprising the steps of:

[0007] The second chessboard image is obtained by photographing the first chessboard image projected by the projector through a camera;

[0008] Determine whether the second chessboard image is complete, and if so, obtain symmetrical corner points as target symmetrical point pairs, and obtain the first world coordinates of the target symmetrical point pairs and the second world coordinates of the light point of the projector; calculate the yaw angle between the projection plane and the direction of the projector according to the first world coordinates and the second world coordinates;

[0009] Otherwise, obtaining the distance from the light spot to the left and right sides of the second chessboard image, and calculating the yaw angle between the projection plane and the direction of the projector according to the distance and the second world coordinate;

[0010] Acquire an image correction formula according to the yaw angle, and correct the image to be projected according to the image correction formula and then project it;

[0011] The obtaining of the distance from the light spot to the left and right sides of the second chessboard image comprises:

[0012] Taking regions of interest of the same size on the symmetrical left and right sides of the second chessboard image respectively;

[0013] Turning on the Tof function of the Tof camera, and obtaining the distances from the light spot to the left and right sides of the second chessboard image according to the region of interest;

[0014] The regions of interest having the same size on the left and right sides of the symmetrical second chessboard image include:

[0015] dividing the second chessboard image into regions of a preset matrix size;

[0016] Get the number of matrices corresponding to the preset area size;

[0017] The regions which are symmetrical on the left and right sides and whose number is the number of the matrices are respectively acquired as regions of interest.

[0018] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0019] A terminal for trapezoidal correction includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0020] The second chessboard image is obtained by photographing the first chessboard image projected by the projector through a camera;

[0021] Determine whether the second chessboard image is complete, and if so, obtain symmetrical corner points as target symmetrical point pairs, and obtain the first world coordinates of the target symmetrical point pairs and the second world coordinates of the light point of the projector; calculate the yaw angle between the projection plane and the direction of the projector according to the first world coordinates and the second world coordinates;

[0022] Otherwise, obtaining the distance from the light spot to the left and right sides of the second chessboard image, and calculating the yaw angle between the projection plane and the direction of the projector according to the distance and the second world coordinate;

[0023] Acquire an image correction formula according to the yaw angle, and correct the image to be projected according to the image correction formula and then project it;

[0024] The obtaining of the distance from the light spot to the left and right sides of the second chessboard image comprises:

[0025] Taking regions of interest of the same size on the symmetrical left and right sides of the second chessboard image respectively;

[0026] Turning on the Tof function of the Tof camera, and obtaining the distances from the light spot to the left and right sides of the second chessboard image according to the region of interest;

[0027] The regions of interest having the same size on the left and right sides of the symmetrical second chessboard image include:

[0028] dividing the second chessboard image into regions of a preset matrix size;

[0029] Get the number of matrices corresponding to the preset area size;

[0030] The regions which are symmetrical on the left and right sides and whose number is the number of the matrices are respectively acquired as regions of interest.

[0031] The beneficial effects of the present invention are as follows: a chessboard image projected by a projector is photographed by a camera, and a target symmetric point on a second chessboard image is selected, and the yaw angle is calculated by placing both the target symmetric point and the projector light spot in a world coordinate system to obtain the first world coordinate of the target symmetric point and the second world coordinate of the projector light spot, or the yaw angle is calculated by obtaining the distance from the second world coordinate of the projector light spot to the left and right ends of the chessboard image, and the angle between the projector and the wall is calculated, so that the calculation process can be simplified by constructing a geometric relationship between the projector and the projection plane in a unified coordinate system, and the yaw angle can be calculated by obtaining the target symmetric point. The heading angle is improved, thereby improving the success rate of calibration during the trapezoidal correction process. The same left and right regions of interest are set to obtain the distance, which ensures that the possible independent variables on the left and right sides are as similar as possible when estimating the distance, thereby improving the accuracy of the final estimated yaw angle; the second chessboard image is divided into regions of the same size. For example, each chessboard grid in the second chessboard image can be directly used as a region, and the same number of regions symmetrical on the left and right sides are taken as regions of interest for calculation according to the preset region size. The symmetry of the region of interest in size and position is ensured by unitizing the area size, thereby improving the accuracy of subsequent calculation results. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flowchart of a method for trapezoidal correction according to an embodiment of the present invention;

[0033] Figure 2 Schematic diagram of the optical axis convergence model;

[0034] Figure 3 A schematic diagram of a geometric model associated with a yaw angle constructed for an embodiment of the present invention;

[0035] Figure 4 Schematic diagram of the ROI region of Tof according to an embodiment of the present invention;

[0036] Figure 5 A calibration diagram of an embodiment of the present invention;

[0037] Figure 6Another schematic flow chart of a method for trapezoidal correction according to an embodiment of the present invention;

[0038] Figure 7 A schematic diagram of the structure of a terminal for trapezoidal correction according to an embodiment of the present invention;

[0039] Description of labels:

[0040] 1. A terminal for trapezoidal correction; 2. A processor; 3. A memory. DETAILED DESCRIPTION

[0041] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0042] Please refer to Figure 1 , a shape correction method, comprising the steps of:

[0043] The second chessboard image is obtained by photographing the first chessboard image projected by the projector through a camera;

[0044] Determine whether the second chessboard image is complete, and if so, obtain symmetrical corner points as target symmetrical point pairs, and obtain the first world coordinates of the target symmetrical point pairs and the second world coordinates of the light point of the projector; calculate the yaw angle between the projection plane and the direction of the projector according to the first world coordinates and the second world coordinates;

[0045] Otherwise, obtaining the distance from the light spot to the left and right sides of the second chessboard image, and calculating the yaw angle between the projection plane and the direction of the projector according to the distance and the second world coordinate;

[0046] Acquire an image correction formula according to the yaw angle, and correct the image to be projected according to the image correction formula and then project it;

[0047] The obtaining of the distance from the light spot to the left and right sides of the second chessboard image comprises:

[0048] Taking regions of interest of the same size on the symmetrical left and right sides of the second chessboard image respectively;

[0049] Turning on the Tof function of the Tof camera, and obtaining the distances from the light spot to the left and right sides of the second chessboard image according to the region of interest;

[0050] The regions of interest having the same size on the left and right sides of the symmetrical second chessboard image include:

[0051] dividing the second chessboard image into regions of a preset matrix size;

[0052] Get the number of matrices corresponding to the preset area size;

[0053] The regions which are symmetrical on the left and right sides and whose number is the number of the matrices are respectively acquired as regions of interest.

[0054] From the above description, it can be seen that the beneficial effects of the present invention are: the chessboard image projected by the projector is photographed by a camera, and the target symmetry point on the second chessboard image is selected, and the yaw angle is calculated by placing the target symmetry point and the projector light spot in the world coordinate system to obtain the first world coordinate of the target symmetry point and the second world coordinate of the projector light spot, or the yaw angle is calculated by obtaining the distance from the second world coordinate of the projector light spot to the left and right ends of the chessboard image, and the angle between the projector and the wall is calculated, so that the calculation process can be simplified by constructing the geometric relationship between the projector and the projection plane in a unified coordinate system, and the target symmetry point can be obtained by obtaining the yaw angle. The yaw angle is calculated, thereby improving the success rate of calibration during the trapezoidal correction process, and the same left and right regions of interest are set to obtain the distance, thereby ensuring that the possible independent variables on the left and right sides are as similar as possible when estimating the distance, thereby improving the accuracy of the final estimated yaw angle; the second chessboard image is divided into regions of the same size, for example, each chessboard grid in the second chessboard image can be directly used as a region, and the same number of regions symmetrical on the left and right sides are taken as regions of interest for calculation according to the preset region size, and the symmetry of the region of interest in size and position is ensured by unitizing the area size, thereby improving the accuracy of subsequent calculation results.

[0055] Further, obtaining the first world coordinates of the target symmetric point pair includes:

[0056] Acquire coordinates of a first symmetrical point pair of a target symmetrical point pair in the first chessboard image;

[0057] Obtaining a calibration matrix between the camera and the projector and a conversion formula between a world coordinate system and a pixel coordinate system;

[0058] Acquire the coordinates of the second symmetric point pair of the target symmetric point pair in the second chessboard image according to the coordinates of the first symmetric point pair and the calibration matrix;

[0059] The first world coordinates of the target symmetrical point pair are calculated according to the coordinates of the second symmetrical point pair and the conversion formula.

[0060] From the above description, it can be seen that since the coordinate systems of the first chessboard image projected by the projector and the second chessboard image taken by the camera are different, in order to obtain the first world coordinates of the target symmetric point pair, it is necessary to calibrate the camera and the projector, establish a mapping relationship between the first chessboard image and the second chessboard image, and then convert them to the world coordinate system, so as to unify the calculation of each coordinate system, eliminate the errors between different coordinate systems, and ensure the accuracy of the calculation results.

[0061] Further, the calculating the yaw angle between the projection plane and the projector orientation according to the first world coordinate and the second world coordinate comprises:

[0062] Calculate the angle between the target symmetrical point pair and the light spot, and the distance from each symmetrical point in the target symmetrical point pair to the light spot according to the first world coordinate and the second world coordinate, marked as a first distance and a second distance;

[0063] Calculate the third distance between the symmetrical points by using a trigonometric function according to the included angle, the first distance and the second distance;

[0064] The yaw angle between the projection plane and the projector orientation is calculated by trigonometric function according to the included angle, the first distance, the second distance and the third distance.

[0065] From the above description, it can be seen that by constructing the geometric relationship between the target symmetrical point pair and the light spot, the calculation method of the yaw angle can be obtained with the help of geometric auxiliary lines. By first calculating the distance between the two symmetrical points and then calculating the yaw angle with the help of the relationship between trigonometric functions and angles, the calculation process and the required parameters are simplified.

[0066] Further, calculating the third distance between the symmetrical points by using a trigonometric function according to the included angle, the first distance, and the second distance includes:

[0067] d= ;

[0068] Wherein, d represents the third distance, D1 represents the first distance, D2 represents the second distance, and α represents the angle.

[0069] From the above description, it can be seen that with the help of the cosine theorem, a triangle is constructed based on existing known quantities, so that the third side, that is, the third distance between the symmetric points, can be calculated when two sides and one angle are known. The calculation process is convenient because it is an existing formula and can be easily implemented directly through existing software, which also improves the convenience of implementing the solution.

[0070] Further, the calculating the yaw angle between the projection plane and the projector orientation by trigonometric function according to the included angle, the first distance, the second distance and the third distance comprises:

[0071] cos(θ')=(D2-D1×cos(2α)) / d;

[0072] θ = θ' + α;

[0073] Yaw = 90°-θ;

[0074] Among them, θ' represents the angle between the projection plane and the line from the symmetric point to the light spot; θ represents the complementary angle of the yaw angle; Yaw represents the yaw angle; d represents the third distance, D1 represents the first distance, D2 represents the second distance, and α represents the angle.

[0075] From the above description, it can be seen that after constructing the geometric relationship, the yaw angle is calculated through the correspondence between the angles. There is no need to directly obtain the relevant parameters required for calculating the yaw angle. Instead, the calculated yaw angle is converted into an angle related to the yaw angle that is more convenient to calculate, and then converted into the yaw angle through the relevant relationship. The calculation process is simplified by simply obtaining the yaw angle, reducing the complexity of the calculation formula, thereby improving the calculation efficiency.

[0076] Further, obtaining the distance from the light spot to the left and right sides of the second chessboard image includes:

[0077] The distances from the light spot to the left and right sides of the second chessboard image are acquired by a Tof camera.

[0078] From the above description, it can be seen that by utilizing the built-in ranging function of the Tof camera itself, the yaw angle can be estimated by the distance from the light spot to the left and right sides of the second chessboard image when the second chessboard image is incomplete. When the complete image cannot be detected, the position of the corner point can be estimated with the help of the plane to achieve trapezoidal correction, so that the solution can adapt to different scenes.

[0079] Further, the determining whether the second chessboard image is complete includes:

[0080] The first number of corner points detected on the acquired second chessboard image and the second number of corner points set on the acquired first chessboard image;

[0081] Determine whether the number of the first corner points is the same as the number of the second corner points;

[0082] If they are the same, the second chessboard image is complete.

[0083] From the above description, it can be seen that by detecting whether the number of corner points on the second chessboard image captured by the camera is the same as the number of corner points of the first chessboard image projected by the projector, it is possible to easily determine whether the projected image is complete, so that different correction methods can be used according to the judgment results to improve the accuracy of the correction results.

[0084] Please refer to Figure 7 A trapezoidal correction terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step in the above-mentioned trapezoidal correction method is implemented.

[0085] The above-mentioned trapezoidal correction method and terminal of the present invention can be applied to the correction of the projection picture during the projection process of the projector, and are described below through specific implementation methods.

[0086] Please refer to Figure 1-6 , Embodiment 1 of the present invention is:

[0087] A method for trapezoidal correction, comprising the steps of:

[0088] S1, obtaining a second chessboard image by photographing a first chessboard image projected by a projector through a camera;

[0089] S2, determining whether the second chessboard image is complete, if so, executing S3-S4; otherwise, executing S5;

[0090] In an optional embodiment, whether the second chessboard image is complete is determined based on whether the number of corner points detected on the acquired second chessboard image is the same as the number of corner points set on the first chessboard image; if they are the same, the second chessboard image is complete; if the number of corner points detected on the second chessboard image is less, it is incomplete; a ratio can also be set, if the number of corner points detected on the second chessboard image reaches a preset percentage of the number of corner points in the first chessboard image, the second chessboard image is complete; if it does not reach a preset percentage, it is incomplete; wherein the corner point is the intersection of the black and white chessboard grids in the chessboard; that is, the corresponding Figure 6 In, if the image is incomplete, it is impossible to calculate the corner points of the chessboard in the photo;

[0091] S3, obtaining symmetrical corner points as target symmetrical point pairs, and obtaining first world coordinates of the target symmetrical point pairs and second world coordinates of the light point of the projector, including:

[0092] S31, obtaining coordinates of a first symmetric point pair of a target symmetric point pair in the first chessboard image;

[0093] Please refer to Figure 4 In the chessboard illustrated in the example, in an optional implementation manner, the target symmetrical point pair refers to the point pair of the first column from the left and the first column from the right, or the point pair of the second column from the left and the second column from the right, and so on;

[0094] S32, obtaining a calibration matrix between the camera and the projector and a conversion formula between a world coordinate system and a pixel coordinate system;

[0095] Please refer to Figure 2, the projector is regarded as a reverse camera, π is the projector imaging plane, π' is the camera imaging plane, P is a point on the actual projection plane, for example, a calibration point; l and l' are epipolar lines in the epipolar constraint, o and o' represent the light points of the projector and the camera respectively, and p and p' represent the points on the projector and camera imaging planes corresponding to P respectively; in an optional implementation, refer to the following:

[0096] The formula for converting a point's world coordinate system to the pixel coordinate system is as follows:

[0097]

[0098] The parameters in the first matrix of the rightmost equation are the intrinsic parameters of the camera (f x ,f y ,u0,v0), the parameters in the second matrix are the external parameters of the camera (R, T); because the image taken by the camera is projected from the projector, the known quantity is the image coordinate system corresponding to the projection, so it is necessary to calibrate the internal and external parameters of the camera and projector; Z c represents the depth information, i.e., the scale factor; (u, v) represents the pixel coordinates of point J in the pixel coordinate system; (X W ,Y W ,Z W ) represents the physical coordinates of point J in the world coordinate system; u0 and v0 represent the coordinates of the center of the camera plate in the pixel coordinate system; R represents the rotation matrix, and T represents the translation vector;

[0099] In the above formula, the unit of the image coordinate system corresponding to the camera is length mm, the unit of the pixel coordinate system is pixel, dx represents how many mm each row represents (1pixel = dx mm), dy represents how many mm each column represents (1pixel = dy mm); f x Indicates the focal length of the camera in the x direction, f y Indicates the focal length of the camera in the y direction;

[0100] The internal and external parameters of the projector and camera can be calibrated in advance using Zhang Youzheng's calibration method.

[0101] The calibration matrix between the camera and the projector is obtained as follows:

[0102] S321, for the same group of calibration points, obtaining pixel coordinates (u1, v1, 1) of their projections in the first chessboard image π and pixel coordinates (u2, v2, 1) in the second chessboard image π';

[0103] S322, respectively determine the mapping matrices of the camera and the projector:

[0104] (1); (2);

[0105] in,

[0106] (3);

[0107] M left Represents the transformation matrix from the world coordinate system to the pixel coordinate system corresponding to the projector; M right Represents the transformation matrix from the world coordinate system to the pixel coordinate system corresponding to the camera; the elements in the M matrix represent the undetermined elements; R 00 -R 22 represents the unknown element in the rotation matrix, T 00 -T 02 represents the undetermined element in the translation vector;

[0108] M for M left When , the superscript of the elements in the matrix is ​​1, for example ; M is M right When , the superscript of the elements in the matrix is ​​2, for example ; Z c1 Indicates the corresponding depth information during the projector conversion process; Z c1 Indicates the corresponding depth information during the camera conversion process;

[0109] According to (3), (1) and (2) can be written as:

[0110] (4);

[0111] (5);

[0112] According to (4) and (5), we can get:

[0113] ;

[0114] ;

[0115] ;

[0116] ;

[0117] Finally, the internal parameters of the projector and camera (f x ,f y ,u0,v0), external parameters (R, T), solve the basic matrix M; jointly calculate the world coordinates (X, Y, Z) corresponding to the calibration points; for example, the calibration points can be directly set to the target symmetrical point pair;

[0118] In an optional implementation, the world coordinates are obtained by solving the linear equations in OpenCV, that is, the world coordinates of the corner point set of the chessboard diagram projected on the wall are obtained, for example, the world coordinates can be obtained by solving (A, B, XYZ, DECOMP_SVD); wherein A represents a 4×3 matrix, (XYZ) represents a 3x1 matrix, B represents a 1×4 matrix, and DECOMP_SVD represents using the least squares method to solve the linear equation A (XYZ) = B;

[0119] S322 can calculate the depth information after calibrating the internal and external parameters by Zhang Youzheng calibration method;

[0120] S33, acquiring the coordinates of the second symmetric point pair of the target symmetric point pair in the second chessboard image according to the coordinates of the first symmetric point pair and the calibration matrix;

[0121] S34, calculating the first world coordinates of the target symmetrical point pair according to the coordinates of the second symmetrical point pair and the conversion formula;

[0122] S4, calculating the yaw angle between the projection plane and the projector orientation according to the first world coordinate and the second world coordinate, including:

[0123] S41, calculating the angle between the target symmetrical point pair and the light spot, and the distance from each symmetrical point in the target symmetrical point pair to the light spot according to the first world coordinate and the second world coordinate, and marking them as a first distance and a second distance;

[0124] Specifically, the average value of the Z-axis values ​​of the left and right target symmetric points can be selected to estimate the distances D1 and D2 from the projector to the left and right sides of the projection wall;

[0125] S42, calculating the third distance between the symmetrical points by a trigonometric function according to the included angle, the first distance and the second distance:

[0126] d= ;

[0127] Wherein, d represents the third distance, D1 represents the first distance, D2 represents the second distance, and α represents the angle;

[0128] S43, calculating the yaw angle between the projection plane and the projector orientation by trigonometric function according to the included angle, the first distance, the second distance and the third distance:

[0129] cos(θ')=(D2-D1×cos(2α)) / d;

[0130] θ = θ' + α;

[0131] Yaw = 90°-θ;

[0132] Wherein, θ' represents the angle between the projection plane and the line from the symmetric point to the light spot; θ represents the complementary angle of the yaw angle; Yaw represents the yaw angle;

[0133] Please refer to Figure 3 , point A is the light point, B and C are two symmetrical points on the projection plane, forming a target symmetrical point pair; the dotted arrow is a perpendicular line through the light point to the target projection plane facing the projector; the plane where the line between B and C lies is the projection plane, i.e., the actual projection plane;

[0134] S5, obtaining the distance from the light spot to the left and right sides of the second chessboard image, including:

[0135] S51, taking regions of interest of the same size on the symmetrical left and right sides of the second chessboard image respectively, including:

[0136] S511, dividing the second chessboard image into regions of a preset matrix size;

[0137] S512, obtaining the number of matrices corresponding to the preset area size;

[0138] S513, respectively obtaining the regions that are symmetrical on the left and right sides and whose number is the number of the matrices as regions of interest;

[0139] S52, turning on the Tof function of the Tof camera, and acquiring the distances from the light spot to the left and right sides of the second chessboard image according to the region of interest, as the first distance and the second distance respectively;

[0140] Please refer to Figure 4 , the ToF (Time of flight) camera is used to obtain the symmetrical distances D1 and D2 from the region of interest to the light point. The left and right angles of the photon window emitted by ToF are 27 degrees. The window is divided into 16X16 areas. The effective area is first set to [0,15]~[4,0], and the distance D1 from the left end of the projection plane to ToF is estimated. Then the effective area is set to [11,15]~[15,0], and the distance D2 from the right end of the projection plane to ToF is estimated. That is, the size of the region of interest can be set in ToF.

[0141] Then, the yaw angle can be calculated by referring to the step in S4, wherein the included angle can be calculated by obtaining the center points of the two regions of interest and calculating the angle between the center point and the light spot;

[0142] S6, calculating the yaw angle between the projection plane and the direction of the projector according to the distance and the second world coordinate;

[0143] S7, obtaining an image correction formula according to the yaw angle, including:

[0144] Please refer to Figure 5 , point D is the light source of the projector, that is, the light point mentioned above, the ABFE plane is the front projection plane of the projector, which is a regular rectangle; the AGHE plane is the plane displayed when the projector is side-projected, which is a trapezoid; the actual distance of DC is L, the projection ratio is T, then AB=TL; the degree of angle GAB is yaw (yaw angle); AB= AJ;

[0145] Let point C be the origin of the coordinate system (0,0);

[0146] The coordinates of point J are (TLcos(yaw)-0.5×TL,TLsin(yaw));

[0147] Let the foot of the perpendicular from J to CD be J';

[0148] According to the law of similar triangles CL / JJ'=CD / DJ';

[0149] CL=L(TLcos(yaw)-0.5TL) / (L+TLsin(yaw))=L(Tcos(yaw)-0.5T) / (1+Tsin(yaw));

[0150] BL= 0.5TL-CL=TL(1-cos(yaw)+0.5Tsin(yaw)) / (1+Tsin(yaw));

[0151] Convert the length to pixels, let the pixel of BL be x, and W be the pixel size of the wide side;

[0152] BL / TL=x / W;

[0153] x= W(1-cos(yaw)+0.5Tsin(yaw)) / (1+Tsin(yaw));

[0154] According to the law of similar triangles ML / KJ=DL / DJ =DC / DJ';

[0155] ML = KJ(1 / (1+_Tsin(yaw)));

[0156] KJ = TL × H / W;

[0157] Convert the length to pixels, let ML be y in pixels, and H be the pixel size of the narrow side;

[0158] ML / (TL×H / W) = y / H;

[0159] y=H / (1+Tsin(yaw));

[0160] Assume that the ABFE plane is the projection plane with coordinates E(0,0), F(W,0), B(W,H), A(0,H);

[0161] In order to image ABFE as an equiproportional rectangle on AGHE, point F needs to be deformed to point M, while the coordinates of the other three points remain unchanged.

[0162] The coordinates of point M are:

[0163] (WW(1-cos(yaw)+0.5Tsin(yaw)) / (1+Tsin(yaw)),HH / (1+Tsin(yaw)));

[0164] In an optional implementation, the pitch angle and the roll angle are obtained by a gyroscope on the projector; an image correction formula is obtained according to the yaw angle, the pitch angle and the roll angle to further improve the accuracy;

[0165] After the yaw angle is obtained, the pitch angle and the roll angle can be easily obtained through the gyroscope set in the projector, so that the correction formula can be obtained according to the yaw angle, the pitch angle and the roll angle to correct the projected image. When the projector does not move, there is no need to calibrate again, which is convenient for use;

[0166] S8, correcting the image to be projected according to the image correction form and then projecting it;

[0167] In an optional implementation, after the coordinates of the original four vertices and the coordinates of the deformed four vertices are known, the corrected image to be projected is projected through the perspective transformation of OpenCV.

[0168] Please refer to Figure 7 , Embodiment 2 of the present invention is:

[0169] A terminal 1 for trapezoidal correction includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, each step in the first embodiment is implemented.

[0170] In summary, the present invention provides a method and terminal for trapezoidal correction, which projects a first chessboard image before formal projection and obtains a second chessboard image by photographing the projection result through a camera, determines whether there is trapezoidal distortion, that is, an angle is formed between the actual projection surface and the expected projection surface, and if there is distortion, obtains the world coordinates of the target symmetrical point pair and the projector light spot, and calculates the yaw angle according to the two world coordinates and the established geometric relationship; different from the method of directly obtaining parameters related to the yaw angle for calculating the yaw angle, an indirect calculation and a method of obtaining the yaw angle size through geometric relationships are adopted, which simplifies the calculation process and improves the calculation efficiency; and, when the corner points can be obtained, symmetrical corner points are used as symmetrical point pairs, and when the corner points cannot be obtained, the yaw angle is calculated through symmetrical regions of interest. If the chessboard image is blocked during the projection process, the yaw angle can also be calculated, thereby being able to adapt to more scenarios.

[0171] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for trapezoidal correction, characterized in that: Includes steps: The second chessboard image is obtained by photographing the first chessboard image projected by the projector through a camera; Determine whether the second chessboard image is complete, and if so, obtain symmetrical corner points as target symmetrical point pairs, and obtain the first world coordinates of the target symmetrical point pairs and the second world coordinates of the light point of the projector; calculate the yaw angle between the projection plane and the direction of the projector according to the first world coordinates and the second world coordinates; Otherwise, obtaining the distance from the light spot to the left and right sides of the second chessboard image, and calculating the yaw angle between the projection plane and the direction of the projector according to the distance and the second world coordinate; Acquire an image correction formula according to the yaw angle, and correct the image to be projected according to the image correction formula and then project it; The obtaining the distance from the light spot to the left and right sides of the second chessboard image comprises: Taking regions of interest of the same size on the symmetrical left and right sides of the second chessboard image respectively; Turn on the Tof function of the Tof camera, and obtain the distances from the light spot to the left and right sides of the second chessboard image according to the region of interest, as the first distance and the second distance respectively; obtain the center points of the two regions of interest, and calculate the angle between the center points and the light spot; The regions of interest having the same size on the left and right sides of the symmetrical second chessboard image include: dividing the second chessboard image into regions of a preset matrix size; Get the number of matrices corresponding to the preset area size; Respectively obtaining the regions which are symmetrical on the left and right sides and whose number is the number of the matrices as regions of interest; Calculating the yaw angle between the projection plane and the projector orientation according to the first world coordinate and the second world coordinate includes: Calculate the angle between the target symmetrical point pair and the light spot, and the distance from each symmetrical point in the target symmetrical point pair to the light spot according to the first world coordinate and the second world coordinate, marked as a first distance and a second distance; Calculating the yaw angle between the projection plane and the projector orientation according to the first world coordinate and the second world coordinate and calculating the yaw angle between the projection plane and the projector orientation according to the distance and the second world coordinate include: Calculate the third distance between the symmetrical points by using a trigonometric function according to the included angle, the first distance and the second distance; The yaw angle between the projection plane and the projector orientation is calculated by trigonometric function according to the included angle, the first distance, the second distance and the third distance.

2. A trapezoidal correction method according to claim 1, characterized in that: The obtaining of the first world coordinates of the target symmetric point pair comprises: Acquire coordinates of a first symmetrical point pair of a target symmetrical point pair in the first chessboard image; Obtaining a calibration matrix between the camera and the projector and a conversion formula between a world coordinate system and a pixel coordinate system; Acquire the coordinates of the second symmetric point pair of the target symmetric point pair in the second chessboard image according to the coordinates of the first symmetric point pair and the calibration matrix; The first world coordinates of the target symmetrical point pair are calculated according to the coordinates of the second symmetrical point pair and the conversion formula.

3. The method for trapezoidal correction according to claim 1, characterized in that: Calculating the third distance between the symmetrical points by using a trigonometric function according to the included angle, the first distance, and the second distance comprises: ; Wherein, d represents the third distance, D1 represents the first distance, D2 represents the second distance, and α represents the angle.

4. The method for trapezoidal correction according to claim 1, characterized in that: The calculating the yaw angle between the projection plane and the projector orientation by trigonometric function according to the included angle, the first distance, the second distance and the third distance comprises: cos(θ')=(D2-D1×cos(2α)) / d; θ = θ' + α; Yaw = 90°-θ; Among them, θ' represents the angle between the projection plane and the line from the symmetric point to the light spot; θ represents the complementary angle of the yaw angle; Yaw represents the yaw angle; α represents the angle, D1 represents the first distance; D2 represents the second distance, and d represents the third distance.

5. The method for trapezoidal correction according to claim 1, characterized in that: The obtaining of the distance from the light spot to the left and right sides of the second chessboard image comprises: The distances from the light spot to the left and right sides of the second chessboard image are acquired by a Tof camera.

6. The method for trapezoidal correction according to claim 1, characterized in that: The determining whether the second chessboard image is complete comprises: The first number of corner points detected on the acquired second chessboard image and the second number of corner points set on the acquired first chessboard image; Determine whether the number of the first corner points is the same as the number of the second corner points; If they are the same, the second chessboard image is complete.

7. A terminal for trapezoidal correction, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps in the trapezoidal correction method described in any one of claims 1-6 are implemented.