[go: up one dir, main page]

WO2018152710A1 - Image correction method and device - Google Patents

Image correction method and device Download PDF

Info

Publication number
WO2018152710A1
WO2018152710A1 PCT/CN2017/074432 CN2017074432W WO2018152710A1 WO 2018152710 A1 WO2018152710 A1 WO 2018152710A1 CN 2017074432 W CN2017074432 W CN 2017074432W WO 2018152710 A1 WO2018152710 A1 WO 2018152710A1
Authority
WO
WIPO (PCT)
Prior art keywords
quadrilateral
sets
aspect ratio
image
difference
Prior art date
Application number
PCT/CN2017/074432
Other languages
French (fr)
Chinese (zh)
Inventor
秦超
郜文美
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2017/074432 priority Critical patent/WO2018152710A1/en
Priority to CN201780005563.1A priority patent/CN108780572B/en
Publication of WO2018152710A1 publication Critical patent/WO2018152710A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/80Geometric correction
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis

Definitions

  • the present application relates to the field of image processing, and in particular, to a method and apparatus for image correction.
  • the smart terminal When the smart terminal acquires an image of the subject from the front side, an image that substantially matches the ratio of the subject can be obtained, thereby allowing the user to view or perform Optical Character Recognition (OCR).
  • OCR Optical Character Recognition
  • the image may have a perspective distortion, which will affect the review or recognition, so it is necessary to correct the distortion image.
  • the present application describes a method and apparatus for image correction that can be obtained by increasing the accuracy of the original image aspect ratio estimation.
  • an image correction method which acquires a first aspect ratio of a quadrilateral of an image to be corrected and a geometric feature of the quadrilateral; and acquires a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral; Computing a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral, calculating a second aspect ratio of the quadrilateral; calculating a transformation matrix according to a second aspect ratio of the quadrilateral; correcting the method according to the transformation matrix The image to be corrected.
  • the accuracy of the aspect ratio of the rectangle in the corrected image can be improved as a whole.
  • the step of acquiring the quadrilateral compensation factor according to the geometric features of the quadrilateral comprises obtaining a compensation factor of the quadrilateral according to the geometric features of the quadrilateral and a compensation formula.
  • the determining method of the compensation formula includes: acquiring N images of a rectangle of a known aspect ratio at N different angles, wherein N is an integer not less than 2; from each of the N images, Obtaining a first aspect ratio of the rectangle and a geometric feature of the rectangle, obtaining corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; and fitting a compensation formula according to the N sets of corresponding data.
  • the step of fitting a compensation formula according to the N sets of corresponding data includes dividing the N sets of corresponding data into a plurality of types corresponding to different geometric features, according to each of the plurality of types of data Fit the compensation formula separately. In this way, multiple shooting scenes can be combined to refine the scene classification, and each scene uses a compensation formula to make the compensation result more accurate.
  • the compensation formula is predetermined before the image is corrected. Thereby, the process of correcting the image can be simplified.
  • the geometric feature comprises at least one of a distance feature or an angular feature.
  • Different image acquisition scenarios can be determined by different types of geometric features.
  • the angular feature comprises: a difference between two sets of opposite sides of the quadrilateral; or The trigonometric function value of the difference between the two sets of the sides of the quadrilateral; or the difference between the two sets of the trigonometric angles of the quadrilateral.
  • the geometric features include a first geometric feature and a second geometric feature.
  • the first geometric feature includes at least one of the following: a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected, or a diagonal length of the quadrilateral and the to-be-corrected The ratio of the diagonal length of the image, or the angle between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the set of opposite sides of the quadrilateral.
  • the second geometric feature includes: a difference between two sets of opposite sides of the quadrilateral, or a trigonometric function of a difference between two sets of opposite sides of the quadrilateral, or two sets of opposite sides of the quadrilateral.
  • a set of features can be obtained that effectively represent the relative size of the quadrilateral, the relative distance from the lens, and the degree of quadrilateral tilt.
  • Different types of geometric features can be used to determine different shooting scenes and to obtain compensation formulas suitable for different shooting scenes.
  • the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate
  • the width estimate is a median line length that is smaller than an angle in the horizontal direction
  • the height estimate is the length of the median line that is less angled to the vertical.
  • the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being a length of a pair of opposite sides that are smaller than the horizontal direction.
  • the length of the edge is the length of the long side of a pair of opposite sides that is smaller than the vertical direction.
  • the functional form of the compensation formula includes a first function, a quadratic function, or a higher order function form.
  • the general form of the compensation formula can be determined, and the compensation formula can be obtained by calculating the parameters of the function.
  • an apparatus including: a first acquiring module, configured to acquire a first aspect ratio of a quadrilateral in an image to be corrected and a geometric feature of the quadrilateral; and a second acquiring module, configured to Calculating a compensation factor of the quadrilateral according to a geometric feature of the quadrilateral; a first calculating module, configured to calculate a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral; a calculation module, configured to calculate a transformation matrix according to a second aspect ratio of the quadrilateral; and a correction module, configured to correct the image to be corrected according to the transformation matrix.
  • the second obtaining module is configured to obtain a compensation factor of the quadrilateral according to the geometric features and the compensation formula of the quadrilateral.
  • the second obtaining module includes: a first acquiring unit, configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second acquiring unit obtains The aspect ratio of the rectangle and the geometric feature of the rectangle obtain corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; the fitting unit is configured to fit according to the N sets of corresponding data Compensation formula.
  • the fitting unit further includes: a classification sub-module for dividing the N sets of corresponding data into a plurality of types; and a fitting sub-module for each of the plurality of types A type of data is fitted to the compensation formula.
  • the compensation formula is predetermined before the image is corrected. Thereby, the process of correcting the image can be simplified.
  • the geometric feature comprises at least one of a distance feature or an angular feature.
  • Different image acquisition scenarios can be determined by different types of geometric features.
  • the angular feature comprises: a difference between two sets of opposite sides of the quadrilateral; or a trigonometric value of a difference between two sets of opposite sides of the quadrilateral; or the quadrilateral The difference between the two sets of trigonometric values of the angle between the two sides. In this way, a set of features can be obtained that effectively represent the degree of tilt of the quadrilateral.
  • the geometric features include a first geometric feature and a second geometric feature.
  • the first geometric feature includes at least one of the following: a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected, or a diagonal length of the quadrilateral and the to-be-corrected The ratio of the diagonal length of the image, or the angle between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the set of opposite sides of the quadrilateral.
  • the second geometric feature includes: a difference between two sets of opposite sides of the quadrilateral, or a trigonometric function of a difference between two sets of opposite sides of the quadrilateral, or two sets of opposite sides of the quadrilateral.
  • a set of features can be obtained that effectively represent the relative size of the quadrilateral, the relative distance from the lens, and the degree of quadrilateral tilt.
  • Different types of geometric features can be used to determine different shooting scenes and to obtain compensation formulas suitable for different shooting scenes.
  • the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate
  • the width estimate is a median line length that is smaller than an angle in the horizontal direction
  • the height estimate is the length of the median line that is less angled to the vertical.
  • the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being a length of a pair of opposite sides that are smaller than the horizontal direction.
  • the length of the edge is the length of the long side of a pair of opposite sides that is smaller than the vertical direction.
  • the functional form of the compensation formula includes a first function, a quadratic function, or a higher order function form.
  • the general form of the compensation formula can be determined, and the compensation formula can be obtained by calculating the parameters of the function.
  • an apparatus comprising: one or more processors, a memory, and one or more programs, the one or more programs being stored in a memory and configured to be configured by one or more Executed by the processor, the one or more programs include instructions for performing the method of the first aspect.
  • a computer program product comprising instructions for causing a computer to perform the method of the first aspect when the instructions are run on a computer.
  • a computer readable storage medium having stored therein instructions that, when executed on a computer, cause the computer to perform the method of the first aspect.
  • FIG. 1 is a schematic diagram of an image correction scenario according to an embodiment of the present invention
  • FIG. 2 is a flowchart of an image correction method according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a first aspect ratio according to an embodiment of the present invention.
  • FIG. 4 is a flowchart of a method for determining a compensation formula according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of acquiring N images of a rectangle having a known aspect ratio according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of classification according to an image tilt posture according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of classification according to image distance according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of classification according to an image tilt posture and distance according to an embodiment of the present invention.
  • FIG. 9 is a flowchart of another method for determining a compensation formula according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of a device according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of a second acquiring module according to an embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of another second acquiring module according to an embodiment of the present invention.
  • FIG. 13 is a schematic structural diagram of another device according to an embodiment of the present invention.
  • FIG. 1 is a schematic diagram of an image acquisition scenario according to an embodiment of the present invention.
  • the subject 102 is placed on the support structure 103, and the device 101 takes an image of the subject 102.
  • the subject 102 can be any object containing text and/or images, such as documents, pictures, business cards, documents, books, slides, whiteboards, street signs, and advertising signs.
  • the device 101 can be any device capable of acquiring an image or processing an image, for example, a mobile phone (or "mobile phone"), a tablet (Tablet Personal Computer, TPC), a computer, a digital camera, a wearable device (Wearable Device) ), virtual reality devices, digital broadcast terminals, messaging devices, game consoles, medical devices, fitness equipment, personal digital assistants (PDAs), e-book readers, and scanners .
  • the device 101 can acquire images through optical components such as cameras, cameras or optical sensors, which can be built into the device 101 or externally connected to the device 101. For the sake of clarity and convenience, the optical components of the present application are uniformly described using a camera.
  • part (A) of Fig. 1 when the device 101 is photographed from the front side, an image 104 substantially in proportion to the subject 102 can be obtained.
  • the see-through effect causes the acquired image 104' to be distorted, so the distortion image 104' needs to be corrected.
  • the image correction process First, the image 104' is input, then the quadrilateral in the image is detected, then the aspect ratio of the object 102 is estimated according to the quadrilateral, and the transformation matrix is calculated according to the estimated aspect ratio, and finally the distortion image 104' is corrected by using the transformation matrix. It is a rectangular image 104".
  • the above image correction process uses a complex formula for estimating the aspect ratio, which is based on the assumed lens focal length parameter. In practical applications, since the lens focal length is different from the assumed lens focal length, the pair is shot.
  • the aspect ratio estimation error of the object is large, especially when the tilt angle of the device 101 is large, the deviation between the estimated value of the aspect ratio and the actual value is larger.
  • Figure 2 shows a flow chart of the method, which may be performed by device 101, the method comprising:
  • Step 201 Acquire a first aspect ratio R 0 of a quadrilateral of the image to be corrected and a geometric feature of the quadrilateral;
  • Step 202 obtaining a quadrilateral compensation factor k according to the geometric feature of the quadrilateral
  • Step 203 calculating a second aspect ratio R 1 of the quadrilateral according to the first aspect ratio R 0 of the quadrilateral and the compensation factor k of the quadrilateral;
  • Step 204 calculating a transformation matrix K according to a second aspect ratio R 1 of the quadrilateral
  • Step 205 correcting the image to be corrected according to the transformation matrix K.
  • an image to be corrected of the subject is acquired.
  • the image to be corrected may be an image acquired by the camera in real time, such as a frame for capturing a subject or capturing a preview video of the subject, or an existing image, such as an image stored on a memory.
  • the object may be presented as a rectangle as a whole, such as a document, a picture, a business card, a document, a book, a slide, a whiteboard, a street sign, and an advertisement sign mentioned above, or may be a partial area including a rectangle, for example, in a subject. Contains a rectangular image or text block.
  • device 101 detects a quadrilateral edge to extract a quadrilateral in the image.
  • the detection algorithm of the quadrilateral edge can adopt a known method, and will not be described here.
  • the user can manually select a quadrilateral in the image, for example, the user drags the four corners of the quadrilateral box in the image, selects the quadrilateral in the image, and extracts the quadrilateral in the image.
  • the four corner coordinates of the quadrilateral can be obtained according to the extracted quadrilateral, thereby calculating the first aspect ratio R 0 of the quadrilateral and the geometric features of the quadrilateral.
  • the first aspect ratio R 0 may be a ratio of the lengths of the adjacent sides of the quadrilateral. As shown in part (A) of Fig. 3, from the two sets of opposite sides of the quadrilateral, the horizontal opposite side and the vertical opposite side are respectively determined, and the length l CD of the longer side of the horizontal opposite side is taken as the width estimation value W.
  • the step of determining the horizontal opposite side and the vertical opposite side comprises: comparing the angle between any two adjacent sides of the quadrilateral and the horizontal direction, the side with the smaller angle and the opposite side being the horizontal opposite side, and the remaining A set of opposite sides is a vertical opposite side.
  • the angle between any two adjacent edges and the vertical direction may be compared, and the smaller side and the opposite side are vertical opposite sides, and the remaining set of opposite sides are horizontal opposite sides.
  • the geometric features of the quadrilateral include angular features.
  • the smaller angle of the opposite side of the two sets of opposite sides can be used to determine the degree of inclination of the opposite side with less distortion of the quadrilateral: the larger the angle of the opposite side, the greater the inclination; the opposite side The smaller the angle, the smaller the tilt.
  • the absolute value ⁇ of the difference between the two sets of opposite sides can be used to determine the degree of deformation of the image as a whole: the larger the absolute value ⁇ , the greater the degree of deformation; the smaller the absolute value ⁇ , the smaller the degree of deformation.
  • the angular feature may include a trigonometric function value of two sets of opposite sides of the quadrilateral, and a trigonometric function value of the absolute value of the difference between the two sets of angles of the opposite sides or a trigonometric function value of the two sets of opposite sides The absolute value of the difference.
  • the trigonometric value includes a sine, a tangent, a cosine, or a cotangent.
  • the trigonometric function values of the two sets of angles of the opposite sides can be used to determine the degree of inclination of the opposite sides of the quadrilateral distortion, the trigonometric function values of the absolute values of the difference between the two sets of sides, or the two sets of opposite side clips
  • the absolute value of the difference between the angular trigonometric values can be used to determine the degree of deformation of the image as a whole.
  • the embodiment of the present invention refers to the absolute angle between the two sets of opposite sides of the quadrilateral ⁇ H and ⁇ V and the difference between the two sets of opposite sides.
  • the value ⁇ When the method according to the embodiment of the present invention is applied to an embodiment in which the geometric feature includes a trigonometric function value, the two sets of opposite angles may be replaced by two sets of trigonometric values of the opposite sides, and two pairs of pairs may be used.
  • the absolute value of the difference between the absolute value of the difference between the edges and the value of the trigonometric function of the two sets of angles replaces the absolute value of the difference between the two sets of opposite sides.
  • the length of each side of the quadrilateral, the length of the median line, the angle of the opposite side, and the value of the trigonometric function can be obtained by calculating the coordinates of the four corner points of the quadrilateral, which belongs to the conventional geometric knowledge in the field, and is not here. Let me repeat.
  • step 202 according to the geometric features of the quadrilateral and the compensation formula, the geometric features of the quadrilateral are substituted into the compensation formula, and the compensation factor of the quadrilateral can be obtained.
  • the functional form of the compensation formula can be a one-time function, a quadratic function, or a higher-order function form.
  • the compensation formula may be determined in advance before the image correction method of the embodiment of the present invention is implemented, or may be determined in the process of implementing the image correction method of the embodiment of the present invention.
  • the quadrilateral can be classified according to the characteristics of the quadrilateral tilt posture, and a compensation formula is determined for each type of quadrilateral.
  • a flowchart of a method for determining the compensation formula is shown in FIG. 4, and the method may be performed by the device 101, including:
  • Step 2021 Acquire N images of rectangles of known aspect ratio at N different angles
  • Step 2022 Obtain a first aspect ratio R Q and a geometric feature of the rectangle from each of the N images, and obtain corresponding data of the compensation factor k Q of the N sets of rectangles and the geometric feature;
  • Step 2023 the N sets of corresponding data are divided into multiple types
  • step 2024 the compensation formula is respectively fitted according to each type of data of multiple types.
  • N images of rectangles of known aspect ratio at N different angles may be acquired by the camera of device 110. Acquiring N images may capture the rectangle through the camera, or may capture a frame of the preview video of the rectangle.
  • the plane of the rectangle coincides with the XOY plane, when the device is in space
  • the number N of angles is an integer not less than 2, which is used to satisfy the basic condition for obtaining the compensation formula. Since the accuracy of the compensation formula increases as the number N increases, more images can be acquired at more angles in order to obtain a more accurate compensation formula.
  • one direction is selected every 45° (i.e., ⁇ is taken as 0°, 45°, 90°, ..., 315°) in the range of ⁇ ⁇ [0°, 360°), and in these directions.
  • an image is taken every 4° in the range of ⁇ (0°, 90°) (that is, ⁇ is taken as 4°, 8°, ..., 88°, respectively). It should be noted that the above angular range and angular interval are only examples, and other angular ranges and angular intervals may be selected to obtain more or less images.
  • the rectangle is displayed as a quadrilateral Q in the image, by selecting different horizontal-to-edge angles ⁇ QH of the quadrilateral Q and the angle between the vertical opposite sides ⁇ QV (reference numeral not shown), thereby acquiring N images.
  • an image can be acquired every 1° in the range of the horizontal-to-edge angle ⁇ QH ⁇ [0°, 50°]; at the same time, the angle ⁇ QV ⁇ [0°, 50° at the vertical opposite side In the range of ], an image is acquired every 1°.
  • an image can also be acquired every 2°. It should be noted that the above angular range and angular interval are only examples, and other angular ranges and angular intervals may also be selected.
  • the first aspect ratio rectangular quadrilateral R Q R 0 corresponding to the first aspect ratio, when the aspect ratio of a quadrangle R 0 using a first adjacent side length ratio, the width of the rectangular first step
  • the high ratio R Q also uses the ratio of the corresponding adjacent side lengths.
  • the first aspect ratio R 0 of the quadrilateral uses the ratio of the lengths of the two median lines
  • the first aspect ratio R Q of the rectangle also adopts the ratio of the lengths of the corresponding two median lines.
  • the geometrical features of the rectangle correspond to the geometric features of the quadrilateral.
  • the geometric features of the quadrilateral include the two sets of opposite angles ⁇ H and ⁇ V of the quadrilateral and the absolute value ⁇ of the difference between the two sets of opposite sides
  • the compensation factor k Q of the rectangle corresponds to the compensation factor k of the quadrilateral, and the compensation factor k Q of the rectangle reflects the relationship between the original aspect ratio R of the rectangle and the first aspect ratio R Q .
  • a corresponding set of rectangular compensation factors k Q and geometric features can be obtained, that is, the compensation factor k Q , two pairs of pairs The angle ⁇ QH and ⁇ QV of the side and the absolute value ⁇ Q of the difference between the angles of the two sets of opposite sides.
  • the geometric features of the rectangle are compared to a classification threshold to classify the N sets of corresponding data into a type corresponding to the quadrilateral type.
  • the quadrilateral can be classified into the following four categories: horizontal unilateral inclination, horizontal bilateral inclination, vertical unilateral inclination, and vertical bilateral inclination.
  • the two sets of opposite side angles ⁇ QH and ⁇ QV of the rectangle are compared with the angle classification threshold ⁇ T , thereby dividing the N sets of corresponding data into four types corresponding to the quadrilateral type.
  • the vertical-to-edge angle ⁇ QV of the horizontal double-sided tilt type shown in part (B) of FIG. 6 is smaller than the vertical-to-edge angle ⁇ QV , and the angle classification threshold ⁇ T is smaller than the horizontal-to-edge angle ⁇ QH ;
  • the vertical unilateral tilt type ⁇ QV of the vertical unilateral tilt type shown in part (C) is smaller than the horizontal opposite side angle ⁇ QH , and the angle classification threshold ⁇ T is between the two sets of opposite side angles;
  • the vertical-to-edge angle ⁇ QV of the vertical double-sided tilt type shown in the (D) portion is smaller than the horizontal-to-edge angle ⁇ QH , and the angle classification threshold ⁇ T is smaller than the vertical-to-edge angle ⁇ QV .
  • the angle classification threshold ⁇ T can be used to classify the N sets of corresponding data into corresponding quadrilateral types according to a certain ratio or uniformly, and classify the corrected quadrilaterals to select a corresponding compensation formula.
  • the angle classification threshold ⁇ T may be a horizontal-to-edge angle ⁇ QH of a rectangle or a statistical quantile of a vertical-to-edge angle ⁇ QV .
  • the quantile includes quartiles or other proportional quantiles.
  • the angle classification threshold ⁇ T may be the median of the selection angle-to-edge angle ⁇ QH (also referred to as the second quartile), that is, all the horizontal-to-edge angles ⁇ QH are arranged from small to large and then ranked 50th.
  • the value of %) can also be the median of the angle ⁇ QV between the vertical and the opposite sides, or the mean of the median of the angle between the horizontal and the opposite sides and the median of the angle between the vertical and the opposite sides.
  • the angle classification threshold ⁇ T may also be the mean of the horizontal-to-edge angle ⁇ QH of the rectangle or the vertical-to-edge angle ⁇ QV .
  • the angle classification threshold ⁇ T may also be valued empirically, for example, from a range of [2°, 5°].
  • step 2024 in each of the N sets of corresponding data, a compensation formula is fitted according to the absolute value ⁇ Q of the difference between the two sets of opposite sides of the rectangle and the compensation factor k Q .
  • Table 1 shows the corresponding data of the absolute value ⁇ Q of the difference between the two sets of opposite sides of the rectangle in the horizontal unilateral tilt type and the compensation factor k Q , thereby fitting the horizontal unilateral tilt
  • the type of compensation formula may be any one of the following, where x represents a geometric feature and k represents a compensation factor:
  • the two sets of opposite side angles ⁇ H and ⁇ V of the quadrilateral to be corrected are compared with the angle classification threshold ⁇ T , so that the quadrilateral to be corrected is divided into corresponding types, and the compensation formula under the type is selected.
  • the absolute value ⁇ of the difference between the two sets of angles is substituted into the compensation formula to calculate the compensation factor k of the quadrilateral.
  • the image acquisition scenes of different angles are classified, and the compensation formula is obtained by using a statistical method for each type of image acquisition scene, and the preliminary estimation of the quadrilateral aspect ratio is compensated, so that the corrected image is obtained.
  • the aspect ratio is closer to the original aspect ratio of the subject, which improves the image correction effect.
  • FIG. 2 Another embodiment of the present invention provides an image correction method.
  • the method will be described below with reference to FIGS. 2, 4, 7, and 8.
  • the flowchart of the image correction method is as shown in FIG. 2, wherein steps 203 to 205 of the method are the same as steps 203 to 205 described above, and details are not described herein again.
  • steps 201 and 202 and steps 201 and 202 described above will be described.
  • the geometric features of the quadrilateral include a first geometric feature and a second geometric feature.
  • the first geometric feature is a combination of a length feature and an angle feature for classifying the quadrilateral.
  • the length feature may include a side length ratio D of the quadrilateral.
  • the aspect ratio D can be used to determine the relative distance between the subject and the camera. The larger the side length ratio, the closer the distance between the subject and the camera; the smaller the side length ratio, the farther the subject is from the camera.
  • the angular feature may include two sets of opposite angles ⁇ H and ⁇ V , and may also include trigonometric values of two sets of opposite sides of the quadrilateral, for example, sine, tangent, cosine or Cotangent value.
  • the above values can be used to determine the degree of tilt of the opposite sides with less quadrilateral distortion.
  • the second geometric feature includes an angular feature of the quadrilateral for calculating the compensation factor k.
  • the value of the trigonometric function of the difference between the angles, or the difference between the two sets of trigonometric values of the angles of the edges, or the trigonometric function of the absolute difference between the two sets of angles between the two sides, or the trigonometric function of the two sets of angles between the opposite sides The absolute value of the difference in values. The above values can be used to determine the degree of deformation of the entire image.
  • the absolute value ⁇ of the difference between the two groups When the method according to the embodiment of the present invention is applied to an embodiment in which the geometric feature includes a trigonometric function value, the two sets of opposite angles may be replaced by two sets of trigonometric values of the opposite sides, and two pairs of pairs may be used.
  • the absolute value of the difference between the absolute value of the difference between the edges and the value of the trigonometric function of the two sets of angles replaces the absolute value of the difference between the two sets of opposite sides.
  • a compensation factor is obtained based on the geometric features of the quadrilateral and the compensation formula.
  • the second geometric feature of the quadrilateral is substituted into the compensation formula, and the compensation factor of the quadrilateral can be calculated.
  • the compensation formula may reflect the relationship of the second geometric feature to the compensation factor k in the same form as described in step 202 above.
  • the quadrilateral can be classified according to the characteristics of the distance and the tilting posture, Each type of quadrilateral determines a compensation formula.
  • FIG. 4 A flowchart of the method for determining the compensation formula is shown in FIG. 4 .
  • the steps 2021 and 2024 of the method are the same as the steps 2021 and 2024 described above, and are not described herein again.
  • the differences between steps 2022 and 2023 and steps 2022 and 2023 described above will be described.
  • step 2022 since the geometric feature of the rectangle corresponds to the geometric feature of the quadrilateral to be corrected, when the geometric feature of the quadrilateral to be corrected includes the first geometric feature and the second geometric feature, the geometric feature of the rectangle also includes the corresponding first geometric feature. And the second geometric feature.
  • the first geometric feature of the rectangle is compared to a classification threshold to classify the N sets of corresponding data into a type corresponding to the quadrilateral type.
  • quadrilaterals can be divided into the following three categories based on distance: near, medium, and far.
  • the quadrilateral can be divided into two types: near and far, or divided into five categories: near, medium, medium, medium, and long distance. It should be noted that the above classification should not be a limitation on the present application as long as the classification can describe the distance between the object and the device.
  • the side length ratio D Q and the distance classification threshold T of the rectangle may be compared first, and the N sets of corresponding data are classified into a category corresponding to the quadrilateral distance type.
  • the data is then compared with the two sets of opposite side angles ⁇ QH and ⁇ QV of the rectangle and the angle classification threshold ⁇ T , thereby further classifying each large class of data into small class data corresponding to the quadrilateral tilt type.
  • the distance classification threshold T can be used to classify the N sets of corresponding data into corresponding quadrilateral distance types according to a certain ratio or substantially uniformly, and classify the corrected quadrilaterals to select a corresponding compensation formula.
  • the distance classification threshold T may be a statistical quantile of the square side length ratio D Q .
  • the distance classification threshold T may be a 1/3 quantile of the side length ratio D Q (ie, all values are determined by The value of the 1/3 position after the small to large arrangement and the 2/3 quantile (that is, the value of all the values from the small to the large and the 2/3 position).
  • the distance classification threshold T may also be the mean of the rectangular side length ratio D Q .
  • the distance classification threshold T may also be based on empirical values, such as 0.5 and 0.8.
  • the quadrilateral can be classified into three types: far, medium, and close.
  • the side length ratio of the close-up quadrilateral shown in part (A) of FIG. 7 is h/H>0.8
  • the side length of the medium-distance quadrilateral shown in part (B) of FIG. 7 is 0.5 ⁇ h/ H ⁇ 0.8
  • the side length ratio of the distance-like quadrilateral shown in part (C) of Fig. 7 is h/H ⁇ 0.5.
  • the N sets of corresponding data are divided into three categories of data corresponding to the three kinds of distances, and then each of the large types of data is divided into four sub-classes of data corresponding to the four tilting postures, as shown in FIG. data.
  • the types of image acquisition scenes are further refined, so that the compensation formula corresponding to each type of image acquisition scene can more accurately reflect the geometric features and compensation of the quadrilateral.
  • the relationship of the factors, so the corrected image aspect ratio is closer to the actual aspect ratio of the subject, thereby improving the effect of image correction in each type of scene.
  • FIG. 2 Another embodiment of the present invention provides an image correction method.
  • the method will be described below with reference to FIGS. 2 and 9.
  • the flowchart of the image correction method is as shown in FIG. 2, wherein steps 203 to 205 of the method are the same as steps 203 to 205 described above, and details are not described herein again.
  • steps 201 and 202 and steps 201 and 202 described above will be described.
  • the geometric feature of the quadrilateral may be the difference between the two sets of opposite sides of the quadrilateral.
  • the magnitude of the difference ⁇ HV can be used to determine the degree of tilt of the image as a whole, and the sign of the difference ⁇ HV is used to indicate the tilt direction (ie, horizontal or vertical tilt).
  • ⁇ HV >0 the image is tilted as a whole.
  • ⁇ HV ⁇ 0 the image as a whole is vertically inclined.
  • ⁇ VH >0 the rectangular image is vertically inclined as a whole
  • ⁇ VH ⁇ 0, the rectangular image as a whole is horizontally inclined.
  • the geometric feature of the quadrilateral may also be a trigonometric function value of the difference between the two sets of angles of the opposite sides, or a difference between the two sets of trigonometric values of the angles of the opposite sides.
  • These geometric features can indicate the degree of tilt and tilt of the image as a whole. Oblique direction.
  • the embodiment of the present invention refers to the difference ⁇ HV between the two sets of opposite sides of the quadrilateral unless otherwise stated.
  • the geometric feature includes a trigonometric function value
  • the difference between the two sets of trigonometric values of the difference between the sides of the edges or the difference between the two sets of trigonometric values of the opposite sides can be used.
  • the difference between the corresponding two sets of opposite sides can be used.
  • step 202 the geometric feature of the quadrilateral is substituted into the compensation formula, and the compensation factor k of the quadrilateral can be calculated.
  • the compensation formula may reflect the relationship of the geometric feature to the compensation factor k in the same form as described in step 202 above. Since the difference between the two sets of opposite sides of the quadrilateral can indicate the degree of tilt and the tilt direction of the image as a whole, the quadrilateral can be classified without using a compensation formula to represent the relationship between the geometrical features of the quadrilateral and the compensation factor k.
  • FIG. 9 Another method for determining a compensation formula according to an embodiment of the present invention is described below with reference to FIG. 9, which may be performed by the device 101, including:
  • Step 2021' obtaining N images of rectangles of known aspect ratio at N different angles.
  • Step 2022' Obtain a first aspect ratio R Q and a geometric feature of the rectangle from each of the N images, and obtain corresponding data of the compensation factor k Q of the N sets of rectangles and the geometric features.
  • Step 2023' fitting the compensation formula according to the N sets of compensation factors k Q and the corresponding data of the geometric features.
  • step 2021' is similar to the previous step 2021, it will not be described again here. Step 2022' and step 2023' will be specifically described below.
  • step 2022' since the geometric features of the rectangle correspond to the geometric features of the quadrilateral, when the geometric features of the quadrilateral include the difference between the two sets of opposite sides, the geometrical features of the rectangle also include the difference between the two sets of opposite sides.
  • step 2023' since the quadrilateral is unclassified, the N sets of corresponding data may not be classified, and the compensation formula may be directly fitted according to the difference ⁇ QHV between the two sets of opposite sides of the rectangle and the compensation factor k Q .
  • Table 2 shows the corresponding data of the difference ⁇ QHV between the two sets of opposite sides of the rectangle and the compensation factor k Q , whereby the compensation formula can be fitted.
  • the type of the image acquisition scene can be reduced, and the compensation formula can still accurately reflect the relationship between the geometric features of the quadrilateral and the compensation factor, thereby simplifying the image.
  • the step of correcting improves the processing speed of image correction.
  • FIG. 10 is a schematic structural diagram of a device according to an embodiment of the present invention.
  • the device 1000 includes: The first obtaining module 1001, the second obtaining module 1002, the first calculating module 1003, and the second calculating module 1004 and the correcting module 1005.
  • the first obtaining module 1001 is configured to acquire a first aspect ratio of a quadrilateral in the image to be corrected and a geometric feature of the quadrilateral.
  • the second obtaining module 1002 is configured to obtain a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral.
  • the first calculating module 1003 is configured to calculate a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral.
  • the second calculating module 1004 is configured to calculate a transformation matrix according to the second aspect ratio of the quadrilateral.
  • the correction module 1005 is configured to correct the image to be corrected according to the transformation matrix.
  • FIG. 11 is a schematic structural diagram of a second acquiring module according to an embodiment of the present invention.
  • the second acquiring module 1002 further includes: a first acquiring unit 10021, a second acquiring unit 10022, a classifying unit 10023, and Fitting unit 10024.
  • the first obtaining unit 10021 is configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second obtaining unit 10022 is configured to acquire the rectangle
  • the aspect ratio and the geometric features of the rectangle obtain corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle;
  • the classifying unit 10023 is configured to divide the N sets of corresponding data into multiple types;
  • the merging unit 10024 is configured to respectively fit the compensation formula according to each of the plurality of types of data.
  • FIG. 12 is a schematic structural diagram of another second acquiring module according to an embodiment of the present invention.
  • the second acquiring module 1002 further includes: a first acquiring unit 10021', a second acquiring unit 10022', and a Unit 10023'.
  • the first obtaining unit 10021 ′ is configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second obtaining unit 10022 is configured to acquire the rectangle.
  • the fitting unit 10023' is configured to fit the compensation according to the N sets of corresponding data formula.
  • the device provided by the embodiment of the present invention is used to implement the foregoing method in the embodiment shown in FIG. 1 to FIG. 9.
  • FIG. 13 is a structural diagram of another apparatus according to an embodiment of the present invention.
  • the apparatus 1300 includes: a processor 1301, a camera 1302, a user input device 1303, a display 1304, a memory 1305, and a Or multiple programs.
  • FIG. 13 only shows a part related to the embodiment of the present invention. If the specific technical details are not disclosed, please refer to the above method embodiment and other parts of the application file of the present application.
  • the number of hardware such as the processor 1301, the camera 1302, the user input device 1303, the display 1304 and the memory 1305 may be one or more, depending on the type of the device 1300.
  • the processor 1301 is coupled to the camera 1302, the user input device 1303, the display 1304, and the memory 1305 via one or more buses.
  • the processor 1301 receives the image from the camera 1302 and the user command from the user input device 1303, calls the execution instruction stored in the memory 1305 for processing, and sends it to the display 1304 for presentation.
  • the processor 1301 may be a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), and a field programmable gate array ( Field Programmable Gate Array (FPGA) or other programmable logic device, transistor logic device, hardware component, or any combination thereof.
  • the processor 1301 can implement or perform various exemplary logical blocks, modules, and circuits described in connection with the present disclosure.
  • the processor 1301 may also be a combination of computing functions, such as one or more microprocessor combinations, a combination of a DSP and a microprocessor, and the like. As an example, the processor 1301 is configured to support the device 1300 to perform step 202 in FIG. 2 . Up to 204, steps 2022 through 2024 in Fig. 4, and steps 2022' and 2023' in Fig. 9.
  • the camera 1302 transmits the acquired image to the processor 1301.
  • the camera 1302 can also be a digital camera (also known as a digital camera, digital camera), a scanner, or other optical device capable of acquiring images.
  • the acquired image is distinguished from the perspective of the content, and may be an image, a document, or a mixed image containing both the image and the document.
  • the camera 1302 is used to support the device to perform step 201 in Fig. 2, step 2021 in Fig. 4, and step 2021' in Fig. 9.
  • the user input device 1302 receives the user's operation instructions and transmits them to the processor 1301 for processing.
  • the user input device 1302 includes a touch screen, a button, or a microphone.
  • Display 1304 presents a preview image, a corrected image, and a human-computer interaction interface.
  • Display 1304 can be a display built into device 1300 or other external display device externally connected to device 1300.
  • the memory 1305 stores images, preset models, and one or more programs.
  • Memory 1305 can be any computer readable storage medium.
  • the one or more programs are stored in a memory and configured to be executed by one or more processors, including both execution instructions of the device operating system and execution instructions of the device application, such as correcting images in embodiments of the present invention. Execution instructions.
  • the present invention may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable medium to another computer readable medium, for example, the computer instructions can be wired from a website site, computer, server or data center (for example, coaxial cable, fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to another website, computer, server or data center.
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a Solid State Disk (SSD)) or the like.
  • a magnetic medium eg, a floppy disk, a hard disk, a magnetic tape
  • an optical medium eg, a DVD
  • a semiconductor medium eg, a Solid State Disk (SSD)
  • the functions described herein can be implemented in hardware, software, firmware, or any combination thereof.
  • the functions may be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium.
  • Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another.
  • a storage medium may be any available media that can be accessed by a general purpose or special purpose computer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

Provided is an image correction method, acquiring a first aspect ratio of a quadrangle of an image to be corrected and a geometric feature of the quadrangle; acquiring a compensation factor of the quadrangle according to the geometric feature of the quadrangle; calculating a second aspect ratio of the quadrangle according to the first aspect ratio of the quadrangle and the compensation factor of the quadrangle; calculating a transformation matrix according to the second aspect ratio of the quadrangle; and correcting the image to be corrected according to the transformation matrix. By means of the solution provided in the present application, an estimated value closer to the original aspect ratio of a captured subject can be obtained, thereby obtaining a corrected image that is substantially consistent with the original aspect ratio of the captured subject.

Description

图像校正的方法及装置Image correction method and device 技术领域Technical field
本申请涉及图像处理领域,尤其涉及一种图像校正的方法及装置。The present application relates to the field of image processing, and in particular, to a method and apparatus for image correction.
背景技术Background technique
随着智能终端的快速普及,使用智能终端获取资料成为越来越多用户的选择。智能终端使用的摄像头硬件不断升级,软件功能也越来越丰富,图像校正作为其中一项特色功能,可以满足广大用户获取各类图像的需求。With the rapid spread of smart terminals, the use of smart terminals to obtain data has become the choice of more and more users. The camera hardware used by smart terminals is constantly upgraded, and the software functions are becoming more and more abundant. Image correction is one of the featured functions, which can meet the needs of users to obtain various types of images.
当智能终端从正面获取被摄物体的图像时,能够得到与被摄物体比例基本一致的图像,从而供用户查阅或者进行光学字符识别(Optical Character Recognition,OCR)。然而,当智能终端从侧面获取被摄物体的图像时,图像会产生透视畸变,这将影响查阅或识别,因此有必要对畸变图像进行校正。When the smart terminal acquires an image of the subject from the front side, an image that substantially matches the ratio of the subject can be obtained, thereby allowing the user to view or perform Optical Character Recognition (OCR). However, when the smart terminal acquires an image of the subject from the side, the image may have a perspective distortion, which will affect the review or recognition, so it is necessary to correct the distortion image.
发明内容Summary of the invention
本申请描述了一种图像校正的方法和装置,通过提高对原始图像宽高比估计的准确度,可以获得与原始图像比例基本一致的校正图像。The present application describes a method and apparatus for image correction that can be obtained by increasing the accuracy of the original image aspect ratio estimation.
第一方面,提供了一种图像校正方法,该方法获取待校正图像的四边形的第一宽高比以及所述四边形的几何特征;根据所述四边形的几何特征获取所述四边形的补偿因子;根据所述四边形的第一宽高比和所述四边形的补偿因子,计算所述四边形的第二宽高比;根据所述四边形的第二宽高比计算变换矩阵;根据所述变换矩阵校正所述待校正图像。通过补偿四边形的第一宽高比,可以从整体上提升校正后图像中的矩形的宽高比的准确性。In a first aspect, an image correction method is provided, which acquires a first aspect ratio of a quadrilateral of an image to be corrected and a geometric feature of the quadrilateral; and acquires a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral; Computing a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral, calculating a second aspect ratio of the quadrilateral; calculating a transformation matrix according to a second aspect ratio of the quadrilateral; correcting the method according to the transformation matrix The image to be corrected. By compensating for the first aspect ratio of the quadrilateral, the accuracy of the aspect ratio of the rectangle in the corrected image can be improved as a whole.
在一个可能的设计中,根据所述四边形的几何特征获取所述四边形补偿因子的步骤包括,根据所述四边形的几何特征和补偿公式获取所述四边形的补偿因子。所述补偿公式的确定方法包括:获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;从所述N个图像的每一个图像中,获取所述矩形的第一宽高比以及矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;根据所述N组对应数据拟合补偿公式。通过获取已知宽高比的矩形在多个角度下的图像,借助统计的方法拟合补偿公式,使得补偿的结果更加准确。In one possible design, the step of acquiring the quadrilateral compensation factor according to the geometric features of the quadrilateral comprises obtaining a compensation factor of the quadrilateral according to the geometric features of the quadrilateral and a compensation formula. The determining method of the compensation formula includes: acquiring N images of a rectangle of a known aspect ratio at N different angles, wherein N is an integer not less than 2; from each of the N images, Obtaining a first aspect ratio of the rectangle and a geometric feature of the rectangle, obtaining corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; and fitting a compensation formula according to the N sets of corresponding data. By obtaining an image of a rectangle with a known aspect ratio at multiple angles, the compensation formula is fitted by statistical methods, so that the compensation result is more accurate.
在一个可能的设计中,根据所述N组对应数据拟合补偿公式的步骤包括,将N组对应数据分为对应不同几何特征的多个类型,根据所述多个类型中的每一类数据分别拟合补偿公式。这样,可以对多种拍摄场景进行组合,细化场景分类,每一种场景使用一个补偿公式,使得补偿的结果更加准确。In a possible design, the step of fitting a compensation formula according to the N sets of corresponding data includes dividing the N sets of corresponding data into a plurality of types corresponding to different geometric features, according to each of the plurality of types of data Fit the compensation formula separately. In this way, multiple shooting scenes can be combined to refine the scene classification, and each scene uses a compensation formula to make the compensation result more accurate.
在一个可能的设计中,所述补偿公式在校正图像前预先确定。由此,校正图像过程可以得到简化。In one possible design, the compensation formula is predetermined before the image is corrected. Thereby, the process of correcting the image can be simplified.
在一个可能的设计中,所述几何特征包括距离特征或角度特征中的至少一种。通过不同类型的几何特征,可以确定不同的图像获取场景。In one possible design, the geometric feature comprises at least one of a distance feature or an angular feature. Different image acquisition scenarios can be determined by different types of geometric features.
在一个可能的设计中,所述角度特征包括:所述四边形的两组对边夹角的差值;或 者所述四边形的两组对边夹角的差值的三角函数值;或者所述四边形的两组对边夹角的三角函数值的差值。这样,可以得到一组特征,所述特征能够有效地表示四边形的倾斜程度。In one possible design, the angular feature comprises: a difference between two sets of opposite sides of the quadrilateral; or The trigonometric function value of the difference between the two sets of the sides of the quadrilateral; or the difference between the two sets of the trigonometric angles of the quadrilateral. In this way, a set of features can be obtained that effectively represent the degree of tilt of the quadrilateral.
在一个可能的设计中,所述几何特征包括第一几何特征和第二几何特征。所述第一几何特征包括以下特征中的至少一种:所述四边形的最长边的长度与所述待校正图像的边长的比值,或者所述四边形的对角线长度与所述待校正图像的对角线长度的比值,或者所述四边形的两组对边夹角的大小,或者所述四边形的两组对边夹角的三角函数值。所述第二几何特征包括:所述四边形的两组对边夹角的差值,或者所述四边形的两组对边夹角的差值的三角函数值,或者所述四边形的两组对边夹角的三角函数值的差值,或者所述四边形的两组对边夹角的差值的绝对值,或者所述四边形的两组对边夹角的差值的绝对值的三角函数值,或者所述四边形的两组对边夹角的三角函数值的差值的绝对值。这样,可以得到一组特征,所述特征能够有效地表示四边形的相对大小、距离镜头的相对远近,以及四边形倾斜程度。通过不同类型的几何特征,可以确定不同的拍摄场景,获取适合不同拍摄场景的补偿公式。In one possible design, the geometric features include a first geometric feature and a second geometric feature. The first geometric feature includes at least one of the following: a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected, or a diagonal length of the quadrilateral and the to-be-corrected The ratio of the diagonal length of the image, or the angle between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the set of opposite sides of the quadrilateral. The second geometric feature includes: a difference between two sets of opposite sides of the quadrilateral, or a trigonometric function of a difference between two sets of opposite sides of the quadrilateral, or two sets of opposite sides of the quadrilateral The difference between the trigonometric value of the included angle, or the absolute value of the difference between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the absolute value of the difference between the two sets of opposite sides of the quadrilateral, Or the absolute value of the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral. In this way, a set of features can be obtained that effectively represent the relative size of the quadrilateral, the relative distance from the lens, and the degree of quadrilateral tilt. Different types of geometric features can be used to determine different shooting scenes and to obtain compensation formulas suitable for different shooting scenes.
在一个可能的设计中,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的中位线长度,所述高度估计值是与竖直方向夹角较小的中位线长度。这样,可以获得接近原始宽高比并且有规律可循的宽高比初步估计。In one possible design, the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, and the width estimate is a median line length that is smaller than an angle in the horizontal direction, The height estimate is the length of the median line that is less angled to the vertical. In this way, a preliminary estimate of the aspect ratio close to the original aspect ratio and regularly ruled can be obtained.
在一个可能的设计中,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的一组对边中的长边长度,所述高度估计值是与竖直方向夹角较小的一组对边中的长边长度。这样,可以获得接近原始宽高比并且有规律可循的宽高比初步估计。In one possible design, the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being a length of a pair of opposite sides that are smaller than the horizontal direction. The length of the edge is the length of the long side of a pair of opposite sides that is smaller than the vertical direction. In this way, a preliminary estimate of the aspect ratio close to the original aspect ratio and regularly ruled can be obtained.
在一个可能的设计中,所述补偿公式的函数形式包括一次函数、二次函数或更高次函数形式。这样,可以确定补偿公式的通用形式,通过计算函数的参数即可获得补偿公式。In one possible design, the functional form of the compensation formula includes a first function, a quadratic function, or a higher order function form. In this way, the general form of the compensation formula can be determined, and the compensation formula can be obtained by calculating the parameters of the function.
第二方面,提供了一种设备,其中包括:第一获取模块,用于获取待校正图像中的四边形的第一宽高比以及所述四边形的几何特征;第二获取模块,用于根据所述四边形的几何特征获取所述四边形的补偿因子;第一计算模块,用于根据所述四边形的第一宽高比和所述四边形的补偿因子,计算所述四边形的第二宽高比;第二计算模块,用于根据所述四边形的第二宽高比计算变换矩阵;校正模块,用于根据所述变换矩阵校正所述待校正图像。通过补偿因子补偿四边形的第一宽高比,可以从整体上提升校正后图像中矩形的宽高比的准确性。In a second aspect, an apparatus is provided, including: a first acquiring module, configured to acquire a first aspect ratio of a quadrilateral in an image to be corrected and a geometric feature of the quadrilateral; and a second acquiring module, configured to Calculating a compensation factor of the quadrilateral according to a geometric feature of the quadrilateral; a first calculating module, configured to calculate a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral; a calculation module, configured to calculate a transformation matrix according to a second aspect ratio of the quadrilateral; and a correction module, configured to correct the image to be corrected according to the transformation matrix. By compensating for the first aspect ratio of the quadrilateral by the compensation factor, the accuracy of the aspect ratio of the rectangle in the corrected image can be improved as a whole.
在一个可能的设计中,所述第二获取模块用于根据所述四边形的几何特征和补偿公式获取所述四边形的补偿因子。所述第二获取模块包括:第一获取单元,用于获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;第二获取单元,获取所述矩形的宽高比以及所述矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;拟合单元,用于根据所述N组对应数据拟合补偿公式。通过获取已知宽高比的矩形在多个角度下的图像,借助统计的方法拟合补偿公式,使得 补偿的结果更加准确。In a possible design, the second obtaining module is configured to obtain a compensation factor of the quadrilateral according to the geometric features and the compensation formula of the quadrilateral. The second obtaining module includes: a first acquiring unit, configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second acquiring unit obtains The aspect ratio of the rectangle and the geometric feature of the rectangle obtain corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; the fitting unit is configured to fit according to the N sets of corresponding data Compensation formula. By obtaining an image of a rectangle with a known aspect ratio at multiple angles, the compensation formula is fitted by statistical means. The result of the compensation is more accurate.
在一个可能的设计中,所述拟合单元还包括:分类子模块,用于将所述N组对应数据分为多个类型;拟合子模块,用于根据所述多个类型中的每一类数据分别拟合补偿公式。这样,可以对多种拍摄场景进行组合,细化场景分类,每一类使用一个补偿公式,使得补偿的结果更加准确。In a possible design, the fitting unit further includes: a classification sub-module for dividing the N sets of corresponding data into a plurality of types; and a fitting sub-module for each of the plurality of types A type of data is fitted to the compensation formula. In this way, multiple shooting scenes can be combined to refine the scene classification, and each type uses a compensation formula to make the compensation result more accurate.
在一个可能的设计中,所述补偿公式在校正图像前预先确定。由此,校正图像过程可以得到简化。In one possible design, the compensation formula is predetermined before the image is corrected. Thereby, the process of correcting the image can be simplified.
在一个可能的设计中,所述几何特征包括距离特征或角度特征中的至少一种。通过不同类型的几何特征,可以确定不同的图像获取场景。In one possible design, the geometric feature comprises at least one of a distance feature or an angular feature. Different image acquisition scenarios can be determined by different types of geometric features.
在一个可能的设计中,所述角度特征包括:所述四边形的两组对边夹角的差值;或者所述四边形的两组对边夹角的差值的三角函数值;或者所述四边形的两组对边夹角的三角函数值的差值。这样,可以得到一组特征,所述特征能够有效地表示四边形的倾斜程度。In one possible design, the angular feature comprises: a difference between two sets of opposite sides of the quadrilateral; or a trigonometric value of a difference between two sets of opposite sides of the quadrilateral; or the quadrilateral The difference between the two sets of trigonometric values of the angle between the two sides. In this way, a set of features can be obtained that effectively represent the degree of tilt of the quadrilateral.
在一个可能的设计中,所述几何特征包括第一几何特征和第二几何特征。所述第一几何特征包括以下特征中的至少一种:所述四边形的最长边的长度与所述待校正图像的边长的比值,或者所述四边形的对角线长度与所述待校正图像的对角线长度的比值,或者所述四边形的两组对边夹角的大小,或者所述四边形的两组对边夹角的三角函数值。所述第二几何特征包括:所述四边形的两组对边夹角的差值,或者所述四边形的两组对边夹角的差值的三角函数值,或者所述四边形的两组对边夹角的三角函数值的差值,或者所述四边形的两组对边夹角的差值的绝对值,或者所述四边形的两组对边夹角的差值的绝对值的三角函数值,或者所述四边形的两组对边夹角的三角函数值的差值的绝对值。这样,可以得到一组特征,所述特征能够有效地表示四边形的相对大小、距离镜头的相对远近,以及四边形倾斜程度。通过不同类型的几何特征,可以确定不同的拍摄场景,获取适合不同拍摄场景的补偿公式。In one possible design, the geometric features include a first geometric feature and a second geometric feature. The first geometric feature includes at least one of the following: a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected, or a diagonal length of the quadrilateral and the to-be-corrected The ratio of the diagonal length of the image, or the angle between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the set of opposite sides of the quadrilateral. The second geometric feature includes: a difference between two sets of opposite sides of the quadrilateral, or a trigonometric function of a difference between two sets of opposite sides of the quadrilateral, or two sets of opposite sides of the quadrilateral The difference between the trigonometric value of the included angle, or the absolute value of the difference between the two sets of opposite sides of the quadrilateral, or the trigonometric value of the absolute value of the difference between the two sets of opposite sides of the quadrilateral, Or the absolute value of the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral. In this way, a set of features can be obtained that effectively represent the relative size of the quadrilateral, the relative distance from the lens, and the degree of quadrilateral tilt. Different types of geometric features can be used to determine different shooting scenes and to obtain compensation formulas suitable for different shooting scenes.
在一个可能的设计中,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的中位线长度,所述高度估计值是与竖直方向夹角较小的中位线长度。这样,可以获得接近原始宽高比并且有规律可循的宽高比初步估计。In one possible design, the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, and the width estimate is a median line length that is smaller than an angle in the horizontal direction, The height estimate is the length of the median line that is less angled to the vertical. In this way, a preliminary estimate of the aspect ratio close to the original aspect ratio and regularly ruled can be obtained.
在一个可能的设计中,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的一组对边中的长边长度,所述高度估计值是与竖直方向夹角较小的一组对边中的长边长度。这样,可以获得接近原始宽高比并且有规律可循的宽高比初步估计。In one possible design, the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being a length of a pair of opposite sides that are smaller than the horizontal direction. The length of the edge is the length of the long side of a pair of opposite sides that is smaller than the vertical direction. In this way, a preliminary estimate of the aspect ratio close to the original aspect ratio and regularly ruled can be obtained.
在一个可能的设计中,所述补偿公式的函数形式包括一次函数、二次函数或更高次函数形式。这样,可以确定补偿公式的通用形式,通过计算函数的参数即可获得补偿公式。In one possible design, the functional form of the compensation formula includes a first function, a quadratic function, or a higher order function form. In this way, the general form of the compensation formula can be determined, and the compensation formula can be obtained by calculating the parameters of the function.
第三方面,提供了一种设备,其中包括:一个或多个处理器,存储器,以及一个或多个程序,所述一个或多个程序被存储在存储器中并被配置为被一个或多个处理器执行,所述一个或多个程序包括用于执行第一方面所述的方法的指令。 In a third aspect, an apparatus is provided, comprising: one or more processors, a memory, and one or more programs, the one or more programs being stored in a memory and configured to be configured by one or more Executed by the processor, the one or more programs include instructions for performing the method of the first aspect.
第四方面,提供了一种包含指令的计算机程序产品,当所述指令在计算机上运行时,使得计算机执行第一方面所述的方法。In a fourth aspect, a computer program product comprising instructions for causing a computer to perform the method of the first aspect when the instructions are run on a computer.
第五方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当所述指令在计算机上运行时,使得计算机执行第一方面所述的方法。In a fifth aspect, a computer readable storage medium is provided having stored therein instructions that, when executed on a computer, cause the computer to perform the method of the first aspect.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍。显而易见地,下面附图中反映的仅仅是本发明的一部分实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他实施方式。而所有这些实施例或实施方式都在本申请的保护范围之内。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. Obviously, only some of the embodiments of the present invention are reflected in the following drawings, and other embodiments may be obtained by those skilled in the art without departing from the drawings. All such embodiments or implementations are within the scope of the present application.
图1为本发明实施例的一种图像校正场景示意图;FIG. 1 is a schematic diagram of an image correction scenario according to an embodiment of the present invention; FIG.
图2为本发明实施例的一种图像校正方法的流程图;2 is a flowchart of an image correction method according to an embodiment of the present invention;
图3为本发明实施例的第一宽高比的示意图;3 is a schematic diagram of a first aspect ratio according to an embodiment of the present invention;
图4为本发明实施例的一种补偿公式确定方法的流程图;4 is a flowchart of a method for determining a compensation formula according to an embodiment of the present invention;
图5为本发明实施例的获取已知宽高比的矩形的N个图像的示意图;FIG. 5 is a schematic diagram of acquiring N images of a rectangle having a known aspect ratio according to an embodiment of the present invention; FIG.
图6为本发明实施例的根据图像倾斜姿态分类的示意图;FIG. 6 is a schematic diagram of classification according to an image tilt posture according to an embodiment of the present invention; FIG.
图7为本发明实施例的根据图像距离分类的示意图;FIG. 7 is a schematic diagram of classification according to image distance according to an embodiment of the present invention; FIG.
图8为本发明实施例的根据图像倾斜姿态和距离分类的示意图;FIG. 8 is a schematic diagram of classification according to an image tilt posture and distance according to an embodiment of the present invention; FIG.
图9为本发明实施例的另一种补偿公式确定方法的流程图;FIG. 9 is a flowchart of another method for determining a compensation formula according to an embodiment of the present invention; FIG.
图10为本发明实施例的一种设备的结构示意图;FIG. 10 is a schematic structural diagram of a device according to an embodiment of the present invention; FIG.
图11为本发明实施例的一种第二获取模块的结构示意图;FIG. 11 is a schematic structural diagram of a second acquiring module according to an embodiment of the present invention;
图12为本发明实施例的另一种第二获取模块的结构示意图;FIG. 12 is a schematic structural diagram of another second acquiring module according to an embodiment of the present invention;
图13为本发明实施例的另一种设备的结构示意图。FIG. 13 is a schematic structural diagram of another device according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行进一步描述。The technical solutions in the embodiments of the present invention are further described below in conjunction with the accompanying drawings in the embodiments of the present invention.
图1示出了本发明实施例的一种图像获取场景的示意图。被摄物体102被放置在支撑结构103上,设备101拍摄被摄物体102的图像。被摄物体102可以是任何一种包含文字和/或图像的物体,例如,文稿、图片、名片、证件、书籍、幻灯片、白板、路牌和广告标识等物体。设备101可以是任何一种能够获取图像或处理图像的设备,例如,移动电话(或称“手机”)、平板电脑(Tablet Personal Computer,TPC)、计算机、数码相机、可穿戴式设备(Wearable Device)、虚拟现实设备、数字广播终端、消息收发设备、游戏控制台、医疗设备、健身设备、个人数字助理(Personal Digital Assistant,PDA)、电子书阅读器(e-book reader)和扫描仪等设备。设备101可以通过摄像头、相机或光学传感器等光学元件获取图像,所述光学元件可以内置在设备101中,也可以外接到设备101。为清楚和方便起见,本申请的光学元件统一采用摄像头描述。在图1的(A)部分中,当设备101从正面拍摄时,能够获得与被摄物体102比例基本一致的图像104。FIG. 1 is a schematic diagram of an image acquisition scenario according to an embodiment of the present invention. The subject 102 is placed on the support structure 103, and the device 101 takes an image of the subject 102. The subject 102 can be any object containing text and/or images, such as documents, pictures, business cards, documents, books, slides, whiteboards, street signs, and advertising signs. The device 101 can be any device capable of acquiring an image or processing an image, for example, a mobile phone (or "mobile phone"), a tablet (Tablet Personal Computer, TPC), a computer, a digital camera, a wearable device (Wearable Device) ), virtual reality devices, digital broadcast terminals, messaging devices, game consoles, medical devices, fitness equipment, personal digital assistants (PDAs), e-book readers, and scanners . The device 101 can acquire images through optical components such as cameras, cameras or optical sensors, which can be built into the device 101 or externally connected to the device 101. For the sake of clarity and convenience, the optical components of the present application are uniformly described using a camera. In part (A) of Fig. 1, when the device 101 is photographed from the front side, an image 104 substantially in proportion to the subject 102 can be obtained.
然而,如图1的(B)部分所示,当设备101从侧面拍摄被摄物体102时,透视效应将导致获取的图像104’产生畸变,因此需要校正该畸变图像104’。在图像校正过程中, 首先输入图像104’,然后检测图像中的四边形,接着根据该四边形估计被摄物体102的宽高比,并根据估计出的宽高比计算变换矩阵,最后利用该变换矩阵将畸变图像104’校正为矩形图像104”。上述图像校正过程在估计宽高比时使用了复杂的公式,该公式基于假定的镜头焦距参数。在实际应用中,由于镜头焦距不同于假定的镜头焦距,导致对被摄物体的宽高比估计误差较大,尤其当设备101的倾斜角度较大时,宽高比的估计值与实际值的偏差更大。However, as shown in part (B) of Fig. 1, when the apparatus 101 photographs the subject 102 from the side, the see-through effect causes the acquired image 104' to be distorted, so the distortion image 104' needs to be corrected. During the image correction process, First, the image 104' is input, then the quadrilateral in the image is detected, then the aspect ratio of the object 102 is estimated according to the quadrilateral, and the transformation matrix is calculated according to the estimated aspect ratio, and finally the distortion image 104' is corrected by using the transformation matrix. It is a rectangular image 104". The above image correction process uses a complex formula for estimating the aspect ratio, which is based on the assumed lens focal length parameter. In practical applications, since the lens focal length is different from the assumed lens focal length, the pair is shot. The aspect ratio estimation error of the object is large, especially when the tilt angle of the device 101 is large, the deviation between the estimated value of the aspect ratio and the actual value is larger.
下面结合图2至图6说明本发明实施例的一种图像校正方法。图2示出了所述方法的流程图,所述方法可以由设备101执行,该方法包括:An image correction method according to an embodiment of the present invention will be described below with reference to FIGS. 2 through 6. Figure 2 shows a flow chart of the method, which may be performed by device 101, the method comprising:
步骤201,获取待校正图像的四边形的第一宽高比R0以及四边形的几何特征;Step 201: Acquire a first aspect ratio R 0 of a quadrilateral of the image to be corrected and a geometric feature of the quadrilateral;
步骤202,根据四边形的几何特征获取四边形的补偿因子k; Step 202, obtaining a quadrilateral compensation factor k according to the geometric feature of the quadrilateral;
步骤203,根据四边形的第一宽高比R0和四边形的补偿因子k,计算四边形的第二宽高比R1Step 203, calculating a second aspect ratio R 1 of the quadrilateral according to the first aspect ratio R 0 of the quadrilateral and the compensation factor k of the quadrilateral;
步骤204,根据四边形的第二宽高比R1计算变换矩阵K; Step 204, calculating a transformation matrix K according to a second aspect ratio R 1 of the quadrilateral;
步骤205,根据变换矩阵K校正待校正图像。 Step 205, correcting the image to be corrected according to the transformation matrix K.
其中,步骤201至步骤203将在下文详细阐述;步骤204和205可以采用已有的方法,此处不再赘述。The steps 201 to 203 are explained in detail below; the steps 204 and 205 can adopt the existing methods, and details are not described herein again.
在步骤201中,首先,获取被摄物体的待校正图像。所述待校正图像可以是摄像头实时获取的图像,例如拍摄被摄物体或者抓取被摄物体预览视频的帧,也可以是已有的图像,例如存储在存储器上的图像。被摄物体可以是整体呈现为矩形,例如前文提到的文稿、图片、名片、证件、书籍、幻灯片、白板、路牌和广告标识等物体,也可以是局部区域包括矩形,例如在被摄物体中包含矩形的图像或者文字区块。In step 201, first, an image to be corrected of the subject is acquired. The image to be corrected may be an image acquired by the camera in real time, such as a frame for capturing a subject or capturing a preview video of the subject, or an existing image, such as an image stored on a memory. The object may be presented as a rectangle as a whole, such as a document, a picture, a business card, a document, a book, a slide, a whiteboard, a street sign, and an advertisement sign mentioned above, or may be a partial area including a rectangle, for example, in a subject. Contains a rectangular image or text block.
然后,提取待校正图像中的四边形。在一个示例中,设备101检测四边形边缘,从而提取图像中的四边形。四边形边缘的检测算法可以采用已知的方法,此处不再赘述。Then, the quadrilateral in the image to be corrected is extracted. In one example, device 101 detects a quadrilateral edge to extract a quadrilateral in the image. The detection algorithm of the quadrilateral edge can adopt a known method, and will not be described here.
在另一个示例中,用户可以手动选择图像中的四边形,例如,用户拖动图像中的四边形选框的四个角点,选择图像中的四边形,从而提取图像中的四边形。In another example, the user can manually select a quadrilateral in the image, for example, the user drags the four corners of the quadrilateral box in the image, selects the quadrilateral in the image, and extracts the quadrilateral in the image.
最后,完成四边形提取之后,根据提取的四边形可以获得四边形的四个角点坐标,从而计算四边形的第一宽高比R0以及四边形的几何特征。Finally, after the quadrilateral extraction is completed, the four corner coordinates of the quadrilateral can be obtained according to the extracted quadrilateral, thereby calculating the first aspect ratio R 0 of the quadrilateral and the geometric features of the quadrilateral.
四边形的第一宽高比R0是对四边形原始宽高比的初步估计,可以用四边形的宽度估计值We与高度估计值He的比值来表示,即R0=We/He。在一个示例中,第一宽高比R0可以是四边形相邻边长度的比值。如图3的(A)部分所示,从四边形的两组对边中,分别确定水平对边和竖直对边,将水平对边中较长的一边CD的长度lCD作为宽度估计值We,即We=lCD,将竖直对边中较长的一边AD的长度lAD作为高度估计值He,即He=lAD,因此,第一宽高比R0=We/He=lCD/lAD。所述水平对边和竖直对边的确定步骤包括:比较四边形的任意两个相邻边与水平方向的夹角大小,夹角较小的一边及其对边为水平对边,剩下的一组对边为竖直对边。可选的,也可以比较任意两个相邻边与竖直方向的夹角大小,夹角较小的一边及其对边为竖直对边,剩下的一组对边为水平对边。The first aspect ratio R 0 of the quadrilateral is a preliminary estimate of the original aspect ratio of the quadrilateral, and can be expressed by the ratio of the width estimate W e of the quadrilateral to the height estimate H e , that is, R 0 =W e /H e . In one example, the first aspect ratio R 0 may be a ratio of the lengths of the adjacent sides of the quadrilateral. As shown in part (A) of Fig. 3, from the two sets of opposite sides of the quadrilateral, the horizontal opposite side and the vertical opposite side are respectively determined, and the length l CD of the longer side of the horizontal opposite side is taken as the width estimation value W. e , that is, W e = l CD , the length l AD of the longer side AD of the vertical opposite side is taken as the height estimation value H e , that is, H e = l AD , therefore, the first aspect ratio R 0 =W e /H e =l CD /l AD . The step of determining the horizontal opposite side and the vertical opposite side comprises: comparing the angle between any two adjacent sides of the quadrilateral and the horizontal direction, the side with the smaller angle and the opposite side being the horizontal opposite side, and the remaining A set of opposite sides is a vertical opposite side. Optionally, the angle between any two adjacent edges and the vertical direction may be compared, and the smaller side and the opposite side are vertical opposite sides, and the remaining set of opposite sides are horizontal opposite sides.
在另一个示例中,第一宽高比R0可以是四边形的两条中位线的长度的比值。如图3的(B)部分所示,在四边形的两个中位线中,将与水平方向夹角较小的中位线BD的长 度lBD作为宽度估计值We,即We=lBD,将与竖直方向夹角较小的中位线AC的长度lAC作为高度估计值He,即He=lAC,因此,第一宽高比R0=We/He=lBD/lACIn another example, the first aspect ratio R 0 may be the ratio of the lengths of the two median lines of the quadrilateral. As shown in (B), in two quadrangular bit line, the smaller the angle between the bit line and BD 3 BD horizontal length L as the estimation value width W e, i.e., W e = l BD , the length l AC of the median line AC having a small angle with the vertical direction is taken as the height estimation value H e , that is, H e = l AC , therefore, the first aspect ratio R 0 =W e /H e = l BD /l AC .
四边形的几何特征包括角度特征。在一个示例中,角度特征可以包括四边形的两组对边夹角(即水平对边夹角θH与竖直对边夹角θV),以及两组对边夹角之差的绝对值δ(即δ=|θHV|)。上述两组对边夹角中较小的对边夹角可以用于判断四边形失真较小的对边的倾斜程度:所述较小的对边夹角越大,则倾斜程度越大;对边夹角越小,则倾斜程度越小。所述两组对边夹角之差的绝对值δ可以用于判断图像整体的变形程度:绝对值δ越大,则变形程度越大;绝对值δ越小,则变形程度越小。The geometric features of the quadrilateral include angular features. In one example, the angular feature may include two sets of opposite sides of the quadrilateral (ie, the angle between the horizontally opposite sides θ H and the vertical opposite sides θ V ), and the absolute value of the difference between the two sets of opposite sides δ (ie δ=|θ HV |). The smaller angle of the opposite side of the two sets of opposite sides can be used to determine the degree of inclination of the opposite side with less distortion of the quadrilateral: the larger the angle of the opposite side, the greater the inclination; the opposite side The smaller the angle, the smaller the tilt. The absolute value δ of the difference between the two sets of opposite sides can be used to determine the degree of deformation of the image as a whole: the larger the absolute value δ, the greater the degree of deformation; the smaller the absolute value δ, the smaller the degree of deformation.
在另一个示例中,角度特征可以包括四边形的两组对边夹角的三角函数值,以及两组对边夹角之差的绝对值的三角函数值或者两组对边夹角的三角函数值之差的绝对值。所述三角函数值包括正弦值、正切值、余弦值或余切值。所述两组对边夹角的三角函数值可以用于判断四边形失真较小的对边的倾斜程度,所述两组对边夹角之差的绝对值的三角函数值或者两组对边夹角的三角函数值之差的绝对值可以用于判断图像整体的变形程度。In another example, the angular feature may include a trigonometric function value of two sets of opposite sides of the quadrilateral, and a trigonometric function value of the absolute value of the difference between the two sets of angles of the opposite sides or a trigonometric function value of the two sets of opposite sides The absolute value of the difference. The trigonometric value includes a sine, a tangent, a cosine, or a cotangent. The trigonometric function values of the two sets of angles of the opposite sides can be used to determine the degree of inclination of the opposite sides of the quadrilateral distortion, the trigonometric function values of the absolute values of the difference between the two sets of sides, or the two sets of opposite side clips The absolute value of the difference between the angular trigonometric values can be used to determine the degree of deformation of the image as a whole.
为清楚和方便起见,本发明实施例在提到四边形的几何特征时,如果没有其它说明,是指四边形的两组对边夹角θH和θV以及两组对边夹角之差的绝对值δ。当本发明实施例所述的方法应用到几何特征包括三角函数值的实施例时,可以用两组对边夹角的三角函数值替换相应的两组对边夹角,同时可以用两组对边夹角之差的绝对值的三角函数值或者两组对边夹角的三角函数值之差的绝对值替换相应的两组对边夹角之差的绝对值。For the sake of clarity and convenience, when referring to the geometric features of the quadrilateral, the embodiment of the present invention refers to the absolute angle between the two sets of opposite sides of the quadrilateral θ H and θ V and the difference between the two sets of opposite sides. The value δ. When the method according to the embodiment of the present invention is applied to an embodiment in which the geometric feature includes a trigonometric function value, the two sets of opposite angles may be replaced by two sets of trigonometric values of the opposite sides, and two pairs of pairs may be used. The absolute value of the difference between the absolute value of the difference between the edges and the value of the trigonometric function of the two sets of angles replaces the absolute value of the difference between the two sets of opposite sides.
需要说明的是,上述四边形的各边长度、中位线长度、对边夹角及其三角函数值可以通过四边形的四个角点坐标计算获得,这属于本领域的常规几何知识,此处不再赘述。It should be noted that the length of each side of the quadrilateral, the length of the median line, the angle of the opposite side, and the value of the trigonometric function can be obtained by calculating the coordinates of the four corner points of the quadrilateral, which belongs to the conventional geometric knowledge in the field, and is not here. Let me repeat.
在步骤202中,根据四边形的几何特征和补偿公式,将四边形的几何特征代入到补偿公式中,可以获得四边形的补偿因子。所述补偿公式反映几何特征与补偿因子k的关系,其一般形式为k=f(x),其中,x表示几何特征,k表示补偿因子。补偿公式的函数形式可以是一次函数、二次函数或更高次函数形式。补偿公式可以在实施本发明实施例的图像校正方法前预先确定,也可以在实施本发明实施例的图像校正方法的过程中确定。由于在不同的图像获取场景中,四边形的倾斜姿态也不同,因此,可以根据四边形倾斜姿态的特点对四边形分类,针对每一类四边形分别确定一个补偿公式。所述补偿公式的确定方法的流程图如图4所示,该方法可以由设备101执行,其中包括:In step 202, according to the geometric features of the quadrilateral and the compensation formula, the geometric features of the quadrilateral are substituted into the compensation formula, and the compensation factor of the quadrilateral can be obtained. The compensation formula reflects the relationship between the geometric feature and the compensation factor k, and its general form is k=f(x), where x represents a geometric feature and k represents a compensation factor. The functional form of the compensation formula can be a one-time function, a quadratic function, or a higher-order function form. The compensation formula may be determined in advance before the image correction method of the embodiment of the present invention is implemented, or may be determined in the process of implementing the image correction method of the embodiment of the present invention. Since the tilt posture of the quadrilateral is different in different image acquisition scenes, the quadrilateral can be classified according to the characteristics of the quadrilateral tilt posture, and a compensation formula is determined for each type of quadrilateral. A flowchart of a method for determining the compensation formula is shown in FIG. 4, and the method may be performed by the device 101, including:
步骤2021,获取已知宽高比的矩形在N个不同角度下的N个图像;Step 2021: Acquire N images of rectangles of known aspect ratio at N different angles;
步骤2022,从N个图像的每一个图像中,获取矩形的第一宽高比RQ和几何特征,得到N组矩形的补偿因子kQ与几何特征的对应数据;Step 2022: Obtain a first aspect ratio R Q and a geometric feature of the rectangle from each of the N images, and obtain corresponding data of the compensation factor k Q of the N sets of rectangles and the geometric feature;
步骤2023,将N组对应数据分为多个类型; Step 2023, the N sets of corresponding data are divided into multiple types;
步骤2024,根据多个类型的每一类数据分别拟合补偿公式。In step 2024, the compensation formula is respectively fitted according to each type of data of multiple types.
在步骤2021中,可以通过设备110的摄像头获取已知宽高比的矩形在N个不同角度下的N个图像。获取N个图像可以通过摄像头拍摄所述矩形,也可以通过抓取所述矩形的预览视频的帧。如图5的(A)部分所示,所述矩形的原始宽高比可以是任何已知的数值,例如,所述矩形的原始宽高比R=1(即正方形)。为方便起见,本文采用R=1的矩 形统一描述。In step 2021, N images of rectangles of known aspect ratio at N different angles may be acquired by the camera of device 110. Acquiring N images may capture the rectangle through the camera, or may capture a frame of the preview video of the rectangle. As shown in part (A) of Fig. 5, the original aspect ratio of the rectangle may be any known value, for example, the original aspect ratio R = 1 (i.e., square) of the rectangle. For convenience, this paper uses the moment of R=1 Unified description.
为了获取在N个不同角度下的N个图像,在一个示例中,如图5的(B)部分所示,在空间三维直角坐标系中,矩形所在的平面与XOY平面重合,当设备在空间中的P点获取矩形的图像时,所述角度可以用P点在XOY平面的投影P’与X轴正向的夹角α=∠P’OZ,以及P点与Z轴正向的夹角β=∠P’OZ的组合来表示,其中,α和β的数值范围分别为α∈[0°,360°),β∈[0°,90°)。当设备从Z轴上的一个点获取矩形的图像时(即从正面拍摄),角度α=β=0°。角度的数量N是不小于2的整数,用于满足获取补偿公式的基本条件。由于补偿公式的精度随着数量N的增加而提高,因此,为了获得更精确的补偿公式,可以在更多的角度下获取更多的图像。作为一个例子,在α∈[0°,360°)的范围内每隔45°(即α分别取0°,45°,90°,……,315°)选定一个方向,并在这些方向上,在β∈(0°,90°)范围内每隔4°(即β分别取4°,8°,……,88°)获取一个图像。需要说明的是,上述角度范围和角度间隔只是示例,也可以选择其它的角度范围和角度间隔,从而获取更多或更少的图像。In order to obtain N images at N different angles, in one example, as shown in part (B) of Figure 5, in a spatial three-dimensional Cartesian coordinate system, the plane of the rectangle coincides with the XOY plane, when the device is in space When the P point in the middle acquires a rectangular image, the angle can be the angle between the projection P' of the P point on the XOY plane and the positive direction of the X axis α=∠P'OZ, and the angle between the P point and the positive direction of the Z axis. A combination of β = ∠ P'OZ is expressed, wherein the numerical ranges of α and β are α ∈ [0°, 360°), β ∈ [0°, 90°), respectively. When the device acquires a rectangular image from a point on the Z-axis (ie, taken from the front), the angle α = β = 0°. The number N of angles is an integer not less than 2, which is used to satisfy the basic condition for obtaining the compensation formula. Since the accuracy of the compensation formula increases as the number N increases, more images can be acquired at more angles in order to obtain a more accurate compensation formula. As an example, one direction is selected every 45° (i.e., α is taken as 0°, 45°, 90°, ..., 315°) in the range of α ∈ [0°, 360°), and in these directions. On the other hand, an image is taken every 4° in the range of β∈ (0°, 90°) (that is, β is taken as 4°, 8°, ..., 88°, respectively). It should be noted that the above angular range and angular interval are only examples, and other angular ranges and angular intervals may be selected to obtain more or less images.
在另一个示例中,如图5的(C)部分所示,所述矩形在图像中显示为四边形Q,通过选择四边形Q的不同的水平对边夹角θQH和竖直对边夹角θQV(附图标记未示出),从而获取N个图像。作为一个例子,可以在水平对边夹角θQH∈[0°,50°]的范围内每隔1°获取一个图像;同时,在竖直对边夹角θQV∈[0°,50°]的范围内,每隔1°获取一个图像。作为另一个例子,也可以每隔2°获取一个图像。需要说明的是,上述角度范围和角度间隔只是示例,也可以选择其它的角度范围和角度间隔。In another example, as shown in part (C) of FIG. 5, the rectangle is displayed as a quadrilateral Q in the image, by selecting different horizontal-to-edge angles θ QH of the quadrilateral Q and the angle between the vertical opposite sides θ QV (reference numeral not shown), thereby acquiring N images. As an example, an image can be acquired every 1° in the range of the horizontal-to-edge angle θ QH ∈ [0°, 50°]; at the same time, the angle θ QV竖 [0°, 50° at the vertical opposite side In the range of ], an image is acquired every 1°. As another example, an image can also be acquired every 2°. It should be noted that the above angular range and angular interval are only examples, and other angular ranges and angular intervals may also be selected.
在步骤2022中,矩形的第一宽高比RQ与四边形的第一宽高比R0相应,当四边形的第一宽高比R0采用相邻边长度的比值时,矩形的第一宽高比RQ也采用对应的相邻边长度的比值。当四边形的第一宽高比R0采用两条中位线长度的比值时,矩形的第一宽高比RQ也采用对应的两条中位线长度的比值。获取矩形第一宽高比RQ的具体方法可以参见步骤201的记载,此处不再赘述。In 2022, the first aspect ratio rectangular quadrilateral R Q R 0 corresponding to the first aspect ratio, when the aspect ratio of a quadrangle R 0 using a first adjacent side length ratio, the width of the rectangular first step The high ratio R Q also uses the ratio of the corresponding adjacent side lengths. When the first aspect ratio R 0 of the quadrilateral uses the ratio of the lengths of the two median lines, the first aspect ratio R Q of the rectangle also adopts the ratio of the lengths of the corresponding two median lines. For the specific method of obtaining the first aspect ratio R Q of the rectangle, refer to the description of step 201, and details are not described herein again.
矩形的几何特征与四边形的几何特征相应,当四边形的几何特征包括四边形的两组对边夹角θH和θV以及两组对边夹角之差的绝对值δ时,矩形的几何特征也包括两组对边夹角θQH和θQV以及两组对边夹角之差的绝对值δQ=|θQHQV|。The geometrical features of the rectangle correspond to the geometric features of the quadrilateral. When the geometric features of the quadrilateral include the two sets of opposite angles θ H and θ V of the quadrilateral and the absolute value δ of the difference between the two sets of opposite sides, the geometrical features of the rectangle are also The absolute values δ Q =|θ QHQV | of the difference between the two sets of opposite angles θ QH and θ QV and the angle between the two sets of opposite sides are included.
矩形的补偿因子kQ与四边形的补偿因子k相应,矩形的补偿因子kQ反映了矩形的原始宽高比R与第一宽高比RQ之间的关系。在一个示例中,矩形的补偿因子kQ可以用矩形的原始宽高比R与第一宽高比RQ的比值来表示,即kQ=R/RQ。在另一个示例中,矩形的补偿因子可以用矩形的第一宽高比RQ与矩形的原始宽高比R的比值来表示,即kQ=RQ/R。由于矩形的原始宽高比R与第一宽高比RQ都是已知的数值,因此可以得到一组矩形的补偿因子kQ与几何特征的对应数据,即补偿因子kQ、两组对边夹角θQH和θQV以及两组对边夹角之差的绝对值δQ。对N个图像执行上述操作,可以得到N组矩形的补偿因子kQ与矩形的几何特征的对应数据。The compensation factor k Q of the rectangle corresponds to the compensation factor k of the quadrilateral, and the compensation factor k Q of the rectangle reflects the relationship between the original aspect ratio R of the rectangle and the first aspect ratio R Q . In one example, the compensation factor k Q of the rectangle may be represented by the ratio of the original aspect ratio R of the rectangle to the first aspect ratio R Q , ie k Q =R/R Q . In another example, the compensation factor for the rectangle may be expressed by the ratio of the first aspect ratio R Q of the rectangle to the original aspect ratio R of the rectangle, ie k Q =R Q /R. Since the original aspect ratio R of the rectangle and the first aspect ratio R Q are both known values, a corresponding set of rectangular compensation factors k Q and geometric features can be obtained, that is, the compensation factor k Q , two pairs of pairs The angle θ QH and θ QV of the side and the absolute value δ Q of the difference between the angles of the two sets of opposite sides. By performing the above operations on the N images, corresponding data of the N sets of rectangular compensation factors k Q and the geometric features of the rectangle can be obtained.
在步骤2023中,将矩形的几何特征与分类阈值进行比较,从而将所述N组对应数据分入与四边形类型相应的类型。在一个示例中,如图6所示,四边形可以分为以下四类:水平单边倾斜,水平双边倾斜,竖直单边倾斜,竖直双边倾斜。将矩形的两组对边夹角θQH 和θQV与角度分类阈值θT进行比较,从而将所述N组对应数据分入与四边形类型对应的四种类型。其中,图6的(A)部分所示的水平单边倾斜类的水平对边夹角θQH小于竖直对边夹角θQV,且角度分类阈值θT在两组对边夹角之间;图6的(B)部分所示的水平双边倾斜类的水平对边夹角θQH小于竖直对边夹角θQV,且角度分类阈值θT小于水平对边夹角θQH;图6的(C)部分所示的竖直单边倾斜类的竖直对边夹角θQV小于水平对边夹角θQH,且角度分类阈值θT在两组对边夹角之间;图6的(D)部分所示的竖直双边倾斜类的竖直对边夹角θQV小于水平对边夹角θQH,且角度分类阈值θT小于竖直对边夹角θQVIn step 2023, the geometric features of the rectangle are compared to a classification threshold to classify the N sets of corresponding data into a type corresponding to the quadrilateral type. In one example, as shown in FIG. 6, the quadrilateral can be classified into the following four categories: horizontal unilateral inclination, horizontal bilateral inclination, vertical unilateral inclination, and vertical bilateral inclination. The two sets of opposite side angles θ QH and θ QV of the rectangle are compared with the angle classification threshold θ T , thereby dividing the N sets of corresponding data into four types corresponding to the quadrilateral type. Wherein, the horizontal-to-edge angle θ QH of the horizontal unilateral tilt type shown in part (A) of FIG. 6 is smaller than the vertical-to-edge angle θ QV , and the angle classification threshold θ T is between the two sets of opposite sides The horizontal-to-edge angle θ QH of the horizontal double-sided tilt type shown in part (B) of FIG. 6 is smaller than the vertical-to-edge angle θ QV , and the angle classification threshold θ T is smaller than the horizontal-to-edge angle θ QH ; The vertical unilateral tilt type θ QV of the vertical unilateral tilt type shown in part (C) is smaller than the horizontal opposite side angle θ QH , and the angle classification threshold θ T is between the two sets of opposite side angles; The vertical-to-edge angle θ QV of the vertical double-sided tilt type shown in the (D) portion is smaller than the horizontal-to-edge angle θ QH , and the angle classification threshold θ T is smaller than the vertical-to-edge angle θ QV .
角度分类阈值θT可用于将所述N组对应数据按照一定比例或者均匀地分入对应的四边形类型,并对待校正四边形进行分类,以便选择相应的补偿公式。在一个示例中,角度分类阈值θT可以是矩形的水平对边夹角θQH或者竖直对边夹角θQV的统计分位数。所述分位数包括四分位数或者其它比例的分位数。例如,角度分类阈值θT可以是选择水平对边夹角θQH的中位数(也称第二四分位数,即所有水平对边夹角θQH由小到大排列后排在第50%的数值),也可以是竖直对边夹角θQV的中位数,还可以是水平对边夹角的中位数和竖直对边夹角的中位数的均值。The angle classification threshold θ T can be used to classify the N sets of corresponding data into corresponding quadrilateral types according to a certain ratio or uniformly, and classify the corrected quadrilaterals to select a corresponding compensation formula. In one example, the angle classification threshold θ T may be a horizontal-to-edge angle θ QH of a rectangle or a statistical quantile of a vertical-to-edge angle θ QV . The quantile includes quartiles or other proportional quantiles. For example, the angle classification threshold θ T may be the median of the selection angle-to-edge angle θ QH (also referred to as the second quartile), that is, all the horizontal-to-edge angles θ QH are arranged from small to large and then ranked 50th. The value of %) can also be the median of the angle θ QV between the vertical and the opposite sides, or the mean of the median of the angle between the horizontal and the opposite sides and the median of the angle between the vertical and the opposite sides.
在另一个示例中,角度分类阈值θT也可以是矩形的水平对边夹角θQH或者竖直对边夹角θQV的均值。In another example, the angle classification threshold θ T may also be the mean of the horizontal-to-edge angle θ QH of the rectangle or the vertical-to-edge angle θ QV .
在另一个示例中,角度分类阈值θT还可以根据经验取值,例如,从[2°,5°]的范围内取值。In another example, the angle classification threshold θ T may also be valued empirically, for example, from a range of [2°, 5°].
在步骤2024中,在所述N组对应数据中的每一类数据中,根据矩形的两组对边夹角之差的绝对值δQ与补偿因子kQ拟合补偿公式。在一个示例中,表1示出了水平单边倾斜类型中矩形的两组对边夹角之差的绝对值δQ与补偿因子kQ的对应数据,由此可以拟合出水平单边倾斜类型的补偿公式。补偿公式的形式可以是以下任意一种,其中,x表示几何特征,k表示补偿因子:In step 2024, in each of the N sets of corresponding data, a compensation formula is fitted according to the absolute value δ Q of the difference between the two sets of opposite sides of the rectangle and the compensation factor k Q . In one example, Table 1 shows the corresponding data of the absolute value δ Q of the difference between the two sets of opposite sides of the rectangle in the horizontal unilateral tilt type and the compensation factor k Q , thereby fitting the horizontal unilateral tilt The type of compensation formula. The form of the compensation formula may be any one of the following, where x represents a geometric feature and k represents a compensation factor:
一次函数(也称线性函数),即:k=a*x+b,其中,参数a和b通过表1中的数据拟合确定,其中,a=0.0095,b=0.9409。A linear function (also called a linear function), namely: k = a * x + b, where parameters a and b are determined by data fitting in Table 1, where a = 0.0095 and b = 0.9409.
二次函数,即:k=a*x2+b*x+c,其中,参数a,b和c通过表1中的数据拟合确定,其中,a=0.0003,b=0.0013,c=0.9858。The quadratic function, ie: k = a * x 2 + b * x + c, where the parameters a, b and c are determined by the data fit in Table 1, where a = 0.0003, b = 0.0013, c = 0.9858 .
三次函数,即:k=a*x3+b*x2+c*x+d,其中,参数a,b,c和d通过表1中的数据拟合确定,其中,a=-5E-6,b=0.0005,c=-0.0018,d=0.9945。The cubic function, ie: k = a * x 3 + b * x 2 + c * x + d, where the parameters a, b, c and d are determined by the data fit in Table 1, where a = -5E- 6, b = 0.0005, c = -0.0018, d = 0.9945.
四次函数,即:k=a*x4+b*x3+c*x2+d*x+e,其中,参数a,b,c,d和e通过表1中的数据拟合确定,其中,a=3E-7,b=-2E-5,c=0.0009,d=-0.0046,e=0.9991。Quadratic function, ie: k = a * x 4 + b * x 3 + c * x 2 + d * x + e, where the parameters a, b, c, d and e are determined by the data fit in Table 1. Where a = 3E-7, b = -2E-5, c = 0.0009, d = -0.0046, e = 0.9991.
五次函数,即:k=a*x5+b*x4+c*x3+d*x2+e*x+f,其中,参数a,b,c,d,e和f通过表1中数据拟合确定,其中,a=3E-9,b=-7E-8,c=-8E-6,d=0.0006,e=-0.0026,f=0.9961。The quintic function, ie: k=a*x 5 +b*x 4 +c*x 3 +d*x 2 +e*x+f, where the parameters a, b, c, d, e and f pass the table The data fit in 1 was determined, wherein a=3E-9, b=-7E-8, c=-8E-6, d=0.0006, e=-0.0026, f=0.9961.
本领域技术人员能够了解,只要能够通过拟合算法获得符合精度要求的结果,补偿模板选择五次以上的高次函数也是可以的。上述拟合的算法可以采用已知的算法,此处不再赘述。Those skilled in the art will appreciate that as long as the result of the accuracy requirement can be obtained by the fitting algorithm, it is also possible to compensate the template for a higher order function of five or more times. The above-mentioned fitting algorithm can adopt a known algorithm and will not be described here.
表1 绝对值δQ与补偿因子kQ的对应数据表Table 1 Correspondence data table of absolute value δ Q and compensation factor k Q
Figure PCTCN2017074432-appb-000001
Figure PCTCN2017074432-appb-000001
Figure PCTCN2017074432-appb-000002
Figure PCTCN2017074432-appb-000002
在补偿公式确定后,将待校正四边形的两组对边夹角θH和θV与角度分类阈值θT进行比较,从而将待校正四边形分为相应的类型,选择该类型下的补偿公式,并将两组对边夹角之差的绝对值δ代入到补偿公式中,算出四边形的补偿因子k。对待校正四边形的分类可参照步骤2023的描述,此处不再赘述。After the compensation formula is determined, the two sets of opposite side angles θ H and θ V of the quadrilateral to be corrected are compared with the angle classification threshold θ T , so that the quadrilateral to be corrected is divided into corresponding types, and the compensation formula under the type is selected. The absolute value δ of the difference between the two sets of angles is substituted into the compensation formula to calculate the compensation factor k of the quadrilateral. For the classification of the corrected quadrilateral, refer to the description of step 2023, and details are not described herein again.
在步骤203中,四边形的第二宽高比R1是对第一宽高比R0进行补偿后的结果,用作四边形宽高比的最终估计。由于四边形的补偿因子k与矩形的补偿因子kQ相应,因此,当矩形的补偿因子kQ为原始宽高比R与第一宽高比RQ的比值时,四边形的第二宽高比R1可以用补偿因子k与第一宽高比R0的乘积表示,即R1=k*R0。当矩形的补偿因子kQ为第一宽高比RQ与原始宽高比R的比值时,四边形的第二宽高比R1可以用第一宽高比R0与补偿因子k的比值表示,即R1=R0/k。将前述步骤得到的第一宽高比R0和补偿因子k的数值代入上述表达式,可以获得第二宽高比R1的值。In step 203, the second aspect ratio R 1 of the quadrilateral is a result of compensating for the first aspect ratio R 0 and is used as a final estimate of the quadrilateral aspect ratio. Since the compensation factor k rectangular quadrilateral Q compensation factor k corresponding Therefore, when the rectangular original aspect ratio compensation factor k Q R Q R and the aspect ratio of the first ratio, the aspect ratio of the second quadrangular R 1 can be expressed by the product of the compensation factor k and the first aspect ratio R 0 , that is, R 1 =k*R 0 . When the compensation factor k Q of the rectangle is the ratio of the first aspect ratio R Q to the original aspect ratio R, the second aspect ratio R 1 of the quadrilateral can be represented by the ratio of the first aspect ratio R 0 to the compensation factor k , that is, R 1 =R 0 /k. By substituting the values of the first aspect ratio R 0 and the compensation factor k obtained in the foregoing steps into the above expression, the value of the second aspect ratio R 1 can be obtained.
在本发明实施例中,通过对不同角度的图像获取场景进行分类,针对每个类型的图像获取场景通过统计方法获取补偿公式,对四边形宽高比的初步估计进行补偿,从而使校正后的图像宽高比更接近被摄物体的原始宽高比,提高了图像校正的效果。In the embodiment of the present invention, the image acquisition scenes of different angles are classified, and the compensation formula is obtained by using a statistical method for each type of image acquisition scene, and the preliminary estimation of the quadrilateral aspect ratio is compensated, so that the corrected image is obtained. The aspect ratio is closer to the original aspect ratio of the subject, which improves the image correction effect.
本发明实施例还提供了另一种图像校正方法,下面结合图2、图4、图7和图8说明该方法。所述图像校正方法的流程图如图2所示,其中,该方法的步骤203至205与前文所述的步骤203至205相同,此处不再赘述。以下,针对步骤201和202与前文所述的步骤201和202之间的区别进行说明。Another embodiment of the present invention provides an image correction method. The method will be described below with reference to FIGS. 2, 4, 7, and 8. The flowchart of the image correction method is as shown in FIG. 2, wherein steps 203 to 205 of the method are the same as steps 203 to 205 described above, and details are not described herein again. Hereinafter, the differences between steps 201 and 202 and steps 201 and 202 described above will be described.
在步骤201中,四边形的几何特征包括第一几何特征和第二几何特征。其中,第一几何特征为长度特征和角度特征的组合,用于对四边形进行分类。长度特征可以包括四边形的边长占比D。边长占比D可以用于判断被摄物体与摄像头之间的相对距离。边长占比越大,被摄物体与摄像头的距离越近;边长占比越小,被摄物体与摄像头的距离越远。在一个示例中,边长占比D可以是四边形最长边的长度h与待校正图像的边长(例 如,图像的高度H或者宽度W)的比值,即D=h/H或者D=h/W。In step 201, the geometric features of the quadrilateral include a first geometric feature and a second geometric feature. The first geometric feature is a combination of a length feature and an angle feature for classifying the quadrilateral. The length feature may include a side length ratio D of the quadrilateral. The aspect ratio D can be used to determine the relative distance between the subject and the camera. The larger the side length ratio, the closer the distance between the subject and the camera; the smaller the side length ratio, the farther the subject is from the camera. In one example, the side length ratio D may be the length h of the longest side of the quadrilateral and the side length of the image to be corrected (eg, For example, the ratio of the height H or the width W) of the image, that is, D=h/H or D=h/W.
在另一个示例中,边长占比D为四边形的对角线长度l与待校正图像的对角线长度L的比值,即D=l/L。In another example, the side length ratio D is the ratio of the diagonal length l of the quadrilateral to the diagonal length L of the image to be corrected, ie, D=l/L.
角度特征可以包括两组对边夹角θH和θV,也可以包括四边形的两组对边夹角的三角函数值,例如,两组对边夹角的正弦值、正切值、余弦值或余切值。上述数值可以用于判断四边形失真较小的对边的倾斜程度。The angular feature may include two sets of opposite angles θ H and θ V , and may also include trigonometric values of two sets of opposite sides of the quadrilateral, for example, sine, tangent, cosine or Cotangent value. The above values can be used to determine the degree of tilt of the opposite sides with less quadrilateral distortion.
第二几何特征包括四边形的角度特征,用于计算补偿因子k。四边形的角度特征可以包括两组对边夹角之差的绝对值δ(即δ=|θHV|),也可以包括两组对边夹角的差值,或者两组对边夹角之差的三角函数值,或者两组对边夹角的三角函数值之差,或者或者两组对边夹角之差的绝对值的三角函数值,或者两组对边夹角的三角函数值之差的绝对值。上述数值可以用于判断图像整体的变形程度。The second geometric feature includes an angular feature of the quadrilateral for calculating the compensation factor k. The angular feature of the quadrilateral may include the absolute value δ of the difference between the two sets of opposite sides (ie, δ=|θ HV |), and may also include the difference between the two sets of opposite sides, or two sets of opposite side clips. The value of the trigonometric function of the difference between the angles, or the difference between the two sets of trigonometric values of the angles of the edges, or the trigonometric function of the absolute difference between the two sets of angles between the two sides, or the trigonometric function of the two sets of angles between the opposite sides The absolute value of the difference in values. The above values can be used to determine the degree of deformation of the entire image.
为清楚和方便起见,本发明实施例在提到四边形的几何特征时,如果没有其它说明,是指四边形的边长占比D=h/H、两组对边夹角θH和θV以及两组对边夹角之差的绝对值δ。当本发明实施例所述的方法应用到几何特征包括三角函数值的实施例时,可以用两组对边夹角的三角函数值替换相应的两组对边夹角,同时可以用两组对边夹角之差的绝对值的三角函数值或者两组对边夹角的三角函数值之差的绝对值替换相应的两组对边夹角之差的绝对值。For the sake of clarity and convenience, when referring to the geometric features of the quadrilateral, the embodiment of the present invention refers to the ratio of the side length of the quadrilateral D=h/H, the angle between the two sets of opposite sides θ H and θ V , and the like. The absolute value δ of the difference between the two groups. When the method according to the embodiment of the present invention is applied to an embodiment in which the geometric feature includes a trigonometric function value, the two sets of opposite angles may be replaced by two sets of trigonometric values of the opposite sides, and two pairs of pairs may be used. The absolute value of the difference between the absolute value of the difference between the edges and the value of the trigonometric function of the two sets of angles replaces the absolute value of the difference between the two sets of opposite sides.
在步骤202中,根据四边形的几何特征和补偿公式获取补偿因子。其中,将四边形的第二几何特征代入到补偿公式中,可以算出四边形的补偿因子。补偿公式可以反映第二几何特征与补偿因子k的关系,其形式与前文步骤202所述的相同。由于在不同的图像获取场景中,除了拍摄角度不同将导致四边形Q的倾斜姿态不同外,拍摄距离不同将导致四边形Q的大小也不同,因此,可以根据距离和倾斜姿态的特点对四边形分类,针对每一类四边形分别确定一个补偿公式。所述补偿公式确定方法的流程图如图4所示。其中,该方法的步骤2021和2024与前文所述的步骤2021和2024相同,此处不再赘述。以下,针对步骤2022和2023与前文所述的步骤2022和2023之间的区别进行说明。In step 202, a compensation factor is obtained based on the geometric features of the quadrilateral and the compensation formula. Wherein, the second geometric feature of the quadrilateral is substituted into the compensation formula, and the compensation factor of the quadrilateral can be calculated. The compensation formula may reflect the relationship of the second geometric feature to the compensation factor k in the same form as described in step 202 above. In different image acquisition scenes, except that the shooting angle is different, the tilting posture of the quadrilateral Q is different, and the shooting distance is different, which causes the quadrilateral Q to have different sizes. Therefore, the quadrilateral can be classified according to the characteristics of the distance and the tilting posture, Each type of quadrilateral determines a compensation formula. A flowchart of the method for determining the compensation formula is shown in FIG. 4 . The steps 2021 and 2024 of the method are the same as the steps 2021 and 2024 described above, and are not described herein again. Hereinafter, the differences between steps 2022 and 2023 and steps 2022 and 2023 described above will be described.
在步骤2022中,由于矩形的几何特征与待校正四边形的几何特征相应,当待校正四边形的几何特征包括第一几何特征和第二几何特征时,矩形的几何特征也包括相应的第一几何特征和第二几何特征。作为一个例子,当四边形的第一几何特征包括边长占比D、两组对边夹角θH和θV,第二几何特征包括两组对边夹角之差的绝对值δ时,矩形的第一几何特征相应地包括边长占比DQ、两组对边夹角θQH和θQV,第二几何特征包括两组对边夹角之差的绝对值δQ=|θQHQV|,由此获得N组矩形的补偿因子kQ、第一几何特征和第二几何特征的对应数据。In step 2022, since the geometric feature of the rectangle corresponds to the geometric feature of the quadrilateral to be corrected, when the geometric feature of the quadrilateral to be corrected includes the first geometric feature and the second geometric feature, the geometric feature of the rectangle also includes the corresponding first geometric feature. And the second geometric feature. As an example, when the first geometric feature of the quadrilateral includes the side length ratio D, the two sets of opposite side angles θ H and θ V , and the second geometric feature includes the absolute value δ of the difference between the two sets of opposite sides, the rectangle The first geometric feature correspondingly includes a side length ratio D Q , two sets of opposite side angles θ QH and θ QV , and the second geometric feature includes an absolute value of the difference between the two sets of opposite sides δ Q =| θ QH - θ QV |, thereby obtaining corresponding data of the N sets of rectangular compensation factors k Q , the first geometric features and the second geometric features.
在步骤2023中,将矩形的第一几何特征与分类阈值进行比较,从而将所述N组对应数据分入与四边形类型对应的类型。在一个示例中,四边形根据距离可以分为以下三类:近距、中距和远距类。在其它一些示例中,四边形可以分为近、远距两类,或者分为近、中近、中、中远、远距五类。需要说明的是,上述分类不应成为对本申请的限制,只要分类能够描述被摄物体与设备之间距离的远近程度。In step 2023, the first geometric feature of the rectangle is compared to a classification threshold to classify the N sets of corresponding data into a type corresponding to the quadrilateral type. In one example, quadrilaterals can be divided into the following three categories based on distance: near, medium, and far. In other examples, the quadrilateral can be divided into two types: near and far, or divided into five categories: near, medium, medium, medium, and long distance. It should be noted that the above classification should not be a limitation on the present application as long as the classification can describe the distance between the object and the device.
在对所述N组对应数据进行分类的过程中,作为一个例子,可以先比较矩形的边长 占比DQ与距离分类阈值T,将N组对应数据分入与四边形距离类型相应的大类数据;然后,再比较矩形的两组对边夹角θQH和θQV与角度分类阈值θT,从而进一步将每一大类数据分入与四边形倾斜类型相应的小类数据。作为另一个例子,也可以先比较矩形的两组对边夹角θQH和θQV与角度分类阈值θT,将N组对应数据分入与四边形倾斜类型相应的大类数据;然后,再比较矩形的边长占比DQ与距离分类阈值T,进一步将每一大类数据分入与四边形距离类型相应的小类数据。In the process of classifying the N sets of corresponding data, as an example, the side length ratio D Q and the distance classification threshold T of the rectangle may be compared first, and the N sets of corresponding data are classified into a category corresponding to the quadrilateral distance type. The data is then compared with the two sets of opposite side angles θ QH and θ QV of the rectangle and the angle classification threshold θ T , thereby further classifying each large class of data into small class data corresponding to the quadrilateral tilt type. As another example, it is also possible to compare the two sets of opposite side angles θ QH and θ QV of the rectangle with the angle classification threshold θ T , and divide the N sets of corresponding data into the large class data corresponding to the quadrilateral tilt type; and then compare The side length of the rectangle occupies the ratio D Q and the distance classification threshold T, and further divides each large class of data into small class data corresponding to the quadrilateral distance type.
在上述过程中,确定角度分类阈值θT和根据倾斜姿态分类可以参照前文所述的步骤2023的记载,此处不再赘述。距离分类阈值T可用于将所述N组对应数据按照一定比例或者基本均匀地分入对应的四边形距离类型,并对待校正四边形进行分类,以便选择相应的补偿公式。在一个示例中,距离分类阈值T可以是矩形边长占比DQ的统计分位数,例如,距离分类阈值T可以是边长占比DQ的1/3分位数(即所有数值由小到大排列后排在1/3位置的数值)和2/3分位数(即所有数值由小到大排列后排在2/3位置的数值)。In the above process, the determination of the angle classification threshold θ T and the classification according to the tilt posture can refer to the description of the step 2023 described above, and details are not described herein again. The distance classification threshold T can be used to classify the N sets of corresponding data into corresponding quadrilateral distance types according to a certain ratio or substantially uniformly, and classify the corrected quadrilaterals to select a corresponding compensation formula. In one example, the distance classification threshold T may be a statistical quantile of the square side length ratio D Q . For example, the distance classification threshold T may be a 1/3 quantile of the side length ratio D Q (ie, all values are determined by The value of the 1/3 position after the small to large arrangement and the 2/3 quantile (that is, the value of all the values from the small to the large and the 2/3 position).
在另一个示例中,距离分类阈值T也可以是矩形边长占比DQ的均值。In another example, the distance classification threshold T may also be the mean of the rectangular side length ratio D Q .
在另一个示例中,距离分类阈值T还可以根据经验取值,例如0.5和0.8。In another example, the distance classification threshold T may also be based on empirical values, such as 0.5 and 0.8.
作为一个例子,如图7所示,当距离分类阈值T为一组数0.5和0.8时,四边形可以分为远、中、近距三类。其中,图7的(A)部分所示的近距类四边形的边长占比h/H>0.8;图7的(B)部分所示的中距类四边形的边长占比0.5<h/H<0.8;图7的(C)部分所示的远距类四边形的边长占比h/H<0.5。将N组对应数据分为对应三种距离的三大类数据,然后再将每一大类数据分为对应四种倾斜姿态的四小类数据,如图8所示,由此得到十二组数据。As an example, as shown in FIG. 7, when the distance classification threshold T is a set of numbers 0.5 and 0.8, the quadrilateral can be classified into three types: far, medium, and close. Wherein, the side length ratio of the close-up quadrilateral shown in part (A) of FIG. 7 is h/H>0.8; the side length of the medium-distance quadrilateral shown in part (B) of FIG. 7 is 0.5<h/ H<0.8; the side length ratio of the distance-like quadrilateral shown in part (C) of Fig. 7 is h/H < 0.5. The N sets of corresponding data are divided into three categories of data corresponding to the three kinds of distances, and then each of the large types of data is divided into four sub-classes of data corresponding to the four tilting postures, as shown in FIG. data.
在本发明实施例中,通过对不同距离和角度的场景进行分类,进一步细化了图像获取场景的类型,使得每一类图像获取场景对应的补偿公式能够更准确地反映四边形的几何特征与补偿因子的关系,因此校正后的图像宽高比更接近被摄物体的实际宽高比,从而提高了每一类场景下的图像校正的效果。In the embodiment of the present invention, by classifying scenes with different distances and angles, the types of image acquisition scenes are further refined, so that the compensation formula corresponding to each type of image acquisition scene can more accurately reflect the geometric features and compensation of the quadrilateral. The relationship of the factors, so the corrected image aspect ratio is closer to the actual aspect ratio of the subject, thereby improving the effect of image correction in each type of scene.
本发明实施例还提供了另一种图像校正方法,下面结合图2和图9说明该方法。所述图像校正方法的流程图如图2所示,其中,该方法的步骤203至205与前文所述的步骤203至205相同,此处不再赘述。以下,针对步骤201和202与前文所述的步骤201和202之间的区别进行说明。Another embodiment of the present invention provides an image correction method. The method will be described below with reference to FIGS. 2 and 9. The flowchart of the image correction method is as shown in FIG. 2, wherein steps 203 to 205 of the method are the same as steps 203 to 205 described above, and details are not described herein again. Hereinafter, the differences between steps 201 and 202 and steps 201 and 202 described above will be described.
在步骤201中,四边形的几何特征可以是四边形的两组对边夹角之差。在一个示例中,所述两组对边夹角之差可以是水平对边夹角θH与竖直对边夹角θV的差值δHV=θHV。所述差值δHV的大小可以用于判断图像整体的倾斜程度,差值δHV的符号用于表示倾斜方向(即水平或竖直倾斜),当δHV>0时,图像整体呈水平倾斜,当δHV<0时,图像整体呈竖直倾斜。In step 201, the geometric feature of the quadrilateral may be the difference between the two sets of opposite sides of the quadrilateral. In one example, the angle difference between the two sides of the edge may be a horizontal angle θ H of the vertical sides of the angle difference δ HV of θ V = θ HV. The magnitude of the difference δ HV can be used to determine the degree of tilt of the image as a whole, and the sign of the difference δ HV is used to indicate the tilt direction (ie, horizontal or vertical tilt). When δ HV >0, the image is tilted as a whole. When δ HV <0, the image as a whole is vertically inclined.
在另一个示例中,所述两组对边夹角的差还可以是竖直对边夹角与水平对边夹角的差值δVH=θVH。当δVH>0时,矩形图像整体呈竖直倾斜,当δVH<0时,矩形图像整体呈水平倾斜。In another example, the difference between the two sets of opposite sides may also be the difference δ VH = θ V - θ H between the angle between the vertical and the opposite sides. When δ VH > 0, the rectangular image is vertically inclined as a whole, and when δ VH < 0, the rectangular image as a whole is horizontally inclined.
在其它一些示例中,四边形的几何特征还可以是两组对边夹角之差的三角函数值,或者两组对边夹角的三角函数值之差。这些几何特征可以表示图像整体的倾斜程度和倾 斜方向。In other examples, the geometric feature of the quadrilateral may also be a trigonometric function value of the difference between the two sets of angles of the opposite sides, or a difference between the two sets of trigonometric values of the angles of the opposite sides. These geometric features can indicate the degree of tilt and tilt of the image as a whole. Oblique direction.
为清楚和方便起见,本发明实施例在提到四边形的几何特征时,如果没有其它说明,是指四边形的两组对边夹角之差δHV。当本发明实施例所述的方法应用到几何特征包括三角函数值的实施例时,可以用两组对边夹角之差的三角函数值或者两组对边夹角的三角函数值之差替换相应的两组对边夹角之差。For the sake of clarity and convenience, when referring to the geometric features of the quadrilateral, the embodiment of the present invention refers to the difference δ HV between the two sets of opposite sides of the quadrilateral unless otherwise stated. When the method according to the embodiment of the present invention is applied to an embodiment in which the geometric feature includes a trigonometric function value, the difference between the two sets of trigonometric values of the difference between the sides of the edges or the difference between the two sets of trigonometric values of the opposite sides can be used. The difference between the corresponding two sets of opposite sides.
在步骤202中,将四边形的几何特征代入到补偿公式中,可以算出四边形的补偿因子k。补偿公式可以反映几何特征与补偿因子k的关系,其形式与前文步骤202所述的相同。由于四边形的两组对边夹角之差可以表示图像整体的倾斜程度和倾斜方向,因此,可以不对四边形进行分类,采用一个补偿公式就可以表示四边形的几何特征与补偿因子k的关系。In step 202, the geometric feature of the quadrilateral is substituted into the compensation formula, and the compensation factor k of the quadrilateral can be calculated. The compensation formula may reflect the relationship of the geometric feature to the compensation factor k in the same form as described in step 202 above. Since the difference between the two sets of opposite sides of the quadrilateral can indicate the degree of tilt and the tilt direction of the image as a whole, the quadrilateral can be classified without using a compensation formula to represent the relationship between the geometrical features of the quadrilateral and the compensation factor k.
下面结合图9说明本发明实施例的另一种补偿公式的确定方法,该方法可以由设备101执行,其中包括:Another method for determining a compensation formula according to an embodiment of the present invention is described below with reference to FIG. 9, which may be performed by the device 101, including:
步骤2021’,获取已知宽高比的矩形在N个不同角度下的N个图像。Step 2021', obtaining N images of rectangles of known aspect ratio at N different angles.
步骤2022’,从N个图像的每一个图像中,获取矩形的第一宽高比RQ和几何特征,得到N组矩形的补偿因子kQ与几何特征的对应数据。Step 2022': Obtain a first aspect ratio R Q and a geometric feature of the rectangle from each of the N images, and obtain corresponding data of the compensation factor k Q of the N sets of rectangles and the geometric features.
步骤2023’,根据N组补偿因子kQ和几何特征的对应数据拟合补偿公式。Step 2023', fitting the compensation formula according to the N sets of compensation factors k Q and the corresponding data of the geometric features.
由于步骤2021’与前文步骤2021类似,此处不再赘述。下面具体说明步骤2022’和步骤2023’。Since step 2021' is similar to the previous step 2021, it will not be described again here. Step 2022' and step 2023' will be specifically described below.
在步骤2022’中,由于矩形的几何特征与四边形的几何特征相应,当四边形的几何特征包括两组对边夹角之差时,矩形的几何特征也包括两组对边夹角之差。作为一个例子,当四边形的几何特征包括两组对边夹角θH与θV的差值δHV时,矩形的几何特征也包括两组对边夹角θQH与θQV的差值δQHV=θQHQV。由此,得到N组矩形的补偿因子kQ与几何特征δHV的对应数据。In step 2022', since the geometric features of the rectangle correspond to the geometric features of the quadrilateral, when the geometric features of the quadrilateral include the difference between the two sets of opposite sides, the geometrical features of the rectangle also include the difference between the two sets of opposite sides. As an example, when the geometric feature of the quadrilateral includes the difference δ HV between the two sets of opposite angles θ H and θ V , the geometrical features of the rectangle also include the difference δ QHV between the two sets of opposite angles θ QH and θ QV . =θ QHQV . Thereby, corresponding data of the compensation factor k Q of the N sets of rectangles and the geometrical feature δ HV are obtained.
在步骤2023’中,由于四边形未分类,因此可以不对N组对应数据进行分类,直接根据矩形的两组对边夹角之差δQHV与补偿因子kQ拟合补偿公式。在一个示例中,表2示出了矩形的两组对边夹角之差δQHV与补偿因子kQ的对应数据,由此可以拟合出补偿公式。作为一个例子,所述补偿公式是二次函数,即:k=a*x2+b*x+c,其中,x表示几何特征,k表示补偿因子,参数a,b和c通过表2中数据拟合确定,其中,a=0.0001,b=0.0165,c=1.0。In step 2023', since the quadrilateral is unclassified, the N sets of corresponding data may not be classified, and the compensation formula may be directly fitted according to the difference δ QHV between the two sets of opposite sides of the rectangle and the compensation factor k Q . In one example, Table 2 shows the corresponding data of the difference δ QHV between the two sets of opposite sides of the rectangle and the compensation factor k Q , whereby the compensation formula can be fitted. As an example, the compensation formula is a quadratic function, ie: k=a*x 2 +b*x+c, where x represents a geometric feature, k represents a compensation factor, and parameters a, b, and c pass through Table 2. Data fitting was determined, where a = 0.0001, b = 0.0165, and c = 1.0.
本领域技术人员能够了解,只要能够通过拟合算法获得符合精度要求的结果,补偿模板选择一次、三次或更高次函数也是可以的。上述拟合的算法可以采用已知的算法,此处不再赘述。Those skilled in the art will appreciate that it is also possible to select one, three or higher order functions for the compensation template as long as the results that meet the accuracy requirements can be obtained by the fitting algorithm. The above-mentioned fitting algorithm can adopt a known algorithm and will not be described here.
表2 两组对边夹角之差δQHV与补偿因子kQ的对应数据表Table 2 Corresponding data table of the difference δ QHV and compensation factor k Q between the two groups
Figure PCTCN2017074432-appb-000003
Figure PCTCN2017074432-appb-000003
Figure PCTCN2017074432-appb-000004
Figure PCTCN2017074432-appb-000004
在本发明实施例中,通过选择能够表示四边形整体倾斜情况的几何特征,可以减少图像获取场景的类型,同时保证补偿公式仍然能够准确地反映四边形的几何特征与补偿因子的关系,因此简化了图像校正的步骤,提升了图像校正的处理速度。In the embodiment of the present invention, by selecting geometric features capable of representing the overall tilt of the quadrilateral, the type of the image acquisition scene can be reduced, and the compensation formula can still accurately reflect the relationship between the geometric features of the quadrilateral and the compensation factor, thereby simplifying the image. The step of correcting improves the processing speed of image correction.
图10为本发明实施例的一种设备的结构示意图,如图10所示,该设备1000包括: 第一获取模块1001、第二获取模块1002、第一计算模块1003和第二计算模块1004和校正模块1005。其中,第一获取模块1001,用于获取待校正图像中的四边形的第一宽高比以及所述四边形的几何特征。第二获取模块1002,用于根据所述四边形的几何特征获取所述四边形的补偿因子。第一计算模块1003,用于根据所述四边形的第一宽高比和所述四边形的补偿因子,计算所述四边形的第二宽高比。第二计算模块1004,用于根据所述四边形的第二宽高比计算变换矩阵。校正模块1005,用于根据所述变换矩阵校正所述待校正图像。FIG. 10 is a schematic structural diagram of a device according to an embodiment of the present invention. As shown in FIG. 10, the device 1000 includes: The first obtaining module 1001, the second obtaining module 1002, the first calculating module 1003, and the second calculating module 1004 and the correcting module 1005. The first obtaining module 1001 is configured to acquire a first aspect ratio of a quadrilateral in the image to be corrected and a geometric feature of the quadrilateral. The second obtaining module 1002 is configured to obtain a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral. The first calculating module 1003 is configured to calculate a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral. The second calculating module 1004 is configured to calculate a transformation matrix according to the second aspect ratio of the quadrilateral. The correction module 1005 is configured to correct the image to be corrected according to the transformation matrix.
图11为本发明实施例的一种第二获取模块的结构示意图,如图11所示,所述第二获取模块1002还包括:第一获取单元10021、第二获取单元10022、分类单元10023和拟合单元10024。其中,第一获取单元10021用于获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;第二获取单元10022用于获取所述矩形的宽高比以及所述矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;分类单元10023用于将所述N组对应数据分为多个类型;拟合单元10024用于根据所述多个类型中的每一类数据分别拟合补偿公式。FIG. 11 is a schematic structural diagram of a second acquiring module according to an embodiment of the present invention. As shown in FIG. 11 , the second acquiring module 1002 further includes: a first acquiring unit 10021, a second acquiring unit 10022, a classifying unit 10023, and Fitting unit 10024. The first obtaining unit 10021 is configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second obtaining unit 10022 is configured to acquire the rectangle The aspect ratio and the geometric features of the rectangle obtain corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; the classifying unit 10023 is configured to divide the N sets of corresponding data into multiple types; The merging unit 10024 is configured to respectively fit the compensation formula according to each of the plurality of types of data.
图12为本发明实施例的另一种第二获取模块的结构示意图,如图12所示,所述第二获取模块1002还包括:第一获取单元10021’、第二获取单元10022’和拟合单元10023’。其中,第一获取单元10021’用于获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;第二获取单元10022用于获取所述矩形的宽高比以及所述矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;拟合单元10023’,用于根据所述N组对应数据拟合补偿公式。FIG. 12 is a schematic structural diagram of another second acquiring module according to an embodiment of the present invention. As shown in FIG. 12, the second acquiring module 1002 further includes: a first acquiring unit 10021', a second acquiring unit 10022', and a Unit 10023'. The first obtaining unit 10021 ′ is configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2; and the second obtaining unit 10022 is configured to acquire the rectangle. The aspect ratio and the geometric features of the rectangle, obtaining corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle; the fitting unit 10023' is configured to fit the compensation according to the N sets of corresponding data formula.
本发明实施例提供的设备用于实现上述图1至图9中所示的实施例的方法,具体的流程或原理可以参见上述方法实施例。The device provided by the embodiment of the present invention is used to implement the foregoing method in the embodiment shown in FIG. 1 to FIG. 9. For the specific process or principle, refer to the foregoing method embodiment.
图13示出了本发明实施例的另一种设备的结构图,如图13所示,所述设备1300包括:处理器1301,摄像头1302,用户输入设备1303,显示器1304,存储器1305,以及一个或多个程序。为了方便说明,图13仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本申请上述方法实施例及申请文件的其他部分。本领域技术人员应当知晓,上述处理器1301,摄像头1302,用户输入设备1303,显示器1304和存储器1305等硬件的数量可以为一个或多个,这取决于设备1300的种类。FIG. 13 is a structural diagram of another apparatus according to an embodiment of the present invention. As shown in FIG. 13, the apparatus 1300 includes: a processor 1301, a camera 1302, a user input device 1303, a display 1304, a memory 1305, and a Or multiple programs. For the convenience of description, FIG. 13 only shows a part related to the embodiment of the present invention. If the specific technical details are not disclosed, please refer to the above method embodiment and other parts of the application file of the present application. Those skilled in the art should know that the number of hardware such as the processor 1301, the camera 1302, the user input device 1303, the display 1304 and the memory 1305 may be one or more, depending on the type of the device 1300.
处理器1301与摄像头1302、用户输入设备1303、显示器1304和存储器1305通过一条或多条总线连接。处理器1301接收来自摄像头1302的图像和来自用户输入设备1303的用户指令,调用存储器1305存储的执行指令进行处理,并发送给显示器1304进行呈现。处理器1301可以是中央处理器(Central Processing Unit,CPU),通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC),现场可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。处理器1301可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器1301也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等等。作为示例,所述处理器1301用于支持设备1300执行图2中的步骤202 至204、图4中的步骤2022至2024,以及图9中的步骤2022’和2023’。The processor 1301 is coupled to the camera 1302, the user input device 1303, the display 1304, and the memory 1305 via one or more buses. The processor 1301 receives the image from the camera 1302 and the user command from the user input device 1303, calls the execution instruction stored in the memory 1305 for processing, and sends it to the display 1304 for presentation. The processor 1301 may be a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), and a field programmable gate array ( Field Programmable Gate Array (FPGA) or other programmable logic device, transistor logic device, hardware component, or any combination thereof. The processor 1301 can implement or perform various exemplary logical blocks, modules, and circuits described in connection with the present disclosure. The processor 1301 may also be a combination of computing functions, such as one or more microprocessor combinations, a combination of a DSP and a microprocessor, and the like. As an example, the processor 1301 is configured to support the device 1300 to perform step 202 in FIG. 2 . Up to 204, steps 2022 through 2024 in Fig. 4, and steps 2022' and 2023' in Fig. 9.
摄像头1302将获取的图像传输给处理器1301。摄像头1302还可以是数字照相机(也称数码相机、数字相机)、扫描仪或其它能够获取图像的光学装置。获取的图像从内容的角度区分,可以是图像,也可以是文稿,还可以是同时包含图像和文稿的混合图像。作为示例,摄像头1302用于支持设备执行图2中的步骤201、图4中的步骤2021和图9中的步骤2021’。The camera 1302 transmits the acquired image to the processor 1301. The camera 1302 can also be a digital camera (also known as a digital camera, digital camera), a scanner, or other optical device capable of acquiring images. The acquired image is distinguished from the perspective of the content, and may be an image, a document, or a mixed image containing both the image and the document. As an example, the camera 1302 is used to support the device to perform step 201 in Fig. 2, step 2021 in Fig. 4, and step 2021' in Fig. 9.
用户输入设备1302接收用户的操作指令,并传输给处理器1301处理。所述用户输入设备1302包括触摸屏、按键或麦克风。The user input device 1302 receives the user's operation instructions and transmits them to the processor 1301 for processing. The user input device 1302 includes a touch screen, a button, or a microphone.
显示器1304呈现预览图像、校正后的图像以及人机交互界面。显示器1304可以是内置在设备1300上的显示屏,也可以是外接到设备1300的其它外部显示设备。 Display 1304 presents a preview image, a corrected image, and a human-computer interaction interface. Display 1304 can be a display built into device 1300 or other external display device externally connected to device 1300.
存储器1305存储图像、预置模型以及一个或多个程序。存储器1305可以是任何计算机可读存储介质。所述一个或多个程序存储在存储器中并被配置为被一个或多个处理器执行,既包括设备操作系统的执行指令,也包括设备应用程序的执行指令,例如本发明实施例中校正图像的执行指令。The memory 1305 stores images, preset models, and one or more programs. Memory 1305 can be any computer readable storage medium. The one or more programs are stored in a memory and configured to be executed by one or more processors, including both execution instructions of the device operating system and execution instructions of the device application, such as correcting images in embodiments of the present invention. Execution instructions.
在上述本发明实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读介质向另一个计算机可读介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如,固态硬盘(Solid State Disk,SSD))等。In the above embodiments of the present invention, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable medium to another computer readable medium, for example, the computer instructions can be wired from a website site, computer, server or data center (for example, coaxial cable, fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to another website, computer, server or data center. The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media. The usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a Solid State Disk (SSD)) or the like.
本领域技术人员应该可以意识到,在上述一个或多个示例中,本发明所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。Those skilled in the art will appreciate that in one or more examples described above, the functions described herein can be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium. Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. A storage medium may be any available media that can be accessed by a general purpose or special purpose computer.
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,应当理解的是,以上所述仅为本发明技术方案的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The specific embodiments of the present invention have been described in detail with reference to the preferred embodiments of the present invention. The scope of protection of the invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.

Claims (23)

  1. 一种图像校正方法,其特征在于,所述方法包括:An image correction method, the method comprising:
    获取待校正图像的四边形的第一宽高比以及所述四边形的几何特征;Obtaining a first aspect ratio of a quadrilateral of the image to be corrected and a geometric feature of the quadrilateral;
    根据所述四边形的几何特征获取所述四边形的补偿因子;Acquiring a compensation factor of the quadrilateral according to geometric features of the quadrilateral;
    根据所述四边形的第一宽高比和所述四边形的补偿因子,计算所述四边形的第二宽高比;Calculating a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral;
    根据所述四边形的第二宽高比计算变换矩阵;Calculating a transformation matrix according to a second aspect ratio of the quadrilateral;
    根据所述变换矩阵校正所述待校正图像。The image to be corrected is corrected according to the transformation matrix.
  2. 根据权利要求1所述的图像校正方法,其特征在于,The image correction method according to claim 1, wherein
    根据所述四边形的几何特征获取所述四边形补偿因子包括:根据所述四边形的几何特征和补偿公式获取所述四边形的补偿因子;Obtaining the quadrilateral compensation factor according to the geometric feature of the quadrilateral comprises: acquiring a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral and a compensation formula;
    所述补偿公式的确定方法包括:The method for determining the compensation formula includes:
    获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;Obtaining N images of rectangles of known aspect ratio at N different angles, where N is an integer not less than 2;
    从所述N个图像的每一个图像中,获取所述矩形的第一宽高比以及矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;Obtaining, from each of the N images, a first aspect ratio of the rectangle and a geometric feature of the rectangle, to obtain corresponding data of the compensation factor of the N sets of the rectangle and the geometric feature of the rectangle;
    根据所述N组对应数据拟合补偿公式。A compensation formula is fitted according to the N sets of corresponding data.
  3. 根据权利要求2所述的图像校正方法,其特征在于,所述根据所述N组对应数据拟合补偿公式包括:将所述N组对应数据分为多个类型;根据所述多个类型中的每一类数据分别拟合补偿公式。The image correction method according to claim 2, wherein the fitting the compensation formula according to the N sets of corresponding data comprises: dividing the N sets of corresponding data into a plurality of types; according to the plurality of types Each type of data is fitted to the compensation formula.
  4. 根据权利要求2或3所述的图像校正方法,其特征在于,所述补偿公式在校正图像前预先确定。The image correction method according to claim 2 or 3, wherein the compensation formula is predetermined before the image is corrected.
  5. 根据权利要求1-4任一项所述的图像校正方法,其特征在于,所述几何特征包括距离特征或角度特征中的至少一种。The image correction method according to any one of claims 1 to 4, wherein the geometric feature comprises at least one of a distance feature or an angle feature.
  6. 根据权利要求5所述的图像校正方法,其特征在于,所述角度特征包括:The image correction method according to claim 5, wherein the angle feature comprises:
    所述四边形的两组对边夹角的差值;a difference between the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的三角函数值;Or a trigonometric function value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值。Alternatively, the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral.
  7. 根据权利要求1-4任一项所述的图像校正方法,其特征在于,所述几何特征包括第一几何特征和第二几何特征,The image correction method according to any one of claims 1 to 4, wherein the geometric feature comprises a first geometric feature and a second geometric feature.
    所述第一几何特征包括以下特征中的至少一种:The first geometric feature includes at least one of the following features:
    所述四边形的最长边的长度与所述待校正图像的边长的比值;a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected;
    或者,所述四边形的对角线长度与所述待校正图像的对角线长度的比值;Or the ratio of the diagonal length of the quadrilateral to the diagonal length of the image to be corrected;
    或者,所述四边形的两组对边夹角的大小;Or the size of the angle between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值;Or a trigonometric function value of the two sets of opposite sides of the quadrilateral;
    所述第二几何特征包括:The second geometric feature includes:
    所述四边形的两组对边夹角的差值;a difference between the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的三角函数值;Or a trigonometric function value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值; Or the difference between the values of the trigonometric functions of the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的绝对值;Or the absolute value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的绝对值的三角函数值;Or a trigonometric function value of the absolute value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值的绝对值。Alternatively, the absolute value of the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral.
  8. 根据权利要求1-7任一项所述的图像校正方法,其特征在于,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的中位线长度,所述高度估计值是与竖直方向夹角较小的中位线长度。The image correction method according to any one of claims 1 to 7, wherein the first aspect ratio of the quadrilateral or the rectangle is a ratio of a width estimation value to a height estimation value, and the width estimation value is a level The length of the median line with a small angle of direction is the length of the median line that is smaller than the angle between the vertical directions.
  9. 根据权利要求1-7任一项所述的图像校正方法,其特征在于,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的一组对边中的长边长度,所述高度估计值是与竖直方向夹角较小的一组对边中的长边长度。The image correction method according to any one of claims 1 to 7, wherein the first aspect ratio of the quadrilateral or the rectangle is a ratio of a width estimation value to a height estimation value, and the width estimation value is a level The length of the long side of a pair of opposite sides having a smaller angle of the direction, the height estimate being the length of the long side of a pair of opposite sides having a smaller angle with the vertical direction.
  10. 根据权利要求1-9任一项所述的图像校正方法,其特征在于,所述补偿公式的函数形式为一次函数、二次函数或更高次函数形式。The image correction method according to any one of claims 1 to 9, characterized in that the function form of the compensation formula is a one-time function, a quadratic function or a higher-order function form.
  11. 一种设备,其特征在于,所述设备包括:A device, characterized in that the device comprises:
    第一获取模块,用于获取待校正图像中的四边形的第一宽高比以及所述四边形的几何特征;a first acquiring module, configured to acquire a first aspect ratio of a quadrilateral in the image to be corrected and a geometric feature of the quadrilateral;
    第二获取模块,用于根据所述四边形的几何特征获取所述四边形的补偿因子;a second acquiring module, configured to acquire a compensation factor of the quadrilateral according to the geometric feature of the quadrilateral;
    第一计算模块,用于根据所述四边形的第一宽高比和所述四边形的补偿因子,计算所述四边形的第二宽高比;a first calculating module, configured to calculate a second aspect ratio of the quadrilateral according to a first aspect ratio of the quadrilateral and a compensation factor of the quadrilateral;
    第二计算模块,用于根据所述四边形的第二宽高比计算变换矩阵;a second calculating module, configured to calculate a transformation matrix according to a second aspect ratio of the quadrilateral;
    校正模块,用于根据所述变换矩阵校正所述待校正图像。And a correction module, configured to correct the image to be corrected according to the transformation matrix.
  12. 根据权利要求11所述的设备,其特征在于,所述第二获取模块用于根据所述四边形的几何特征和补偿公式获取所述四边形的补偿因子;The apparatus according to claim 11, wherein the second obtaining module is configured to obtain a compensation factor of the quadrilateral according to a geometric feature of the quadrilateral and a compensation formula;
    所述第二获取模块包括:The second obtaining module includes:
    第一获取单元,用于获取已知宽高比的矩形在N个不同角度下的N个图像,其中,N为不小于2的整数;a first acquiring unit, configured to acquire N images of a rectangle of a known aspect ratio at N different angles, where N is an integer not less than 2;
    第二获取单元,用于获取所述矩形的宽高比以及所述矩形的几何特征,得到N组所述矩形的补偿因子与所述矩形的几何特征的对应数据;a second acquiring unit, configured to acquire an aspect ratio of the rectangle and a geometric feature of the rectangle, to obtain corresponding data of a compensation factor of the N sets of the rectangle and a geometric feature of the rectangle;
    拟合单元,用于根据所述N组对应数据拟合补偿公式。And a fitting unit, configured to fit a compensation formula according to the N sets of corresponding data.
  13. 根据权利要求12所述的设备,其特征在于,所述拟合单元还包括:The apparatus according to claim 12, wherein the fitting unit further comprises:
    分类子模块,用于将所述N组对应数据分为多个类型;a classification sub-module, configured to divide the N sets of corresponding data into multiple types;
    拟合子模块,用于根据所述多个类型中的每一类数据分别拟合补偿公式。A fitting submodule is configured to respectively fit the compensation formula according to each of the plurality of types of data.
  14. 根据权利要求12或13所述的设备,其特征在于,所述补偿公式在校正图像前预先确定。Apparatus according to claim 12 or claim 13 wherein the compensation formula is predetermined prior to correcting the image.
  15. 根据权利要求11-14任一项所述的设备,其特征在于,所述几何特征包括距离特征或角度特征中的至少一种。Apparatus according to any of claims 11-14, wherein the geometric feature comprises at least one of a distance feature or an angular feature.
  16. 根据权利要求15所述的设备,其特征在于,所述角度特征包括:The apparatus of claim 15 wherein said angular features comprise:
    所述四边形的两组对边夹角的差值;a difference between the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的三角函数值;Or a trigonometric function value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值。 Alternatively, the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral.
  17. 根据权利要求11-14任一项所述的设备,其特征在于,所述几何特征包括第一几何特征和第二几何特征;Apparatus according to any of claims 11-14, wherein the geometric features comprise a first geometric feature and a second geometric feature;
    所述第一几何特征包括以下特征中的至少一种:The first geometric feature includes at least one of the following features:
    所述四边形的最长边的长度与所述待校正图像的边长的比值;a ratio of a length of a longest side of the quadrilateral to a side length of the image to be corrected;
    或者,所述四边形的对角线长度与所述待校正图像的对角线长度的比值;Or the ratio of the diagonal length of the quadrilateral to the diagonal length of the image to be corrected;
    或者,所述四边形的两组对边夹角的大小;Or the size of the angle between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值;Or a trigonometric function value of the two sets of opposite sides of the quadrilateral;
    所述第二几何特征包括:The second geometric feature includes:
    所述四边形的两组对边夹角的差值;a difference between the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的三角函数值;Or a trigonometric function value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值;Or the difference between the values of the trigonometric functions of the two sets of opposite sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的绝对值;Or the absolute value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的差值的绝对值的三角函数值;Or a trigonometric function value of the absolute value of the difference between the two sets of sides of the quadrilateral;
    或者,所述四边形的两组对边夹角的三角函数值的差值的绝对值。Alternatively, the absolute value of the difference between the values of the trigonometric functions of the two sets of sides of the quadrilateral.
  18. 根据权利要求11-17任一项所述的设备,其特征在于,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的中位线长度,所述高度估计值是与竖直方向夹角较小的中位线长度。The apparatus according to any one of claims 11-17, wherein the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being clipped with a horizontal direction The length of the median line having a smaller angle, which is the length of the median line that is smaller than the angle in the vertical direction.
  19. 根据权利要求11-17任一项所述的设备,其特征在于,所述四边形或矩形的第一宽高比为宽度估计值和高度估计值的比值,所述宽度估计值是与水平方向夹角较小的一组对边中的长边长度,所述高度估计值是与竖直方向夹角较小的一组对边中的长边长度。The apparatus according to any one of claims 11-17, wherein the first aspect ratio of the quadrilateral or rectangle is a ratio of a width estimate to a height estimate, the width estimate being clipped with a horizontal direction The length of the long side of a pair of opposite sides of a smaller angle, the height estimate being the length of the long side of a set of opposite sides that are smaller than the vertical.
  20. 根据权利要求11-19任一项所述的设备,其特征在于,所述补偿公式的函数形式为一次函数、二次函数或者更高次函数形式。Apparatus according to any one of claims 11-19, characterized in that the functional form of the compensation formula is in the form of a linear function, a quadratic function or a higher order function.
  21. 一种设备,其特征在于,所述设备包括显示器,一个或多个处理器,存储器,以及一个或多个程序,所述一个或多个程序存储在存储器中并被配置为被一个或多个处理器执行,所述一个或多个程序包括用于执行如权利要求1-10任一项所述的方法的指令。An apparatus, comprising: a display, one or more processors, a memory, and one or more programs, the one or more programs being stored in the memory and configured to be configured by one or more The processor executes, the one or more programs comprising instructions for performing the method of any of claims 1-10.
  22. 一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行如权利要求1-10任一项所述的方法。A computer readable storage medium comprising instructions which, when run on a computer, cause the computer to perform the method of any of claims 1-10.
  23. 一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行如权利要求1-10任一项所述的方法。 A computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any of claims 1-10.
