CN115965955B - Rotation method and device of official seal image, electronic equipment and medium - Google Patents

Rotation method and device of official seal image, electronic equipment and medium Download PDF

Info

Publication number
CN115965955B
CN115965955B CN202111187897.XA CN202111187897A CN115965955B CN 115965955 B CN115965955 B CN 115965955B CN 202111187897 A CN202111187897 A CN 202111187897A CN 115965955 B CN115965955 B CN 115965955B
Authority
CN
China
Prior art keywords
target
information
rotation
position information
detection model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111187897.XA
Other languages
Chinese (zh)
Other versions
CN115965955A (en
Inventor
方磊
周审章
严京旗
徐敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zetyun Tech Co ltd
Original Assignee
Beijing Zetyun Tech Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zetyun Tech Co ltd filed Critical Beijing Zetyun Tech Co ltd
Priority to CN202111187897.XA priority Critical patent/CN115965955B/en
Publication of CN115965955A publication Critical patent/CN115965955A/en
Application granted granted Critical
Publication of CN115965955B publication Critical patent/CN115965955B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Image Analysis (AREA)

Abstract

The application provides a rotation method, a rotation device, electronic equipment and a rotation medium of a official seal image, wherein the rotation method of the official seal image comprises the following steps: acquiring a target official seal image; determining target position information of a five-pointed star pattern in the target official seal image according to a pre-acquired first target detection model; determining rotation information according to the target position information; and rotating the target official seal image according to the rotation information. By applying the first target detection model, namely applying the target detection algorithm, the rotary centering operation of the target official seal image is replaced by manually completing, so that error interference caused by human factors is avoided, the rotary error of the target official seal image is reduced, and the rotary method has better generalization and robustness.

Description

Rotation method and device of official seal image, electronic equipment and medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method and apparatus for rotating a official seal image, an electronic device, and a medium.
Background
The official seal refers to a seal used by institutions, groups and enterprises and public institutions, and an image of the official seal is a series of images including the official seal in the content.
In recent years, image processing technology is continuously developed, so that the use of official seals by people is greatly facilitated, for example, official seal identification based on official seal images, official seal authenticity identification and the like. In practical application, the official seal image uploaded by the user is mostly in an undetermined state, and the official seal image is mostly rotated in a manual mode at present so as to adjust the official seal image to be in a correct state, and the rotation error of the official seal image is large under the influence of working experience and working state, namely, a large position deviation exists between the rotated official seal image and the official seal image in the correct state.
Disclosure of Invention
The application aims to provide a rotation method, a rotation device, electronic equipment and a rotation medium for a official seal image, which are used for solving the problem of large rotation error of the official seal image.
In a first aspect, an embodiment of the present application provides a method for rotating a official seal image, including:
acquiring a target official seal image;
determining target position information of a five-pointed star pattern in the target official seal image according to a pre-acquired first target detection model;
determining rotation information according to the target position information;
And rotating the target official seal image according to the rotation information.
Optionally, the determining, according to the pre-acquired first target detection model, the target position information of the five-pointed star pattern in the target official seal image includes:
Detecting the target official seal image according to the first target detection model to obtain a plurality of pieces of alternative bounding box information of the five-pointed star figure vertexes in the target official seal image;
And determining the target position information in the plurality of candidate boundary box information according to a preset filtering condition, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target official seal image.
Optionally, the rotation information includes rotation center information and rotation angle information;
the determining rotation information according to the target position information includes:
acquiring rotation center information according to the target position information, wherein the distances between a center point indicated by the rotation center information and vertexes corresponding to positions in the target position information are the same;
and obtaining the rotation angle information according to the target position information.
Optionally, the obtaining rotation angle information according to the target position information includes:
Affine transformation is carried out on at least 2 position information in the target position information to obtain the rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
Optionally, the determining rotation center information according to the target position information includes:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
Optionally, the acquiring process of the first object detection model includes:
Acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
Marking the vertex positions of five-pointed star graphics of each sample official seal image in the first sample set to obtain a second sample set;
And training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
Optionally, marking the vertex positions of the five-pointed star pattern of each sample official seal image in the first sample set, and obtaining a second sample set; training and evaluating the N candidate detection models according to the second sample set, and before obtaining the first target detection model, the method further comprises:
Performing data enhancement on the second sample set to obtain a third sample set;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
and training and evaluating the N alternative detection models according to the third sample set to obtain the first target detection model.
Optionally, the third sample set includes a training subset and a validation subset;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
Optionally, after the target official seal image is acquired; before determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model, the method further comprises:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
The determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model comprises the following steps:
and determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
In a second aspect, an embodiment of the present application provides a rotation apparatus for a official seal image, including:
The acquisition module is used for acquiring a target official seal image;
The detection module is used for determining target position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model;
the processing module is used for determining rotation information according to the target position information;
and the rotation module is used for rotating the target official seal image according to the rotation information.
Optionally, the detection module includes:
Detecting the target official seal image according to the first target detection model to obtain a plurality of pieces of alternative bounding box information of the five-pointed star figure vertexes in the target official seal image;
And determining the target position information in the plurality of candidate boundary box information according to a preset filtering condition, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target official seal image.
Optionally, the rotation information includes rotation center information and rotation angle information;
the processing module comprises:
A center obtaining unit, configured to obtain the rotation center information according to the target position information, where distances between a center point indicated by the rotation center information and vertices corresponding to positions in the target position information are the same;
and the angle acquisition unit is used for acquiring the rotation angle information according to the target position information.
Optionally, the angle acquisition unit includes:
Affine transformation is carried out on at least 2 position information in the target position information to obtain the rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
Optionally, the center acquisition unit includes:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
Optionally, the rotating device further includes a model building module, the model building module including:
The data acquisition unit is used for acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
the sample marking unit is used for marking the vertex positions of the five-pointed star pattern of each sample official seal image in the first sample set to obtain a second sample set;
The model construction unit is used for training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
Optionally, the model building module further includes:
the data enhancement unit is used for enhancing the data of the second sample set to obtain a third sample set;
The model construction unit is further configured to train and evaluate the N candidate detection models according to the third sample set, so as to obtain the first target detection model.
Optionally, the third sample set includes a training subset and a validation subset;
The model construction unit includes:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
Optionally, the rotating device further includes a model transformation module, the model transformation module includes:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
the detection module is further used for determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a processor, a memory and a program or instruction stored on the memory and executable on the processor, which when executed by the processor, implements the steps in the method of rotation of a official seal image as described in the first aspect above.
In a fourth aspect, an embodiment of the present application provides a readable storage medium having stored thereon a program or instructions which, when executed by a processor, implement the steps in the rotation method of the official seal image as described in the first aspect above.
According to the rotation method provided by the embodiment of the application, the rotation centering operation of the target official seal image is replaced by manually completing the rotation centering operation of the target official seal image in a mode of applying the first target detection model, namely, in a mode of applying the target detection algorithm, so that error interference caused by human factors is avoided, and rotation error of the target official seal image is reduced; in addition, the specific pattern (five-pointed star pattern) in the official seal image is used as the basis for calculating the rotation information, the rotation information can be determined through the vertex information of the five-pointed star pattern, and the calculation complexity of the rotation information can be reduced to a certain extent.
Drawings
Fig. 1 is a flowchart of a rotation method of a official seal image according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a sample official seal image according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a rotation device for official seal images according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which are derived by a person skilled in the art from the embodiments according to the application without creative efforts, fall within the protection scope of the application.
Referring to fig. 1, fig. 1 is a flowchart of a rotation method of a official seal image according to an embodiment of the present application, and as shown in fig. 1, the rotation method includes:
And step 101, acquiring a target official seal image.
And 102, determining target position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model.
And step 103, determining rotation information according to the target position information.
And 104, rotating the target official seal image according to the rotation information.
As described above, the rotation centering operation of the target official seal image is replaced by manually completing the rotation centering operation of the target official seal image by applying the first target detection model, namely applying the target detection algorithm, so that error interference caused by human factors is avoided, and the rotation error of the target official seal image is reduced; in addition, the specific pattern (five-pointed star pattern) in the official seal image is used as the basis for calculating the rotation information, the rotation information can be determined through the vertex information of the five-pointed star pattern, and the calculation complexity of the rotation information is reduced to a certain extent.
For example, if the target official seal image is a color image, there is a significant color difference between the image block of the pentagram and the other image blocks of the target official seal image (e.g., the image block of the pentagram is red and the other image blocks of the target official seal image are white); if the target common seal image is a gray image, there is a significant difference in pixel values between the image block where the five-pointed star image is located and the other image blocks of the target common seal image (for example, the gray value of the image block where the five-pointed star image is located is 0, and the gray value of the other image blocks of the target common seal image is 255). The color difference or the pixel value difference existing between the image block where the five-pointed star pattern is located and other image blocks of the target official seal image can be utilized to further reduce the difficulty in confirming the target position information by the first target detection model, so that the rotation method has better generalization and robustness.
It should be noted that the first object detection model includes, but is not limited to: R-CNN (Regions with Convolutional Neural Network features) model, SPP-Net (SPATIAL PYRAMID Pooling Networks) model, fast R-CNN model, YOLO (You Only Look Once,) v 1-v 5 model, YOLOX model, centerNe model, etc.
Optionally, the determining, according to the pre-acquired first target detection model, the target position information of the five-pointed star pattern in the target official seal image includes:
Detecting the target official seal image according to the first target detection model to obtain a plurality of pieces of alternative bounding box information of the five-pointed star figure vertexes in the target official seal image;
And determining the target position information in the plurality of candidate boundary box information according to a preset filtering condition, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target official seal image.
As described above, the method of characterizing the whole five-pointed star pattern by using the vertices of the five-pointed star pattern, that is, directly detecting the vertex positions of the five-pointed star pattern, can reduce the difficulty of detecting the five-pointed star pattern by the first target detection model, further improve the calculation efficiency of the rotation information, and improve the rotation efficiency of the target official seal image.
It should be emphasized that, preferably, the vertex is an outward convex vertex of the five-pointed star pattern, as shown in fig. 2, the vertex included in the dashed line frame in fig. 2 is an outward convex vertex, and the outward convex vertex is located at the outward extending tip of the five-pointed star pattern, so that in the process of identifying the outward convex vertex, the detection and identification of the outward convex vertex are less interfered by other parts of the five-pointed star pattern, which makes the detection accuracy of the outward convex vertex higher. Based on the method, the convex vertexes of the five-pointed star pattern are determined to be vertexes to be detected by the first target detection model, so that the rotation error of the target official seal image can be further reduced.
In practice, the candidate bounding box information includes at least the first block coordinates of the candidate bounding box, the confidence of the first block coordinates, and the number of the pentagram vertices included in the candidate bounding box. For example, in the case where the candidate bounding box is rectangular, the block coordinates include at least two endpoint coordinates (e.g., a lower left endpoint coordinate and an upper right endpoint coordinate or a lower left endpoint coordinate and a lower right endpoint coordinate within the candidate bounding box) that are relatively disposed within the candidate bounding box. As shown in fig. 2, the above numbering process of the vertices of the five-pointed star pattern includes, but is not limited to, setting the top left vertex of the five-pointed star pattern as the vertex No. 0, and setting the bottom left vertex, the bottom right vertex, the top right vertex, and the middle vertex of the five-pointed star pattern as the vertex No. 1, the vertex No. 2, the vertex No. 3, and the vertex No. 4 in this order in the counterclockwise direction.
The determining the target position information in the plurality of candidate bounding box information according to the preset filtering condition may be:
Filtering the plurality of candidate bounding box information to obtain a plurality of target bounding box information by adopting a mode including but not limited to a Non-maximum suppression (Non-Maximum Suppression, NMS) algorithm based on the confidence level of the first block coordinate corresponding to each candidate bounding box information; each piece of target boundary frame information comprises a second block coordinate of the target boundary frame, a confidence coefficient of the second block coordinate and position information corresponding to the target boundary frame (comprising the number of the five-pointed star figure vertex positioned in the target boundary frame and the coordinate of the five-pointed star figure vertex); and obtaining the target position information based on a plurality of position information corresponding to the target boundary box information respectively. The coordinates of the vertices of the five-pointed star graph are the coordinates of the central point of the target boundary box where the vertices are located.
For example, if the target bounding box is rectangular, and the second block coordinates of the target bounding box include (1, 1) and (3, 3), where coordinates (1, 1) are the lower left endpoint coordinates of the target bounding box, and coordinates (3, 3) are the upper right endpoint coordinates of the target bounding box, then the coordinates of the vertices of the five-pointed star pattern located within the target bounding box are (2, 2).
In practice, the number of the position information included in the target position information is preferably set to be 3, if the number of the target bounding box information is greater than 3, the plurality of target bounding box information is ordered according to the confidence level of the second block coordinates from high to low, and three position information corresponding to three target bounding box information in front of the confidence level row is summarized to obtain the target position information.
As described above, by adopting the non-maximum suppression algorithm, in the process of detecting and identifying five vertices of the five-pointed star pattern by the first target detection model (multi-target identification), filtering the multiple pieces of candidate bounding box information, and respectively reserving the target bounding box information with the highest confidence coefficient for each vertex; the number of the position information included in the target position information is preferably set to be 3, and on the premise that the rotation information can be normally obtained through the target position information in the subsequent step, the target boundary box information with the highest confidence coefficient, which is reserved by each vertex, is further screened, so that interference possibly generated by the target boundary box information with lower confidence coefficient is avoided, the overall confidence coefficient of the target position information is further improved, and the accuracy of the rotation information determined based on the target position information is further improved.
Optionally, the rotation information includes rotation center information and rotation angle information;
the determining rotation information according to the target position information includes:
acquiring rotation center information according to the target position information, wherein the distances between a center point indicated by the rotation center information and vertexes corresponding to positions in the target position information are the same;
and obtaining the rotation angle information according to the target position information.
As described above, rotation center information and rotation angle information are respectively obtained based on the target position information, and the rotation center indicated by the rotation center information is used as the rotation center, and the rotation of the target official seal image is performed according to the rotation angle and the rotation direction indicated by the rotation angle information, so that the rotation correcting operation of the target official seal image can be completed.
In practice, the rotation angle information is preferably set to be a combination of the rotation angle and the rotation direction, so as to reduce the occupation of the storage space by the rotation angle information, and illustratively, a positive sign indicates a rotation direction clockwise, and a negative sign indicates a rotation direction counterclockwise, and if the rotation angle information is +40°, the rotation angle information specifically means that the target official seal image is rotated clockwise by 40 °.
Optionally, the obtaining rotation angle information according to the target position information includes:
Affine transformation is carried out on at least 2 position information in the target position information to obtain the rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
As described above, at least 2 pieces of position information are selected from the target position information, and affine transformation is performed on at least 2 vertex coordinates corresponding to the selected at least 2 pieces of position information, respectively, to obtain rotation matrix information; the rotation angle information is then processed, including but not limited to, by the Rodrigues (Rodrigues) transform, to obtain the rotation angle information.
In practice, it is preferable to set the number of position information subjected to affine transformation to 3 or more, that is, increase the number of vertex coordinates subjected to affine transformation to improve the accuracy of the obtained rotation matrix information, so as to improve the accuracy of the obtained rotation angle information, and further reduce the rotation error of the target official seal image.
Optionally, the determining rotation center information according to the target position information includes:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
As described above, the perpendicular bisector corresponding to the perpendicular bisector information is a perpendicular bisector of a line segment formed by any two points in the target position information, and the center point corresponding to the rotation center information is an intersection point of at least 2 perpendicular bisectors corresponding to at least 2 perpendicular bisector information, that is, a center point of the five-pointed star pattern.
The characteristic that the five-pointed star pattern is positioned in the center of the target official seal image is utilized, and the center point of the five-pointed star pattern is determined to be the rotation center, so that the acquisition efficiency of the determined rotation center can be improved on the premise of guaranteeing the accuracy of the determined rotation center, and the rotation efficiency of the target official seal image is further improved.
Optionally, the acquiring process of the first object detection model includes:
Acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
Marking the vertex positions of five-pointed star graphics of each sample official seal image in the first sample set to obtain a second sample set;
And training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
Such alternative detection models include, but are not limited to: R-CNN (Regions with Convolutional Neural Network features) model, SPP-Net (SPATIAL PYRAMID Pooling Networks) model, fast R-CNN model, YOLO (You Only Look Once,) v 1-v 5 model, YOLOX model, centerNe model, etc.
In the case where N is a positive integer greater than or equal to 2, the N candidate detection models are different from each other.
In the invention, the vertex positions of the five-pointed star graphics of each sample common seal image in the first sample set are marked (a rectangular frame area taking the vertex as a center point is marked, the size of the rectangular frame area can be adjusted based on practical adaptability), the upper left vertex of the five-pointed star graphics is set as a number 0 vertex by taking the five-pointed star graphics in fig. 2 as an example, and the numbering setting of the remaining four vertices of the five-pointed star graphics is sequentially completed in a clockwise direction, namely, the number 1 vertex, the number 2 vertex, the number 3 vertex and the number 4 vertex of the five-pointed star graphics can be sequentially obtained under the condition that the number 0 vertex is taken as a starting point and the clockwise direction is taken as a traversing direction; on the other hand, by using the above-mentioned association setting of a plurality of numbers, the detection efficiency of the candidate detection models for a plurality of dashed-line frame areas can also be improved, and the training efficiency of the N candidate detection models can also be improved to some extent.
Optionally, marking the vertex positions of the five-pointed star pattern of each sample official seal image in the first sample set, and obtaining a second sample set; training and evaluating the N candidate detection models according to the second sample set, and before obtaining the first target detection model, the method further comprises:
Performing data enhancement on the second sample set to obtain a third sample set;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
and training and evaluating the N alternative detection models according to the third sample set to obtain the first target detection model.
The method has the advantages that through a data enhancement mode, the sample number of the second sample set can be enriched, a third sample set with larger data volume (the sample number of the third sample set is larger than that of the second sample set) can be obtained, and the problem that the alternative detection model is under-fitted in the training process is avoided; the diversity of the second sample set can be improved, so that the third sample set after data enhancement can better simulate the target official seal image, the generalization capability and the robust performance of the first target detection model obtained after training and evaluation of N alternative detection models are improved, and the rotation operation of the target official seal image can be accurately and rapidly completed by the first target detection model under a complex scene.
In practical applications, the data enhancement methods include, but are not limited to: a manner of increasing or decreasing a value of saturation of each sample official image in the second sample set, a manner of increasing or decreasing a value of contrast of each sample official image in the second sample set, a manner of increasing or decreasing a value of brightness of each sample official image in the second sample set, a manner of graying each sample official image in the second sample set, a manner of rotating each sample official image in the second sample set, a manner of randomly cutting or supplementing an edge pixel block to each sample official image in the second sample set, and the like; the user may select one or more of the data enhancement modes described above to perform the data enhancement operation on the second sample set based on actual requirements.
Optionally, the third sample set includes a training subset and a validation subset;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
As described above, to better apply the third sample set obtained after data enhancement, the plurality of sample elements included in the third sample set may be further divided, for example, by means of random classification, into a training subset, a verification subset, and a test subset, and then training the N candidate detection models by the training subset to obtain M candidate detection models; then, evaluating the M candidate detection models by using the verification subset, and obtaining evaluation information (comprising rotation accuracy) corresponding to each candidate detection model; and finally, determining the candidate detection model with the highest rotation accuracy as the first target detection model, and testing the first target detection model by utilizing a test subset to obtain test information for explaining the actual rotation performance of the first target detection model on the official seal image.
Illustratively, the process of obtaining the candidate detection models from the candidate detection models may be:
if the training subset is set to 300 training rounds of an alternative detection model, after 150 training rounds, the loss function of the alternative detection model tends to be stable, and in the last 150 training rounds, each time 1 training round is performed, the obtained trained alternative detection model is a candidate detection model, that is, 150 alternative detection models can be obtained after training the alternative detection model.
It should be noted that, after each 1-round training, the weight information of each node corresponding to the candidate detection model is adjusted, that is, each node of the plurality of candidate detection models corresponding to the same candidate detection model is the same, but the weight information of each node is different.
The fact that the loss function tends to be stable means that the loss function is smaller than or equal to a preset loss threshold value, and in practice, the loss threshold value may be adaptively adjusted based on a user requirement, which is not limited by the embodiment of the present application.
Through the arrangement, through a plurality of steps such as training, verification, evaluation, testing and the like, a candidate detection model with highest rotation accuracy rate is selected from M candidate detection models and is determined to be a first target detection model, so that the rotation information with higher accuracy degree can be obtained after the target official seal image is identified and detected through the first target detection model, and the purpose of reducing the rotation error of the target official seal image is achieved.
For example, the quantitative ratio between the training subset, the validation subset, and the test subset may be 6:2:2; the quantitative ratio between the training subset, the validation subset and the test subset is preferably set to 8:1:1, a step of; in the event that the third sample set has too many sample elements, the quantitative ratio between the training subset, the validation subset, and the test subset may also be set to 98:1:1, the user can adaptively adjust the number ratio according to actual requirements, which is not limited in the embodiment of the application.
Optionally, after the target official seal image is acquired; before determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model, the method further comprises:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
The determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model comprises the following steps:
and determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
As described above, the first target detection model (the number of dependent libraries corresponding to the configuration environment is large) suitable for training is converted into the second target detection model (the number of dependent libraries corresponding to the configuration environment is small) suitable for reasoning, so as to improve the recognition and detection efficiency of the five-pointed star pattern vertices in the target official seal image, and achieve the purpose of improving the rotation efficiency of the target official seal image.
Specifically, the configuration environment corresponding to the target detection model comprises a first class and a second class, wherein the first class of configuration environment takes training efficiency as a guide, and more dependency libraries (mostly for model training purposes) exist, so that the effect of improving the training efficiency of the target detection model is achieved at the expense of the detection efficiency of the target detection model; the second type of configuration environment takes detection efficiency as a guide, and the number of dependent libraries is small (most of model detection uses), so that the detection efficiency of a target detection model can be improved to a certain extent.
In practice, in order to accelerate the acquisition efficiency of the first target detection model, that is, the training efficiency of the N candidate detection models, the first type configuration environment is preferably applied to perform model training, that is, the construction and training of the N candidate detection models are completed in the first type configuration environment.
After a first target detection model is obtained under a first type of configuration environment, extracting and converting first weight information of the first target detection model to obtain second weight information corresponding to a second type of configuration environment, and generating a second target detection model with higher detection efficiency based on the second weight information; because the number of the dependent libraries of the corresponding configuration environment is smaller, the configuration efficiency of the second target detection model is better than that of the first target detection model, and the use experience of a user can be improved.
The first type of configuration environment includes, but is not limited to PyTorch frameworks, and the second type of configuration environment includes, but is not limited to ONNX frameworks, tensorRT frameworks, and the like.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a rotation device 200 for a official seal image according to an embodiment of the application, and as shown in fig. 3, the rotation device 200 includes:
An acquisition module 201, configured to acquire a target official seal image;
The detection module 202 is configured to determine target position information of a five-pointed star pattern in the target official seal image according to a pre-acquired first target detection model;
a processing module 203, configured to determine rotation information according to the target position information;
and the rotation module 204 is used for rotating the target official seal image according to the rotation information.
Optionally, the detection module 202 includes:
Detecting the target official seal image according to the first target detection model to obtain a plurality of pieces of alternative bounding box information of the five-pointed star figure vertexes in the target official seal image;
And determining the target position information in the plurality of candidate boundary box information according to a preset filtering condition, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target official seal image.
Optionally, the rotation information includes rotation center information and rotation angle information;
The processing module 203 includes:
A center obtaining unit, configured to obtain the rotation center information according to the target position information, where distances between a center point indicated by the rotation center information and vertices corresponding to positions in the target position information are the same;
and the angle acquisition unit is used for acquiring the rotation angle information according to the target position information.
Further, the angle acquisition unit includes:
Affine transformation is carried out on at least 2 position information in the target position information to obtain the rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
Further, the center acquisition unit includes:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
Optionally, the rotating apparatus 200 further includes a model building module, where the model building module includes:
The data acquisition unit is used for acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
the sample marking unit is used for marking the vertex positions of the five-pointed star pattern of each sample official seal image in the first sample set to obtain a second sample set;
The model construction unit is used for training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
Optionally, the model building module further includes:
the data enhancement unit is used for enhancing the data of the second sample set to obtain a third sample set;
The model construction unit is further configured to train and evaluate the N candidate detection models according to the third sample set, so as to obtain the first target detection model.
Further, the third sample set includes a training subset and a validation subset;
The model construction unit includes:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
Optionally, the rotating device 200 further includes a model transformation module, where the model transformation module includes:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
the detection module is further used for determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
It should be noted that, the rotation device 200 of the official seal image in the embodiment of the present application may be a device, or may be a component, an integrated circuit or a chip in an electronic device.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application, and as shown in fig. 4, the electronic device includes: bus 301, transceiver 302, antenna 303, bus interface 304, processor 305 and memory 306. The processor 305 can implement the processes of the rotation method embodiment of the official seal image, and achieve the same technical effects, and for avoiding repetition, the description is omitted here.
In fig. 3, a bus architecture (represented by bus 301), the bus 301 may comprise any number of interconnected buses and bridges, with the bus 301 linking together various circuits, including one or more processors, represented by processor 305, and memory, represented by memory 306. The bus 301 may also link together various other circuits such as peripheral devices, voltage regulators, power management circuits, etc., which are well known in the art and, therefore, will not be described further herein. Bus interface 304 provides an interface between bus 301 and transceiver 302. The transceiver 302 may be one element or may be a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 305 is transmitted over a wireless medium via the antenna 303, and further, the antenna 303 receives the data and transmits the data to the processor 305.
The processor 305 is responsible for managing the bus 301 and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory 306 may be used to store data used by processor 305 in performing operations.
Alternatively, the processor 305 may be CPU, ASIC, FPGA or a CPLD.
The embodiment of the application also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the processes of the above method embodiment, and can achieve the same technical effects, and in order to avoid repetition, the description is omitted here. Among them, a computer-readable storage medium such as Read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, and the like.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a second terminal device, etc.) to perform the method according to the embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are to be protected by the present application.

