Trapezoidal correction method, device and storage medium for image

This image correction method, which combines trapezoidal scene detection and radial offset with homography transformation, solves the problem that existing technologies cannot simultaneously capture distant details and near-end geometric accuracy, generating high-quality corrected images.

CN120495141BActive Publication Date: 2025-12-16GUANGXI TIEXIANG TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510464140.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-12-16
Estimated Expiration
2045-04-14

AI Technical Summary

Technical Problem

Existing image trapezoidal correction methods cannot simultaneously preserve distant details and near-end geometric accuracy, resulting in decreased image quality and affecting subsequent processing.

Method used

Vertex coordinates are determined by trapezoidal scene detection, radial offset is performed and a target transformation matrix is ​​constructed. Then, homography transformation is combined to perform geometric correction on image pixels, generating a high-quality corrected image.

Benefits of technology

It effectively magnifies the clarity of distant details, maintains the geometric integrity of nearby areas, and improves the overall image quality and analytical value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495141B_ABST
    Figure CN120495141B_ABST
Patent Text Reader

Abstract

The application discloses a trapezoidal correction method and device of an image and a storage medium, relates to the technical field of computer vision, and comprises the following steps: determining first vertex coordinates of trapezoidal region vertices in a to-be-processed image through trapezoidal scene detection; performing radial offset on the trapezoidal region vertices along the central axis of the trapezoidal region based on the first vertex coordinates, and taking the offset positions as second vertex coordinates corresponding to target trapezoidal regions; determining a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates; and converting each pixel point of the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image, so that the technical problem that the trapezoidal correction method of the image in the prior art cannot simultaneously consider far details and near geometric accuracy is solved, and the geometric integrity of a near region is maintained while the far details in the enlarged image are magnified.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer vision, and particularly relates to a trapezoidal correction method of an image, a device and a storage medium. BACKGROUND

[0002] With the popularization and development of digital camera technology, digital images have been widely applied in various fields. However, due to the influence of factors such as the angle and position of the camera equipment in the image acquisition process, the problem of trapezoidal distortion often occurs, which reduces the quality of the image and brings influence to the subsequent image processing. Specifically, due to the perspective effect, the pixel density of the top of the trapezoidal image obtained by shooting is low, which may cause the key details in the distance to be unable to be clearly presented. At present, for the preprocessing of the trapezoidal region in the image, although the method of using a fisheye lens or affine transformation can expand the field of view, the geometric structure of the near region will be damaged, and the method of using traditional perspective transformation can correct the geometric distortion caused by the shooting angle, but the clarity of the details in the distance is limited.

[0003] Therefore, there is an urgent need for a trapezoidal correction method of an image which can effectively enlarge the details in the distance while maintaining the geometric integrity of the near region, so as to improve the overall quality and analysis value of the image. SUMMARY

[0004] The main purpose of the present application is to provide a trapezoidal correction method of an image, a device and a storage medium, which aims to solve the technical problem that the existing trapezoidal correction method of an image cannot balance the details in the distance and the geometric accuracy of the near region.

[0005] To achieve the above-mentioned purpose, the present application provides a trapezoidal correction method of an image, which comprises:

[0006] determining a first vertex coordinate of a trapezoidal region vertex in a to-be-processed image through trapezoidal scene detection;

[0007] based on the first vertex coordinate, performing radial offset on the trapezoidal region vertex along the central axis of the trapezoidal region, and taking the offset position as a second vertex coordinate corresponding to a target trapezoidal region;

[0008] determining a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinate and the second vertex coordinate;

[0009] performing conversion on each pixel point of the trapezoidal region according to the target conversion matrix, to generate a corrected target trapezoidal region image.

[0010] In an embodiment, the method for determining the first vertex coordinate of the trapezoidal region vertex in the to-be-processed image through trapezoidal scene detection comprises:

[0011] performing edge detection on the image to be processed to obtain an edge binary image, wherein a brightness value of an edge pixel in the edge binary image is higher than a brightness value of a non-edge pixel;

[0012] performing straight line detection on the edge binary image to obtain a set of trapezoidal region boundary candidate straight lines;

[0013] determining a first vertex coordinate of a top vertex of the trapezoidal region through the set of trapezoidal region boundary candidate straight lines.

[0014] In some embodiments, the trapezoidal region vertexes include a top vertex of a trapezoidal region and a bottom vertex of a trapezoidal region, and the radial offsetting of the trapezoidal region vertexes along a central axis of the trapezoidal region based on the first vertex coordinate and the determination of the second vertex coordinate of the target trapezoidal region corresponding to the offset position include:

[0015] determining a first depth between the top vertex of the trapezoidal region and the bottom vertex of the trapezoidal region, and determining a first adjustment coefficient corresponding to the first depth according to a preset corresponding relationship between depths and adjustment coefficients and the first depth;

[0016] determining a first radial offset amount of the top vertex according to a length of an upper edge of the trapezoidal region and the first adjustment coefficient;

[0017] radially offsetting the top vertex of the trapezoidal region along the central axis of the trapezoidal region based on the first radial offset amount of the top vertex to obtain a second top vertex coordinate of a target top vertex of the trapezoidal region, and determining a first bottom vertex coordinate of the bottom vertex of the trapezoidal region as a second bottom vertex coordinate of a target bottom vertex of the trapezoidal region.

[0018] In some embodiments, the trapezoidal region vertexes include a top vertex of a trapezoidal region and a bottom vertex of a trapezoidal region, and the radial offsetting of the trapezoidal region vertexes along a central axis of the trapezoidal region based on the first vertex coordinate and the determination of the second vertex coordinate of the target trapezoidal region corresponding to the offset position include:

[0019] obtaining a second adjustment coefficient input by a user, and determining a second radial offset amount of the top vertex according to a length of an upper edge of the trapezoidal region and the second adjustment coefficient;

[0020] radially offsetting the top vertex of the trapezoidal region along the central axis of the trapezoidal region based on the second radial offset amount of the top vertex to obtain a second top vertex coordinate of a target top vertex of the trapezoidal region, and determining a first bottom vertex coordinate of the bottom vertex of the trapezoidal region as a second bottom vertex coordinate of a target bottom vertex of the trapezoidal region.

[0021] In some embodiments, the determining a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates of the trapezoidal region vertex and the second vertex coordinates of the target trapezoidal region vertex comprises:

[0022] Based on the first vertex coordinates of the trapezoidal region vertex and the second vertex coordinates of the target trapezoidal region vertex, a perspective transformation matrix algorithm is called to obtain the target conversion matrix.

[0023] In some embodiments, the converting each pixel point of the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image comprises:

[0024] Iterating through each pixel point of the trapezoidal region, the corresponding coordinates of each pixel point in the target trapezoidal region image are calculated through the target conversion matrix.

[0025] Based on the corresponding coordinates of each pixel point in the target trapezoidal region image, an initial target trapezoidal region image is generated.

[0026] Mask fusion is performed on the initial target trapezoidal region image and the trapezoidal region image to fill the blank area in the initial target trapezoidal region image that is not covered by the original pixel, to obtain the corrected target trapezoidal region image.

[0027] In some embodiments, after the corrected target trapezoidal region image is generated, the method further comprises:

[0028] A super-resolution algorithm is used to supplement pixels of the target trapezoidal region image to obtain an enhanced target trapezoidal region image.

[0029] The enhanced target trapezoidal region image is replaced with the trapezoidal region image in the to-be-processed image to obtain a processed image.

[0030] In some embodiments, after the corrected target trapezoidal region image is generated, the method further comprises:

[0031] Target detection is performed on the target trapezoidal region image to obtain a target detection result, the target detection result being used to indicate the category of the to-be-detected target and the confidence of the to-be-detected target in the target trapezoidal region image.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a trapezoidal correction device for image, which comprises:

[0033] A trapezoidal scene detection module is configured to determine the first vertex coordinates of the trapezoidal region vertex in the to-be-processed image through trapezoidal scene detection.

[0034] a radial offset module configured to offset the first vertex coordinates of the trapezoidal region along a central axis of the trapezoidal region based on the first vertex coordinates, and to obtain second vertex coordinates of a target trapezoidal region as a result of the offset;

[0035] a conversion matrix determination module configured to determine a target conversion matrix between the trapezoidal region and the target trapezoidal region based on the first vertex coordinates and the second vertex coordinates;

[0036] a geometric correction module configured to convert each pixel point of the trapezoidal region based on the target conversion matrix, and to generate a corrected target trapezoidal region image.

[0037] In addition, to achieve the above object, the present application further provides a device for trapezoidal correction of an image, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the method for trapezoidal correction of an image.

[0038] In addition, to achieve the above object, the present application further provides a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the method for trapezoidal correction of an image.

[0039] In addition, to achieve the above object, the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps of the method for trapezoidal correction of an image.

[0040] The one or more technical solutions provided in the application have at least the following technical effects: through trapezoidal scene detection, four vertex coordinates of the trapezoidal region are extracted, that is, the first vertex coordinates of the trapezoidal region vertex in the image to be processed. Based on the first vertex coordinates, a radial offset is applied to the trapezoidal region vertex along the central axis of the trapezoidal region from the top to the bottom as required, so that the width of the top of the trapezoidal region increases, and the offset position is taken as the second vertex coordinates of the target trapezoidal region. The details of the distant place are enlarged in a targeted manner, which helps to improve the visibility and clarity of the features in the distant place, while minimizing the impact on the nearby area. According to the first vertex coordinates and the second vertex coordinates, a target transformation matrix between the trapezoidal region and the target trapezoidal region is determined, and the target transformation matrix defines how to map from the trapezoidal region to the target trapezoidal region. The target transformation matrix is applied to geometric transformation of each pixel point of the trapezoidal region. For each pixel point, its corresponding position in the new image (target trapezoidal region image) is calculated through the target transformation matrix, and a target trapezoidal region image after geometric correction is obtained. The generated target trapezoidal region image has a wider top and clearer details in the distant place. The trapezoidal correction method of the image provided in the application can increase the pixel density in the distant place and improve the clarity of the details in the distant place through radial offset. On the other hand, combined with homography transformation (using the target transformation matrix), the perspective distortion and local stretching deformation are eliminated to realize geometric correction, solving the technical problem that the existing trapezoidal correction method of the image cannot balance the details in the distant place and the geometric accuracy of the nearby area. Combined with radial distortion correction and perspective transformation, a high-quality corrected image (i.e. target trapezoidal region image) is generated, which enlarges the details in the distant place and maintains the geometric integrity of the nearby area, effectively improving the overall quality and analysis value of the corrected target trapezoidal region image. BRIEF DESCRIPTION OF DRAWINGS

[0041] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the application.

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0043] Figure 1 A flowchart of a trapezoidal correction method of an image provided in the embodiments of the application;

[0044] Figure 2 A comparison chart of processing effects of the trapezoidal correction method of the image provided in the application;

[0045] Figure 3A prior fisheye lens processing effect comparison chart provided for the present application;

[0046] Figure 4 A module structure schematic diagram of an image trapezoidal correction device provided for an embodiment of the present application;

[0047] Figure 5 A device structure schematic diagram of a hardware running environment involved in the image trapezoidal correction method in an embodiment of the present application. DETAILED DESCRIPTION

[0048] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.

[0049] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.

[0050] The main solution of the embodiment of the present application is: determining the first vertex coordinates of the trapezoidal region vertex in the image to be processed through trapezoidal scene detection; radially offsetting the trapezoidal region vertex along the central axis of the trapezoidal region based on the first vertex coordinates, and taking the offset position as the second vertex coordinates corresponding to the target trapezoidal region; determining the target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates; converting each pixel point of the trapezoidal region according to the target conversion matrix to obtain the target trapezoidal region image after geometric correction, and the generated target trapezoidal region image is wider at the top and the details in the distance are clearer.

[0051] In the present embodiment, for the sake of description, the following describes the image trapezoidal correction system as the execution subject.

[0052] With the popularization and development of digital camera technology, digital images have been widely applied in various fields. However, due to the influence of factors such as camera equipment angle, position, etc. in the image acquisition process, the problem of trapezoidal distortion often occurs, which reduces the quality of the image and brings influence to the subsequent image processing. Specifically, due to the perspective effect, the top pixel points of the trapezoidal image obtained by shooting are low in density, which may result in that the key details in the distance cannot be clearly presented. At present, for the preprocessing of the trapezoidal region in the image, although the methods of fisheye lens or affine transformation can expand the field of view, they will damage the geometric structure of the near region, and the method of traditional perspective transformation can correct the geometric distortion caused by the shooting angle, but the clarity of the details in the distance is limited. Therefore, there is an urgent need for an image trapezoidal correction method which can effectively enlarge the details in the distance while maintaining the geometric integrity of the near region, so as to improve the overall quality and analysis value of the image.