PCT/CN2017/074432 2017-02-22 2017-02-22 Image correction method and device WO2018152710A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2017/074432 WO2018152710A1 (en) 2017-02-22 2017-02-22 Image correction method and device
CN201780005563.1A CN108780572B (en) 2017-02-22 2017-02-22 Method and device for image correction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/074432 WO2018152710A1 (en) 2017-02-22 2017-02-22 Image correction method and device

Publications (1)

Publication Number Publication Date
WO2018152710A1 true WO2018152710A1 (en) 2018-08-30

Family

ID=63253488

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/074432 WO2018152710A1 (en) 2017-02-22 2017-02-22 Image correction method and device

Country Status (2)

Country Link
CN (1) CN108780572B (en)
WO (1) WO2018152710A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111652937A (en) * 2019-03-04 2020-09-11 广州汽车集团股份有限公司 Vehicle camera calibration method and device

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110717492B (en) * 2019-10-16 2022-06-21 电子科技大学 A method for correcting the orientation of strings in drawings based on joint features
CN112837394B (en) * 2019-11-25 2024-06-18 珠海金山办公软件有限公司 Polygonal drawing method and device, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5027227A (en) * 1987-07-24 1991-06-25 Sharp Kabushiki Kaisha Image rotating device
EP1071274A2 (en) * 1999-07-21 2001-01-24 Konica Corporation Image reading apparatus and image forming apparatus
CN102254171A (en) * 2011-07-13 2011-11-23 北京大学 Method for correcting Chinese document image distortion based on text boundaries
CN105450900A (en) * 2014-06-24 2016-03-30 佳能株式会社 Distortion correction method and equipment for document image
CN106296745A (en) * 2015-05-26 2017-01-04 富士通株式会社 The method and apparatus that file and picture is corrected

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002101443A2 (en) * 2001-06-12 2002-12-19 Silicon Optix Inc. System and method for correcting keystone distortion
CN1996389A (en) * 2007-01-09 2007-07-11 北京航空航天大学 Method for quickly correcting distortion of camera based on collinear feature point
US20090046182A1 (en) * 2007-08-14 2009-02-19 Adams Jr James E Pixel aspect ratio correction using panchromatic pixels
JP4630936B1 (en) * 2009-10-28 2011-02-09 シャープ株式会社 Image processing apparatus, image processing method, image processing program, and recording medium recording image processing program
CN102903092B (en) * 2012-09-07 2016-05-04 珠海一多监测科技有限公司 A kind of image adaptive bearing calibration based on four point transformation
US9135720B2 (en) * 2013-03-27 2015-09-15 Stmicroelectronics Asia Pacific Pte. Ltd. Content-based aspect ratio detection
JP6128086B2 (en) * 2014-09-12 2017-05-17 カシオ計算機株式会社 Page image correction apparatus, page image correction method, and program
PL3308350T3 (en) * 2015-06-12 2020-05-18 Moleskine S.R.L. Method of correcting a captured image, method of selecting a drawing sketched on a page or on two adjacent pages of a notebook, a relative app for smartphone, a hardback notebook and a hardback agenda

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5027227A (en) * 1987-07-24 1991-06-25 Sharp Kabushiki Kaisha Image rotating device
EP1071274A2 (en) * 1999-07-21 2001-01-24 Konica Corporation Image reading apparatus and image forming apparatus
CN102254171A (en) * 2011-07-13 2011-11-23 北京大学 Method for correcting Chinese document image distortion based on text boundaries
CN105450900A (en) * 2014-06-24 2016-03-30 佳能株式会社 Distortion correction method and equipment for document image
CN106296745A (en) * 2015-05-26 2017-01-04 富士通株式会社 The method and apparatus that file and picture is corrected

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111652937A (en) * 2019-03-04 2020-09-11 广州汽车集团股份有限公司 Vehicle camera calibration method and device
CN111652937B (en) * 2019-03-04 2023-11-03 广州汽车集团股份有限公司 Vehicle-mounted camera calibration method and device

Also Published As

Publication number Publication date
CN108780572B (en) 2021-04-20
CN108780572A (en) 2018-11-09

Similar Documents

Publication Publication Date Title
US10915998B2 (en) Image processing method and device
US9275281B2 (en) Mobile image capture, processing, and electronic form generation
US9807263B2 (en) Mobile document capture assistance using augmented reality
WO2018214365A1 (en) Image correction method, apparatus, device, and system, camera device, and display device
WO2021233266A1 (en) Edge detection method and apparatus, and electronic device and storage medium
US10909719B2 (en) Image processing method and apparatus
CN109120854B (en) Image processing method, image processing device, electronic equipment and storage medium
WO2021147219A1 (en) Image-based text recognition method and apparatus, electronic device, and storage medium
CN113627428A (en) Document image correction method, device, storage medium and intelligent terminal device
CN108965742A (en) Abnormity screen display method, apparatus, electronic equipment and computer readable storage medium
JP2017130929A (en) Correction method and correction device for document image acquired by imaging apparatus
WO2021135683A1 (en) Display terminal adjustment method and display terminal
CN107368829B (en) Method and apparatus for determining a rectangular target area in an input image
CN111325798B (en) Camera model correction method, device, AR implementation equipment and readable storage medium
CN110431563B (en) Method and apparatus for image correction
US20180253852A1 (en) Method and device for locating image edge in natural background
CN108230333A (en) Image processing method, device, computer program, storage medium and electronic equipment
CN108874187A (en) A kind of projector Notes System
CN110119733A (en) Page identification method and device, terminal equipment and computer readable storage medium
US20190355104A1 (en) Image Correction Method and Apparatus
WO2018152710A1 (en) Image correction method and device
US10643095B2 (en) Information processing apparatus, program, and information processing method
US10586099B2 (en) Information processing apparatus for tracking processing
JP2018046337A (en) Information processing device, program and control method
US10999513B2 (en) Information processing apparatus having camera function, display control method thereof, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17897882

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17897882

Country of ref document: EP

Kind code of ref document: A1