WO2022267027A1 - 图像矫正方法、装置、电子设备和存储介质 - Google Patents

图像矫正方法、装置、电子设备和存储介质 Download PDF

Info

Publication number
WO2022267027A1
WO2022267027A1 PCT/CN2021/102453 CN2021102453W WO2022267027A1 WO 2022267027 A1 WO2022267027 A1 WO 2022267027A1 CN 2021102453 W CN2021102453 W CN 2021102453W WO 2022267027 A1 WO2022267027 A1 WO 2022267027A1
Authority
WO
WIPO (PCT)
Prior art keywords
deviation
image
mark
marking
preset
Prior art date
Application number
PCT/CN2021/102453
Other languages
English (en)
French (fr)
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 CN202180001907.8A priority Critical patent/CN113678163A/zh
Priority to PCT/CN2021/102453 priority patent/WO2022267027A1/zh
Publication of WO2022267027A1 publication Critical patent/WO2022267027A1/zh

Links

Images

Classifications

    • G06T5/80
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Definitions

  • Embodiments of the present disclosure relate to an image correction method, device, electronic equipment, and storage medium.
  • Framing is a necessary prerequisite for taking photos and videos, and framing is essentially to determine the relative position of the camera and the target object on the six-axis space, and framing directly affects the quality of photos and videos.
  • an image correction method for solving various embodiments of the present disclosure, an image correction method, device, electronic device, and storage medium are provided.
  • An image correction method comprising:
  • the target image collected by the camera and including four positioning marks, wherein the four positioning marks are located on the marking plane in the object space, and are arranged at equal intervals and around them;
  • Correction is performed on the target image according to the marked position.
  • An image correction device comprising:
  • the image acquisition module is configured to acquire the target image collected by the camera and includes four positioning marks, wherein the four positioning marks are located on the marking plane in the object space, and are arranged at equal intervals and around them;
  • a marker position determination module configured to determine marker positions of the four positioning markers in the target image
  • the image correction module is configured to correct the target image according to the marked position.
  • An electronic device including a memory and one or more processors, the memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, an image correction method provided by any embodiment of the present disclosure is implemented step.
  • One or more non-volatile computer-readable instructions storing computer-readable instructions, on which computer-readable instructions are stored, and when executed by one or more processors, the computer-readable instructions implement any of the embodiments provided by the present disclosure
  • the steps of an image correction method are not limited to:
  • Fig. 1 is a schematic diagram of positioning marks in one or more embodiments
  • Fig. 2 is a schematic diagram of an identification plane in one or more embodiments
  • Fig. 3 is a schematic diagram of an application scenario in one or more embodiments
  • Fig. 4 is a schematic diagram of a deviation image and a standard image in one or more embodiments
  • Fig. 5 is a schematic flowchart of an image correction method in one or more embodiments
  • Fig. 6 is a schematic flowchart of an image correction method in one or more embodiments
  • Fig. 7 is a schematic diagram of a positional relationship between an image plane and an identification plane in one or more embodiments
  • Fig. 8 is a schematic diagram of a projection angle measurement in one or more embodiments.
  • Fig. 9 is a structural block diagram of an image correction device in one or more embodiments.
  • Figure 10 is a diagram of the internal structure of an electronic device in one or more embodiments.
  • the viewfinder mainly relies on the human eye to observe the content of the photo in real time on the viewfinder or the preview display screen to fine-tune the position of the camera.
  • the viewfinder/preview display screen due to the influence of human eye observation or the size of the viewfinder/preview display screen, it will inevitably bring about a large error in the position of the scene in the image; moreover, when precise positioning is required, the operator needs to repeatedly observe and adjust the camera, which is time-consuming and labor-intensive. Low efficiency; in addition, the consistency of multiple viewing results is an important prerequisite to ensure image quality evaluation, but the positioning that relies on human eye observation has the disadvantage of poor repeatability.
  • the embodiment of the present disclosure obtains the target image containing four positioning marks collected by the camera, identifies the position in the target image according to the four positioning marks, and corrects the target image, which can improve the accuracy and efficiency of framing and ensure Consistency of framing results.
  • the positioning mark involved in the embodiment of the present disclosure can be a graphic with high contrast and spatial symmetry, which can have high anti-interference in image recognition.
  • the positioning mark can be a figure as shown in Figure 1, such as the positioning mark 110 , the positioning mark 120, the positioning mark 130 and the positioning mark 140, the specific graphic structure of the positioning mark is not limited.
  • four positioning marks can be placed at fixed spatial positions relative to the shooting target to obtain a marking plane.
  • a schematic diagram of a marking plane shown in FIG. 2 uses the positioning mark 120 in FIG.
  • the four positioning marks 120 are placed in the object space at equal intervals in sequence to obtain a marking plane, and the distance between any two adjacent positioning marks 120 is the same.
  • the graphics of the four positioning marks in the mark plane may be the same or different.
  • the image correction method provided by the embodiments of the present disclosure may be executed by a terminal or a server.
  • the terminal or the server can correct the target image through the positions of the four positioning marks in the target image.
  • the server 32 calculates the deviation of the target image through the positions of the four positioning marks in the target image, and sends the deviation of the target image to the terminal 31, and the terminal 31 according to The received deviation is directly corrected to the target image, wherein the target image may be captured by the terminal 31 and sent to the server 32 .
  • the target image is acquired by the terminal 31 from other devices.
  • the target image is an image obtained after the terminal 31 performs image processing on a preset image, and the preset image may be obtained by shooting by the terminal 31, or the preset image may be obtained by the terminal 31 from other devices.
  • other devices are not specifically limited.
  • the terminal 31 acquires the target image, and sends the target image to the server 32, and the server 32 corrects the target image according to the positions of the four positioning marks in the target image.
  • the terminal 31 obtains the target image by shooting, and further, the terminal 31 corrects the target image by using the positions of the four positioning marks in the target image.
  • the target image collected by the camera deviates from the standard image.
  • the deviation of the target image relative to the standard image may include any one or combination of the following: front and rear deviation (refer to image (a) in FIG. 4 ); horizontal deviation (refer to image (b) in FIG. 4 ) ; vertical deviation (refer to image (c) in Fig. 4); rotation deviation (refer to image (d) in Fig. 4); Image (f) in 4).
  • the image (o) in FIG. 4 is a standard image.
  • the image plane of the camera when at least one of the front-to-back deviation, horizontal deviation, vertical deviation and rotation deviation occurs in the target image captured by the camera, the image plane of the camera is still parallel to the logo plane, and when the target image captured by the camera appears When there are flip deviations such as left-right flip deviation or up-down flip deviation, the image plane of the camera intersects the logo plane.
  • the technical solution of the present disclosure can calculate any of the above-mentioned deviations or combined deviations, so as to correct the target image and obtain a standard image.
  • an image correction method is provided, which is suitable for the precise positioning of the relative position between the camera and the target object, and can be applied to automatic optical inspection and machine vision shooting Scenes.
  • the method is applied to a terminal for illustration.
  • the terminal may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
  • the image correction method comprises the following steps as shown in Figure 5:
  • the four positioning marks are located on the mark plane in the object space, and are equally spaced and arranged in a circle.
  • the camera collects information including four positioning marks and the shooting target to generate a target image.
  • the embodiments of the present disclosure are not limited to acquiring the target image by taking photos, and may also acquire the target image by previewing screenshots, video recording, and the like.
  • S520 Determine the marker positions of the four positioning markers in the target image.
  • the image processing algorithm can be used to calculate the identification positions of the four positioning markers in the target image, wherein the marker positions include specific position information of the four positioning markers in the target image, such as four The coordinates of a positioning mark in the Cartesian coordinate system of the target image.
  • the four positioning marks are used to locate the relative position between the camera and the target object photographed, so that the relative position between the camera and the target object can be determined according to the marked positions of the four positioning marks, and then by correcting the marked positions, that is The relative position between the camera and the target object can be corrected, and the target image can be corrected to obtain the standard image corresponding to the target image.
  • the target image containing four positioning marks collected by the camera is obtained, wherein the four positioning marks are located on the marking plane in the object space, and are arranged at equal intervals and around them;
  • the marked position in ; according to the marked position, the target image is corrected.
  • the technical solution of the present disclosure pre-sets four positioning marks on the target object, uses a camera to obtain the target image corresponding to the target object containing the above four positioning marks, and can determine the shooting position according to the identification positions of the four positioning marks in the target image.
  • the deviation of the target object so as to quickly correct the target image according to the marked position, improve the accuracy and efficiency of framing, and ensure the consistency of framing results.
  • a kind of image correction method is provided, and in this embodiment, according to mark position, correct target image, comprises the following steps as shown in Figure 6:
  • S610 Determine the marking deviation according to the marking position.
  • the identification deviation is used to characterize the deviation between the target image and the standard image
  • the standard image is a pre-shot image that satisfies the framing requirements and serves as a reference image for correcting the target image.
  • the identification deviation includes at least one of front and rear deviation, vertical deviation, horizontal deviation, rotation deviation and flip deviation, that is, the identification deviation can be front and rear deviation, vertical deviation, horizontal deviation, rotation deviation or flip deviation, or Combination of two or more of front and back deviation, vertical deviation, horizontal deviation, rotation deviation and rollover deviation.
  • front-to-back deviation means that the target image is enlarged or reduced relative to the standard image, but the imaging surface is parallel to the logo plane.
  • the vertical deviation means that the target image deviates up and down relative to the standard image, but the imaging surface is parallel to the logo plane, which is reflected in the actual shooting
  • the horizontal deviation means that the target image deviates left and right relative to the standard image, but the imaging surface and
  • the logo plane is parallel, which is reflected in the actual shooting when the main optical axis of the camera is perpendicular to the logo plane, the camera is not facing the target object, and is translated left or right relative to the target object
  • the image rotates counterclockwise or clockwise, but the imaging surface is parallel to the logo plane.
  • determine the mark deviation according to the mark position including S611 and S612:
  • S611 Determine the positional relationship between the image plane of the camera and the marker plane according to the marker position.
  • the positional relationship includes that the image plane is parallel to or intersects with the identification plane.
  • the image plane refers to the plane where the target image collected by the camera is located. Understandably, the positional relationship is the positional relationship between the image plane and the identification plane when the camera captures the target image.
  • the image plane is parallel to the marking plane; when determined by the marking positions When any of the lengths of the first set of opposite sides and the second set of lengths of opposite sides of , are not equal, the image plane intersects the logo plane.
  • the four positioning marks sequentially include a first positioning mark, a second positioning mark, a third positioning mark and a fourth positioning mark in the arrangement direction.
  • the first imaging distance between the first positioning mark and the second positioning mark, the second imaging distance between the second positioning mark and the third positioning mark, and the third positioning mark can be determined by using the distance algorithm between two points.
  • the sides corresponding to the first imaging distance and the third imaging distance are the first group of opposite sides
  • the sides corresponding to the second imaging distance and the fourth imaging distance are the second group of opposite sides.
  • the image plane is parallel to the logo plane; when the first imaging distance is not equal to the third imaging distance, or When the second imaging distance is not equal to the fourth imaging distance, the image plane intersects the logo plane.
  • 710 indicates that the image plane 712 is parallel to the logo plane 711, that is, the camera 713 is placed directly in front of the logo plane 711, and the camera 713 is positioned on the logo plane 711. Directly in front of the intersection point, that is, the dotted line in the figure is perpendicular to the marking plane 711, and the camera 713 generates the target image on the image plane 712, which includes the target image. At this time, the imaging distances determined between the four positioning marks are equal, and can be The generated target image is regarded as a reduced image of the logo plane.
  • the lens of the camera 713 has an oblique angle to the logo plane 711, that is, the main optical axis of the camera 713 is not perpendicular to the logo plane 711, and four of the image planes 721 corresponding to the camera 713
  • the positions of the positioning marks are also inclined relative to the marking plane 711 , and at this time, the positions of the four positioning marks in the target image are inclined compared with the positions of the four positioning marks in the marking plane.
  • the four positioning marks in the target image in FIG. 7 are respectively the first positioning mark P 1 ′, the second positioning mark P 2 ′, the third positioning mark P 3 ′, and the fourth positioning mark P 4 ′.
  • the first imaging distance can be calculated according to the positions of P 1 ' and P 2 '
  • the second imaging distance can be calculated according to the positions of P 2 ' and P 3 '
  • the position of P 3 ' and P 4 ' can be
  • the third imaging distance is calculated
  • the fourth imaging distance can be calculated according to the positions of P 4 ′ and P 1 ′.
  • S612 Determine the marking deviation according to the positional relationship and the marking position.
  • the positional relationship is first determined according to the position of the marking, and then the marking deviation is determined according to the marking position when the positional relationship is determined, which can improve the efficiency and accuracy of determining the marking deviation.
  • the marking deviation may be front-to-back deviation or flipping deviation, and further determination of the marking deviation is required.
  • the positional relationship is determined, for example, the positional relationship is that the image plane is parallel to the logo plane, then the logo deviation in the above situation can only be the front and back deviation, and the position relationship is that the image plane and the logo plane intersect, so the logo deviation in the above situation can only be is the flipping bias.
  • a Cartesian coordinate system is established with the target image point in the image plane as the origin, the x-axis of the Cartesian coordinate system is parallel to the first side determined by the preset standard position, and the y-axis of the Cartesian coordinate system is determined parallel to the preset standard position
  • the preset standard position is the position of the four positioning marks in the standard image; in the Cartesian coordinate system, determine the mark coordinates of the four positioning marks in the target image and the standard coordinates in the standard image.
  • the target image point can be located in the lower left corner of the image plane of the camera, so that all other image points are located in the first quadrant of the Cartesian coordinate system, that is, both the abscissa and the ordinate are positive values, which is convenient for calculation.
  • the four positioning marks P 1 ′′, P 2 ′′, P 3 ′′ and P 4 ′′ in the standard image (o), and the edge P 1 ′′P 2 ′′ formed by the connection of P 1 ′′ and P 2 ′′ is the preset
  • the identification deviation is determined according to the positional relationship and the identification position, including at least one of the following:
  • the marking deviation is the front and rear deviation
  • the mark deviation is determined to be a vertical deviation
  • the mark deviation is determined to be a horizontal deviation
  • the marked deviation is determined to be a flipping deviation.
  • the distance P 1 'P 2 ' between P 1 ' and P 2 ' is determined by the coordinates of P 1 ' and P 2 '
  • the distance P 1 ”P 2 ” between P 1 ” and P 2 ” is determined by the corresponding coordinates of P 1 ” and P 2 ”, when P 1 'P 2 'is not equal to P 1 ”P 2 ”, determine Identify the bias as the front-back bias.
  • the forward and backward deviation may include forward translation deviation or backward translation deviation.
  • the average value of the ordinate determined by the coordinates of P 1 ', P 2 ', P 3 ' and P 4 ' in the target image (c) is not equal to the value of P 1 ", P 2 in the standard image (o) ”, P 3 ” and P 4 ” coordinates to determine the average value of the ordinate, determine the logo deviation as the vertical deviation.
  • the vertical deviation includes upward translation deviation or downward translation deviation.
  • the average value of the abscissa determined by the coordinates of P 1 ', P 2 ', P 3 ' and P 4 ' in the target image (b) is not equal to the value of P 1 ", P 2 in the standard image (o) ”, P 3 ” and P 4 ” coordinates determined by the average value of the abscissa, determine the logo deviation as a horizontal deviation.
  • the horizontal deviation includes a leftward translation deviation or a rightward translation deviation.
  • the side P 1 'P 2 ' determined by the coordinates of P 1 ' and P 2 ' and the side P 3 'P 4 determined by the coordinates of P 3 ' and P 4 '' is the first pair of sides
  • the side P 2 'P 3 ' determined by the coordinates of P 2 ' and P 3 ' and the side P 4 'P 1 ' determined by the coordinates of P 4 ' and P 1 ' are the second
  • the straight line passing through the midpoint of P 1 'P 2 ' and the midpoint of P 3 'P 4 ' is the straight line passing through the midpoint of the first set of opposite sides, passing through the midpoint of P 2 'P 3 ' and
  • the straight line of the midpoint of P 4 'P 1 ' is the straight line passing through the midpoint of the second set of opposite sides; when the straight line passing through the midpoint of the first set of opposite sides intersects the y-axis, or passes When the straight line of the point intersects the
  • the rotation deviation includes counterclockwise rotation deviation or clockwise rotation deviation.
  • the intersection of a straight line passing through the midpoints of the first group of opposite sides and the y-axis is taken as an example for illustration.
  • the counterclockwise direction is the positive direction
  • the angle between the straight line at the midpoint of the opposite side and the y-axis is less than 0, it is a clockwise rotation deviation, that is, the camera rotates counterclockwise relative to the target object.
  • the flip deviation includes left-right flip bias and/or up-down flip bias.
  • the side P 2 'P 3 ' determined by the coordinates of P 2 ' and P 3 ' and the side P 4 'P 1 determined by the coordinates of P 4 ' and P 1 '' is the second group of opposite sides, when P 2 'P 3 ' and P 4 'P 1 ' are not equal, it is the left-right flip deviation.
  • the left-right flip bias includes a left flip bias or a right flip bias.
  • the up and down flip bias includes up flip bias or down flip bias.
  • P 1 'P 2 ' is greater than P 3 'P 4 ', it is down flip bias, that is, the camera flips down relative to the target object;
  • the correction of the target image is realized by adjusting the pose of the camera and/or the pose of the target object. That is, according to the logo deviation, adjust the pose of the camera and/or the pose of the target object until the logo deviation satisfies the preset deviation condition, wherein the four marks are located on the target object, so that the target image can be corrected according to the logo deviation.
  • the preset deviation condition is that the logo deviation meets the framing requirements, and the preset deviation condition can be adapted to the setting according to different application scenarios.
  • the preset deviation condition is that the identification deviation does not exist.
  • the target image can be corrected step by step, and the target image can also be corrected at one time by calculating a specific deviation amount.
  • the pose of the camera and/or the target object is adjusted until the identification deviation meets the preset deviation condition, including S621 and S622:
  • S621 Determine a first compensation parameter of the camera and/or the target object according to the identification deviation.
  • the first compensation parameter includes a first compensation type and a first compensation direction
  • the first compensation type includes an angle and/or a length.
  • the pose of the camera or the target object can be adjusted independently to correct the target image, or the pose of the camera and the target object can be adjusted simultaneously to correct the target image. Since the camera and the target image are arranged relatively, the first compensation directions of the camera and the target object are opposite.
  • both the first compensation type and the first compensation direction can be determined according to the identification deviation. For example, take adjusting the pose of the camera as an example for illustration.
  • the first compensation type When the logo deviation is forward translation deviation, the first compensation type is length, and the first compensation direction is backward translation; when the logo deviation is left translation deviation, the first compensation type is length, and the first compensation direction is left Translation; when the logo deviation is counterclockwise rotation deviation, the first compensation type is angle, and the first compensation direction is counterclockwise rotation; when the logo deviation is upward flip deviation, the first compensation type is angle, and the first compensation direction is direction Flip down.
  • S622 According to the first compensation parameter, stepwise adjust the pose of the camera and/or the pose of the target object until the marked deviation satisfies a preset deviation condition.
  • the adjustment of the pose of the camera is taken as an example for description.
  • stepping motors can be used to realize the step adjustment of the camera pose.
  • the preset compensation amount is the amount of one step preset by the stepping motor, which can be determined as the step length or step according to the first compensation type. angle.
  • the stepper motor controls the camera to translate the first preset length L1 backward; when the logo deviation is a leftward translation deviation, the stepper motor controls the camera to shift the second preset length to the left L2; when the logo deviation is a counterclockwise rotation deviation, the stepping motor controls the camera to rotate the first preset angle A1 counterclockwise; when the logo deviation is an upward flipping deviation, the stepping motor controls the camera to flip down the second preset angle A2 .
  • S6222 Collect the current image including the four positioning marks through the camera, and use the current image as the target image.
  • S6223 Determine the marker positions of the four positioning markers in the target image.
  • S6225 Determine the first compensation parameter of the camera and/or the target object according to the identification deviation.
  • S6226 Go back to the first compensation direction, and adjust the camera and/or the target object again according to the preset compensation amount corresponding to the first compensation type until the deviation of the identification meets the preset deviation condition.
  • the marking deviation since there is no need to determine the precise deviation amount, it may be determined whether the marking deviation satisfies the preset deviation condition during the process of determining the marking deviation.
  • the identification deviation is a forward translation deviation
  • the target image may be corrected at one time by calculating a specific deviation amount.
  • the above method further includes: determining the deviation amount corresponding to the marking deviation according to the marking position.
  • the identification deviation adjust the pose of the camera and/or the pose of the target object until the identification deviation meets the preset deviation condition, including S623 and S624:
  • S623 Determine a second compensation parameter of the camera and/or the target object according to the identification deviation.
  • the second compensation parameter includes a second compensation type and a second compensation direction, and the second compensation type includes angle and/or length.
  • the second compensation parameter is similar to the above-mentioned first compensation parameter, and will not be repeated here.
  • S624 Adjust the pose of the camera and/or the pose of the target object according to the second compensation parameter and the deviation amount corresponding to the identification deviation.
  • the camera and/or the target object are adjusted according to the deviation amount corresponding to the second compensation type.
  • the camera and/or the target object can be adjusted to a standard pose at one time, and the target image can be corrected through one compensation, which further improves the efficiency of framing.
  • the deviation amount corresponding to the mark deviation is determined, including at least one of the following:
  • the marking deviation is a flipping deviation
  • determine the first projection angle and the second projection angle and use the first projection angle and the second projection angle as the deviation amount corresponding to the marking deviation
  • the marking plane rotates around the first predetermined Set the straight line to rotate the second projection angle
  • the first preset straight line passes through the first diagonal of the four positioning marks in the object space
  • the second preset The straight line passes through the second diagonal of the four positioning marks in the object space
  • the current object distance is determined according to the marking position, and the difference between the current object distance and the preset standard object distance is used as the deviation amount corresponding to the marking deviation;
  • the logo deviation is a vertical deviation
  • the preset point is the intersection point of the main optical axis of the lens of the camera and the logo plane
  • the preset angle is the angle between the straight line passing through the center of the four positioning marks in the object space and the preset point and the horizontal line
  • the logo deviation is a horizontal deviation
  • the marking deviation is a rotation deviation
  • the rotation angle of the target image around the main optical axis of the lens of the camera is determined, and the rotation angle is used as a deviation amount corresponding to the marking deviation.
  • the first projection angle and the second projection angle are determined according to the location of the logo, including:
  • represents the first projection angle
  • represents the second projection angle
  • A'1 represents the distance from the first positioning mark to the mark imaging center in the target image
  • A'2 represents the distance from the second position mark to the mark imaging in the target image
  • the distance from the center A'3 represents the distance from the third positioning mark to the mark imaging center in the target image
  • A'4 represents the distance from the fourth position mark to the mark imaging center in the target image
  • f represents the focal length of the camera
  • mark imaging The center is the intersection point of the diagonal lines connecting the four positioning marks in the target image.
  • the first projection angle and the second projection angle are calculated by the following formulas (1)-(12), and are described with symbols marked in FIG. 8 .
  • Formula (1) and formula (2) can be obtained by combining Fig. 8 and the imaging formula.
  • point O is the intersection of the straight line LP 2 connecting the camera L with the second positioning mark P 2 and the straight line passing through the midline point C and perpendicular to the straight line CL
  • P is the extension of the straight line connecting the camera and the fourth positioning mark P 4
  • D is the distance between the center point C and the camera center L
  • C' is the connection line between P 1 ' and P 3 ' in the target image and P 2 '
  • the intersection point of the line connecting P 4 ', A' 2 is the distance between C' and P2'
  • f is the focal length of the camera.
  • A' 4 is the distance between C' and P 4 '.
  • A is the distance between the second positioning mark P2 and the center point C in the mark plane.
  • the distance from any positioning mark to the center point C in the mark plane is equal to A.
  • P 2 M is perpendicular to MC, and the included angle between P 2 M and P 2 C is the first projection angle ⁇ .
  • P 4 N is perpendicular to CL, and the included angle between P 4 N and P 4 C is the first projection angle ⁇ .
  • the first projection angle ⁇ can be obtained.
  • the calculation method of the second projection angle ⁇ is the same as the principle of the first projection angle ⁇ , and will not be repeated here.
  • determine the current object distance including:
  • determine the rotation angle of the target image around the main optical axis of the lens of the camera according to the position of the logo including:
  • the coordinates of P 1 ' are (x 1 ', y 1 '), the coordinates of P 2 ' are (x 2 ', y 2 '), and the coordinates of P 3 ' are (x 3 ', y 3 '), The coordinates of P 3 ' are (x 3 ', y 3 ').
  • an image correction device 900 is provided, and the image correction device 900 includes an image acquisition module 910, a marker position determination module 920, and an image correction module 930; wherein, the image acquisition module 910, It is configured to acquire the target image collected by the camera and includes four positioning marks, wherein the four positioning marks are located on the marking plane in the object space, and are arranged at equal intervals and around them; the marking position determining module 920 is configured to determine the four positioning marks The marked position in the target image; the image correction module 930 configured to correct the target image according to the marked position.
  • Each module in the above-mentioned image correction device may be fully or partially realized by software, hardware or a combination thereof.
  • the above-mentioned modules can be embedded in hardware or independent of one or more processors in the electronic device, and can also be stored in the memory of the electronic device in the form of software, so that one or more processors can call and execute the above The operation corresponding to the module.
  • the image correction module 930 includes: a deviation determination unit configured to determine the mark deviation according to the mark position; an image correction unit configured to correct the target image according to the mark deviation.
  • the deviation determination unit includes: a positional relationship determination subunit configured to determine the positional relationship between the image plane of the camera and the identification plane according to the position of the identification, wherein the positional relationship includes that the image plane and the identification plane are parallel or intersecting; the deviation determination subunit A unit configured to determine a marker deviation based on the positional relationship and the marker position.
  • the image plane is parallel to the marked plane; when the first group of pairs determined by the marked position When the side lengths are not equal to the lengths of any pair of opposite sides in the second group of opposite side lengths, the image plane intersects the identification plane.
  • the identification deviation includes at least one of front-back deviation, vertical deviation, horizontal deviation, rotation deviation and flip deviation.
  • the image correction device further includes: a coordinate system establishment module configured to establish a rectangular coordinate system with the target image point in the image plane as the origin, the x-axis of the rectangular coordinate system is parallel to the first side determined by the preset standard position , the y-axis of the Cartesian coordinate system is parallel to the second side determined by the preset standard position, and the preset standard position is the position of the four positioning marks in the standard image; the logo coordinate determination module is configured to determine the four positioning marks in the Cartesian coordinate system The identification coordinates of a positioning marker in the target image and the standard coordinates in the standard image.
  • a coordinate system establishment module configured to establish a rectangular coordinate system with the target image point in the image plane as the origin, the x-axis of the rectangular coordinate system is parallel to the first side determined by the preset standard position , the y-axis of the Cartesian coordinate system is parallel to the second side determined by the preset standard position, and the preset standard position is the position of the four positioning marks in the standard image
  • the logo deviation is the front-to-back deviation
  • the average value of the ordinate determined by the marked coordinates is not equal to the average value of the ordinate determined by the standard coordinates
  • the marked deviation is a vertical deviation
  • the average value of the coordinates is not equal to the average value of the abscissa determined by the standard coordinates
  • the logo deviation is a horizontal deviation
  • the image plane is parallel to the logo plane and passes through the straight line of the midpoint of the first group of opposite sides determined by the logo coordinates, Intersect with the y-axis, or pass through the midpoint of the second group of opposite sides determined by the logo coordinates.
  • the logo deviation is a rotation deviation; when the image plane intersects the logo plane and is determined by the logo coordinates.
  • the marking deviation is determined to be a flipping deviation.
  • the front and rear deviations include forward translation deviations or backward translation deviations
  • the vertical deviations include upward translation deviations or downward translation deviations
  • the horizontal deviations include leftward translation deviations or rightward translation deviations
  • the rotation deviations include counterclockwise rotation deviations or The clockwise rotation bias
  • the flip bias includes one or both of an up flip bias, a down flip bias, a left flip bias and a right flip bias.
  • the image correction unit includes: a pose adjustment subunit, configured to adjust the pose of the camera and/or the pose of the target object according to the mark deviation until the mark deviation satisfies the preset deviation condition, and the four marks are located on the target object superior.
  • a pose adjustment subunit configured to adjust the pose of the camera and/or the pose of the target object according to the mark deviation until the mark deviation satisfies the preset deviation condition, and the four marks are located on the target object superior.
  • the pose adjustment subunit is specifically configured to determine a first compensation parameter of the camera and/or the target object according to the identification deviation, the first compensation parameter includes a first compensation type and a first compensation direction, and the first compensation type includes an angle and/or the length; according to the first compensation parameter, the pose of the camera and/or the pose of the target object is adjusted step by step until the identified deviation satisfies a preset deviation condition.
  • the pose adjustment subunit is specifically configured to stepwise adjust the pose of the camera and/or the pose of the target object according to the first compensation parameter until the marked deviation satisfies the preset deviation condition: along the first Compensation direction, adjust the camera and/or the target object once according to the preset compensation amount corresponding to the first compensation type; collect the current image containing four positioning marks through the camera, and use the current image as the target image; determine the four positioning marks in the target The mark position in the image; according to the mark position, determine the mark deviation; according to the mark deviation, determine the first compensation parameter of the camera and/or the target object; return to along the first compensation direction, according to the preset compensation amount corresponding to the first compensation type Adjust the camera and/or the target object again until the mark deviation meets the preset deviation condition.
  • the image correction device further includes: a deviation determination module configured to determine a deviation corresponding to the marking deviation according to the position of the marking.
  • the pose adjustment subunit is specifically configured to determine the second compensation parameters of the camera and/or the target object according to the identification deviation, the second compensation parameters include a second compensation type and a second compensation direction, and the second compensation type includes angle and/or length ; Adjust the pose of the camera and/or the pose of the target object according to the second compensation parameter and the deviation amount corresponding to the identification deviation.
  • the deviation determination module is specifically configured to: when the marking deviation is a flipping deviation, determine the first projection angle and the second projection angle according to the position of the marking, and use the first projection angle and the second projection angle as the corresponding marking deviation The amount of deviation, wherein, the logo plane is rotated around the first preset straight line by the second projection angle, and after being rotated around the second preset straight line by the first projection angle, it is parallel to the image plane, and the first preset straight line passes through four The first diagonal of the positioning mark, the second preset straight line passes through the second diagonal of the four positioning marks in the object space; when the mark deviation is the front and rear deviation, the current object distance is determined according to the mark position, and the current object distance and the preset Set the difference of the standard object distance as the deviation corresponding to the marking deviation; when the marking deviation is a vertical deviation, according to the position of the marking, determine the preset distance from the center of the four positioning marks in the object space to the preset point, and set the preset distance The product of the sine value of the
  • the deviation determination module determines the first projection angle and the second projection angle according to the position of the mark, it is specifically configured as:
  • represents the first projection angle
  • represents the second projection angle
  • A'1 represents the distance from the first positioning mark to the mark imaging center in the target image
  • A'2 represents the distance from the second position mark to the mark imaging in the target image
  • the distance from the center A'3 represents the distance from the third positioning mark to the mark imaging center in the target image
  • A'4 represents the distance from the fourth position mark to the mark imaging center in the target image
  • f represents the focal length of the camera
  • mark imaging The center is the intersection point of the diagonal lines connecting the four positioning marks in the target image.
  • the deviation determination module determines the current object distance according to the position of the mark, it is specifically configured to: determine the imaging distance between any two positioning marks in the target image according to the position of the mark; according to the imaging distance and combined with the imaging principle, Determine the current object distance.
  • an electronic device is provided.
  • the electronic device may be a terminal, and its internal structure may be as shown in FIG. 10 .
  • the electronic device includes one or more processors, memory, communication interface, display screen, and input device connected by a system bus.
  • one or more processors of the electronic device are configured to provide computing and control capabilities.
  • the memory of the electronic device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system and computer readable instructions.
  • the internal memory provides an environment for the execution of the operating system and computer readable instructions in the non-volatile storage medium.
  • the communication interface of the electronic device is configured to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, an operator network, near field communication (NFC) or other technologies.
  • the computer readable instructions when executed by one or more processors, implement a method.
  • the display screen of the electronic device may be a liquid crystal display screen or an electronic ink display screen
  • the input device of the electronic device may be a touch layer covered on the display screen, or a button, a trackball or a touch pad provided on the housing of the electronic device , and can also be an external keyboard, touchpad, or mouse.
  • FIG. 10 is only a block diagram of a partial structure related to the disclosed solution, and does not constitute a limitation on the electronic device to which the disclosed solution is applied.
  • the specific electronic device can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
  • the image correction device provided by the present disclosure can be implemented in the form of a computer readable instruction, and the computer readable instruction can be run on the electronic device as shown in FIG. 10 .
  • Various program modules constituting the image correction device can be stored in the memory of the electronic device, for example, the image acquisition module 910 , the marker position determination module 920 and the image correction module 930 shown in FIG. 9 .
  • Computer-readable instructions constituted by various program modules enable one or more processors to execute the steps in the image correction method of various embodiments described in this specification.
  • the electronic device shown in FIG. 10 may execute step S510 through the image acquisition module 910 in the device shown in FIG. 9 .
  • the electronic device may execute step S520 by identifying the position determining module 920 .
  • the electronic device may execute step S530 through the image correction module 930 .
  • an electronic device which includes a memory and one or more processors, the memory stores computer-readable instructions, and the one or more processors execute the computer-readable instructions to implement any of the above-mentioned embodiments.
  • the steps of the image rectification method are provided.
  • Non-volatile memory may include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory or optical memory, etc.
  • Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory.
  • RAM Random Access Memory
  • SRAM Static Random Access Memory
  • DRAM Dynamic Random Access Memory
  • the image correction method provided by the present disclosure makes it possible to determine the photographed object according to the identification positions of the four positioning marks in the target image by acquiring the target image corresponding to the target object with four positioning marks preset when taking pictures for framing.
  • the deviation of the target object so as to quickly correct the target image according to the marked position, improve the accuracy and efficiency of framing, ensure the consistency of framing results, and have strong industrial applicability.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)

Abstract

涉及图像处理技术领域,具体涉及一种图像矫正方法、装置、电子设备和存储介质。其中方法包括:获取摄像头采集的包含四个定位标识的目标图像(S510),其中,所述四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;确定所述四个定位标识在所述目标图像中的标识位置(S520);根据所述标识位置,对所述目标图像进行矫正(S530)。方法根据目标图像中的四个定位标识,对目标图像进行自动矫正,提高了取景的精度和效率,保证了取景结果的一致性。

Description

图像矫正方法、装置、电子设备和存储介质 技术领域
本公开实施例涉及一种图像矫正方法、装置、电子设备和存储介质。
背景技术
取景是拍摄照片和录像的必要前提动作,而取景本质上是在空间六轴上确定摄像头和目标物体的相对位置,取景直接影响照片和视频质量。
现有的取景主要依靠人眼在取景器或者预览显示屏上实时地去观察照片的内容来微调摄像头的位置,有时依靠激光测距等设备简单判断目标物体的距离。但是,现有的取景存在误差大、效率低和重复性差等问题。
发明内容
(一)要解决的技术问题
在现有技术中,拍照取景时存在误差大、效率低和重复性差等问题。
(二)技术方案
根据本公开公开的各种实施例,提供了一种图像矫正方法、装置、电子设备和存储介质。
一种图像矫正方法,所述方法包括:
获取摄像头采集的包含四个定位标识的目标图像,其中,所述四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;
确定所述四个定位标识在所述目标图像中的标识位置;
根据所述标识位置,对所述目标图像进行矫正。
一种图像矫正装置,包括:
图像获取模块,配置成获取摄像头采集的包含四个定位标识的目标图像,其中,所述四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;
标识位置确定模块,配置成确定所述四个定位标识在所述目标图像中的标识位置;
图像矫正模块,配置成根据所述标识位置,对所述目标图像进行矫正。
一种电子设备,包括存储器和一个或多个处理器,存储器存储有计算机可读指令,一个或多个处理器执行计算机可读指令时实现本公开任意实施例所提供的一种图像矫正方法的步骤。
一个或多个存储有计算机可读指令的非易失性计算机可读指令,其上存储有计算机可读指令,计算机可读指令被一个或多个处理器执行时实现本公开任意实施例所提供的一种图像矫正方法的步骤。
本公开的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见。本公开的目的和其他优点在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。为使本公开的上述目的、特征和优点能更明显易懂,下文特举可选实施例,并配合所附附图,作详细说明如下。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用来解释本公开的原理。
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为一个或多个实施例中定位标识的示意图;
图2为一个或多个实施例中一种标识平面的示意图;
图3为一个或多个实施例中一种应用场景的示意图;
图4为一个或多个实施例中偏差图像与标准图像的示意图;
图5为一个或多个实施例中一种图像矫正方法的流程示意图;
图6为一个或多个实施例中一种图像矫正方法的流程示意图;
图7为一个或多个实施例中一种像平面与标识平面位置关系的示意图;
图8为一个或多个实施例中一种投影角度测量的示意图;
图9为一个或多个实施例中一种图像矫正装置的结构框图;
图10为一个或多个实施例中电子设备的内部结构图。
具体实施方式
为了使本公开的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本公开进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本公开,并不构成对本公开的限定。
目前,取景主要依靠人眼在取景器或者预览显示屏上实时地去观察照片的内容来微调摄像头的位置。然而,由于人眼观察或者取景器/预览显示屏尺寸的影响,必然带来图像中景物位置的较大误差;而且,需要精确定位时,操作人员需要反复观察调整摄像头,耗时耗力,取景效率低;另外,多次取景结果的一致性是保证图像质量评测的重要前提,但是依靠人眼观察的定位存在着重复性差的缺点。
针对上述技术问题,本公开实施例通过获取摄像头采集的包含四个定位标识的目标图像,根据四个定位标识在目标图像中标识位置, 对目标图像进行矫正,可提高取景的精度和效率,保证取景结果的一致性。
本公开实施例涉及的定位标识可以是具有较高对比度以及空间对称性的图形,能够在图像识别中具有较高的抗干扰性,定位标识可以是如图1所示的图形,如定位标识110、定位标识120、定位标识130和定位标识140,对于定位标识的具体图形结构不作限定。
本公开实施例中,可以在相对于拍摄目标,在固定空间位置上放置四个定位标识得到标识平面,例如,图2所示的一种标识平面的示意图,采用图1中定位标识120,将四个定位标识120依次等间距环绕放置在物空间中得到标识平面,任意相邻两个定位标识120之间的距离相同。另外,标识平面内的四个定位标识的图形可以相同,也可以不同。
本公开实施例提供的图像矫正方法可以由终端或服务器来执行。终端或服务器可以通过目标图像中的四个定位标识的位置,对目标图像进行矫正。
例如,在一种应用场景中,如图3所示,服务器32通过目标图像中的四个定位标识的位置,计算目标图像的偏差情况,将目标图像的偏差情况发送至终端31,终端31根据接收到的偏差情况直接对目标图像进行矫正,其中,该目标图像可以是终端31拍摄获得的并发送至服务器32。或者,该目标图像是终端31从其他设备中获取的。再或者,该目标图像是终端31对预设图像进行图像处理后得到的图像,该预设图像可以是终端31拍摄获得的,或者该预设图像可以是终端31从其他设备中获取的。此处,并不对其他设备做具体限定。
在另一种应用场景中,终端31获取目标图像,将目标图像发送至服务器32,服务器32根据目标图像中的四个定位标识的位置,对目标图像进行矫正。
在又一种应用场景中,终端31拍摄获得目标图像,进一步,终端31通过目标图像中的四个定位标识的位置,对目标图像进行矫正。
在实际取景过程中,由于摄像头与目标物体的相对位置出现偏差,造成摄像头采集的目标图像相对于标准图像出现偏差。本公开实施例中,目标图像相对于标准图像的偏差可包括以下任一种或组合:前后偏差(参考图4中的图像(a));水平偏差(参考图4中的图像(b));垂直偏差(参考图4中的图像(c));旋转偏差(参考图4中的图像(d));左右翻转偏差(参考图4中的图像(e));上下翻转偏差(参考图4中的图像(f))。另外,图4中的图像(o)为标准图像。本公开实施例中,当摄像头采集的目标图像出现前后偏差、水平偏差、垂直偏差和旋转偏差中的至少一种偏差时,摄像头的像平面仍与标识平面平行,而当摄像头采集的目标图像出现左右翻转偏差或上下翻转 偏差等翻转偏差时,摄像头的像平面与标识平面相交。本公开技术方案可针对上述任一偏差或组合偏差进行计算,从而对目标图像进行矫正,得到标准图像。
在一个实施例中,如图5所示,提供了一种图像矫正方法,该图像矫正方法适用于摄像头与目标物体的相对位置的精确定位的情况,可应用于自动光学检测和机器视觉等拍摄场景。本实施例以该方法应用于终端进行举例说明,该终端可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。图像矫正方法包括如图5所示的以下步骤:
S510:获取摄像头采集的包含四个定位标识的目标图像。
可选的,四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列。
可理解的,相对于拍摄目标(目标物体),在物空间(实际空间)中的固定空间位置上放置四个定位标识,参考图2所示的标识平面中四个定位标识的位置,在摄像头与拍摄目标存在一定距离(物距)的情况下,通过摄像头采集包括四个定位标识以及拍摄目标的信息生成目标图像。本公开实施例不限于通过拍摄照片获取目标图像,也可以通过预览截屏和录像等方式获取目标图像。
S520:确定四个定位标识在目标图像中的标识位置。
可理解的,在上述S510的基础上,可以利用图像处理算法计算出四个定位标识在目标图像中的标识位置,其中,标识位置包括四个定位标识在目标图像中的具体位置信息,如四个定位标识在目标图像的直角坐标系下的坐标。
S530:根据标识位置,对目标图像进行矫正。
本公开实施例中,四个定位标识用于定位摄像头与其所拍摄的目标物体的相对位置,从而根据四个定位标识的标识位置即可确定摄像头与目标物体的相对位置,进而通过矫正标识位置即可矫正摄像头与目标物体的相对位置,实现对目标图像的矫正,以得到目标图像对应的标准图像。
在上述实施例中,通过获取摄像头采集的包含四个定位标识的目标图像,其中,四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;确定四个定位标识在目标图像中的标识位置;根据标识位置,对目标图像进行矫正。本公开技术方案通过在目标物体上预先设置四个定位标识,采用摄像头获取包含上述四个定位标识的目标物体对应的目标图像,根据四个定位标识在目标图像中的标识位置即可确定拍摄的目标物体的偏差情况,从而根据标识位置对目标图像进行快速矫正,提高了取景的精度和效率,保证了取景结果的一致性。
在一个实施例中,如图6所示,提供了一种图像矫正方法,本实 施例中,根据标识位置,对目标图像进行矫正,包括如图6所示的以下步骤:
S610:根据标识位置,确定标识偏差。
其中,标识偏差用于表征目标图像与标准图像之间的偏差,标准图像是预先拍摄的满足取景需求的图像,作为矫正目标图像的参考图像。可选的,标识偏差包括前后偏差、垂直偏差、水平偏差、旋转偏差和翻转偏差中的至少一种,即标识偏差可以是前后偏差、垂直偏差、水平偏差、旋转偏差或翻转偏差,也可以是前后偏差、垂直偏差、水平偏差、旋转偏差和翻转偏差中两种或两种以上的组合。在本公开实施例中,前后偏差是指目标图像相对于标准图像出现放大或缩小,但成像面与标识平面平行,实际拍摄中体现在摄像头的主光轴与标识平面垂直的情况下,摄像头正对目标物体,且摄像头沿其主光轴移动时距离目标物体过近或过远;垂直偏差是指目标图像相对于标准图像出现上下偏移,但成像面与标识平面平行,实际拍摄中体现在摄像头的主光轴与标识平面垂直的情况下,摄像头未正对目标物体,且相对于目标物体向上或向下平移;水平偏差是指目标图像相对于标准图像出现左右偏移,但成像面与标识平面平行,实际拍摄中体现在摄像头的主光轴与标识平面垂直的情况下,摄像头未正对目标物体,且相对于目标物体向左或向右平移;旋转偏差是指目标图像相对于标准图像出现逆时针或顺时针旋转,但成像面与标识平面平行,实际拍摄中体现在摄像头的主光轴与标识平面垂直的情况下,摄像头正对目标物体,且摄像头绕其主光轴顺时针或逆时针旋转;翻转偏差是指目标图像相对于标准图像出现翻转,成像面与标识平面相交,实际拍摄中体现在摄像头的主光轴与标识平面不垂直的情况下,摄像头对目标物体进行拍摄,即摄像头以一定的倾斜角度拍摄目标物体。
可选的,根据标识位置,确定标识偏差,包括S611和S612:
S611:根据标识位置,确定摄像头的像平面与标识平面的位置关系。
其中,位置关系包括像平面与标识平面平行或相交。像平面是指摄像头采集到的目标图像所在的平面。可理解的,该位置关系是摄像头采集目标图像时的像平面与标识平面的位置关系。
在本实施例一实施方案中,当由标识位置确定的第一组对边长度相等,且由标识位置确定的第二组对边长度相等时,像平面与标识平面平行;当由标识位置确定的第一组对边长度和第二组对边长度中的任一组对边长度不相等时,像平面与标识平面相交。
具体的,四个定位标识在排列方向上依次包括第一定位标识、第二定位标识、第三定位标识和第四定位标识。根据标识位置,采用两点间距离算法可确定第一定位标识与第二定位标识之间的第一成像距 离、第二定位标识与第三定位标识之间的第二成像距离、第三定位标识与第四定位标识之间的第三成像距离以及第四定位标识与第一定位标识之间的第四成像距离。其中,第一成像距离和第三成像距离对应的边为第一组对边,第二成像距离和第四成像距离对应的边为第二组对边。由此,当第一成像距离与第三成像距离相等,且第二成像距离与第四成像距离相等时,像平面与标识平面平行;当第一成像距离与第三成像距离不相等时,或第二成像距离与第四成像距离不相等时,像平面与标识平面相交。
示例性的,参考图7,710表示的是像平面712与标识平面711平行,也就是摄像头713放置在标识平面711的正前方,摄像头713在标识平面711中四个定位标识对角连线的交点的正前方,也就是图中虚线与标识平面711垂直,摄像头713在像平面712生成目标图像,像平面712包括目标图像,此时,四个定位标识之间确定的成像距离相等,可以将生成的目标图像看作是标识平面缩小后的图像。720表示的是像平面721与标识平面711相交,摄像头713的镜头与标识平面711存在倾斜角度,也就是摄像头713的主光轴与标识平面711不垂直,摄像头713对应的像平面721中四个定位标识的位置相对于标识平面711也发生了倾斜,此时,四个定位标识在目标图像中的位置相比较于标识平面中四个定位标识的位置发生了倾斜。图7中目标图像中的四个定位标识分别为第一定位标识P 1’、第二定位标识P 2’、第三定位标识P 3’和第四定位标识P 4’。此时,根据P 1’和P 2’的位置可计算出第一成像距离,根据P 2’和P 3’的位置可计算出第二成像距离,根据P 3’和P 4’的位置可计算出第三成像距离,根据P 4’和P 1’的位置可计算出第四成像距离。
S612:根据位置关系和标识位置,确定标识偏差。
本实施例先根据标识位置确定位置关系,在位置关系确定的情况下再根据标识位置来确定标识偏差,可提高标识偏差判定的效率和准确性。例如,在直接根据标识位置确定标识偏差时,如果标识位置确定的两个定位标识之间的距离不等于标准距离,则标识偏差可能为前后偏差,也可能为翻转偏差,需要进一步判定标识偏差。而在位置关系确定的情况下,例如位置关系为像平面与标识平面平行,那么上述情况的标识偏差只能为前后偏差,位置关系为像平面与标识平面相交,那么上述情况的标识偏差只能为翻转偏差。
具体的,以像平面中的目标像点为原点,建立直角坐标系,直角坐标系的x轴平行于预设标准位置确定的第一边,直角坐标系的y轴平行于预设标准位置确定的第二边,预设标准位置为四个定位标识在标准图像中的位置;在直角坐标系下,确定四个定位标识在目标图像中的标识坐标以及在标准图像中的标准坐标。其中,目标像点可以位 于摄像头的像平面的左下角,使得其他像点全部位于直角坐标系的第一象限,即横坐标和纵坐标均为正值,便于计算。参考图4,标准图像(o)中的四个定位标识P 1”、P 2”、P 3”和P 4”,P 1”和P 2”连接形成的边P 1”P 2”为预设标准位置确定的第一边,P 2”和P 3”连接形成的边P 2”P 3”为预设标准位置确定的第二边。
相应的,根据位置关系和标识位置,确定标识偏差,包括如下至少一个:
当像平面与标识平面平行,且由标识坐标确定的两点之间距离,不等于由标准坐标确定的对应两点之间距离时,确定标识偏差为前后偏差;
当像平面与标识平面平行,且由标识坐标确定的纵坐标平均值,不等于由标准坐标确定的纵坐标平均值时,确定标识偏差为垂直偏差;
当像平面与标识平面平行,且由标识坐标确定的横坐标平均值,不等于由标准坐标确定的横坐标平均值时,确定标识偏差为水平偏差;
当像平面与标识平面平行,且经过由标识坐标确定的第一组对边的中点的直线,与y轴相交,或者经过由标识坐标确定的第二组对边的中点的直线,与x轴相交时,确定标识偏差为旋转偏差;
当像平面与标识平面相交,且由标识坐标确定的第一组对边不相等,或者由标识坐标确定的第二组对边不相等时,确定标识偏差为翻转偏差。
示例性的,参考图4,目标图像(a)中,由P 1’和P 2’的坐标确定P 1’和P 2’之间的距离P 1’P 2’,标准图像(o)中,由对应的P 1”和P 2”的坐标确定P 1”和P 2”之间的距离P 1”P 2”,当P 1’P 2’不等于P 1”P 2”时,确定标识偏差为前后偏差。具体的,前后偏差可包括向前平移偏差或向后平移偏差,当P 1’P 2’大于P 1”P 2”时,为向前平移偏差,即摄像头距离目标物体过近;当P 1’P 2’小于P 1”P 2”时,为向后平移偏差,即摄像头距离目标物体过远。
参考图4,由目标图像(c)中P 1’、P 2’、P 3’和P 4’的坐标确定的纵坐标平均值,不等于由标准图像(o)中P 1”、P 2”、P 3”和P 4”的坐标确定的纵坐标平均值时,确定标识偏差为垂直偏差。具体的,垂直偏差包括向上平移偏差或向下平移偏差,当P 1’、P 2’、P 3’和P 4’的坐标确定的纵坐标平均值,大于P 1”、P 2”、P 3”和P 4”的坐标确定的纵坐标平均值时,为向上平移偏差,即摄像头相对于目标物体向下偏移;当P 1’、P 2’、P 3’和P 4’的坐标确定的纵坐标平均值,小于P 1”、P 2”、P 3”和P 4”的坐标确定的纵坐标平均值时,为向下平移偏差,即摄像头相对于目标物体向上偏移。
参考图4,由目标图像(b)中P 1’、P 2’、P 3’和P 4’的坐标确定的横坐标平均值,不等于由标准图像(o)中P 1”、P 2”、P 3”和P 4”的坐标 确定的横坐标平均值时,确定标识偏差为水平偏差。具体的,水平偏差包括向左平移偏差或向右平移偏差,当P 1’、P 2’、P 3’和P 4’的坐标确定的横坐标平均值,大于P 1”、P 2”、P 3”和P 4”的坐标确定的横坐标平均值时,为向右平移偏差,即摄像头相对于目标物体向左偏移;当P 1’、P 2’、P 3’和P 4’的坐标确定的横坐标平均值,小于P 1”、P 2”、P 3”和P 4”的坐标确定的横坐标平均值时,为向左平移偏差,即摄像头相对于目标物体向右偏移。
参考图4,在目标图像(d)中,由P 1’和P 2’的坐标确定的边P 1’P 2’与由P 3’和P 4’的坐标确定的边P 3’P 4’为第一组对边,由P 2’和P 3’的坐标确定的边P 2’P 3’与由P 4’和P 1’的坐标确定的边P 4’P 1’为第二组对边,经过P 1’P 2’的中点以及P 3’P 4’的中点的直线为经过第一组对边的中点的直线,经过P 2’P 3’的中点以及P 4’P 1’的中点的直线为经过第二组对边的中点的直线;当经过第一组对边的中点的直线与y轴相交,或者经过第二组对边的中点的直线与x轴相交时,确定标识偏差为旋转偏差。具体的,旋转偏差包括逆时针旋转偏差或顺时针旋转偏差。示例性的,以经过第一组对边的中点的直线与y轴相交为例进行说明。假设逆时针方向为正方向,当经过第一组对边的中点的直线与y轴的夹角大于0时,为逆时针旋转偏差,即摄像头相对于目标物体顺时针旋转;当经过第一组对边的中点的直线与y轴的夹角小于0时,为顺时针旋转偏差,即摄像头相对于目标物体逆时针旋转。
另外,翻转偏差包括左右翻转偏差和/或上下翻转偏差。参考图4,在目标图像(e)中,由P 2’和P 3’的坐标确定的边P 2’P 3’与由P 4’和P 1’的坐标确定的边P 4’P 1’为第二组对边,当P 2’P 3’和P 4’P 1’不相等时,为左右翻转偏差。具体的,左右翻转偏差包括向左翻转偏差或向右翻转偏差,当P 2’P 3’大于P 4’P 1’时,为向左翻转偏差,即摄像头相对于目标物体向左翻转;当当P 2’P 3’小于P 4’P 1’时,为向右翻转偏差,即摄像头相对于目标物体向右翻转。在目标图像(f)中,由P 1’和P 2’的坐标确定的边P 1’P 2’与由P 3’和P 4’的坐标确定的边P 3’P 4’为第一组对边,当P 1’P 2’和P 3’P 4’不相等时,为上下翻转偏差。具体的,上下翻转偏差包括向上翻转偏差或向下翻转偏差,当P 1’P 2’大于P 3’P 4’时,为向下翻转偏差,即摄像头相对于目标物体向下翻转;当P 1’P 2’小于P 3’P 4’时,为向上翻转偏差,即摄像头相对于目标物体向上翻转。
S620:根据标识偏差,对目标图像进行矫正。
在本公开实施例中,通过调节摄像头的位姿和/或目标物体的位姿,实现对目标图像的矫正。即根据标识偏差,调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件,其中,四个标识位于目标物体上,从而依据标识偏差即可矫正目标图像。预设偏差条件为标识偏差符合取景要求,该预设偏差条件可根据不同的应用场景适 应设置。优选的,预设偏差条件为标识偏差不存在。
在本实施例中,可步进式矫正目标图像,也可通过计算出具体的偏差量一次性矫正目标图像。
在本实施例一实施方案中,根据标识偏差,调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件,包括S621和S622:
S621:根据标识偏差,确定摄像头和/或目标物体的第一补偿参数。
其中,第一补偿参数包括第一补偿类型和第一补偿方向,第一补偿类型包括角度和/或长度。可理解的,本公开可单独调节摄像头或目标物体的位姿,实现对目标图像的矫正,也可同时调节摄像头和目标物体的位姿,实现对目标图像的矫正。由于摄像头和目标图像相对设置,因此,摄像头和目标物体的第一补偿方向相反。另外,第一补偿类型和第一补偿方向均可根据标识偏差确定。例如,以调节摄像头的位姿为例进行说明。当标识偏差为向前平移偏差时,第一补偿类型为长度,第一补偿方向为向后平移;当标识偏差为向左平移偏差时,第一补偿类型为长度,第一补偿方向为向左平移;当标识偏差为逆时针旋转偏差时,第一补偿类型为角度,第一补偿方向为逆时针旋转;当标识偏差为向上翻转偏差时,第一补偿类型为角度,第一补偿方向为向下翻转。其他根据标识偏差确定第一补偿参数的情况可参考上述确定方式,此处不再赘述。
S622:根据第一补偿参数,步进式调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件。
具体的,包括S6221至S6226:
S6221:沿第一补偿方向,按照第一补偿类型对应的预设补偿量调节一次摄像头和/或目标物体。
示例性的,以调节摄像头的位姿为例进行说明。本公开实施例可利用步进电机实现对摄像头位姿的步进调节,预设补偿量为步进电机预设的一次步进的量,可根据第一补偿类型确定为步进长度或步进角度。例如,当标识偏差为向前平移偏差时,步进电机控制摄像头向后平移第一预设长度L1;当标识偏差为向左平移偏差时,步进电机控制摄像头向左平移第二预设长度L2;当标识偏差为逆时针旋转偏差时,步进电机控制摄像头逆时针旋转第一预设角度A1;当标识偏差为向上翻转偏差时,步进电机控制摄像头向下翻转第二预设角度A2。
S6222:通过摄像头采集包含四个定位标识的当前图像,并将当前图像作为目标图像。
S6223:确定四个定位标识在目标图像中的标识位置。
S6224:根据标识位置,确定标识偏差。
S6225:根据标识偏差,确定摄像头和/或目标物体的第一补偿参数。
S6226:返回至沿第一补偿方向,按照第一补偿类型对应的预设补偿量再次调节摄像头和/或目标物体,直至标识偏差满足预设偏差条件。
该实施方案中,因为无需确定精准的偏差量,因此,可在确定标识偏差的过程中判断标识偏差是否满足预设偏差条件。示例性的,当标识偏差为向前平移偏差时,可判断由标识坐标确定的两点之间距离,与由标准坐标确定的对应两点之间距离之差是否小于预设距离差,当由标识坐标确定的两点之间距离,与由标准坐标确定的对应两点之间距离之差小于预设距离差时,标识偏差满足预设偏差条件。
在本实施例另一实施方案中,可通过计算出具体的偏差量一次性矫正目标图像。
具体的,上述方法还包括:根据标识位置,确定标识偏差对应的偏差量。相应的,根据标识偏差,调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件,包括S623和S624:
S623:根据标识偏差,确定摄像头和/或目标物体的第二补偿参数。
其中,第二补偿参数包括第二补偿类型和第二补偿方向,第二补偿类型包括角度和/或长度。第二补偿参数与上述第一补偿参数相似,此处不再赘述。
S624:根据第二补偿参数以及标识偏差对应的偏差量,调节摄像头的位姿和/或目标物体的位姿。
该实施方案中,沿第二补偿方向,按照第二补偿类型对应的偏差量调节摄像头和/或目标物体。由此,可一次将摄像头和/或目标物体调节到标准位姿,通过一次补偿即可实现对目标图像的矫正,进一步提高了取景的效率。
上述方案中,根据标识位置,确定标识偏差对应的偏差量,包括如下至少一个:
当标识偏差为翻转偏差时,根据标识位置,确定第一投影角度和第二投影角度,并将第一投影角度和第二投影角度作为标识偏差对应的偏差量,其中,标识平面绕第一预设直线旋转第二投影角度,且绕第二预设直线旋转第一投影角度后,与像平面平行,第一预设直线经过物空间中四个定位标识的第一对角,第二预设直线经过物空间中四个定位标识的第二对角;
当标识偏差为前后偏差时,根据标识位置,确定当前物距,将当前物距与预设标准物距的差值作为标识偏差对应的偏差量;
当标识偏差为垂直偏差时,根据标识位置,确定物空间中四个定位标识的中心到预设点的预设距离,将预设距离与预设角度的正弦值的乘积作为标识偏差对应的偏差量,其中,预设点为摄像头的镜头主光轴与标识平面的交点,预设角度为经过物空间中四个定位标识的中心和预设点的直线与水平线的夹角;
当标识偏差为水平偏差时,根据标识位置,确定物空间中四个定位标识的中心到预设点的预设距离,将预设距离与预设角度的余弦值的乘积作为标识偏差对应的偏差量;
当标识偏差为旋转偏差时,根据标识位置,确定目标图像绕摄像头的镜头主光轴的旋转角度,并将旋转角度作为标识偏差对应的偏差量。
可选的,根据标识位置,确定第一投影角度和第二投影角度,包括:
采用如下公式确定第一投影角度:
Figure PCTCN2021102453-appb-000001
采用如下公式确定第二投影角度:
Figure PCTCN2021102453-appb-000002
其中,α表示第一投影角度,β表示第二投影角度,A' 1表示在目标图像中第一定位标识到标识成像中心的距离,A' 2表示在目标图像中第二定位标识到标识成像中心的距离,A' 3表示在目标图像中第三定位标识到标识成像中心的距离,A' 4表示在目标图像中第四定位标识到标识成像中心的距离,f表示摄像头的焦距,标识成像中心为在目标图像中四个定位标识对角连线的交点。
具体的,通过如下公式(1)-(12)计算得到第一投影角度以及第二投影角度,以图8中标记的符号进行说明。
结合图8和成像公式可以得到公式(1)和公式(2)。
Figure PCTCN2021102453-appb-000003
其中,O点为摄像头L与第二定位标识P 2连接的直线LP 2和过中线点C且与直线CL垂直的直线的交点,P为摄像头与第四定位标识P 4连接的直线的延长线LP 4与过中线点C且与直线CL垂直的直线的交点,D为中心点C与摄像头中心L的距离,C’为目标图像中P 1’和P 3’的连线与P 2’和P 4’的连线的交点,A' 2为C’与P2’之间的距离,f为摄像头的焦距。
Figure PCTCN2021102453-appb-000004
其中,A' 4为C’与P 4’之间的距离。
结合图8和三角几何关系可以得到公式(3)至公式(8)。
P 2C=A       公式(3)
其中,A为标识平面内第二定位标识P 2与中心点C的距离。
P 4C=A      公式(4)
其中,在标识平面内任一定位标识到中心点C的距离均相等为A。
P 2M=A×cosα    公式(5)
其中,P 2M与MC垂直,且P 2M与P 2C的夹角为第一投影角度α。
P 4N=A×cosα       公式(6)
其中,P 4N与CL垂直,且P 4N与P 4C的夹角为第一投影角度α。
MC=A×sinα                     公式(7)
NC=A×sinα                     公式(8)
根据由P 2ML组成的三角形与由OCL组成的三角形相似,可以得到公式(9)。
Figure PCTCN2021102453-appb-000005
结合上述公式(1)、公式(5)、公式(7)和公式(9),得到如下公式(10)。
Figure PCTCN2021102453-appb-000006
根据由P 4NL组成的三角形与由PCL组成的三角形相似,可以得到公式(11)。
Figure PCTCN2021102453-appb-000007
结合上述公式(2)、公式(6)、公式(8)和公式(10),得到如下公式(12)。
Figure PCTCN2021102453-appb-000008
根据公式(10)和公式(12),可以得到第一投影角度α。
另外,第二投影角度β的计算方式与第一投影角度α的原理相同,在此不作赘述。
可选的,确定当前物距,包括:
根据标识位置,确定目标图像中任意两个定位标识之间的成像距离;根据成像距离并结合成像原理,确定当前物距。
可选的,根据标识位置,确定目标图像绕摄像头的镜头主光轴的旋转角度,包括:
参考图4中的目标图像(d),采用如下公式确定旋转角度θ:
Figure PCTCN2021102453-appb-000009
或者,
Figure PCTCN2021102453-appb-000010
其中,P 1’的坐标为(x 1’,y 1’),P 2’的坐标为(x 2’,y 2’),P 3’的坐标为(x 3’,y 3’),P 3’的坐标为(x 3’,y 3’)。
在一个实施例中,如图9所示,提供了一种图像矫正装置900,该图像矫正装置900包括图像获取模块910、标识位置确定模块920和图像矫正模块930;其中,图像获取模块910,配置成获取摄像头采集的包含四个定位标识的目标图像,其中,四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;标识位置确定模块920,配置成确定四个定位标识在目标图像中的标识位置;图像矫正模块930,配置成根据标识位置,对目标图像进行矫正。
关于图像矫正装置的具体限定可以参见上文中对于图像矫正方法的限定,在此不再赘述。上述图像矫正装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的一个或多个处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于一个或多个处理器调用执行以上各个模块对应的操作。
可选的,图像矫正模块930包括:偏差确定单元,配置成根据标识位置,确定标识偏差;图像矫正单元,配置成根据标识偏差,对目标图像进行矫正。
可选的,偏差确定单元包括:位置关系确定子单元,配置成根据标识位置,确定摄像头的像平面与标识平面的位置关系,其中,位置关系包括像平面与标识平面平行或相交;偏差确定子单元,配置成根据位置关系和标识位置,确定标识偏差。
可选的,当由标识位置确定的第一组对边长度相等,且由标识位置确定的第二组对边长度相等时,像平面与标识平面平行;当由标识位置确定的第一组对边长度和第二组对边长度中的任一组对边长度不相等时,像平面与标识平面相交。
可选的,标识偏差包括前后偏差、垂直偏差、水平偏差、旋转偏 差和翻转偏差中的至少一种。
可选的,图像矫正装置还包括:坐标系建立模块,配置成以像平面中的目标像点为原点,建立直角坐标系,直角坐标系的x轴平行于预设标准位置确定的第一边,直角坐标系的y轴平行于预设标准位置确定的第二边,预设标准位置为四个定位标识在标准图像中的位置;标识坐标确定模块,配置成在直角坐标系下,确定四个定位标识在目标图像中的标识坐标以及在标准图像中的标准坐标。
可选的,当像平面与标识平面平行,且由标识坐标确定的两点之间距离,不等于由标准坐标确定的对应两点之间距离时,确定标识偏差为前后偏差;当像平面与标识平面平行,且由标识坐标确定的纵坐标平均值,不等于由标准坐标确定的纵坐标平均值时,确定标识偏差为垂直偏差;当像平面与标识平面平行,且由标识坐标确定的横坐标平均值,不等于由标准坐标确定的横坐标平均值时,确定标识偏差为水平偏差;当像平面与标识平面平行,且经过由标识坐标确定的第一组对边的中点的直线,与y轴均相交,或者经过由标识坐标确定的第二组对边的中点的直线,与x轴相交时,确定标识偏差为旋转偏差;当像平面与标识平面相交,且由标识坐标确定的第一组对边不相等,或者由标识坐标确定的第二组对边不相等时,确定标识偏差为翻转偏差。
可选的,前后偏差包括向前平移偏差或向后平移偏差,垂直偏差包括向上平移偏差或向下平移偏差,水平偏差包括向左平移偏差或向右平移偏差,旋转偏差包括逆时针旋转偏差或顺时针旋转偏差,翻转偏差包括向上翻转偏差、向下翻转偏差、向左翻转偏差和向右翻转偏差中的一个或两个。
可选的,图像矫正单元包括:位姿调节子单元,配置成根据标识偏差,调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件,四个标识位于目标物体上。
可选的,位姿调节子单元具体配置成根据标识偏差,确定摄像头和/或目标物体的第一补偿参数,第一补偿参数包括第一补偿类型和第一补偿方向,第一补偿类型包括角度和/或长度;根据第一补偿参数,步进式调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件。
可选的,位姿调节子单元在根据第一补偿参数,步进式调节摄像头的位姿和/或目标物体的位姿,直至标识偏差满足预设偏差条件时,具体配置成:沿第一补偿方向,按照第一补偿类型对应的预设补偿量调节一次摄像头和/或目标物体;通过摄像头采集包含四个定位标识的当前图像,并将当前图像作为目标图像;确定四个定位标识在目标图像中的标识位置;根据标识位置,确定标识偏差;根据标识偏差,确定摄像头和/或目标物体的第一补偿参数;返回至沿第一补偿方向,按 照第一补偿类型对应的预设补偿量再次调节摄像头和/或目标物体,直至标识偏差满足预设偏差条件。
可选的,图像矫正装置还包括:偏差量确定模块,配置成根据标识位置,确定标识偏差对应的偏差量。位姿调节子单元具体配置成根据标识偏差,确定摄像头和/或目标物体的第二补偿参数,第二补偿参数包括第二补偿类型和第二补偿方向,第二补偿类型包括角度和/或长度;根据第二补偿参数以及标识偏差对应的偏差量,调节摄像头的位姿和/或目标物体的位姿。
可选的,偏差量确定模块具体配置成:当标识偏差为翻转偏差时,根据标识位置,确定第一投影角度和第二投影角度,并将第一投影角度和第二投影角度作为标识偏差对应的偏差量,其中,标识平面绕第一预设直线旋转第二投影角度,且绕第二预设直线旋转第一投影角度后,与像平面平行,第一预设直线经过物空间中四个定位标识的第一对角,第二预设直线经过物空间中四个定位标识的第二对角;当标识偏差为前后偏差时,根据标识位置,确定当前物距,将当前物距与预设标准物距的差值作为标识偏差对应的偏差量;当标识偏差为垂直偏差时,根据标识位置,确定物空间中四个定位标识的中心到预设点的预设距离,将预设距离与预设角度的正弦值的乘积作为标识偏差对应的偏差量,其中,预设点为摄像头的镜头主光轴与标识平面的交点,预设角度为经过物空间中四个定位标识的中心和预设点的直线与水平线的夹角;当标识偏差为水平偏差时,根据标识位置,确定物空间中四个定位标识的中心到预设点的预设距离,将预设距离与预设角度的余弦值的乘积作为标识偏差对应的偏差量;当标识偏差为旋转偏差时,根据标识位置,确定目标图像绕摄像头的镜头主光轴的旋转角度,并将旋转角度作为标识偏差对应的偏差量。
可选的,偏差量确定模块在根据标识位置,确定第一投影角度和第二投影角度时,具体配置成:
采用如下公式确定第一投影角度:
Figure PCTCN2021102453-appb-000011
采用如下公式确定第二投影角度:
Figure PCTCN2021102453-appb-000012
其中,α表示第一投影角度,β表示第二投影角度,A' 1表示在目标图像中第一定位标识到标识成像中心的距离,A' 2表示在目标图像中第二定位标识到标识成像中心的距离,A' 3表示在目标图像中第三定位 标识到标识成像中心的距离,A' 4表示在目标图像中第四定位标识到标识成像中心的距离,f表示摄像头的焦距,标识成像中心为在目标图像中四个定位标识对角连线的交点。
可选的,偏差量确定模块在根据标识位置,确定当前物距时,具体配置成:根据标识位置,确定目标图像中任意两个定位标识之间的成像距离;根据成像距离并结合成像原理,确定当前物距。
在一个实施例中,提供了一种电子设备,该电子设备可以是终端,其内部结构图可以如图10所示。该电子设备包括通过系统总线连接的一个或多个处理器、存储器、通信接口、显示屏和输入装置。其中,该电子设备的一个或多个处理器配置成提供计算和控制能力。该电子设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机可读指令。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该电子设备的通信接口配置成与外部的终端进行有线或无线方式的通信,无线方式可通过WIFI、运营商网络、近场通信(NFC)或其他技术实现。该计算机可读指令被一个或多个处理器执行时以实现一种方法。该电子设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该电子设备的输入装置可以是显示屏上覆盖的触摸层,也可以是电子设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。
本领域技术人员可以理解,图10中示出的结构,仅仅是与本公开方案相关的部分结构的框图,并不构成对本公开方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
在一个实施例中,本公开提供的图像矫正装置可以实现为一种计算机可读指令的形式,计算机可读指令可在如图10所示的电子设备上运行。电子设备的存储器中可存储组成该图像矫正装置的各个程序模块,比如,图9所示的图像获取模块910、标识位置确定模块920和图像矫正模块930。各个程序模块构成的计算机可读指令使得一个或多个处理器执行本说明书中描述的各个实施例的图像矫正方法中的步骤。
例如,图10所示的电子设备可以通过如图9所示的装置中的图像获取模块910执行步骤S510。电子设备可通过标识位置确定模块920执行步骤S520。电子设备可通过图像矫正模块930执行步骤S530。
一个实施例中,提供了一种电子设备,包括存储器和一个或多个处理器,存储器存储有计算机可读指令,该一个或多个处理器执行计算机可读指令时实现上述任一实施例所提供的图像矫正方法的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成的,计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算 机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本公开所提供的各实施例中所使用的对存储器、数据库或其它介质的任何引用,均可包括非易失性和易失性存储器中的至少一种。非易失性存储器可包括只读存储器(Read-Only Memory,ROM)、磁带、软盘、闪存或光存储器等。易失性存储器可包括随机存取存储器(Random Access Memory,RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,比如静态随机存取存储器(Static Random Access Memory,SRAM)和动态随机存取存储器(Dynamic Random Access Memory,DRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本公开的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本公开构思的前提下,还可以做出若干变形和改进,这些都属于本公开的保护范围。因此,本公开专利的保护范围应以所附权利要求为准。
工业实用性
本公开提供的图像矫正方法,使得在拍摄照片进行取景时,通过获取预先设置有四个定位标识的目标物体对应的目标图像,根据四个定位标识在目标图像中的标识位置即可确定拍摄的目标物体的偏差情况,从而根据标识位置对目标图像进行快速矫正,提高了取景的精度和效率,保证了取景结果的一致性,具有很强的工业实用性。

Claims (20)

  1. 一种图像矫正方法,其特征在于,包括:
    获取摄像头采集的包含四个定位标识的目标图像,其中,所述四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;
    确定所述四个定位标识在所述目标图像中的标识位置;
    根据所述标识位置,对所述目标图像进行矫正。
  2. 根据权利要求1所述的方法,其特征在于,根据所述标识位置,对所述目标图像进行矫正,包括:
    根据所述标识位置,确定标识偏差;
    根据所述标识偏差,对所述目标图像进行矫正。
  3. 根据权利要求2所述的方法,其特征在于,根据所述标识位置,确定标识偏差,包括:
    根据所述标识位置,确定所述摄像头的像平面与所述标识平面的位置关系,其中,所述位置关系包括所述像平面与所述标识平面平行或相交;
    根据所述位置关系和所述标识位置,确定所述标识偏差。
  4. 根据权利要求3所述的方法,其特征在于,根据所述标识位置,确定所述摄像头的像平面与所述标识平面的位置关系,包括:
    当由所述标识位置确定的第一组对边长度相等,且由所述标识位置确定的第二组对边长度相等时,所述像平面与所述标识平面平行;
    当由所述标识位置确定的第一组对边长度和第二组对边长度中的任一组对边长度不相等时,所述像平面与所述标识平面相交。
  5. 根据权利要求3所述的方法,其特征在于,所述标识偏差包括前后偏差、垂直偏差、水平偏差、旋转偏差和翻转偏差中的至少一种。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    以像平面中的目标像点为原点,建立直角坐标系,所述直角坐标系的x轴平行于预设标准位置确定的第一边,所述直角坐标系的y轴平行于所述预设标准位置确定的第二边,所述预设标准位置为所述四个定位标识在标准图像中的位置;
    在所述直角坐标系下,确定所述四个定位标识在所述目标图像中的标识坐标以及在所述标准图像中的标准坐标。
  7. 根据权利要求6所述的方法,其特征在于,根据所述位置关系 和所述标识位置,确定所述标识偏差,包括如下至少一个:
    当所述像平面与所述标识平面平行,且由所述标识坐标确定的两点之间距离,不等于由所述标准坐标确定的对应两点之间距离时,确定所述标识偏差为所述前后偏差;
    当所述像平面与所述标识平面平行,且由所述标识坐标确定的纵坐标平均值,不等于由所述标准坐标确定的纵坐标平均值时,确定所述标识偏差为所述垂直偏差;
    当所述像平面与所述标识平面平行,且由所述标识坐标确定的横坐标平均值,不等于由所述标准坐标确定的横坐标平均值时,确定所述标识偏差为所述水平偏差;
    当所述像平面与所述标识平面平行,且经过由所述标识坐标确定的第一组对边的中点的直线,与所述y轴均相交,或者经过由所述标识坐标确定的第二组对边的中点的直线,与所述x轴相交时,确定所述标识偏差为所述旋转偏差;
    当所述像平面与所述标识平面相交,且由所述标识坐标确定的第一组对边不相等,或者由所述标识坐标确定的第二组对边不相等时,确定所述标识偏差为所述翻转偏差。
  8. 根据权利要求7所述的方法,其特征在于,所述前后偏差包括向前平移偏差或向后平移偏差,所述垂直偏差包括向上平移偏差或向下平移偏差,所述水平偏差包括向左平移偏差或向右平移偏差,所述旋转偏差包括逆时针旋转偏差或顺时针旋转偏差,所述翻转偏差包括向上翻转偏差、向下翻转偏差、向左翻转偏差和向右翻转偏差中的一个或两个。
  9. 根据权利要求2所述的方法,其特征在于,根据所述标识偏差,对所述目标图像进行矫正,包括:
    根据所述标识偏差,调节所述摄像头的位姿和/或目标物体的位姿,直至所述标识偏差满足预设偏差条件,所述四个标识位于所述目标物体上。
  10. 根据权利要求9所述的方法,其特征在于,根据所述标识偏差,调节所述摄像头的位姿和/或目标物体的位姿,直至所述标识偏差满足预设偏差条件,包括:
    根据所述标识偏差,确定所述摄像头和/或所述目标物体的第一补偿参数,所述第一补偿参数包括第一补偿类型和第一补偿方向,所述 第一补偿类型包括角度和/或长度;
    根据所述第一补偿参数,步进式调节所述摄像头的位姿和/或目标物体的位姿,直至所述标识偏差满足预设偏差条件。
  11. 根据权利要求10所述的方法,其特征在于,根据所述第一补偿参数,步进式调节所述摄像头的位姿和/或目标物体的位姿,直至所述标识偏差满足预设偏差条件,包括:
    沿所述第一补偿方向,按照所述第一补偿类型对应的预设补偿量调节一次所述摄像头和/或所述目标物体;
    通过所述摄像头采集包含所述四个定位标识的当前图像,并将所述当前图像作为所述目标图像;
    确定所述四个定位标识在所述目标图像中的标识位置;
    根据所述标识位置,确定标识偏差;
    根据所述标识偏差,确定所述摄像头和/或所述目标物体的第一补偿参数;
    返回至沿所述第一补偿方向,按照所述第一补偿类型对应的预设补偿量再次调节所述摄像头和/或所述目标物体,直至所述标识偏差满足预设偏差条件。
  12. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    根据所述标识位置,确定所述标识偏差对应的偏差量。
  13. 根据权利要求12所述的方法,其特征在于,根据所述标识偏差,调节所述摄像头的位姿和/或目标物体的位姿,直至所述标识偏差满足预设偏差条件,包括:
    根据所述标识偏差,确定所述摄像头和/或所述目标物体的第二补偿参数,所述第二补偿参数包括第二补偿类型和第二补偿方向,所述第二补偿类型包括角度和/或长度;
    根据所述第二补偿参数以及所述标识偏差对应的偏差量,调节所述摄像头的位姿和/或目标物体的位姿。
  14. 根据权利要求12所述的方法,其特征在于,根据所述标识位置,确定所述标识偏差对应的偏差量,包括如下至少一个:
    当所述标识偏差为翻转偏差时,根据所述标识位置,确定第一投影角度和第二投影角度,并将所述第一投影角度和所述第二投影角度作为所述标识偏差对应的偏差量,其中,所述标识平面绕第一预设直线旋转所述第二投影角度,且绕第二预设直线旋转所述第一投影角度 后,与像平面平行,所述第一预设直线经过物空间中所述四个定位标识的第一对角,所述第二预设直线经过所述物空间中所述四个定位标识的第二对角;
    当所述标识偏差为前后偏差时,根据所述标识位置,确定当前物距,将所述当前物距与预设标准物距的差值作为所述标识偏差对应的偏差量;
    当所述标识偏差为垂直偏差时,根据所述标识位置,确定物空间中所述四个定位标识的中心到预设点的预设距离,将所述预设距离与预设角度的正弦值的乘积作为所述标识偏差对应的偏差量,其中,所述预设点为所述摄像头的镜头主光轴与所述标识平面的交点,所述预设角度为经过物空间中所述四个定位标识的中心和所述预设点的直线与水平线的夹角;
    当所述标识偏差为水平偏差时,根据所述标识位置,确定物空间中所述四个定位标识的中心到预设点的预设距离,将所述预设距离与预设角度的余弦值的乘积作为所述标识偏差对应的偏差量;
    当所述标识偏差为旋转偏差时,根据所述标识位置,确定所述目标图像绕所述摄像头的镜头主光轴的旋转角度,并将所述旋转角度作为所述标识偏差对应的偏差量。
  15. 根据权利要求14所述的方法,其特征在于,根据所述标识位置,确定第一投影角度和第二投影角度,包括:
    采用如下公式确定所述第一投影角度:
    Figure PCTCN2021102453-appb-100001
    采用如下公式确定所述第二投影角度:
    Figure PCTCN2021102453-appb-100002
    其中,α表示所述第一投影角度,β表示所述第二投影角度,A' 1表示在所述目标图像中第一定位标识到标识成像中心的距离,A' 2表示在所述目标图像中第二定位标识到标识成像中心的距离,A' 3表示在所述目标图像中第三定位标识到标识成像中心的距离,A' 4表示在所述目标图像中第四定位标识到标识成像中心的距离,f表示所述摄像头的 焦距,所述标识成像中心为在所述目标图像中所述四个定位标识对角连线的交点。
  16. 根据权利要求14所述的方法,其特征在于,根据所述标识位置,确定当前物距,包括:
    根据所述标识位置,确定所述目标图像中任意两个定位标识之间的成像距离;
    根据所述成像距离并结合成像原理,确定所述当前物距。
  17. 一种图像矫正装置,其特征在于,包括:
    图像获取模块,配置成获取摄像头采集的包含四个定位标识的目标图像,其中,所述四个定位标识在物空间中位于标识平面,且依次等间距并环绕排列;
    标识位置确定模块,配置成确定所述四个定位标识在所述目标图像中的标识位置;
    图像矫正模块,配置成根据所述标识位置,对所述目标图像进行矫正。
  18. 根据权利要求17所述的装置,其特征在于,所述图像矫正模块,包括:
    偏差确定单元,配置成根据标识位置,确定标识偏差;
    图像矫正单元,配置成根据标识偏差,对目标图像进行矫正。
  19. 一种电子设备,包括存储器和一个或多个处理器,所述存储器存储有计算机可读指令,其特征在于,所述一个或多个处理器执行所述计算机可读指令时实现权利要求1至16中任一项所述方法的步骤。
  20. 一个或多个存储有计算机可读指令的非易失性计算机可读指令,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被一个或多个处理器执行时实现权利要求1至16中任一项所述方法的步骤。
PCT/CN2021/102453 2021-06-25 2021-06-25 图像矫正方法、装置、电子设备和存储介质 WO2022267027A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202180001907.8A CN113678163A (zh) 2021-06-25 2021-06-25 图像矫正方法、装置、电子设备和存储介质
PCT/CN2021/102453 WO2022267027A1 (zh) 2021-06-25 2021-06-25 图像矫正方法、装置、电子设备和存储介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/102453 WO2022267027A1 (zh) 2021-06-25 2021-06-25 图像矫正方法、装置、电子设备和存储介质

Publications (1)

Publication Number Publication Date
WO2022267027A1 true WO2022267027A1 (zh) 2022-12-29

Family

ID=78551016

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/102453 WO2022267027A1 (zh) 2021-06-25 2021-06-25 图像矫正方法、装置、电子设备和存储介质

Country Status (2)

Country Link
CN (1) CN113678163A (zh)
WO (1) WO2022267027A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117579813A (zh) * 2024-01-16 2024-02-20 四川新视创伟超高清科技有限公司 一种焦深区域成像芯片位姿角度矫正方法及矫正系统

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060043264A1 (en) * 2004-09-02 2006-03-02 Casio Computer Co., Ltd. Imaging apparatus, image processing method for imaging apparatus, recording medium and carrier wave signal
CN101561924A (zh) * 2008-04-18 2009-10-21 株式会社Pfu 笔记本信息处理器和投影变换参数计算方法
CN105894467A (zh) * 2016-03-30 2016-08-24 联想(北京)有限公司 一种图像校正方法及系统
WO2018053756A1 (zh) * 2016-09-22 2018-03-29 华为技术有限公司 一种图像检测方法及终端
CN110677634A (zh) * 2019-11-27 2020-01-10 成都极米科技股份有限公司 投影仪的梯形校正方法、装置、系统及可读存储介质
CN112689135A (zh) * 2021-03-19 2021-04-20 深圳市火乐科技发展有限公司 投影校正方法、装置、存储介质及电子设备
CN113516131A (zh) * 2020-12-24 2021-10-19 阿里巴巴集团控股有限公司 图像处理方法、装置、设备和存储介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106203257B (zh) * 2016-06-27 2019-12-06 深圳市新国都支付技术有限公司 一种可识别标识的方法和系统
CN110766615B (zh) * 2019-09-09 2023-07-14 北京美院帮网络科技有限公司 一种图片矫正方法、装置、终端及计算机可读存储介质

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060043264A1 (en) * 2004-09-02 2006-03-02 Casio Computer Co., Ltd. Imaging apparatus, image processing method for imaging apparatus, recording medium and carrier wave signal
CN101561924A (zh) * 2008-04-18 2009-10-21 株式会社Pfu 笔记本信息处理器和投影变换参数计算方法
CN105894467A (zh) * 2016-03-30 2016-08-24 联想(北京)有限公司 一种图像校正方法及系统
WO2018053756A1 (zh) * 2016-09-22 2018-03-29 华为技术有限公司 一种图像检测方法及终端
CN110677634A (zh) * 2019-11-27 2020-01-10 成都极米科技股份有限公司 投影仪的梯形校正方法、装置、系统及可读存储介质
CN113516131A (zh) * 2020-12-24 2021-10-19 阿里巴巴集团控股有限公司 图像处理方法、装置、设备和存储介质
CN112689135A (zh) * 2021-03-19 2021-04-20 深圳市火乐科技发展有限公司 投影校正方法、装置、存储介质及电子设备

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117579813A (zh) * 2024-01-16 2024-02-20 四川新视创伟超高清科技有限公司 一种焦深区域成像芯片位姿角度矫正方法及矫正系统
CN117579813B (zh) * 2024-01-16 2024-04-02 四川新视创伟超高清科技有限公司 一种焦深区域成像芯片位姿角度矫正方法及矫正系统

Also Published As

Publication number Publication date
CN113678163A (zh) 2021-11-19

Similar Documents

Publication Publication Date Title
WO2019183845A1 (zh) 云台的控制方法、装置、系统、计算机存储介质及无人机
WO2018068719A1 (zh) 一种图像拼接方法及装置
TWI494535B (zh) 物體控制系統、物體控制方法與程式及旋轉中心位置指定裝置
WO2013005244A1 (ja) 3次元相対座標計測装置およびその方法
WO2023087894A1 (zh) 区域调整方法和装置、摄像头和存储介质
WO2019232793A1 (zh) 双摄像头标定方法、电子设备、计算机可读存储介质
WO2023274090A1 (zh) 便携式电子设备的扫描方法及系统、电子设备及存储介质
WO2022267027A1 (zh) 图像矫正方法、装置、电子设备和存储介质
WO2020181506A1 (zh) 一种图像处理方法、装置及系统
WO2023061110A1 (zh) 坐标系标定方法、自动组装方法及装置
CN110378972A (zh) 一种内参标定的方法、装置及设备
JP4764896B2 (ja) カメラ校正装置、カメラ校正方法、カメラ校正プログラムおよびそのプログラムを記録した記録媒体
TWI412725B (zh) 距離量測與定位方法
JP5648159B2 (ja) 3次元相対座標計測装置およびその方法
CN115174878B (zh) 投影画面校正方法、装置和存储介质
TWM594322U (zh) 全向立體視覺的相機配置系統
CN116485902A (zh) 标志点匹配方法、装置、计算机设备和存储介质
WO2022252277A1 (zh) 校准om和sem坐标关系的方法和装置、设备和存储介质
WO2019056219A1 (zh) 一种投影机左右梯形校正方法
JP2009264898A (ja) ワーク位置姿勢計測方法および計測装置
WO2021111613A1 (ja) 3次元地図作成装置、3次元地図作成方法、及び3次元地図作成プログラム
CN115147268A (zh) 实时取景方法、全景相机及计算机可读存储介质
WO2021134715A1 (zh) 一种控制方法、设备、无人机及存储介质
CN110675445A (zh) 一种视觉定位方法、装置及存储介质
JP2020067511A (ja) カメラシステム、その制御方法およびプログラム

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: 21946520

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE