Image tilt correction method, device, medium and equipment

By inputting the water meter image into the object detection model to obtain the center point prediction coordinates and calculate the tilt angle for rotation correction, the problem of complex image tilt correction and high computing resources in the prior art is solved, and efficient and accurate image tilt correction is achieved .

CN117541769BActive Publication Date: 2025-02-14GUANGDONG UNIV OF PETROCHEMICAL TECH +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311682257.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-08
Publication Date
2025-02-14
Estimated Expiration
2043-12-08

AI Technical Summary

Technical Problem

The existing image tilt correction methods require complex image preprocessing and a large number of computing resources, and the parameter adjustment is cumbersome, making it difficult to adapt to the characteristics of different pictures.

Method used

By acquiring the water meter image and inputting it into a pre-configured object detection model, several center point prediction coordinates are obtained, the slope is calculated from these coordinates to determine the inclination angle, and corresponding rotation correction is performed.

Benefits of technology

No image preprocessing is required, reducing computational complexity, reducing parameter adjustment, and improving versatility and efficiency, especially when processing large amounts of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117541769B_ABST
    Figure CN117541769B_ABST
Patent Text Reader

Abstract

The present invention discloses an image tilt correction method, device, medium and equipment, the method comprising: acquiring a water meter image; inputting the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image; and performing tilt correction on the water meter image according to the number of center point prediction coordinates, thereby eliminating the need for image preprocessing, reducing computational complexity, and eliminating the need for frequent parameter adjustment, with strong versatility and therefore higher efficiency in situations where the amount of data is large.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to an image tilt correction method, device, medium and equipment. Background Art

[0002] Existing tilt correction methods usually require complex image preprocessing, and then use Hough transform to detect the straight lines in the picture to determine the tilted straight lines of the picture, and finally achieve tilt correction by rotating the picture. However, this tilt correction method usually requires a large amount of calculation in the image preprocessing stage, and using Hough transform for straight line detection often takes a lot of time to adjust parameters. In addition, since different pictures have different characteristics, one set of parameters cannot meet the correction requirements of all pictures, so it is often necessary to adjust many sets of parameters to fully achieve the correction of all pictures. This will take a lot of time and effort when processing large amounts of data. Summary of the invention

[0003] In order to solve the above technical problems, the embodiments of the present invention propose an image tilt correction method, device, medium and equipment, which can perform efficient and accurate tilt correction on water meter images without image preprocessing.

[0004] In order to achieve the above object, an embodiment of the present invention provides an image tilt correction method, comprising:

[0005] Get water meter image;

[0006] Input the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image;

[0007] The water surface image is tilt-corrected according to the predicted coordinates of the plurality of center points.

[0008] Furthermore, the step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes:

[0009] Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image;

[0010] Determining a rotation angle of the water meter image according to the tilt angle;

[0011] The water meter image is rotated according to the rotation angle.

[0012] Furthermore, the target detection model is determined by the following steps:

[0013] Acquire a data set related to the water meter image, and divide the data set into a training set, a validation set, and a test set according to a preset ratio;

[0014] The training set and the validation set are labeled; wherein each image in the labeled training set and the validation set has a true labeled result and a plurality of bounding boxes of equal size, and the center points of the plurality of bounding boxes are located on the same straight line;

[0015] Using the labeled training set, the preset neural network model is iteratively trained through the back propagation algorithm until the preset stop training condition is met, then the iterative training is stopped to obtain a trained neural network model;

[0016] The neural network model obtained after each iterative training is verified using the annotated verification set, and the best model weight file with the best verification result is stored, and the target detection model is obtained according to the configuration of the best model weight file.

[0017] Furthermore, the preset training stop condition includes at least one of the following:

[0018] The number of iterative training reaches the preset iteration number threshold;

[0019] Determine the convergence of the neural network model during the iterative training process.

[0020] Furthermore, determining the convergence of the neural network model during the iterative training process includes the following steps:

[0021] Input each image in the labeled training set into the neural network model obtained from the previous training to obtain the current calculation result of each image in the labeled training set;

[0022] Compare the current calculated result of each image with the true result to determine the current loss value of each image;

[0023] According to the loss value of each current image, it is determined whether the neural network model obtained by the previous training has converged.

[0024] Furthermore, the rotation angle θ ′ Determined by the following formula:

[0025]

[0026] Wherein, θ is the tilt angle.

[0027] The embodiment of the present invention further provides an image tilt correction device, comprising:

[0028] An image acquisition module, used for acquiring water meter images;

[0029] A center point prediction module, used for inputting the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image;

[0030] The tilt correction module is used to perform tilt correction on the water meter image according to the predicted coordinates of the plurality of center points.

[0031] Furthermore, the step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes:

[0032] Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image;

[0033] Determining a rotation angle of the water meter image according to the tilt angle;

[0034] The water meter image is rotated according to the rotation angle.

[0035] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned image tilt correction methods are implemented.

[0036] An embodiment of the present invention further provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the steps of any of the above-mentioned image tilt correction methods when executing the computer program.

[0037] In summary, the present invention has the following beneficial effects:

[0038] According to the embodiment of the present invention, a water meter image is acquired; the water meter image is input into a preconfigured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image; and the water meter image is tilt corrected according to the number of center point prediction coordinates. This eliminates the need for image preprocessing, reduces computational complexity, and eliminates the need for frequent parameter adjustments. The system has strong versatility and is therefore more efficient when the amount of data is large. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flow chart of an embodiment of an image tilt correction method provided by the present invention;

[0040] Figure 2It is a structural schematic diagram of an embodiment of an image tilt correction device provided by the present invention;

[0041] Figure 3 is a structural schematic diagram of an embodiment of a computer device provided by the present invention;

[0042] Figure 4 is a schematic diagram of an embodiment of a water meter image provided by the present invention;

[0043] Figure 5 It is a schematic diagram of an embodiment of image tilt correction based on Hough transform provided by the present invention;

[0044] Figure 6 is a schematic diagram of an embodiment of a water meter image before image tilt correction provided by the present invention;

[0045] Figure 7 It is a schematic diagram of an embodiment of a water meter image after image tilt correction provided by the present invention. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] In the description of this application, the terms "first", "second", "third", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", "third", etc. may explicitly or implicitly include one or more of the feature. In the description of this application, unless otherwise specified, "plurality" means two or more.

[0048] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0049] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as those commonly understood by those skilled in the art. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood by specific circumstances.

[0050] See also Figure 1 , is a flow chart of an embodiment of the image tilt correction method provided by the present invention, the method includes steps S1-S3, which are as follows:

[0051] S1, obtain water meter image;

[0052] S2, inputting the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image;

[0053] S3, performing tilt correction on the water surface image according to the predicted coordinates of the plurality of center points.

[0054] See also Figure 4 , a water meter image usually contains several characters, wherein the characters are water meter reading characters, and the center points of the rectangular areas occupied by each water meter reading character are located on the same straight line. It can be understood that the embodiment of the present invention predicts the center point coordinates of each character for the water meter image, thereby determining the position of each character.

[0055] It should be noted that each of the center point prediction coordinates is the coordinate of the center point of the detection box where the corresponding character is located.

[0056] In an optional embodiment, the step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes:

[0057] Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image;

[0058] Determining a rotation angle of the water meter image according to the tilt angle;

[0059] The water meter image is rotated according to the rotation angle.

[0060] Specifically, the slope k is calculated and the inclination angle θ is determined by the following formula:

[0061]

[0062] θ=arctan(k)

[0063] Among them, x2 and x1 are the horizontal coordinates of the arbitrary two points, and y2 and y1 are the vertical coordinates of the arbitrary two points.

[0064] It can be understood that by randomly selecting two center points and connecting them, a straight line is obtained. This straight line represents the tilt direction and angle of the character area in the image. By analyzing the slope and angle of the straight line, the overall tilt angle of the image can be determined. This tilt angle is the key to subsequent image correction.

[0065] In an optional embodiment, the target detection model is determined by the following steps:

[0066] Acquire a data set related to the water meter image, and divide the data set into a training set, a validation set, and a test set according to a preset ratio;

[0067] The training set and the validation set are labeled; wherein each image in the labeled training set and the validation set has a true labeled result and a plurality of bounding boxes of equal size, and the center points of the plurality of bounding boxes are located on the same straight line;

[0068] Using the labeled training set, the preset neural network model is iteratively trained through the back propagation algorithm until the preset stop training condition is met, then the iterative training is stopped to obtain a trained neural network model;

[0069] The neural network model obtained after each iterative training is verified using the annotated verification set, and the best model weight file with the best verification result is stored, and the target detection model is obtained according to the configuration of the best model weight file.

[0070] In the specific implementation, labeling the image is a prerequisite for using the target detection model and an important step to improve the performance of the algorithm. The embodiment of the present invention uses the LabelImg tool to manually label the data set. The tool can be downloaded directly in the computer control panel using the pip install labelimg command, and then directly enter labelimg in the control panel to activate it; it is an open source tool for image annotation, supporting multiple annotation formats such as ASCAL VOC, YOLO and Create ML (this example uses the YOLO format to annotate the image), which can help users create and edit annotation boxes on the image for tasks such as target detection and image segmentation. Usually, the data set is divided into a training set, a validation set and a test set according to a preset ratio of 6:1:3, where the training set and the validation set need to be annotated. In the process of annotation, the size of each bounding box should be ensured to be equal as much as possible, and their center points should be on a straight line. It should be understood that the annotation method of the embodiment of the present invention can make the annotated image present a horizontal straight line or have a clear sense of steps, which is conducive to the subsequent determination of the inclined straight line of the image.

[0071] It is understandable that model training is to use a neural network to optimize the parameters of the model using annotated data sets, thereby improving the accuracy of the model in classification, recognition or prediction of new data. Through training, the model gradually learns the features and patterns in the data and has the ability to handle real-world scenarios. Model training can not only improve the accuracy and robustness of the model, but also optimize computational efficiency and accelerate the reasoning speed of the model on new data. In general, model training is to make the model better adapt to practical applications and show higher performance on unseen data. In addition, model verification and model training are carried out simultaneously and are also an automated process. The model will output a result for each round of training, and then this result will be applied to the validation set data, and the performance of the model will be evaluated through various evaluation indicators such as accuracy, precision, recall, etc. After the training is completed, the weight file of the round with the best evaluation index in the training will be automatically saved. Due to the instability of deep learning, the embodiment of the present invention can be trained multiple times, and the weight file of the best experimental result of the model on the validation set will be retained.

[0072] In an optional embodiment, the preset training stop condition includes at least one of the following:

[0073] The number of iterative training reaches the preset iteration number threshold;

[0074] Determine the convergence of the neural network model during the iterative training process.

[0075] In an optional embodiment, determining the convergence of the neural network model during the iterative training process includes the following steps:

[0076] Input each image in the labeled training set into the neural network model obtained from the previous training to obtain the current calculation result of each image in the labeled training set;

[0077] Compare the current calculated result of each image with the true result to determine the current loss value of each image;

[0078] According to the loss value of each current image, it is determined whether the neural network model obtained by the previous training has converged.

[0079] In an optional embodiment, the rotation angle θ ′ Determined by the following formula:

[0080]

[0081] Wherein, θ is the tilt angle.

[0082] Specifically, to ensure that the rotation angle is between -45 degrees and 45 degrees, the embodiment of the present invention performs the following processing: if the rotation angle is greater than 45 degrees, 90 degrees are subtracted to convert it into a counterclockwise rotation angle; if the rotation angle is less than -45 degrees, 90 degrees are added to convert it into a clockwise rotation angle. Through these processing methods, it is ensured that the image is in a horizontal position after correction.

[0083] It is understandable that the beneficial effects of the embodiments of the present invention relative to the prior art are illustrated below through Table 1, specifically: 1070 water meter images taken are collected to form a data set, and the images are randomly divided into a training set, a validation set, and a test set in a ratio of 6:1:3, accounting for 640, 110, and 320 images, respectively. In order to build an accurate detector, the YOLOv5 target detection model is selected to be trained according to the method provided in the embodiment of the present invention. In the final experiment, the existing tilt correction method based on Hough transform is selected for comparison. And the final experimental effect is evaluated in the test set. Through these comparisons, the performance of the embodiment of the present invention in tilt correction of water meter images can be fully understood. The experimental results are shown in Table 1, where the indicators are correction success (T), correction failure (F), and accuracy (P).

[0084] Method T F P(%) Hough 300 20 93.70 Ours 320 0 100.00

[0085] Table 1

[0086] It can be seen from Table 1 that the correction accuracy of the embodiment of the present invention on the 320 test sets reaches 100%, which is 6.30% higher than the existing tilt correction method based on Hough transform.

[0087] Understandably, it is also possible to Figure 5-Figure 7 To illustrate the beneficial effects of the embodiments of the present invention compared with the prior art, specifically:

[0088] Figure 5 The following figure shows some results of tilt correction errors based on the Hough transform method. The upper and lower pictures are a group. Figure 5 Group (a) shows images that cannot be corrected by the Hough transform method. Figure 5 Group (b) shows images with excessive correction. Figure 5 Group (c) shows images where the correction amplitude is too small. Figure 5 Group (d) shows images that could not be corrected due to complex linear factors in the images.

[0089] Figure 6-Figure 7 The same batch of pictures are subjected to the image tilt correction provided by the embodiment of the present invention, wherein: Figure 6 To determine the tilted straight line of each image, it can be seen that each image can correctly locate a straight line that can represent the tilt direction and angle of the entire image. Figure 7 This indicates the final correction result. It can be seen that the tilt correction is successfully completed for each image.

[0090] Correspondingly, an embodiment of the present invention further provides an image tilt correction device, which can implement all processes of the image tilt correction method provided in the above embodiment.

[0091] See also Figure 2 , is a schematic structural diagram of an embodiment of an image tilt correction device provided by the present invention, comprising:

[0092] An image acquisition module 101 is used to acquire a water meter image;

[0093] The center point prediction module 102 is used to input the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond to a number of characters in the water meter image one by one;

[0094] The tilt correction module 103 is used to perform tilt correction on the water meter image according to the predicted coordinates of the plurality of center points.

[0095] In an optional embodiment, the step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes:

[0096] Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image;

[0097] Determining a rotation angle of the water meter image according to the tilt angle;

[0098] The water meter image is rotated according to the rotation angle.

[0099] In an optional embodiment, the target detection model is determined by the following steps:

[0100] Acquire a data set related to the water meter image, and divide the data set into a training set, a validation set, and a test set according to a preset ratio;

[0101] The training set and the validation set are labeled; wherein each image in the labeled training set and the validation set has a true labeled result and a plurality of bounding boxes of equal size, and the center points of the plurality of bounding boxes are located on the same straight line;

[0102] Using the labeled training set, the preset neural network model is iteratively trained through the back propagation algorithm until the preset stop training condition is met, then the iterative training is stopped to obtain a trained neural network model;

[0103] The neural network model obtained after each iterative training is verified using the annotated verification set, and the best model weight file with the best verification result is stored, and the target detection model is obtained according to the configuration of the best model weight file.

[0104] In an optional embodiment, the preset training stop condition includes at least one of the following:

[0105] The number of iterative training reaches the preset iteration number threshold;

[0106] Determine the convergence of the neural network model during the iterative training process.

[0107] In an optional embodiment, determining the convergence of the neural network model during the iterative training process includes the following steps:

[0108] Input each image in the labeled training set into the neural network model obtained from the previous training to obtain the current calculation result of each image in the labeled training set;

[0109] Compare the current calculated result of each image with the true result to determine the current loss value of each image;

[0110] According to the loss value of each current image, it is determined whether the neural network model obtained by the previous training has converged.

[0111] In an optional embodiment, the rotation angle θ ′ Determined by the following formula:

[0112]

[0113] Wherein, θ is the tilt angle.

[0114] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned image tilt correction methods are implemented.

[0115] An embodiment of the present invention further provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the steps of any of the above-mentioned image tilt correction methods when executing the computer program.

[0116] See also Figure 3 The computer device of this embodiment includes: a processor 301, a memory 302, and a computer program stored in the memory 302 and executable on the processor 301, such as an image tilt correction program. When the processor 301 executes the computer program, the steps in the above-mentioned various image tilt correction method embodiments are implemented, such as Figure 1 Steps S1-S3 are shown.

[0117] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 302 and executed by the processor 301 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the computer device.

[0118] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that the schematic diagram is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the diagram, or may combine certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.