Claims (16)

1. A method of rotating a official seal image, comprising:
acquiring a target official seal image;
determining target position information of a five-pointed star pattern in the target official seal image according to a pre-acquired first target detection model;
determining rotation information according to the target position information;
Rotating the target official seal image according to the rotation information;
The determining, according to the pre-acquired first target detection model, target position information of the five-pointed star pattern in the target official seal image includes:
detecting the target official seal image according to the first target detection model, and obtaining a plurality of pieces of alternative boundary frame information of five-pointed star graphic vertexes in the target official seal image, wherein the alternative boundary frame information comprises a first block coordinate of an alternative boundary frame and a confidence degree of the first block coordinate;
Determining a plurality of target bounding box information in the plurality of candidate bounding box information based on the confidence level of the first block coordinates included in each candidate bounding box information, and determining the target position information according to the plurality of target bounding box information, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target common seal image;
wherein after the target official seal image is acquired; before determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model, the method further comprises:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
The determining the position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model comprises the following steps:
and determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
2. The rotation method according to claim 1, wherein the rotation information includes rotation angle information;
the determining rotation information according to the target position information includes:
acquiring rotation center information according to the target position information, wherein the distances between a center point indicated by the rotation center information and vertexes corresponding to positions in the target position information are the same;
and obtaining the rotation angle information according to the target position information.
3. The rotation method according to claim 2, wherein the obtaining rotation angle information from the target position information includes:
affine transformation is carried out on at least 2 position information in the target position information to obtain rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
4. A method according to claim 3, wherein said determining rotation center information from said target position information comprises:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
5. The rotation method according to claim 1, wherein the acquiring of the first object detection model includes:
Acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
Marking the vertex positions of five-pointed star graphics of each sample official seal image in the first sample set to obtain a second sample set;
And training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
6. The rotation method according to claim 5, wherein the vertex positions of the five-pointed star pattern of each sample official image in the first sample set are marked, and a second sample set is obtained; training and evaluating the N candidate detection models according to the second sample set, and before obtaining the first target detection model, the method further comprises:
Performing data enhancement on the second sample set to obtain a third sample set;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
and training and evaluating the N alternative detection models according to the third sample set to obtain the first target detection model.
7. The rotation method of claim 6, wherein the third sample set comprises a training subset and a validation subset;
training and evaluating the N candidate detection models according to the second sample set to obtain the first target detection model, wherein the training and evaluating the N candidate detection models comprises the following steps:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
8. A rotation device of a official seal image, the rotation device comprising:
The acquisition module is used for acquiring a target official seal image;
The detection module is used for determining target position information of the five-pointed star pattern in the target official seal image according to the pre-acquired first target detection model;
the processing module is used for determining rotation information according to the target position information;
the rotation module is used for rotating the target official seal image according to the rotation information;
wherein, the detection module is specifically used for:
detecting the target official seal image according to the first target detection model, and obtaining a plurality of pieces of alternative boundary frame information of five-pointed star graphic vertexes in the target official seal image, wherein the alternative boundary frame information comprises a first block coordinate of an alternative boundary frame and a confidence degree of the first block coordinate;
Determining a plurality of target bounding box information in the plurality of candidate bounding box information based on the confidence level of the first block coordinates included in each candidate bounding box information, and determining the target position information according to the plurality of target bounding box information, wherein the target position information comprises at least 3 pieces of position information, and the at least 3 pieces of position information respectively correspond to different vertexes of a five-pointed star pattern in the target common seal image;
wherein the rotating device further comprises a model transformation module comprising:
acquiring first weight information corresponding to the first target detection model;
converting the first weight information into second weight information, wherein the number of dependent libraries of the configuration environment corresponding to the second weight information is smaller than that of the configuration environment corresponding to the first weight information;
generating a second target detection model according to the second weight information, wherein the processing efficiency of the second target detection model is higher than that of the first target detection model;
the detection module is further used for determining the position information of the five-pointed star pattern in the target official seal image according to the second target detection model.
9. The rotating apparatus according to claim 8, wherein the rotation information includes rotation angle information;
the processing module comprises:
A center obtaining unit, configured to obtain rotation center information according to the target position information, where distances between a center point indicated by the rotation center information and vertices corresponding to positions in the target position information are the same;
and the angle acquisition unit is used for acquiring the rotation angle information according to the target position information.
10. The rotating apparatus according to claim 9, wherein the angle acquisition unit includes:
affine transformation is carried out on at least 2 position information in the target position information to obtain rotation matrix information;
And obtaining the rotation angle information according to the rotation matrix information.
11. The rotating apparatus according to claim 10, wherein the center acquisition unit includes:
acquiring at least 2 pieces of perpendicular bisector information according to the position information of any two points in the target position information;
and determining the rotation center information according to the at least 2 pieces of perpendicular bisector information.
12. The rotating apparatus of claim 8, further comprising a model building module, the model building module comprising:
The data acquisition unit is used for acquiring a first sample set and N alternative detection models, wherein N is a positive integer greater than or equal to 1;
the sample marking unit is used for marking the vertex positions of the five-pointed star pattern of each sample official seal image in the first sample set to obtain a second sample set;
The model construction unit is used for training and evaluating the N alternative detection models according to the second sample set to obtain the first target detection model.
13. The rotating apparatus of claim 12, wherein the model building module further comprises:
the data enhancement unit is used for enhancing the data of the second sample set to obtain a third sample set;
The model construction unit is further configured to train and evaluate the N candidate detection models according to the third sample set, so as to obtain the first target detection model.
14. The rotation device of claim 13, wherein the third sample set comprises a training subset and a validation subset;
The model construction unit includes:
training the N candidate detection models according to the training subset to obtain M candidate detection models, wherein M is a positive integer greater than or equal to N;
Evaluating the M candidate detection models according to the verification subset to obtain evaluation information corresponding to each candidate detection model, wherein the evaluation information comprises the rotation accuracy of the candidate detection models;
And determining a candidate detection model with highest rotation accuracy among the M candidate detection models as the first target detection model.
15. An electronic device comprising a processor, a memory and a program or instruction stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the method of any of claims 1 to 7.
16. A readable storage medium, characterized in that it has stored thereon a program or instructions which, when executed by a processor, implement the steps of the method according to any of claims 1 to 7.
CN202111187897.XA 2021-10-12 2021-10-12 Rotation method and device of official seal image, electronic equipment and medium Active CN115965955B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111187897.XA CN115965955B (en) 2021-10-12 2021-10-12 Rotation method and device of official seal image, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111187897.XA CN115965955B (en) 2021-10-12 2021-10-12 Rotation method and device of official seal image, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN115965955A CN115965955A (en) 2023-04-14
CN115965955B true CN115965955B (en) 2024-05-31

Family

ID=87353434

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111187897.XA Active CN115965955B (en) 2021-10-12 2021-10-12 Rotation method and device of official seal image, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN115965955B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111144358A (en) * 2019-12-30 2020-05-12 上海眼控科技股份有限公司 Vehicle quality certificate verification method and device, computer equipment and storage medium
CN112381081A (en) * 2020-11-16 2021-02-19 深圳壹账通智能科技有限公司 Official seal character automatic identification method and device, computer equipment and storage medium
CN112560852A (en) * 2020-12-15 2021-03-26 三峡大学 Single-stage target detection method with rotation adaptive capacity based on YOLOv3 network
CN113012014A (en) * 2021-02-19 2021-06-22 上海益高信息技术有限公司 Electronic decoding method for optical watermark anti-counterfeiting seal
CN113436080A (en) * 2021-06-30 2021-09-24 平安科技(深圳)有限公司 Seal image processing method, device, equipment and storage medium
CN113469888A (en) * 2021-07-08 2021-10-01 江西金格科技股份有限公司 Method and device for correcting inclination angle of circular electronic seal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111144358A (en) * 2019-12-30 2020-05-12 上海眼控科技股份有限公司 Vehicle quality certificate verification method and device, computer equipment and storage medium
CN112381081A (en) * 2020-11-16 2021-02-19 深圳壹账通智能科技有限公司 Official seal character automatic identification method and device, computer equipment and storage medium
CN112560852A (en) * 2020-12-15 2021-03-26 三峡大学 Single-stage target detection method with rotation adaptive capacity based on YOLOv3 network
CN113012014A (en) * 2021-02-19 2021-06-22 上海益高信息技术有限公司 Electronic decoding method for optical watermark anti-counterfeiting seal
CN113436080A (en) * 2021-06-30 2021-09-24 平安科技(深圳)有限公司 Seal image processing method, device, equipment and storage medium
CN113469888A (en) * 2021-07-08 2021-10-01 江西金格科技股份有限公司 Method and device for correcting inclination angle of circular electronic seal

Also Published As

Publication number Publication date
CN115965955A (en) 2023-04-14

Similar Documents

Publication Publication Date Title
CN112348815B (en) Image processing method, image processing apparatus, and non-transitory storage medium
CN111325769B (en) Target object detection method and device
CN110059750A (en) House type shape recognition process, device and equipment
CN108647634A (en) Framing mask lookup method, device, computer equipment and storage medium
CN112085056B (en) Target detection model generation method, device, equipment and storage medium
CN114445661B (en) Embedded image recognition method based on edge calculation
CN113762229B (en) Intelligent identification method and system for building equipment in building site
CN113592839B (en) Distribution network line typical defect diagnosis method and system based on improved fast RCNN
WO2017034419A1 (en) A process, system and apparatus for machine colour characterisation of digital media
CN111353325A (en) Key point detection model training method and device
CN110942092B (en) Graphic image recognition method and recognition system
CN114240981A (en) Mark identification method and device
CN111402185B (en) Image detection method and device
CN113486879B (en) Image area suggestion frame detection method, device, equipment and storage medium
CN115965955B (en) Rotation method and device of official seal image, electronic equipment and medium
CN108197540A (en) A kind of fire image Feature extraction and recognition method based on SURF
CN112434581A (en) Outdoor target color identification method and system, electronic device and storage medium
CN116597317A (en) Remote sensing image change detection data generation method, device, equipment and medium
CN116994084A (en) Regional intrusion detection model training method and regional intrusion detection method
CN110751163B (en) Target positioning method and device, computer readable storage medium and electronic equipment
CN116071625A (en) Training method of deep learning model, target detection method and device
CN114972335A (en) Image classification method and device for industrial detection and computer equipment
CN114913513A (en) Method and device for calculating similarity of official seal images, electronic equipment and medium
CN115731458A (en) Processing method and device for remote sensing image and electronic equipment
CN113870210A (en) Image quality evaluation method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant