Image correction method and device
By dividing the image into sub-regions and calculating the vertical displacement in a horizontal static state, the posture and smoothing angle of the scanning device are determined, and transformation parameters are generated for image correction. This solves the perspective distortion problem caused by the non-parallelism between the camera and the medium surface, and improves the accuracy of optical character recognition and image correction.
Patent Information
- Application Number
- CN202511154138.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-18
- Publication Date
- 2025-11-25
AI Technical Summary
During image acquisition, perspective distortion, especially trapezoidal distortion, caused by the non-parallelism between the camera and the surface of the photographed medium affects the accuracy of subsequent optical character recognition and the reliability of document information extraction.
By dividing the image into upper and lower sub-regions when the image frame is horizontally stationary, calculating the vertical displacement of the sub-regions, determining the orientation of the scanning device and the target smoothing angle, and generating transformation parameters for geometric correction.
It accurately compensates for vertical position shifts caused by changes in the scanning device's posture, improving the accuracy of optical character recognition and image correction, avoiding erroneous vertical correction, and ensuring the targeted and accurate nature of the correction.
Smart Images

Figure CN121010979A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to an image correction method and apparatus. Background Technology
[0002] In daily work and study, portable devices such as dictionary pens, handheld scanners, or smartphones are widely used to collect image information from paper documents, books, tickets, and other media for optical character recognition (OCR) or data archiving. However, in actual use, it is difficult for users to ensure that the camera is perfectly parallel to the surface of the medium being photographed. This unavoidable operational tilt will cause perspective distortion in the captured image. The most common manifestation of this is trapezoidal distortion, where the originally rectangular document area appears as a trapezoid in the image, and the text lines are also tilted accordingly. Summary of the Invention
[0003] This invention provides an image correction method and apparatus to address the deficiencies in the prior art.
[0004] This invention provides an image correction method, comprising the following steps: Get the current frame image; When the current frame image is stationary in the horizontal direction, a designated area of the current frame image is divided into an upper sub-region and a lower sub-region. Based on the vertical displacements of the upper sub-region and the lower sub-region, respectively, transformation parameters for correcting the current frame image are determined. The current frame image is corrected using the transformation parameters to generate a corrected image.
[0005] According to an image correction method provided by the present invention, determining transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region respectively includes: The scanning posture of the scanning device is determined based on the vertical displacements of the upper sub-region and the lower sub-region, respectively. Based on the scanning posture, the target smoothing angle of the current frame image is determined; The transformation parameters are determined based on the target smoothing angle.
[0006] According to an image correction method provided by the present invention, determining the scanning posture of the scanning device based on the vertical displacements of the upper sub-region and the lower sub-region includes: If the first displacement of the upper sub-region in the vertical direction is less than a first displacement threshold, or the second displacement of the lower sub-region in the vertical direction is greater than a second displacement threshold, the scanning posture is determined to be a downward pressing posture; the first displacement threshold is less than the second displacement threshold. If the first displacement of the upper sub-region in the vertical direction is greater than the second displacement threshold, or the second displacement of the lower sub-region in the vertical direction is less than the first displacement threshold, the scanning posture is determined to be an upward lifting posture.
[0007] According to an image correction method provided by the present invention, determining the target smoothing angle of the current frame image based on the scanning posture includes: Based on the first displacement and the second displacement, the adjustment angle of the current frame image is determined; When the scanning posture is a downward pressing posture, the target smoothing angle is determined based on the difference between the smoothing angle of the reference frame image and the adjustment angle of the current frame image, and a first preset smoothing angle; the reference frame image is a historical frame image of the current frame image; When the scanning posture is an upward lifting posture, the target smoothing angle is determined based on the sum of the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the second preset smoothing angle.
[0008] According to an image correction method provided by the present invention, determining the transformation parameters based on the target smoothing angle includes: From a plurality of candidate smoothing angles, determine two candidate smoothing angles that are numerically adjacent to the target smoothing angle; Based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles, the perspective transformation point coordinates corresponding to the target smoothing angle are determined. The transformation parameters are determined based on the coordinates of the perspective transformation point corresponding to the target smoothing angle.
[0009] According to an image correction method provided by the present invention, determining the perspective transformation point coordinates corresponding to the target smoothing angle based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles respectively includes: The interpolation ratio is determined based on the relative position of the target smoothing angle within the interval formed by the two candidate smoothing angles; Based on the interpolation ratio, the coordinates of the perspective transformation points corresponding to the two candidate smoothing angles are weighted and summed to obtain the coordinates of the perspective transformation points corresponding to the target smoothing angle.
[0010] According to an image correction method provided by the present invention, the step of acquiring the current frame image further includes: Determine the displacement of a specified region on the left side of the current frame image in the horizontal direction; If the displacement in the horizontal direction is less than a threshold, the current frame image is determined to be stationary in the horizontal direction.
[0011] According to an image correction method provided by the present invention, the current frame image is corrected by applying the transformation parameters to generate a corrected image, and then the method further includes: displaying the corrected image on the display screen of a scanning device.
[0012] The present invention also provides an image correction device, comprising the following modules: The acquisition unit is used to acquire the image of the current frame; A segmentation unit is used to divide a specified region of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction. The determining unit is used to determine the transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region, respectively. The correction unit is used to apply the transformation parameters to correct the current frame image and generate a corrected image.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the image correction method as described above.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image correction method as described above.
[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the image correction method as described above.
[0016] The image correction method and apparatus provided by this invention divide a designated area of the image into upper and lower sub-regions under the premise that the image frame is in a horizontal static state. Correction transformation parameters are jointly determined by calculating the vertical displacement of these two sub-regions relative to a reference datum. Finally, these parameters are applied to perform geometric correction on the image, achieving precise compensation for vertical positional shifts caused by changes in the scanning device's posture during scanning. Because this invention triggers the correction logic in a horizontal static state, it accurately isolates the vertical displacement caused by changes in the scanning device's posture from the image displacement caused by normal horizontal scanning. This avoids introducing erroneous vertical correction during normal scanning, ensuring the targeted and accurate nature of the correction, and ultimately improving the accuracy of subsequent optical character recognition. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating the image correction method provided by the present invention.
[0019] Figure 2 This is a flowchart illustrating the current frame image motion state determination method provided by the present invention.
[0020] Figure 3 This is a schematic diagram of each sub-region in the right-hand ROI region provided by the present invention.
[0021] Figure 4 This is a schematic diagram of a frame image obtained when the dictionary pen is tilted at 30° according to the present invention.
[0022] Figure 5 This is a flowchart illustrating another image correction method provided by the present invention.
[0023] Figure 6 This is a schematic diagram of the image correction effect provided by the present invention.
[0024] Figure 7 This is a schematic diagram of the image correction device provided by the present invention.
[0025] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0027] In daily work and study, portable devices such as dictionary pens, handheld scanners, or smartphones are widely used to collect image information from paper documents, books, tickets, and other media for optical character recognition (OCR) or data archiving. However, in actual use, it is difficult for users to ensure that the camera is perfectly parallel to the surface of the medium being photographed. This unavoidable operational tilt will cause perspective distortion in the captured image, the most common form of which is trapezoidal distortion, where the originally rectangular document area appears as a trapezoid in the image, and the text lines are also tilted accordingly.
[0028] The aforementioned image distortion can cause a series of serious problems. First, it reduces the text recognition accuracy of subsequent OCR engines, as most OCR algorithms operate optimally on square text images. Second, distortion can cause spatial displacement of key fields in a document, leading to location failures or extraction errors in template- or coordinate-based automated information extraction processes, severely impacting the efficiency and reliability of automated information processing.
[0029] To address this issue, the present invention provides an image correction method. This method can be applied to image correction of video streams acquired in real time during scanning by scanning devices (such as dictionary pens), to image correction of images captured by mobile terminals such as smartphones during document scanning or screen recording, and to real-time stabilization of video streams captured by vehicle-mounted driver assistance systems or drones. The present invention does not specifically limit the application of this method. For ease of explanation, the following embodiments all use the application of image correction to video streams acquired in real time during the scanning process of a dictionary pen as an example.
[0030] in, Figure 1 This is a flowchart illustrating the image correction method provided by the present invention, as shown below. Figure 1 As shown, the method includes steps 110, 120, 130 and 140.
[0031] Step 110: Obtain the current frame image.
[0032] In this embodiment, the current frame image refers to a specific frame in the video stream captured in real time by the camera during the scanning process of the dictionary pen. Since the scanning process is continuous, each frame image can be regarded as the current frame image and forms a reference relative to its adjacent previous frame image. The current frame image can be acquired periodically, for example, by reading the latest frame image from the video stream buffer at a preset time interval (e.g., 20 milliseconds); or it can be event-driven, for example, by acquiring the image after detecting a specific trigger condition. This embodiment of the invention does not specifically limit the method of acquisition.
[0033] After acquiring the current frame image, the current frame image can be processed by grayscale conversion, Gaussian filtering, etc., to effectively suppress high-frequency noise introduced during image acquisition and to unify the image data format to reduce the computational complexity of subsequent algorithms.
[0034] Step 120: When the current frame image is stationary in the horizontal direction, divide the specified area of the current frame image into an upper sub-region and a lower sub-region.
[0035] Specifically, in typical usage scenarios of dictionary pens, there are two main states: one is when the user holds the dictionary pen and scans the text lines at a constant or variable speed in the horizontal direction; the other is when the user's hand briefly pauses in the horizontal direction at the beginning, end, or during the scan. A key idea of this invention is to distinguish between image changes caused by scanning motion and image content changes caused by displacement of the dictionary pen in the direction perpendicular to the paper (e.g., lifting upwards or pressing downwards). When the scanning device does not undergo macroscopic displacement in the horizontal direction (i.e., is in a "stationary" state), changes in the vertical direction of the image can be attributed with a high probability to the upward lifting or downward pressing action of the dictionary pen. If vertical correction is performed during high-speed horizontal scanning, normal tilted scanning operations may be misjudged as jitter, thus introducing incorrect correction. Therefore, this embodiment first determines the motion state of the current frame image. When it is determined to be stationary in the horizontal direction, the subsequent region division and correction parameter determination steps are initiated, thereby ensuring the accuracy and necessity of the correction.
[0036] As an optional embodiment, the current frame image can be compared with the previous frame or several previous frames. For example, this can be achieved by calculating the cross-correlation of a specific region between the two frames, or by matching feature points (such as ORB, SURF, etc.) in the two frames and calculating the average displacement vector of these feature points in the horizontal direction. When this horizontal displacement is less than a preset minimum threshold (e.g., 1-2 pixels), it can be determined that the current frame image is stationary in the horizontal direction.
[0037] As another optional embodiment, the current frame image can be divided into a left ROI region and a right ROI region. Since the left ROI region is usually close to the tip of the dictionary pen, changes in the image content of this region can most sensitively and accurately reflect the horizontal movement of the pen tip. Figure 2 This is a flowchart illustrating the current frame image motion state determination method provided by the present invention, as shown below. Figure 2 As shown, the displacement of each feature point in the ROI region of the current frame image relative to the corresponding feature point in the previous frame image is calculated, and the average displacement of all feature points is used as the optical flow magnitude. When the optical flow magnitude is less than a threshold, it indicates that the pen tip has basically no horizontal displacement relative to the paper surface, and thus the current frame image is in a static state in the horizontal direction. When the optical flow magnitude is greater than the threshold, it indicates that the current frame image is in a sliding state.
[0038] After determining that the current frame image is stationary in the horizontal direction (e.g., the x-direction), considering the need for accurate analysis of the vertical changes in the image caused by lifting or pressing the dictionary pen, this embodiment determines a designated region of the current frame. This designated region can be understood as the target region for subsequent vertical displacement analysis. The designated region can be determined based on a fixed position and size preset by the hardware field of view, or it can be dynamically determined based on image content features (e.g., detected text line regions). Considering that when the dictionary pen is lifted or pressed, it often forms a lever-like movement with the pen tip (corresponding to the left ROI region) as the fulcrum, the vertical displacement of the image content in the right ROI region, which is farther from the fulcrum, will be more significant and easier to detect. Therefore, this embodiment preferably uses the right ROI region of the current frame image as the designated region.
[0039] Furthermore, to capture vertical motion features more precisely, such as distinguishing between pure vertical translation and jitter with slight rotation, this embodiment divides the designated area into an upper sub-region and a lower sub-region. This division can be achieved by drawing a horizontal line at the vertical center of the designated area, dividing it in two; the portion above this line is the upper sub-region, and the portion below is the lower sub-region. Of course, the dividing line does not necessarily have to be strictly centered and can be slightly adjusted based on the typical position of the text line; the two sub-regions also do not have to be exactly equal in size. For example, the upper sub-region can occupy 40% of the height of the designated area, and the lower sub-region can occupy 60%. Figure 3 This is a schematic diagram of each sub-region in the right-hand ROI region provided by the present invention, as shown below. Figure 3 As shown, the area within the red box in the left image is the upper sub-region of the right ROI area, and the area within the red box in the right image is the lower sub-region of the right ROI area.
[0040] Step 130: Based on the vertical displacements of the upper and lower sub-regions, determine the transformation parameters used to correct the current frame image.
[0041] Specifically, the vertical displacement of the upper and lower sub-regions refers to the vertical movement of the image content within the upper and lower sub-regions of the current frame image relative to a reference base (e.g., the previous frame image as a stable reference or the first "anchor frame" image that has entered a horizontal static state). This displacement can be determined by the vertical displacement of feature points in each sub-region relative to the reference frame image (such as the previous frame image). For example, the average displacement of all feature points in each sub-region can be used as the vertical displacement of each sub-region.
[0042] The smaller the vertical displacement of the upper sub-region (e.g., a negative value or a small positive value close to zero), the more likely the image content in the upper sub-region is to move upwards relative to the reference frame. This is usually caused by the user's grip on the dictionary pen changing from a position perpendicular to the paper to a "pressing down" posture where the pen tip is away from the user and the pen end is close to the user. When this displacement is less than a displacement threshold (e.g., less than 0.2), the dictionary pen can be judged to be in a pressing down posture. Conversely, the larger the vertical displacement of the upper sub-region (e.g., a large positive value), the more likely the image content in the upper sub-region is to move downwards relative to the reference frame. This is usually caused by the user's grip on the dictionary pen changing from a position perpendicular to the paper to a "lifting up" posture where the pen tip is close to the user and the pen end is away from the user. When this displacement is greater than a displacement threshold (e.g., greater than 0.2), the dictionary pen can be judged to be in an lifting up posture.
[0043] Correspondingly, a larger vertical displacement of the lower sub-region (e.g., a large positive value) indicates that the image content in the lower sub-region tends to move downwards relative to the reference frame. This corresponds to the upward movement of the upper sub-region, further confirming that the dictionary pen is in a "pressing down" posture. When this displacement is greater than a displacement threshold (e.g., greater than 0.2), it can be determined that the dictionary pen is in a pressing down posture. Conversely, a smaller vertical displacement of the lower sub-region (e.g., a negative value or a small positive value close to zero) indicates that the image content in the lower sub-region tends to move upwards relative to the reference frame. This corresponds to the downward movement of the upper sub-region, further confirming that the dictionary pen is in an "lifting up" posture. When this displacement is less than a displacement threshold (e.g., less than 0.2), it can be determined that the dictionary pen is in an lifting up posture.
[0044] When a dictionary pen is in different positions, the text area that would normally be rectangular on the paper will appear as a trapezoidal distortion in the captured image. For example, when the dictionary pen is in a "pressing down" position, the image sensor is farther from the text above the paper and closer to the text below, causing the height of the upper text lines to be compressed and the height of the lower text lines to be stretched, resulting in an overall trapezoidal shape that is narrower at the top and wider at the bottom. Conversely, when the pen is in an "lifting up" position, it will appear as a trapezoidal shape that is wider at the top and narrower at the bottom.
[0045] Therefore, this embodiment can determine the posture of the dictionary pen based on the vertical displacements of the upper and lower sub-regions, respectively. Then, based on the dictionary pen's posture—either "pressing down" or "lifting up"—the appropriate perspective transformation correction model is selected. Using the calculated values of the upper and lower sub-region displacements, the parameters of the perspective transformation matrix are precisely solved to determine the transformation parameters. These transformation parameters refer to the parameters used for geometric transformation of the image. In this embodiment, the geometric transformation can be a perspective transformation, used to correct a trapezoidal image into a rectangular image. The perspective transformation parameters can be represented by a 3×3 matrix, or by matrices of other sizes; this embodiment does not specifically limit their representation.
[0046] Step 140: Apply the transformation parameters to correct the current frame image and generate the corrected image.
[0047] Specifically, a corrected image refers to an image that has undergone geometric transformation. Corrected images eliminate image distortion, making the image more square and the text lines more horizontal, thereby improving the accuracy of OCR recognition.
[0048] As an optional embodiment, the position of each pixel in the corrected image can be calculated first based on the transformation parameters; then, the pixel values can be filled using bilinear interpolation to generate the corrected image.
[0049] The image correction method provided in this embodiment divides a specified area of the image into upper and lower sub-regions under the premise that the image frame is in a horizontal static state. The correction transformation parameters are jointly determined by calculating the vertical displacement of these two sub-regions relative to a reference datum. Finally, these parameters are applied to perform geometric correction on the image, achieving precise compensation for vertical positional shifts caused by changes in the scanning device's posture during scanning. Because this embodiment triggers the correction logic in a horizontal static state, it accurately isolates the vertical displacement caused by changes in the scanning device's posture from the image displacement caused by normal horizontal scanning. This avoids introducing erroneous vertical correction during normal scanning (horizontal movement), ensuring the targeted and accurate nature of the correction, and ultimately improving the accuracy of subsequent optical character recognition (OCR).
[0050] Based on the above embodiments, transformation parameters for correcting the current frame image are determined based on the vertical displacements of the upper and lower sub-regions, including: The scanning posture of the scanning device is determined based on the vertical displacement of the upper and lower sub-regions respectively. Based on the scanning posture, determine the target smoothing angle of the current frame image; Determine the transformation parameters based on the target smoothing angle.
[0051] Specifically, scanning posture refers to the specific tilting state in which a user holds a dictionary pen relative to the paper surface, causing a change in image perspective. As mentioned earlier, typical postures include a "pressing-down posture" (the tip of the pen is away from the user, and the pen tip is close to the user) and an "lifting-up posture" (the tip of the pen is close to the user, and the pen tip is away from the user).
[0052] As an optional embodiment, when the vertical displacement of the upper sub-region is detected to be negative (moving upward) and the vertical displacement of the lower sub-region is detected to be positive (moving downward), the posture of the scanning device is determined to be a "pressing downward posture". When the vertical displacement of the upper sub-region is detected to be positive (moving downward) and the vertical displacement of the lower sub-region is detected to be negative (moving upward), the posture of the scanning device is determined to be an "lifting upward posture".
[0053] Furthermore, the target smoothing angle refers to an angle value obtained by smoothing the instantaneous tilt angle calculated from multiple consecutive frames of images. This angle aims to filter out abrupt angle changes caused by rapid fine-tuning of hand posture (high-frequency jitter) and retain the slow, continuous angle changes (low-frequency trend) of the user when scanning text lines, thus representing the true and stable orientation of the text lines on the paper.
[0054] As an optional embodiment, the instantaneous tilt angle θ_raw = arctan((Δy2 - Δy1) / L) caused by the pose tilt of the current frame image can be calculated based on the vertical displacement Δy1 of the upper sub-region, the vertical displacement Δy2 of the lower sub-region, and the known fixed distance L between the two sub-regions in the horizontal direction.
[0055] Then, the instantaneous tilt angle θ_raw is input into a smoothing filter. This filter can be a low-pass filter, such as an exponential moving average (EMA) filter. Its calculation formula is: θ_smooth_t = α × θ_raw_t + (1 - α) × θ_smooth_t-1, where θ_smooth_t is the target smoothing angle of the current frame image, θ_smooth_t-1 is the target smoothing angle of the previous frame image, and α is the smoothing coefficient (0 < α < 1).
[0056] During this process, the smoothing coefficient α can be dynamically adjusted based on the determined scanning posture. For example, when the posture is determined to be "pressing down" or "lifting up", the value of α can be appropriately increased to make the correction response more sensitive.
[0057] Furthermore, the transformation parameters refer to a set of parameters that can rotate the current frame image by an angle of (-θ_smooth_t) and may be combined with translation correction. The goal of this transformation is to adjust the text lines in the image to align with the stable direction represented by the target smooth angle, thereby eliminating the visual tilt caused by pose jitter.
[0058] As an optional embodiment, the target smoothing angle θ_smooth_t determined above can be substituted into a preset geometric transformation model to generate a transformation matrix and obtain transformation parameters.
[0059] This embodiment introduces the determination of scanning posture, calculates the target smoothing angle based on the posture, and then determines the final transformation parameters based on the target smoothing angle, thereby achieving more refined control over the image correction process. Because this method distinguishes between high-frequency posture jitter and low-frequency scanning trends, and uses smoothing filtering to determine the correction target, it avoids frequent and unnatural jumps in the corrected video stream caused by overreaction to instantaneous jitter. This results in a smoother and gentler correction process, higher quality output corrected images, and ultimately provides a more stable and reliable input for subsequent OCR recognition, further improving the overall recognition accuracy.
[0060] Based on any of the above embodiments, determining the scanning posture of the scanning device based on the vertical displacements of the upper and lower sub-regions includes: If the first vertical displacement of the upper sub-region is less than the first displacement threshold, or the second vertical displacement of the lower sub-region is greater than the second displacement threshold, the scanning posture is determined to be a downward pressing posture; the first displacement threshold is less than the second displacement threshold. If the first vertical displacement of the upper sub-region is greater than the second displacement threshold, or the second vertical displacement of the lower sub-region is less than the first displacement threshold, the scanning posture is determined to be an upward lifting posture.
[0061] Specifically, the first vertical displacement of the upper sub-region refers to the vertical distance moved by the upper sub-region of the current frame relative to the reference frame (such as the previous frame), denoted as Δy1. The second vertical displacement of the lower sub-region refers to the vertical distance moved by the lower sub-region of the current frame relative to the reference frame, denoted as Δy2. In this embodiment, the vertically downward direction in the image coordinate system can be defined as the positive direction of displacement. The first displacement threshold can be a negative real number, such as -0.2, and the second displacement threshold can be a positive real number, such as 0.2, where "-" is used to characterize the displacement direction, that is, the direction opposite to the preset positive direction (i.e., vertically downward), i.e., vertically upward.
[0062] When the first displacement is less than the first displacement threshold, it indicates that the image content in the upper sub-region has moved significantly upward relative to the reference frame (i.e., the displacement is negative). This movement is due to the scanning device (such as a dictionary pen) moving away from the user and the pen tip moving closer to the user, forming a "pressing down" posture. This causes the image content in the upper part of the sensor's field of view to shrink towards the image center or upward due to perspective effects. In this case, the scanning posture can be determined as a pressing down posture. When the second displacement is greater than the second displacement threshold, it indicates that the image content in the lower sub-region has moved significantly downward relative to the reference frame. This movement is also a typical characteristic of the "pressing down" posture. It is due to the pen tip being closer to the paper, causing the image content in the lower part of the sensor's field of view to expand outward or downward due to perspective effects. In this case, the scanning posture can also be determined as a pressing down posture.
[0063] When the first displacement is greater than the second displacement threshold, it indicates that the image content in the upper sub-region has moved significantly downward relative to the reference frame. This movement is due to the top of the scanning device moving closer to the user and the pen tip moving further away from the user, creating an "upward lifting" posture. This causes the image content in the upper part of the sensor's field of view to expand outward or downward due to perspective effects. In this case, the scanning posture can be determined as an upward lifting posture. When the second displacement is less than the first displacement threshold, it indicates that the image content in the lower sub-region has moved significantly upward relative to the reference frame (i.e., the displacement is negative). This movement trend is also a typical characteristic of the "upward lifting" posture. It is due to the pen tip moving further away from the paper, causing the image content in the lower part of the sensor's field of view to contract towards the image center or upward due to perspective effects. In this case, the scanning posture can also be determined as an upward lifting posture.
[0064] Furthermore, it should be noted that this embodiment can determine the scanning posture based on either the first or the second displacement, greatly enhancing the robustness of the detection. For example, when the upper half of the scanned text region has sparse texture, resulting in inaccurate calculation or a small value for Δy1, but the lower half has clear texture, and the calculated Δy2 is clearly greater than the second displacement threshold, the current scanning posture can be accurately determined based on the signal of Δy2.
[0065] This embodiment achieves more robust and sensitive judgment of scanning posture by setting judgment thresholds for the first and second displacements and using a logical "OR" combination condition to judge the "downward pressing posture" and the "upward lifting posture". Since this method does not require the simultaneous detection of typical relative motion in both upper and lower sub-regions, but only requires that the motion characteristics of one sub-region be sufficiently obvious, it effectively reduces the probability of missed or false judgments when the displacement calculation of a certain sub-region fails or is inaccurate due to insufficient texture of local image content, uneven illumination, or other factors. This significantly improves the success rate and reliability of posture detection, providing a solid foundation for subsequent accurate image correction.
[0066] Based on any of the above embodiments, determining the target smoothing angle of the current frame image includes: Based on the first displacement and the second displacement, determine the adjustment angle of the current frame image; When the scanning posture is a downward pressing posture, the target smoothing angle is determined based on the difference between the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the first preset smoothing angle; the reference frame image is a historical frame image of the current frame image. When the scanning posture is an upward lifting posture, the target smoothing angle is determined based on the sum of the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the second preset smoothing angle.
[0067] Specifically, the adjustment angle can be understood as an adjustment amount calculated based on the first and second displacements of the current frame to quantify the instantaneous jitter or tilt of the current frame image. Since the first displacement represents the instantaneous vertical movement of the upper sub-region and the second displacement represents the instantaneous vertical movement of the lower sub-region, combining the two can comprehensively evaluate the overall vertical jitter or tilt of the current frame image to obtain the adjustment angle.
[0068] The adjustment angle can be calculated based on the following formula: adjust=0.6×abs(move1+move2) / 2 Here, adjust means to adjust the angle, move1 means the first displacement, and move2 means the second displacement.
[0069] When the scanning posture is a downward pressing posture, considering that the "downward pressing" posture is usually an unconscious hand tremor that needs to be suppressed, which will cause the image to tilt unnecessarily, it is necessary to reverse the angle (i.e. reduce the angle value) to restore the image to a stable state. At this time, it is necessary to combine the difference between the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the first preset smoothing angle to determine the target smoothing angle.
[0070] The reference frame image is a historical frame image of the current frame image. It can be the previous frame image immediately preceding the current frame, a key frame image in the historical frame sequence, or the average state of multiple historical frames. The smoothing angle of the reference frame image refers to the target smoothing angle calculated and finally determined when processing the reference frame. The first preset smoothing angle is a preset lower limit value used to define the minimum tilt angle when the device is working normally. The purpose of determining the target smoothing angle in combination with the first preset smoothing angle is to provide a bottom line for correction, preventing the angle from becoming unrealistically small due to overcorrection, thereby ensuring the stability and rationality of the correction result. The first preset smoothing angle can be set according to the actual situation, such as 30°.
[0071] Alternatively, when the scanning posture is a downward pressing posture, the target smoothing angle can be determined based on the following formula: resAngle = max(base - 0.6×abs(move1+move2) / 2, 30) Where resAngle is the target smoothing angle, base is the smoothing angle of the reference frame image, and the first preset smoothing angle is 30°.
[0072] When the scanning posture is an upward tilt, considering that the "upward tilt" posture may include some intentional adjustments by the user, the system needs to respond to this (i.e., the gain angle value). However, it is also necessary to prevent the angle from becoming too large and exceeding the normal operating range. At this time, it is necessary to combine the sum of the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the second preset smoothing angle, to determine the target smoothing angle. The second preset smoothing angle is a preset upper limit value for the angle, used to define the maximum tilt angle when the device is working normally. The purpose of determining the target smoothing angle in combination with the second preset smoothing angle is to provide a top line for correction, avoiding the angle from continuously increasing beyond the reasonable physical range, and ensuring the convergence and robustness of the correction system. The second preset smoothing angle can be set according to the actual situation, such as 90°.
[0073] Alternatively, when the scanning posture is an upward tilt, the target smoothing angle can be determined based on the following formula: resAngle = min(base + 0.6×abs(move1+move2) / 2, 90) Where resAngle is the target smoothing angle, base is the smoothing angle of the reference frame image, and the second preset smoothing angle is 90°.
[0074] As can be seen from the calculation formulas of the two target smoothing angles above, the first preset smoothing angle is 30° and the second preset smoothing angle is 90°. This allows the target smoothing angle to be controlled between 30° and 90°, ensuring that the corrected angle is always within a reasonable range that conforms to the working characteristics of the equipment, and preventing large deviations caused by calculation fluctuations.
[0075] If the scanning posture is neither a downward pressing posture nor an upward lifting posture, it indicates that the tilt angle of the dictionary pen is small. In this case, the target smoothing angle of the current frame image can be set to the smoothing angle of the previous frame image.
[0076] Based on any of the above embodiments, determining the transformation parameters according to the target smoothing angle includes: From multiple candidate smoothing angles, determine two candidate smoothing angles that are numerically adjacent to the target smoothing angle; Based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles, determine the perspective transformation point coordinates corresponding to the target smoothing angle. The transformation parameters are determined based on the coordinates of the perspective transformation point corresponding to the target smoothing angle.
[0077] Specifically, a mapping relationship can be pre-constructed to characterize the relationship between candidate smoothing angles and perspective transformation point coordinates. That is, this mapping relationship corresponds to multiple candidate smoothing angles, and the perspective transformation point coordinates corresponding to each candidate smoothing angle are pre-calibrated. Based on this, if the target smoothing angle cannot precisely match any candidate smoothing angle in the mapping relationship, its corresponding perspective transformation point coordinates can be determined through linear interpolation. The perspective transformation point coordinates can be understood as defining a set of vertex coordinates of a quadrilateral representing the region of the source image to be corrected. For a rectangular image region, the perspective transformation point coordinates are a set (usually four) defining the vertex coordinates of the region to be corrected in the original image. The quadrilateral formed by these four points will be "stretched" into a standard rectangular image by subsequent perspective transformation operations. For example, the perspective transformation point coordinates may include p1(x1, y1), p2(x1, y2), p3(x2, y3), and p4(x2, y4).
[0078] Specifically, firstly, two candidate smoothing angles that are numerically adjacent to the target smoothing angle are determined from a pool of candidate smoothing angles. For example, if the candidate smoothing angles corresponding to the mapping relationship include 15°, 30°, 45°, 60°, 75°, and 90°, and the target smoothing angle is 32°, then the two corresponding candidate smoothing angles are 30° and 45°. Next, based on the two candidate smoothing angles determined in the previous step, the coordinates of the perspective transformation point corresponding to the target smoothing angle between them are calculated using interpolation. Finally, based on the coordinates of the perspective transformation point corresponding to the target smoothing angle and the coordinates of the expected perspective transformation point after correction, the corresponding perspective transformation matrix is calculated to obtain the final transformation parameters.
[0079] in, Figure 4 This is a schematic diagram of a frame image obtained when the dictionary pen is tilted at 30° according to the present invention, as shown in the figure. Figure 4 As shown, the regions in the current frame image that need to be corrected are four vertices p1(x1, y1), p2(x1, y2), p3(x2, y3), and p4(x2, y4). After correction, the expected coordinates of these four vertices are p1'(x1, y1), p2'(x1, y2), p3'(x2, y1), and p4'(x2, y2), in order to accurately correct the trapezoidal distortion caused by tilted shooting and restore the image content to a square and horizontal normal shape.
[0080] Based on any of the above embodiments, determining the perspective transformation point coordinates corresponding to the target smoothing angle based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles includes: The interpolation ratio is determined based on the relative position of the target smoothing angle within the interval formed by the two candidate smoothing angles. Based on the interpolation ratio, the coordinates of the perspective transformation points corresponding to the two candidate smoothing angles are weighted and summed to obtain the coordinates of the perspective transformation points corresponding to the target smoothing angle.
[0081] Specifically, the interpolation ratio refers to the normalized position of the target smoothing angle within the numerical interval formed by the two candidate smoothing angles. It is used to characterize the relative distance between the target smoothing angle and the starting point of the interval, and its value range is usually [0,1]. The interpolation ratio can be calculated by the following formula: Interpolation ratio = (Target smoothing angle - First candidate smoothing angle) / (Second candidate smoothing angle - First candidate smoothing angle).
[0082] After obtaining the interpolation ratio, the interpolation ratio is used as a weight to perform a weighted summation on the two candidate smoothing angles, thereby obtaining the precise coordinates corresponding to the target smoothing angle. Among them, the candidate smoothing angle that is closer to the target smoothing angle has a greater weight corresponding to its coordinates.
[0083] The perspective transformation point coordinates corresponding to the target smoothing angle can be determined based on the following formula: Target coordinates = (1 - interpolation ratio) × first candidate coordinates + interpolation ratio × second candidate coordinates. Here, the target coordinates are the perspective transformation point coordinates corresponding to the target smoothing angle, the first candidate coordinates are the perspective transformation point coordinates corresponding to the first candidate smoothing angle, and the second candidate coordinates are the perspective transformation point coordinates corresponding to the second candidate smoothing angle.
[0084] Based on any of the above embodiments, the current frame image is obtained, and then the process further includes: Determine the horizontal displacement of a specified region on the left side of the current frame image; If the horizontal displacement is less than a threshold, the current frame image is determined to be stationary in the horizontal direction.
[0085] Specifically, the designated left region refers to a predefined sub-region within the current frame image, typically located on the left side of the image acquisition window. The left region is preferred because, as the user scans text from left to right, this region corresponds to the new content about to enter the core scanning area. These newly entering text features are usually clearer and more textured, facilitating stable and accurate motion estimation. The size and specific location of this region can be set based on the dictionary pen's optical sensor field of view (FOV) and optimal imaging area. For example, it can be defined as a vertically centered rectangular region on the left side of the image, ranging from 1 / 8 to 3 / 8 of its width. The designated left region can be the left-side Region of Interest (ROI).
[0086] The horizontal displacement of the specified left region can be the horizontal displacement of the specified left region in the current frame image relative to the reference frame image. This displacement can be measured by the horizontal displacement of each feature point in the specified left region. For example, the average displacement of all feature points can be used as the horizontal displacement of the specified left region.
[0087] If the horizontal displacement of the specified area on the left is less than the threshold, it indicates that the dictionary pen has not undergone significant macroscopic displacement in the horizontal direction, meaning that the current frame image is stationary in the horizontal direction.
[0088] This embodiment achieves a rapid and accurate determination of whether the device is in a horizontal scanning motion state by monitoring the horizontal displacement of a "specified area on the left side of the image" and comparing it with a threshold. Because this method selects a newly entered, clearly defined left-side region for motion estimation, it improves the reliability of displacement calculation and reduces computational load by calculating only one sub-region. Simultaneously, by setting a reasonable tolerance threshold, noise and meaningless micro-jitter are effectively filtered out, ensuring that the subsequent vertical jitter correction algorithm is only activated when it is truly needed in a "horizontally stationary" state. This avoids erroneous corrections during high-speed scanning and significantly improves the intelligence and robustness of the entire image correction system.
[0089] Based on any of the above embodiments, the current frame image is corrected by applying transformation parameters to generate a corrected image, and then the process further includes: The corrected image is displayed on the screen of the scanning device.
[0090] Specifically, the display screen is the physical screen on the scanning device used for human-computer interaction. As devices such as dictionary pens have increasingly higher screen-to-body ratios, and some even have the entire front surface as a display screen, setting up a physical viewing window has become impractical.
[0091] Therefore, this embodiment sets up an electronic viewing window on the display screen to display the content captured and corrected by the camera in real time, as an alternative to the physical viewing window. The electronic viewing window is a logical display area on the display screen, and its specific form can be flexible and varied. For example, the electronic viewing window can be the entire display area of the display screen; or, in order to display other information at the same time (such as translation results, battery level, etc.), the electronic viewing window can also be a partial display area of the display screen. This partial display area can be a segmented screen area (such as the upper 1 / 3 area of the screen), or a draggable floating window. This embodiment does not specifically limit this. Preferably, in order to simulate the usage habits of a traditional physical viewing window, the electronic viewing window (especially when it is a partial display area) is set on the end of the display screen near the tip of the dictionary pen.
[0092] Based on any of the above embodiments Figure 5 This is a flowchart illustrating another image correction method provided by the present invention, as shown below. Figure 5 As shown, the method includes: First, the current frame image and the reference frame image are processed by grayscale conversion and Gaussian filtering. The reference frame image is a historical frame image of the current frame image.
[0093] Next, feature point detection is performed on the left ROI region of the current frame image. Based on the horizontal displacement of the detected feature points relative to the reference frame image, it is determined whether the current frame image is stationary in the horizontal direction. If the displacement is less than a threshold, the current frame image is stationary in the horizontal direction; otherwise, the current frame image is sliding in the horizontal direction.
[0094] When the current frame image is stationary in the horizontal direction, the right-side ROI region of the current frame image is divided into an upper sub-region and a lower sub-region, and feature point detection is performed on the upper and lower sub-regions respectively. Based on the vertical displacement of the detected feature points in the upper and lower sub-regions relative to the reference frame image, the first vertical displacement move1 of the upper sub-region and the second vertical displacement move2 of the lower sub-region are determined.
[0095] If move1 < -0.2 or move2 > 0.2, it indicates that the dictionary pen is in a downward pressing posture. At this time, the adjustment angle is adjust = 0.6 × abs(move1 + move2) / 2, and the target smoothing angle of the current frame image is resAngle = max(base - adjust, 30), where base is the smoothing angle of the reference frame image.
[0096] If move1>0.2 or move2<-0.2, it indicates that the dictionary pen is in an upward lifting posture. At this time, the adjustment angle is adjust=0.6×abs(move1+move2) / 2, and the target smoothing angle of the current frame image is resAngle=min(base+adjust,90), where base is the smoothing angle of the reference frame image.
[0097] If neither move1 nor move2 meets the above conditions, it indicates that the tilt angle of the dictionary pen changes little. In this case, the smoothing angle of the reference frame image is directly used as the target smoothing angle of the current frame image.
[0098] Next, the coordinates of the perspective transformation point corresponding to the target smoothing angle are determined. Finally, the current frame image is corrected based on the coordinates of the perspective transformation point corresponding to the target smoothing angle.
[0099] in, Figure 6 This is a schematic diagram of the image correction effect provided by the present invention, such as... Figure 6 As shown, the left side is the current frame image taken when the dictionary pen is tilted, and the right side is the corrected current frame image.
[0100] The image correction apparatus provided by the present invention will be described below. The image correction apparatus described below can be referred to in correspondence with the image correction method described above.
[0101] Based on any of the above embodiments Figure 7 This is a schematic diagram of the image correction device provided by the present invention, as shown below. Figure 7 As shown, the device includes: Acquisition unit 710 is used to acquire the current frame image; The partitioning unit 720 is used to divide a specified area of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction. The determining unit 730 is used to determine the transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region, respectively. The correction unit 740 is used to apply transformation parameters to correct the current frame image and generate a corrected image.
[0102] Based on any of the above embodiments, transformation parameters for correcting the current frame image are determined based on the vertical displacements of the upper and lower sub-regions, including: The scanning posture of the scanning device is determined based on the vertical displacement of the upper and lower sub-regions respectively. Based on the scanning posture, determine the target smoothing angle of the current frame image; Determine the transformation parameters based on the target smoothing angle.
[0103] Based on any of the above embodiments, determining the scanning posture of the scanning device based on the vertical displacements of the upper and lower sub-regions includes: If the first vertical displacement of the upper sub-region is less than the first displacement threshold, or the second vertical displacement of the lower sub-region is greater than the second displacement threshold, the scanning posture is determined to be a downward pressing posture; the first displacement threshold is less than the second displacement threshold. If the first vertical displacement of the upper sub-region is greater than the second displacement threshold, or the second vertical displacement of the lower sub-region is less than the first displacement threshold, the scanning posture is determined to be an upward lifting posture.
[0104] Based on any of the above embodiments, determining the target smoothing angle of the current frame image based on the scanning posture includes: Based on the first displacement and the second displacement, determine the adjustment angle of the current frame image; When the scanning posture is a downward pressing posture, the target smoothing angle is determined based on the difference between the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the first preset smoothing angle; the reference frame image is a historical frame image of the current frame image. When the scanning posture is an upward lifting posture, the target smoothing angle is determined based on the sum of the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the second preset smoothing angle.
[0105] Based on any of the above embodiments, determining the transformation parameters according to the target smoothing angle includes: From multiple candidate smoothing angles, determine two candidate smoothing angles that are numerically adjacent to the target smoothing angle; Based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles, determine the perspective transformation point coordinates corresponding to the target smoothing angle. The transformation parameters are determined based on the coordinates of the perspective transformation point corresponding to the target smoothing angle.
[0106] Based on any of the above embodiments, determining the perspective transformation point coordinates corresponding to the target smoothing angle based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles includes: The interpolation ratio is determined based on the relative position of the target smoothing angle within the interval formed by the two candidate smoothing angles. Based on the interpolation ratio, the coordinates of the perspective transformation points corresponding to the two candidate smoothing angles are weighted and summed to obtain the coordinates of the perspective transformation points corresponding to the target smoothing angle.
[0107] Based on any of the above embodiments, the current frame image is obtained, and then the process further includes: Determine the horizontal displacement of a specified region on the left side of the current frame image; If the horizontal displacement is less than a threshold, the current frame image is determined to be stationary in the horizontal direction.
[0108] Based on any of the above embodiments, the current frame image is corrected by applying transformation parameters to generate a corrected image, and then the corrected image is displayed on the display screen of the scanning device.
[0109] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 8As shown, the electronic device may include a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute an image correction method, which includes: acquiring a current frame image; dividing a designated region of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction; determining transformation parameters for correcting the current frame image based on the vertical displacements of the upper and lower sub-regions; and applying the transformation parameters to correct the current frame image to generate a corrected image.
[0110] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0111] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the image correction method provided by the above methods. The method includes: acquiring a current frame image; dividing a designated region of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction; determining transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region; and applying the transformation parameters to correct the current frame image to generate a corrected image.
[0112] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the image correction method provided by the above methods. The method includes: acquiring a current frame image; dividing a designated region of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction; determining transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region, respectively; and applying the transformation parameters to correct the current frame image to generate a corrected image.
[0113] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image correction method, characterized in that, include: Get the current frame image; When the current frame image is stationary in the horizontal direction, a designated area of the current frame image is divided into an upper sub-region and a lower sub-region. Based on the vertical displacements of the upper sub-region and the lower sub-region, respectively, transformation parameters for correcting the current frame image are determined. The current frame image is corrected using the transformation parameters to generate a corrected image.
2. The image correction method according to claim 1, characterized in that, The step of determining the transformation parameters for correcting the current frame image based on the vertical displacements of the upper and lower sub-regions includes: The scanning posture of the scanning device is determined based on the vertical displacements of the upper sub-region and the lower sub-region, respectively. Based on the scanning posture, the target smoothing angle of the current frame image is determined; The transformation parameters are determined based on the target smoothing angle.
3. The image correction method according to claim 2, characterized in that, Determining the scanning posture of the scanning device based on the vertical displacements of the upper and lower sub-regions includes: If the first displacement of the upper sub-region in the vertical direction is less than a first displacement threshold, or the second displacement of the lower sub-region in the vertical direction is greater than a second displacement threshold, the scanning posture is determined to be a downward pressing posture; the first displacement threshold is less than the second displacement threshold. If the first displacement of the upper sub-region in the vertical direction is greater than the second displacement threshold, or the second displacement of the lower sub-region in the vertical direction is less than the first displacement threshold, the scanning posture is determined to be an upward lifting posture.
4. The image correction method according to claim 3, characterized in that, Determining the target smoothing angle of the current frame image based on the scanning posture includes: Based on the first displacement and the second displacement, the adjustment angle of the current frame image is determined; When the scanning posture is a downward pressing posture, the target smoothing angle is determined based on the difference between the smoothing angle of the reference frame image and the adjustment angle of the current frame image, and a first preset smoothing angle; the reference frame image is a historical frame image of the current frame image; When the scanning posture is an upward lifting posture, the target smoothing angle is determined based on the sum of the smoothing angle of the reference frame image and the adjustment angle of the current frame image, as well as the second preset smoothing angle.
5. The image correction method according to claim 2, characterized in that, Determining the transformation parameters based on the target smoothing angle includes: From a plurality of candidate smoothing angles, determine two candidate smoothing angles that are numerically adjacent to the target smoothing angle; Based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles, the perspective transformation point coordinates corresponding to the target smoothing angle are determined. The transformation parameters are determined based on the coordinates of the perspective transformation point corresponding to the target smoothing angle.
6. The image correction method according to claim 5, characterized in that, The step of determining the perspective transformation point coordinates corresponding to the target smoothing angle based on the perspective transformation point coordinates corresponding to the two candidate smoothing angles includes: The interpolation ratio is determined based on the relative position of the target smoothing angle within the interval formed by the two candidate smoothing angles. Based on the interpolation ratio, the perspective transformation point coordinates corresponding to the two candidate smoothing angles are weighted and summed to obtain the perspective transformation point coordinates corresponding to the target smoothing angle.
7. The image correction method according to any one of claims 1 to 6, characterized in that, The process of obtaining the current frame image further includes: Determine the displacement of a specified region on the left side of the current frame image in the horizontal direction; If the displacement in the horizontal direction is less than a threshold, the current frame image is determined to be stationary in the horizontal direction.
8. The image correction method according to any one of claims 1 to 6, characterized in that, The process of applying the transformation parameters to correct the current frame image and generating a corrected image further includes displaying the corrected image on the display screen of the scanning device.
9. An image correction device, characterized in that, include: The acquisition unit is used to acquire the image of the current frame; A segmentation unit is used to divide a specified region of the current frame image into an upper sub-region and a lower sub-region when the current frame image is stationary in the horizontal direction. The determining unit is used to determine the transformation parameters for correcting the current frame image based on the vertical displacements of the upper sub-region and the lower sub-region, respectively. The correction unit is used to apply the transformation parameters to correct the current frame image and generate a corrected image.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the image correction method as described in any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the image correction method as described in any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the image correction method as described in any one of claims 1 to 8.