[0053] The present application provides a trapezoidal correction method of an image, on the one hand, increases the pixel density of the far distance and improves the definition of the far distance details through radial offset, on the other hand, combines homography transformation (uses target conversion matrix) to eliminate perspective distortion and local stretching deformation to realize geometric correction, solves the technical problem that the trapezoidal correction method of the image in the prior art cannot consider the far distance details and the near distance geometric accuracy, skillfully combines radial distortion correction and perspective transformation, generates a high-quality corrected image (i.e. target trapezoidal region image), which enlarges the far distance details and maintains the geometric integrity of the near distance region, effectively improves the overall quality and analysis value of the corrected target trapezoidal region image.

[0054] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an image trapezoidal correction system capable of realizing the above functions. The present embodiment and the following embodiments will be described below taking the image trapezoidal correction system as an example.

[0055] Based on this, the present embodiment provides a trapezoidal correction method of an image, referring to Figure 1 , Figure 1 The present embodiment provides a trapezoidal correction method of an image, referring to

[0056] In the present embodiment, the trapezoidal correction method of the image includes steps 101-104:

[0057] Step 101, through trapezoidal scene detection, determine the first vertex coordinates of the trapezoidal region vertex in the image to be processed.

[0058] Specifically, the trapezoidal scene detection is a process of identifying a specific shape trapezoidal region from the image to be processed. For example, the present application provides a comparison chart of the processing effect of the trapezoidal correction method of the image, referring to Figure 2 The right image, the trapezoidal scene detection can be to detect the railway track with a trapezoidal structure. The first vertex coordinates are the actual coordinates of the four vertices of the trapezoidal region in the image to be processed before any correction or transformation.

[0059] In addition, before the trapezoidal scene detection of the image to be processed, the image to be processed can be preprocessed, and the preprocessing steps can include grayscale processing, denoising, etc. Through grayscale processing, the colored image to be processed can be converted into a single-channel grayscale image, reducing the calculation complexity, and using a Gaussian blur or other smoothing filter to remove noise to improve the accuracy of edge detection.

[0060] In some embodiments, the trapezoidal region boundary in the image to be processed can be identified and located through computer vision technology, and then the four vertex coordinates of the trapezoidal region, i.e., the first vertex coordinates of the trapezoidal region vertices, are extracted. By determining the boundary and vertex position of the trapezoidal region, it helps to ensure that the subsequent processing is only for the trapezoidal region, avoiding the interference of irrelevant regions, and at the same time, the first vertex coordinates of the trapezoidal region vertices are the key input for subsequent geometric transformation calculation, in addition, determining the accurate first vertex coordinates of the trapezoidal region vertices helps to ensure the accuracy of subsequent transformation, so as to achieve the goal of magnifying distant details and keeping the geometric structure of the near region stable.

[0061] In step 102, based on the first vertex coordinates, the trapezoidal region vertices are radially offset along the central axis of the trapezoidal region, and the offset position is taken as the second vertex coordinates corresponding to the target trapezoidal region.

[0062] Specifically, the first vertex coordinates (A, B, C, D) are the actual coordinates of the four vertices of the trapezoidal region in the image to be processed, which are the basis for subsequent transformation. The radial offset in this application is a displacement along the central axis direction of the trapezoidal region according to the distance from the top, so that the width of the top increases, while the bottom region remains almost unchanged. The second vertex coordinates (A', B', C', D') are the new coordinates of the four vertices of the target trapezoidal region after radial offset, which define the corrected target trapezoidal shape.

[0063] In some embodiments, the central axis of the trapezoidal region can be calculated by connecting the midpoints of the two top vertices and the two bottom vertices of the trapezoid, and at the same time, the top expansion ratio (e.g., 80%) or the radial offset amount of the top of the trapezoidal region is determined, which directly determines the width that needs to be increased in the top. For each vertex, the radial offset amount along the central axis direction is determined according to the distance from the vertex to the central axis and the expansion ratio. In this application, the offset amount of the upper vertex is larger, and the offset amount of the lower vertex is smaller or zero. The closer to the top of the vertex, the larger the offset amount; the closer to the bottom of the vertex, the smaller the offset amount. Apply the calculated offset amount of each vertex to each vertex to get the offset position, which is the second vertex coordinates of the target trapezoidal region. By radially offsetting the trapezoidal region vertices along the central axis of the trapezoidal region based on the first vertex coordinates (A, B, C, D), and taking the offset position as the second vertex coordinates (A', B', C', D') of the target trapezoidal region, the problem that the existing trapezoidal correction method for images cannot balance the distant details and the geometric accuracy of the near region is effectively solved. By accurately adjusting the vertex position, both the expressiveness of the distant details and the geometric integrity of the near region are maintained, which is suitable for application scenarios that require high-precision visual analysis.

[0064] Step 103, determining a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates.

[0065] Specifically, the target conversion matrix is a homography matrix, which can be a 3x3 matrix. In this application, the target conversion matrix can be used to map the trapezoidal region to the target trapezoidal region after radial offset. According to the first vertex coordinates and the second vertex coordinates, a solving equation of the target conversion matrix is constructed. The least square method or singular value decomposition can be used to solve the equation to obtain the target conversion matrix. Alternatively, in OpenCV, the target conversion matrix between the trapezoidal region and the target trapezoidal region can be directly calculated by calling the cv::getPerspectiveTransform function.

[0066] By determining the coordinate correspondence between the first vertex coordinates (A, B, C, D) and the second vertex coordinates (A', B', C', D') of the target trapezoidal region, the target conversion matrix is obtained. The target conversion matrix is used to uniformly model the geometric deformation (such as top expansion) of the trapezoidal region and the global perspective correction, so as to realize the pixel density improvement of the far details and the lossless preservation of the near key geometric structure in the to-be-processed image, and solve the problem that the prior art cannot balance the far details and the near geometric accuracy.

[0067] Step 104, converting each pixel point in the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image.

[0068] Specifically, based on the target conversion matrix, an empty target trapezoidal region image is initialized. Each pixel point in the trapezoidal region is traversed, and each pixel point in the trapezoidal region is mapped to the corresponding target trapezoidal region by using the target conversion matrix to calculate the corresponding coordinates of the pixel point in the target trapezoidal region image. For the calculated non-integer value coordinates, an interpolation algorithm can be used to determine the color value at that position. In the interpolation process, the color information of the adjacent pixels in the original trapezoidal region can be weighted and averaged to make the color transition smooth. Further, the interpolated color value is assigned to the corresponding position in the target trapezoidal region image. Repeat the process until all pixel points in the trapezoidal region are processed to generate a corrected target trapezoidal region image. The generated target trapezoidal region image has an expanded top region, which enlarges the far details (trapezoidal region top details), while maintaining the geometric structure of the near region as much as possible. By applying the calculated target conversion matrix to geometrically transform each pixel point in the trapezoidal region, the trapezoidal region in the to-be-processed image is corrected to the target trapezoidal region image, which enlarges the far details while maintaining the geometric structure of the near region and eliminates perspective distortion, generating a high-quality corrected image.

[0069] Based on the trapezoidal correction method of the image provided in the present application, through trapezoidal scene detection, four vertex coordinates of the trapezoidal region are extracted, that is, the first vertex coordinates of the trapezoidal region vertex in the image to be processed. Based on the first vertex coordinates, a radial offset is applied to the trapezoidal region vertex along the central axis of the trapezoidal region from the top to the bottom as required, so that the width of the top of the trapezoidal region increases, and the position after the offset is taken as the second vertex coordinates of the target trapezoidal region. The far distance details are enlarged in a targeted manner, which helps to improve the visibility and clarity of the far distance features, while minimizing the impact on the nearby area. According to the first vertex coordinates and the second vertex coordinates, a target conversion matrix between the trapezoidal region and the target trapezoidal region is determined, and the target conversion matrix defines how to map from the trapezoidal region to the target trapezoidal region. The target conversion matrix is applied to geometrically transform each pixel point of the trapezoidal region. For each pixel point, its corresponding position in the new image (target trapezoidal region image) is calculated through the target conversion matrix, and a target trapezoidal region image after geometric correction is obtained. The generated target trapezoidal region image has a wider top and clearer far distance details. The trapezoidal correction method of the image provided in the present application can increase the pixel density of the far distance on the one hand through radial offset, and improve the clarity of the far distance details. On the other hand, combined with homographic transformation (using the target conversion matrix), the perspective distortion and local stretching deformation are eliminated to realize geometric correction, which solves the technical problem that the existing trapezoidal correction method of the image cannot balance the far distance details and the near distance geometric accuracy. The radial distortion correction and perspective transformation are combined skillfully to generate a high-quality corrected image (i.e. the target trapezoidal region image), which enlarges the far distance details and maintains the geometric integrity of the nearby area, effectively improving the overall quality and analysis value of the corrected target trapezoidal region image.

[0070] In some embodiments, the first vertex coordinates of the trapezoidal region vertex in the image to be processed are determined through trapezoidal scene detection, comprising:

[0071] Edge detection is performed on the image to be processed to obtain an edge binary image, wherein the brightness value of the edge pixel in the edge binary image is higher than the brightness value of the non-edge pixel;

[0072] Straight line detection is performed on the edge binary image to obtain a trapezoidal region boundary candidate straight line set;

[0073] The first vertex coordinates of the trapezoidal region vertex are determined through the trapezoidal region boundary candidate straight line set.

[0074] As an example, the Canny operator can be used for edge detection of the image to be processed, specifically including: converting the image to be processed into a grayscale image, removing noise using a filter, and calculating the intensity gradient at each pixel, retaining only the local maximum along the gradient direction, thinning the edges, and dynamically setting high and low thresholds to generate an edge binary image, in which the edge pixels have a higher brightness value, and the non-edge pixels have a lower brightness value. A straight line detection algorithm is applied to the obtained edge binary image to map the points in the image space to the parameter space, thereby effectively detecting straight lines and obtaining a set containing all detected straight lines, i.e., a set of candidate straight lines of the trapezoidal region boundary. The straight line detection algorithm used can be the Hough transform. The set of candidate straight lines of the trapezoidal region boundary is screened to obtain the straight lines of the trapezoidal region boundary, and the coordinates of the vertices of the trapezoidal region are calculated based on the straight lines of the trapezoidal region boundary. Further, abnormal intersection points that do not meet the expectations can be removed, for example, the effectiveness of the vertices can be confirmed using preset shape constraints (such as the angle range of the trapezoid, the length ratio of the sides, etc.). Finally, the specific coordinates of the four vertices of the trapezoidal region (A, B, C, D), i.e., the first vertex coordinates, are obtained. In addition, the user can manually adjust the positions of the vertices.

[0075] By performing edge detection on the image to be processed to obtain an edge binary image, performing straight line detection on the edge binary image to obtain a set of candidate straight lines of the trapezoidal region boundary, and determining the first vertex coordinates of the vertices of the trapezoidal region from the set of straight lines, the trapezoidal region is accurately located from the image, which not only provides necessary basic data for subsequent geometric correction, but also ensures the accuracy and efficiency of the entire image processing process.

[0076] In some embodiments, the vertices of the trapezoidal region include an upper vertex of the trapezoidal region and a lower vertex of the trapezoidal region, and based on the first vertex coordinates, the vertices of the trapezoidal region are radially offset along the central axis of the trapezoidal region, and the offset positions are taken as second vertex coordinates corresponding to a target trapezoidal region, including:

[0077] determining a first depth between the upper vertex of the trapezoidal region and the lower vertex of the trapezoidal region, and determining a first adjustment coefficient corresponding to the first depth according to a predetermined correspondence between depths and adjustment coefficients and the first depth;

[0078] determining a first radial offset of the upper vertex according to the length of the upper side of the trapezoidal region and the first adjustment coefficient;

[0079] radially offsetting the upper vertex of the trapezoidal region along the central axis of the trapezoidal region based on the first radial offset of the upper vertex to obtain second upper vertex coordinates corresponding to a target upper vertex of the trapezoidal region, and determining the first lower vertex coordinates of the lower vertex of the trapezoidal region as second lower vertex coordinates corresponding to a target lower vertex of the trapezoidal region.

[0080] Specifically, the upper vertices of the trapezoidal region are two vertices at the top of the trapezoidal region, and the lower vertices of the trapezoidal region are two vertices at the bottom of the trapezoidal region. The first depth is the vertical distance between the upper vertices and the lower vertices of the trapezoidal region, which can represent the perspective depth in the image to be processed. The adjustment coefficient is a proportional factor for dynamically adjusting the offset amount according to the depth, which increases linearly with the increase of the depth, and is used to control the offset amount of the vertices. The greater the depth between the upper vertices and the lower vertices of the trapezoidal region, the greater the adjustment coefficient. The first radial offset is the distance of the displacement of the upper vertices along the central axis direction of the trapezoidal region. The upper edge length is the horizontal distance between the two upper vertices at the top of the trapezoidal region.

[0081] As an example, the vertical distance between the upper vertices (A and B) and the lower vertices (C and D) of the trapezoidal region, i.e., the first depth, is calculated. The adjustment coefficient corresponding to the first depth is found or calculated using a pre-set mapping relationship, obtaining the first adjustment coefficient corresponding to the first depth. The mapping relationship can be designed according to the requirements of specific application scenarios. In this application, the adjustment coefficient is positively correlated with the depth. The vertices closer to the top need a larger offset amount, and the greater the depth, the greater the corresponding adjustment coefficient, and the subsequent radial offset is also greater. The length of the upper edge of the trapezoidal region can be calculated according to the first upper vertex coordinates of the upper vertices of the trapezoidal region (the horizontal distance between A and B), and the first adjustment coefficient is multiplied by the upper edge length to obtain the first radial offset of the upper vertices. Further, the position of the central axis of the trapezoidal region is determined. For each upper vertex (A and B), the corresponding first radial offset is moved along the central axis direction to obtain new vertex coordinates (A' and B'), i.e., the second upper vertex coordinates corresponding to the target trapezoidal region upper vertices, and the coordinates of the lower vertices of the trapezoidal region are taken as the corresponding second lower vertex coordinates of the target trapezoidal region lower vertices.

[0082] By calculating the first depth between the upper vertices and the lower vertices of the trapezoidal region, determining the first adjustment coefficient according to the pre-set corresponding relationship between the depth and the adjustment coefficient, and combining the length of the upper edge of the trapezoidal region to calculate the first radial offset of the upper vertices, the upper vertices of the trapezoidal region are radially offset along the central axis of the trapezoidal region based on the first radial offset of the upper vertices, and the lower vertices are almost unchanged, which can effectively enlarge the distant details and maintain the geometric structure of the near region, solving the problem that the image correction method in the prior art cannot balance the distant details and the geometric accuracy of the near end.

[0083] In some embodiments, the trapezoidal region vertices include trapezoidal region upper vertices and trapezoidal region lower vertices, and based on the first vertex coordinates, the trapezoidal region vertices are radially offset along the central axis of the trapezoidal region, and the offset positions are taken as the corresponding second vertex coordinates of the target trapezoidal region, including:

[0084] obtaining a second adjustment coefficient input by a user, and determining a second radial offset of the upper vertex according to the upper edge length of the trapezoidal region image and the second adjustment coefficient;

[0085] radially offsetting the upper vertex of the trapezoidal region along the central axis of the trapezoidal region based on the second radial offset of the upper vertex to obtain a second upper vertex coordinate corresponding to an upper vertex of a target trapezoidal region, and determining the first lower vertex coordinate of the lower vertex of the trapezoidal region as a second lower vertex coordinate corresponding to a lower vertex of the target trapezoidal region.

[0086] Specifically, the second adjustment coefficient is a parameter input by the user, which is used to control the offset of the vertex. For example, the second adjustment coefficient can be any value between 50% and 200%, and the specific value can be adjusted manually according to the application scenario. The second radial offset is the displacement distance of the vertex along the central axis direction calculated based on the second adjustment coefficient and the upper edge length of the trapezoidal region.

[0087] As an example, a second adjustment coefficient input by a user is obtained, which allows the user to flexibly adjust the degree of offset of the upper vertex according to specific requirements, providing a customized method to optimize the image correction result. The upper edge length of the trapezoidal region is calculated, and a formula (i.e., second radial offset = upper edge length of the trapezoidal region image x second adjustment coefficient) is used to determine the second radial offset of each upper vertex. Further, the position of the central axis of the trapezoidal region is calculated, and each upper vertex is radially offset along the central axis based on the calculated second radial offset. For each upper vertex of the trapezoidal region, the corresponding target trapezoidal region upper vertex and the second upper vertex coordinate of the target trapezoidal region upper vertex are obtained by radial offset. For the lower vertex of the trapezoidal region, the first lower vertex coordinate of the lower vertex of the trapezoidal region is directly determined as the second lower vertex coordinate corresponding to the lower vertex of the target trapezoidal region, ensuring that the geometric structure of the bottom region remains unchanged. By radially offsetting the upper vertex of the trapezoidal region along the central axis and refining the adjustment based on the second adjustment coefficient input by the user, the details of the distant area can be effectively enlarged while the geometric structure of the near area is maintained, and a target trapezoidal region image that is more consistent with the user's expectations can be obtained.

[0088] In addition, the first adjustment coefficient is automatically calculated according to the vertical distance between the top vertex and the bottom vertex of the trapezoidal region (i.e., the first depth) and the mapping relationship between the preset depth and the adjustment coefficient, and is mainly used for standardizing the vertex offset at different depths, so that the vertices closer to the top obtain a larger offset, thereby increasing the width of the top and improving the visibility of the distant details. The second adjustment coefficient is manually input by the user, providing higher flexibility and control accuracy, allowing the user to fine-tune the offset of the top vertex according to the specific image content and correction target, for example, in some cases, the user may want to enlarge the top region more significantly to highlight certain features, or conversely, reduce the offset to avoid overstretching. By introducing the second adjustment coefficient, the user's expected visual effect can be achieved more accurately without affecting the overall correction framework.

[0089] In some embodiments, according to the first vertex coordinates and the second vertex coordinates, a target conversion matrix between the trapezoidal region and the target trapezoidal region is determined, comprising:

[0090] Based on the first vertex coordinates of the trapezoidal region vertices and the second vertex coordinates of the target trapezoidal region vertices, a perspective transformation matrix algorithm is called to obtain the target conversion matrix.

[0091] Specifically, the above-mentioned perspective transformation matrix algorithm can be a cv::getPerspectiveTransform function.

[0092] As an example, based on the first vertex coordinates of the trapezoidal region vertices and the second vertex coordinates of the target trapezoidal region vertices, an algorithm for obtaining a perspective transformation matrix (homography matrix) is called, for example, in image processing libraries such as OpenCV, the cv::getPerspectiveTransform function can be used to obtain the target conversion matrix. The cv::getPerspectiveTransform function accepts two sets of point sets as input parameters, the first set of point sets contains the four vertex coordinates of the trapezoidal region, i.e., the first vertex coordinates of the trapezoidal region vertices, and the second set of point sets contains the four vertex coordinates of the target trapezoidal region, i.e., the second vertex coordinates of the target trapezoidal region vertices. The cv::getPerspectiveTransform function returns the target conversion matrix, which describes the mapping relationship between the trapezoidal region and the target trapezoidal region. Further, a high weight can be given to the coordinate mapping error of the lower vertex of the trapezoidal region to force the near-end coordinates to be strictly unchanged. By mapping the vertex coordinates and weighted optimization, the user-defined deformation requirements (such as top edge expansion) and geometric correction are unified into a homography matrix calculation, which not only improves the clarity of distant details, but also maintains the geometric structure of the near-end region, which helps to solve the problem that the existing trapezoidal correction method of images cannot balance the distant details and the near-end geometric accuracy.

[0093] In some embodiments, the target conversion matrix is used to convert each pixel point in the trapezoidal region to generate a corrected target trapezoidal region image, including:

[0094] Each pixel point in the trapezoidal region is traversed, and the corresponding coordinates of each pixel point in the target trapezoidal region image are calculated through the target conversion matrix;

[0095] Based on the corresponding coordinates of each pixel point in the target trapezoidal region image, an initial target trapezoidal region image is generated;

[0096] The initial target trapezoidal region image and the trapezoidal region image are mask fused to fill the blank area in the initial target trapezoidal region image that is not covered by the original pixels, to obtain the corrected target trapezoidal region image.

[0097] As an example, each pixel point in the trapezoidal region is traversed, and for each pixel point, the target conversion matrix is used to calculate its new position in the target trapezoidal region image, i.e. the corresponding coordinates of the pixel point in the target trapezoidal region image. Based on the calculated corresponding coordinates of each pixel point in the target trapezoidal region image, a new blank image is created as the target trapezoidal region image, and for each pixel point in the trapezoidal region, its color value is assigned to the corresponding pixel position in the target trapezoidal region image according to its new coordinates in the target trapezoidal region image. In the case where the corresponding coordinates of the pixel point in the target trapezoidal region image are not integers, an interpolation method can be used to determine the color value of the position, and the interpolation method can include nearest neighbor interpolation, bilinear interpolation, and bicubic interpolation, etc. Specifically, in OpenCV, the cv:warpPerspective function can be called to generate an initial target trapezoidal region image based on the corresponding coordinates of each pixel point in the target trapezoidal region image.

[0098] Further, in the generated initial target trapezoidal region image, there can be some blank areas that are not covered by the original pixels, which are usually black or transparent. To improve the overall quality and visual effect of the image, the blank areas not covered by the original pixels need to be filled. A binary mask can be generated by mask fusion of the initial target trapezoidal region image and the original trapezoidal region image to mark the blank areas in the initial target trapezoidal region image. The blank areas in the initial target trapezoidal region image are filled using background copying, smooth transition, and image repair algorithms, etc. and the filled image is combined with the trapezoidal region image to obtain the corrected target trapezoidal region image, ensuring the consistency and integrity of the entire image.

[0099] The trapezoidal region is accurately mapped to a target trapezoidal region image by applying a target conversion matrix, each pixel point is converted, and an initial target trapezoidal region image is generated, the blank area is filled by using a mask fusion technology, and finally a high-quality target trapezoidal region image is obtained. Not only the clarity of the distant details is improved, but also the geometry of the near region is maintained, solving the problem that the image correction method in the prior art cannot balance the distant details and the near geometry accuracy.

[0100] In some embodiments, referring to Figure 3 , Figure 3 is a comparison chart of the processing effect of the existing fisheye lens, Figure 3 The left side is the image to be processed, the near track, the spike, and the gravel on the ground are clear, and the middle and far distance tracks are gradually narrowed due to the perspective effect, and the background vegetation and tree details are blurred. Figure 3 The right side is the effect chart after processing using the traditional fisheye lens. The fisheye lens can provide a wide field of view, but introduces significant geometric distortion, and Figure 3 The near railway track in the right image presents an arc shape in the image, and the background trees in the far distance present an arc-shaped distortion, and the vegetation density perception is distorted. Not only does it affect the accurate measurement of the track structure, but it can also lead to misjudgment of the subsequent analysis algorithm, and at the same time, the details in the far distance are still not clear enough, which is difficult to meet the needs of high-quality detection.

[0101] Referring to Figure 2 , Figure 2 is a comparison chart of the processing effect of the image trapezoidal correction method proposed in the present application, Figure 2 The right side is the image to be processed, which contains the trapezoidal region of the original track image, and the far distance track is narrow and blurred due to the perspective effect. Figure 2 The left side is the effect chart of the image trapezoidal correction processing method proposed in the present application, the top width is expanded, and the far distance track texture is clear. Figure 2 It directly shows the significant advantages of the present application in correcting perspective deformation and enhancing the far-end details, and Figure 3 exposes the inherent defects of the fisheye lens in the near-end distortion and pseudo-enhancement. By accurately adjusting the position of the top vertex of the trapezoidal region, especially increasing the top width, the image trapezoidal correction method proposed in the present application effectively enlarges the far distance details, even the tiny cracks or other subtle defects can be clearly captured, improving the detection accuracy and reliability. Compared with the fisheye lens, the present application can minimize the geometric distortion in the image, providing more realistic and accurate visual information, focusing on maintaining the geometric invariance of the near track limit, avoiding measurement errors caused by geometric distortion, and ensuring the accuracy of important parameters such as track spacing and spike position.

[0102] In some embodiments, after generating the corrected target trapezoidal region image, further comprising:

[0103] The target trapezoidal region image is subjected to pixel supplementing by using a super-resolution algorithm to obtain an enhanced target trapezoidal region image.

[0104] The enhanced target trapezoidal region image is used to replace the trapezoidal region image in the to-be-processed image to obtain a processed image.

[0105] Specifically, after the corrected target trapezoidal region image is generated, pixel supplementing can be performed by using a super-resolution algorithm to further improve the quality and details of the image. The super-resolution algorithm can be an Enhanced Super-Resolution Generative Adversarial Networks (ESRGAN), a Super-Resolution Convolutional Neural Network (SRCNN), or the like.

[0106] As an example, a pre-trained super-resolution model can be used to process the target trapezoidal region image, including but not limited to size adjustment, normalization, denormalization, and the like. Through the above processes, an enhanced target trapezoidal region image with higher resolution and richer details is obtained. Further, a binary mask corresponding to the enhanced target trapezoidal region image is created, the mask is marked with the region to be replaced, and the mask is applied to the to-be-processed image and the enhanced target trapezoidal region image. Through pixel-by-pixel comparison, the pixel values in the enhanced target trapezoidal region image are used to replace the pixel values in the corresponding positions of the trapezoidal region image in the to-be-processed image, and finally a complete processed image containing enhanced details is obtained.

[0107] Through the above super-resolution processing and image replacement, super-resolution enhancement of the target trapezoidal region image is achieved, and the enhanced target trapezoidal region image is seamlessly integrated back into the original image, thereby greatly improving the visual quality of the specific region (trapezoidal region). Through the application of the super-resolution algorithm, the clarity of the target trapezoidal region image is improved, which helps subsequent image analysis tasks such as object recognition and defect detection. At the same time, the above local enhancement can avoid unnecessary calculations on the entire image, improving the processing efficiency. Finally, through accurate fusion of the enhanced region and the original image (to-be-processed image), the naturalness and consistency of the final result are ensured, obtaining a high-quality processed image that not only enhances the visual effect of the local region but also improves the analysis value of the entire image.

[0108] In some embodiments, after the corrected target trapezoidal region image is generated, the method further includes:

[0109] The target trapezoidal region image is subjected to target detection to obtain a target detection result, which is used to indicate the category of the target to be detected in the target trapezoidal region image and the confidence of the target to be detected.

[0110] In some embodiments, after the corrected target trapezoidal region image is generated, the method further comprises:

[0111] The target trapezoidal region image is subjected to target detection to obtain a target detection result, which is used to indicate the category of the target to be detected in the target trapezoidal region image and the confidence of the target to be detected.

[0112] Specifically, after the corrected target trapezoidal region image is generated, the target trapezoidal region image can be subjected to target detection to identify and classify various targets to be detected in the target trapezoidal region image, and provide category information and confidence scores for each target to be detected.

[0113] As an example, a target detection model suitable for the current application scenario can be selected, the target trapezoidal region image is subjected to target detection by the target detection model, the corrected target trapezoidal region image is input into the target detection model for target detection, the target trapezoidal region image is converted into a format suitable for model input, and the detection result is obtained through forward propagation, and the position, category and confidence of each detected target are output.

[0114] Further, the trapezoidal correction method of the image proposed in the present application can be applied in a railway inspection system. In the railway inspection system, it is crucial to monitor the track and its surrounding environment in real time to ensure the safety and stable operation of the track. After the corrected target trapezoidal region image (or processed image) is generated, certain preprocessing work can be performed on the target trapezoidal region image, including but not limited to image size adjustment, color space conversion and the like, to ensure that the data format input into the target detection model meets the requirements. For railway inspection, good preprocessing can effectively improve the detection accuracy. A pre-trained YOLO model can be selected as a target detector, the preprocessed trapezoidal region image is input into the YOLO model for target detection, and all target detection tasks of the entire image can be completed through one forward propagation, and the position, category and confidence of each detected target are output. In the railway environment, the target detector can identify potential safety hazards such as foreign object intrusion, track cracking, loose spikes and the like. Based on the output result of the YOLO model, the railway inspection system further analyzes, combines the confidence value given by the model and the actual railway maintenance standards and experience knowledge, judges the real safety hazards, and gives corresponding warnings or suggestions. Through accurate target detection on the corrected trapezoidal region image, potential dangerous factors existing on the track, such as fallen branches, stones or other foreign objects, can be discovered and located in time, thereby greatly reducing the risk of serious accidents such as train derailment.

[0115] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the image trapezoidal correction method of the present application. More forms of simple transformation based on this technical concept are within the protection scope of the present application.

[0116] The present application also provides an image trapezoidal correction device, which refers to Figure 4 The image trapezoidal correction device comprises:

[0117] The trapezoidal scene detection module 401 is configured to determine the first vertex coordinates of the vertex of the trapezoidal region in the image to be processed through trapezoidal scene detection.

[0118] The radial offset module 402 is configured to perform radial offset on the vertex of the trapezoidal region along the central axis of the trapezoidal region based on the first vertex coordinates, and take the offset position as the second vertex coordinates corresponding to the target trapezoidal region.

[0119] The conversion matrix determination module 403 is configured to determine the target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates.

[0120] The geometric correction module 404 is configured to perform conversion on each pixel point of the trapezoidal region according to the target conversion matrix, and generate a corrected target trapezoidal region image.

[0121] The image trapezoidal correction device provided by the present application adopts the image trapezoidal correction method in the above embodiment, and can solve the technical problem that the existing image trapezoidal correction method cannot balance the far detail and the near geometric accuracy. Compared with the prior art, the image trapezoidal correction device provided by the present application has the same beneficial effects as the image trapezoidal correction method provided by the above embodiment, and the other technical features in the image trapezoidal correction device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0122] The present application provides an image trapezoidal correction device, which comprises at least one processor and a memory in communication connection with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the image trapezoidal correction method in the above embodiment one.

[0123] The following refers to Figure 5The diagram illustrates a structural schematic of a keystone correction device suitable for implementing the embodiments of this application. The keystone correction device for images in the embodiments of this application may include, but is not limited to, mobile terminals such as laptops, personal digital assistants (PDAs), tablet computers (PADs), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The trapezoidal correction device shown in the image is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0124] like Figure 5 As shown, the image keystone correction device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the image keystone correction device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the image keystone correction device to communicate wirelessly or wiredly with other devices to exchange data. Although image keystone correction devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented or possessed alternatively.

[0125] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program codes for executing the method shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network through a communication device, or installed from the storage device 1003, or installed from the read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiments disclosed in the present application are executed.

[0126] The image trapezoidal correction device provided by the present application adopts the image trapezoidal correction method in the above-mentioned embodiments, and can solve the technical problem that the existing image trapezoidal correction method cannot balance the far detail and the near geometric accuracy. Compared with the prior art, the beneficial effects of the image trapezoidal correction device provided by the present application are the same as those of the image trapezoidal correction method provided by the above-mentioned embodiments, and other technical features in the image trapezoidal correction device are the same as those disclosed in the previous embodiment method, which will not be repeated here.

[0127] It should be understood that various parts of the present application can be realized by hardware, software, firmware or a combination thereof. In the description of the above-mentioned embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0128] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

[0129] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e. computer program) for executing the image trapezoidal correction method in the above-mentioned embodiments.

[0130] The computer readable storage medium provided in the application may, for example, be a U disk, but is not limited to an electric, magnetic, optical, electromagnetic, infrared or semiconductor system, system or device, or any combination of the above. More specific examples of the computer readable storage medium may include, but are not limited to, an electric connection with one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read only memory (ROM), an erasable programmable read only memory (EPROM), an optical fiber, a portable compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiment, the computer readable storage medium may be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to an electric wire, an optical cable, a radio frequency (RF), etc., or any suitable combination of the above.

[0131] The computer readable storage medium described above may be contained in the image trapezoidal correction device, or may exist separately without being assembled into the image trapezoidal correction device.

[0132] The computer readable storage medium described above carries one or more programs, which, when executed by the image trapezoidal correction device, cause the image trapezoidal correction device to: determine a first vertex coordinate of a vertex of a trapezoidal region in a to-be-processed image through trapezoidal scene detection; based on the first vertex coordinate, offset the vertex of the trapezoidal region along a central axis of the trapezoidal region radially, and take the offset position as a second vertex coordinate corresponding to a target trapezoidal region; determine a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinate and the second vertex coordinate; and convert each pixel point of the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image.

[0133] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0134] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0135] The modules involved in the embodiments of the present application can be implemented in software or hardware. In some cases, the name of the module does not constitute a limitation on the module itself.

[0136] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer programs) for executing the image trapezoidal correction method described above, and can solve the technical problem that the existing image trapezoidal correction method cannot balance the far detail and the near geometric accuracy. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the image trapezoidal correction method provided by the above embodiments, and will not be described here.

[0137] The application further provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the trapezoidal correction method of an image as described above.

[0138] The computer program product provided by the application can solve the technical problem that the existing trapezoidal correction method of an image cannot balance the distant details and the near-end geometric accuracy. Compared with the prior art, the beneficial effects of the computer program product provided by the application are the same as those of the trapezoidal correction method of an image provided by the above-described embodiments, and are not described herein.

[0139] The above is only some embodiments of the application, and does not limit the patent scope of the application. Any equivalent structural transformation made by using the content of the specification and drawings, or direct / indirect application in other related technical fields under the technical concept of the application is included in the patent protection scope of the application.

Claims

1. A trapezoidal correction method of an image, characterized by, The trapezoidal correction method comprises: performing edge detection on the image to be processed to obtain an edge binary image, wherein the brightness value of an edge pixel in the edge binary image is higher than the brightness value of a non-edge pixel; performing straight line detection on the edge binary image to obtain a trapezoidal region boundary candidate straight line set; determining first vertex coordinates of trapezoidal region vertices in the image to be processed through the trapezoidal region boundary candidate straight line set; based on the first vertex coordinates, performing radial offset of the trapezoidal region vertices along the central axis of the trapezoidal region, and taking the offset position as second vertex coordinates corresponding to a target trapezoidal region; determining a target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates; performing conversion on each pixel point of the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image.

2. The keystone correction method of an image according to claim 1, wherein The trapezoidal region vertices comprise an upper trapezoidal region vertex and a lower trapezoidal region vertex, and the radial offset of the trapezoidal region vertices along the central axis of the trapezoidal region based on the first vertex coordinates and taking the offset position as the second vertex coordinates corresponding to the target trapezoidal region comprises: determining a first depth between the upper trapezoidal region vertex and the lower trapezoidal region vertex, determining a first adjustment coefficient corresponding to the first depth according to a preset corresponding relationship between the depth and the adjustment coefficient and the first depth; determining a first radial offset amount of the upper trapezoidal region vertex according to the upper edge length of the trapezoidal region and the first adjustment coefficient; performing radial offset of the upper trapezoidal region vertex along the central axis of the trapezoidal region based on the first radial offset amount of the upper trapezoidal region vertex to obtain second upper vertex coordinates corresponding to a target upper trapezoidal region vertex, and determining a first lower vertex coordinate of the lower trapezoidal region vertex as a second lower vertex coordinate corresponding to a target lower trapezoidal region vertex.

3. The trapezoidal correction method of an image according to Claim 1, wherein The trapezoidal region vertices comprise an upper trapezoidal region vertex and a lower trapezoidal region vertex, and the radial offset of the trapezoidal region vertices along the central axis of the trapezoidal region based on the first vertex coordinates and taking the offset position as the second vertex coordinates corresponding to the target trapezoidal region comprises: obtaining a second adjustment coefficient input by a user, and determining a second radial offset amount of the upper trapezoidal region vertex according to the upper edge length of the trapezoidal region and the second adjustment coefficient; performing radial offset of the upper trapezoidal region vertex along the central axis of the trapezoidal region based on the second radial offset amount of the upper trapezoidal region vertex to obtain second upper vertex coordinates corresponding to a target upper trapezoidal region vertex, and determining a first lower vertex coordinate of the lower trapezoidal region vertex as a second lower vertex coordinate corresponding to a target lower trapezoidal region vertex.

4. The trapezoidal correction method of an image according to Claim 1, wherein The determination of the target conversion matrix between the trapezoidal region and the target trapezoidal region according to the first vertex coordinates and the second vertex coordinates comprises: based on the first vertex coordinates of the trapezoidal region vertices and the second vertex coordinates of the target trapezoidal region vertices, calling a perspective transformation matrix algorithm to obtain the target conversion matrix.

5. The trapezoidal correction method of an image according to Claim 1, wherein The conversion of each pixel point of the trapezoidal region according to the target conversion matrix to generate a corrected target trapezoidal region image comprises: Traverse each of the pixel points in the trapezoidal region, and calculate corresponding coordinates of each of the pixel points in the target trapezoidal region image through the target conversion matrix; Generate an initial target trapezoidal region image based on the corresponding coordinates of each of the pixel points in the target trapezoidal region image; Perform mask fusion on the initial target trapezoidal region image and the trapezoidal region image to fill blank regions in the initial target trapezoidal region image that are not covered by original pixels, and obtain a corrected target trapezoidal region image.

6. The trapezoidal correction method of an image according to Claim 1, wherein After the corrected target trapezoidal region image is generated, the method further includes: Perform pixel supplement on the target trapezoidal region image by using a super-resolution algorithm to obtain an enhanced target trapezoidal region image; Replace the trapezoidal region image in the image to be processed with the enhanced target trapezoidal region image to obtain a processed image.

7. The trapezoidal correction method of an image according to Claim 1, wherein After the corrected target trapezoidal region image is generated, the method further includes: Perform target detection on the target trapezoidal region image to obtain a target detection result, the target detection result being used to indicate a category of a target to be detected and a confidence degree of the target to be detected in the target trapezoidal region image.

8. An image keystone correction apparatus characterized by comprising: The device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the trapezoidal correction method of the image according to any one of claims 1 to 7.

9. A storage medium, characterized by The storage medium is a computer-readable storage medium, and the storage medium stores a computer program, the computer program being executable by the processor to implement the steps of the trapezoidal correction method of the image according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Projection image automatic correction method and system based on binocular vision

    CN110830781A

  • Correction method of projection image in projection plane and projection equipment

    CN114567762A