[0119] The processor 301 may be a central processing unit (CPU), or other general-purpose processors 301, digital signal processors 301 (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor 301 may be a microprocessor 301 or any conventional processor 301, etc. The processor 301 is the control center of the computer device, and uses various interfaces and lines to connect various parts of the entire computer device.

[0120] The memory 302 can be used to store the computer program and / or module. The processor 301 implements various functions of the computer device by running or executing the computer program and / or module stored in the memory 302 and calling the data stored in the memory 302. The memory 302 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory 302 can include a high-speed random access memory 302, and can also include a non-volatile memory 302, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage 302, a flash memory device, or other volatile solid-state storage 302.

[0121] Wherein, if the module / unit integrated in the computer device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor 301. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory 302, read-only memory 302 (ROM, Read-Only Memory), random access memory 302 (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0122] In summary, the present invention has the following beneficial effects:

[0123] According to the embodiment of the present invention, a water meter image is acquired; the water meter image is input into a preconfigured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image; and the water meter image is tilt corrected according to the number of center point prediction coordinates. This eliminates the need for image preprocessing, reduces computational complexity, and eliminates the need for frequent parameter adjustments. The system has strong versatility and is therefore more efficient when the amount of data is large.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary hardware platform, and of course can also be implemented entirely by hardware. Based on such an understanding, all or part of the contribution of the technical solution of the present invention to the background technology can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.

[0125] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for image tilt correction, characterized in that: include: Acquire a water meter image, wherein the water meter image contains a plurality of water meter reading characters, and the center point of a rectangular area occupied by each water meter reading character is located on the same straight line; Input the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image; Performing tilt correction on the water surface image according to the predicted coordinates of the plurality of center points; The target detection model is determined by the following steps: Acquire a data set related to the water meter image, and divide the data set into a training set, a validation set, and a test set according to a preset ratio; The training set and the validation set are labeled; wherein each image in the labeled training set and the validation set has a true labeled result and a plurality of bounding boxes of equal size, and the center points of the plurality of bounding boxes are located on the same straight line; Using the labeled training set, the preset neural network model is iteratively trained through the back propagation algorithm until the preset stop training condition is met, then the iterative training is stopped to obtain a trained neural network model; Using the annotated validation set, the neural network model obtained after each iterative training is verified, and the best model weight file with the best validation result is stored, and the target detection model is obtained according to the configuration of the best model weight file; The step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes: Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image; Determining a rotation angle of the water meter image according to the tilt angle; Rotating the water meter image according to the rotation angle; The preset training stop condition includes at least one of the following: The number of iterative training reaches the preset iteration number threshold; Determine the convergence of the neural network model during iterative training; The step of determining whether the neural network model has converged during the iterative training process includes the following steps: Input each image in the labeled training set into the neural network model obtained from the previous training to obtain the current calculation result of each image in the labeled training set; Compare the current calculated result of each image with the true result to determine the current loss value of each image; According to the loss value of each current image, it is determined whether the neural network model obtained by the previous training has converged.

2. The image tilt correction method according to claim 1, characterized in that: The rotation angle θ′ is determined by the following formula: Wherein, θ is the tilt angle.

3. An image tilt correction device, characterized in that: include: An image acquisition module, used for acquiring a water meter image, wherein the water meter image contains a plurality of water meter reading characters, and the center point of a rectangular area occupied by each water meter reading character is located on the same straight line; A center point prediction module, used for inputting the water meter image into a pre-configured target detection model to obtain a number of center point prediction coordinates output by the target detection model; the number of center point prediction coordinates correspond one-to-one to a number of characters in the water meter image; A tilt correction module, used for performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points; The target detection model is determined by the following steps: Acquire a data set related to the water meter image, and divide the data set into a training set, a validation set, and a test set according to a preset ratio; The training set and the validation set are labeled; wherein each image in the labeled training set and the validation set has a true labeled result and a plurality of bounding boxes of equal size, and the center points of the plurality of bounding boxes are located on the same straight line; Using the labeled training set, the preset neural network model is iteratively trained through the back propagation algorithm until the preset stop training condition is met, then the iterative training is stopped to obtain a trained neural network model; Using the annotated validation set, the neural network model obtained after each iterative training is verified, and the best model weight file with the best validation result is stored, and the target detection model is obtained according to the configuration of the best model weight file; The step of performing tilt correction on the water meter image according to the predicted coordinates of the plurality of center points includes: Calculating the slope between any two points in the predicted coordinates of the plurality of center points; wherein the slope is used to indicate the inclination angle of the water meter image; Determining a rotation angle of the water meter image according to the tilt angle; Rotating the water meter image according to the rotation angle; The preset training stop condition includes at least one of the following: The number of iterative training reaches the preset iteration number threshold; Determine the convergence of the neural network model during iterative training; The step of determining whether the neural network model has converged during the iterative training process includes the following steps: Input each image in the labeled training set into the neural network model obtained from the previous training to obtain the current calculation result of each image in the labeled training set; Compare the current calculated result of each image with the true result to determine the current loss value of each image; According to the loss value of each current image, it is determined whether the neural network model obtained by the previous training has converged.

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image tilt correction method according to any one of claims 1 to 2 is implemented.

5. A computer device, characterized in that: The invention comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the image tilt correction method according to any one of claims 1 to 2 is implemented when the processor executes the computer program.

Citation Information

Patent Citations

  • License plate correction method and device, equipment and medium

    CN112634141A