CN111814801A - Method for extracting labeled strings in mechanical diagram - Google Patents

Method for extracting labeled strings in mechanical diagram Download PDF

Info

Publication number
CN111814801A
CN111814801A CN202010862023.9A CN202010862023A CN111814801A CN 111814801 A CN111814801 A CN 111814801A CN 202010862023 A CN202010862023 A CN 202010862023A CN 111814801 A CN111814801 A CN 111814801A
Authority
CN
China
Prior art keywords
character
characters
cluster
rad
value
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.)
Granted
Application number
CN202010862023.9A
Other languages
Chinese (zh)
Other versions
CN111814801B (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.)
University of Electronic Science and Technology of China
Original Assignee
University of Electronic Science and Technology of China
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 University of Electronic Science and Technology of China filed Critical University of Electronic Science and Technology of China
Priority to CN202010862023.9A priority Critical patent/CN111814801B/en
Publication of CN111814801A publication Critical patent/CN111814801A/en
Application granted granted Critical
Publication of CN111814801B publication Critical patent/CN111814801B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • G06F18/232Non-hierarchical techniques
    • G06F18/2321Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2411Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Abstract

The invention discloses a method for extracting a label string in a mechanical drawing, which comprises the steps of separating all characters according to morphological feature differences of the characters and geometric lines and obtaining character feature vectors; next, clustering analysis is carried out on the characteristic quantity by adopting a DBSCAN algorithm; and finally, performing directional growth segmentation on each type of clustered characters until the extraction work of the character strings is completed. Experimental results show that the self-adaptive clustering labeling character string extracting method provided by the scheme is high in accuracy and high in running speed.

Description

Method for extracting labeled strings in mechanical diagram
Technical Field
The invention relates to a character string extraction technology, in particular to a method for extracting a label string in a mechanical diagram.
Background
The character labels in the mechanical drawings are important data for designing, processing and checking parts of mechanical parts. The extraction of character strings and marking information is an extremely important component part for the computer automation processing of mechanical drawings and is also the basis for high-level knowledge understanding. The manual reading of the drawing and the recording of the marking parameters in the drawing have the advantages of complex work, high labor intensity and extremely high requirements on the patience and care of a recorder. Therefore, the computer can automatically extract and identify the label string, so that the recognition, understanding and management of the drawing can be accelerated, the detection quality is improved, and the problems of fatigue, easy inattention, low efficiency and the like caused by manual long-time drawing reading are solved. Extracting a label string from a mechanical drawing is generally divided into two links of character detection and character reorganization. Character detection, also called text separation, separates the character from the geometric lines. Character recombination is also called character clustering, and character combinations belonging to the same labeled string are clustered together.
Researchers at home and abroad have started to research character detection and recognition earlier, and many methods for extracting characters such as scene text images, digital videos, historical documents and the like have been proposed. Research on character extraction in mechanical drawings has also made more progress, and common text extraction methods are classified into methods of extraction based on connected domains, methods of extraction based on edge features, methods of extraction based on colors and character features, and character positioning based on thresholds.
Threshold-based character location is also popular, and AI-Hmouz R et al Gazcon N F et al separate the target character in the image from the image by appropriate connected domain thresholds and size thresholds. The method needs manual calibration and has a good effect on different scenes and complex images. However, different thresholds need to be set for different images, and the thresholds cannot be flexibly determined adaptively.
For the extraction of character strings in mechanical drawings, in the extraction method based on clustering, He and the like utilize a complete connection algorithm to perform clustering to extract the character strings, and the method is only suitable for scenes in which the marked strings are in the same direction in the drawings. And (4) clustering and partitioning the image according to the binary image background region characteristics by the Daiwei et al, and clustering to obtain a character region by using the image region characteristics. Jujianfei et al adopt a regression line-based K-Means clustering algorithm to guide the pixel clustering of the adhesion characters by a regression model, and realize the segmentation of the adhesion characters and the labeling of the belonging text lines. However, when combining strings by using a single clustering method, two horizontally labeled strings that are immediately adjacent to each other may be merged into one string.
In the character string extraction method based on linear analysis, the Hough transformation method is used for carrying out linear analysis on the central position of a character to obtain a character string, and the extraction of the character string is carried out by utilizing whether the central points of the character are collinear and whether the inter-word distance meets a certain threshold condition, but the two methods are only suitable for the character string with a large number of characters and the centers of the characters approximately falling on the same straight line, and are not suitable for the character string with an upper and a lower subscripts in a mechanical drawing.
In summary, although the existing methods implement character detection and character string reorganization to different degrees, the image features used are few, or the methods rely on some specific features, the robustness of the character reorganization method is not high, and the method is difficult to adapt to labeled strings with various layout directions.
Disclosure of Invention
Aiming at the defects in the prior art, the method for extracting the label strings in the mechanical diagram solves the problem that the prior art cannot adapt to the label strings with various layout directions.
In order to achieve the purpose of the invention, the invention adopts the technical scheme that:
the method for extracting the label string in the mechanical drawing is provided, and comprises the following steps:
s1, separating characters and drawings in the mechanical drawings by adopting a graph-text separation algorithm, then respectively extracting a feature vector of each character, and forming a feature vector set by adopting feature vectors of all characters;
s2, obtaining a distance threshold, and clustering elements in the feature vector set by adopting a DBSCAN algorithm to form a plurality of clusters according to the distance threshold;
s3, judging whether the number of characters in each cluster is larger than or equal to a preset threshold value, if so, clustering the feature vectors in the clusters by adopting a DBSCAN algorithm according to a preset distance to form a plurality of clusters, and then entering the step S4; otherwise, directly entering step S4;
s4, reserving a decimal value according to the original camber value and the original camber value of the character direction angle in each cluster, judging whether the cluster contains multiple strings of character strings with different directions, if so, entering the step S5, otherwise, entering the step S6;
s5, according to the type of the characters in each cluster, selecting an expansion strategy to expand each character in the direction vertical to the character until all the characters in each cluster are expanded, and completing extraction of the corresponding character strings in each cluster;
s6, selecting the original radian value with the highest frequency in each cluster as the overall direction of all characters of the current cluster, and constructing a structural element two-dimensional matrix perpendicular to the overall direction of the current cluster as a character expansion core;
and S7, expanding all the characters in the corresponding clusters by adopting the character expansion core until all the characters in each cluster are expanded, and finishing the extraction of the corresponding character strings in each cluster.
The invention has the beneficial effects that: the method adopts a DBSCAN algorithm to cluster the character characteristic vectors, and after clustering, character connection is carried out by adopting a character expansion or expansion segmentation method according to different directions of clustering results to finally obtain each label string; by adopting the method, not only can the character string labels in different directions be well extracted, but also the character strings in parallel of multiple lines can be well divided.
Drawings
FIG. 1 is a flow chart of a method for extracting a string of labels from a mechanical diagram.
FIG. 2 is a diagram of feature vectors of characters.
Fig. 3 is a schematic diagram showing a character direction angle deviation of a character.
Fig. 4 is a schematic diagram after clustering by using DBSCAN.
FIG. 5 is a schematic diagram of character strings in different directions and character expansion results, in which a is a schematic diagram of character strings in different directions not being expanded, and b is a schematic diagram of character strings with too small expansion multiples; c is a schematic diagram of character string with overlarge expansion multiple; d is a diagram showing that the character string is properly expanded by multiple times.
Fig. 6 shows a parallel character string and a segmentation result based on dilation, where a is a plurality of parallel character strings and b is a segmentation result based on dilation.
Fig. 7 shows the character expansion core for four angles of Len ═ 5.
FIG. 8 is a sample graph base feature statistic.
FIG. 9 is a graph showing the results of the experiment.
Detailed Description
The following description of the embodiments of the present invention is provided to facilitate the understanding of the present invention by those skilled in the art, but it should be understood that the present invention is not limited to the scope of the embodiments, and it will be apparent to those skilled in the art that various changes may be made without departing from the spirit and scope of the invention as defined and defined in the appended claims, and all matters produced by the invention using the inventive concept are protected.
Referring to fig. 1, fig. 1 shows a flowchart of a method for extracting a label string from a mechanical drawing, and as shown in fig. 1, the method S includes steps S1 to S7.
In step S1, characters and drawings in the mechanical drawings are separated by using an image-text separation algorithm, and then feature vectors of each character are extracted, and feature vectors of all characters are used to form a feature vector set. The image-text separation algorithm of the scheme is mainly realized based on a connected domain.
When in implementation, the scheme has the advantagesSelecting character's feature vector V ═ x, y, h, w, r, a, d, theta]Wherein x and y are coordinates of a central point c (x, y) of the character connected region, and h and w are the height and the width of the character connected region respectively; a. r is the area h x w and the width-to-height ratio h/w of the character communication area respectively; d is the duty cycle, i.e. the proportion n of character pixels in the character communication regionp/a,npThe number of pixels in a character connected region; theta is the direction angle of the character connection region, namely the character direction angle, which is the included angle between Fv in the long side direction and the positive direction of the x axis, and theta belongs to (-90 DEG, 90 DEG)]。
Each component in the feature vector of the character is shown in fig. 2, OXY is an image coordinate system, an exemplary character is a number 8, an inclined frame is a minimum bounding rectangle of the character, the width is w, the height is h, the direction of a long side is Fv, an included angle between Fv and an x-axis is defined as a character direction angle θ, and the direction perpendicular to Fv is Fn. The non-inclined frame is a bounding box of the character, i.e. a box composed of boundaries in the horizontal direction and the vertical direction. The number of all black pixels of the character 8 is npIf the duty ratio d is equal to np/(w*h)。
The character direction needs to be adjusted when the designer draws drawings of machinery, maps, buildings and the like, and the character direction is consistent with the direction of the corresponding geometric line, so that the user can read and judge the characters conveniently. However, some characters have a direction angle θ that deviates from the actual visual direction of the character or label string, and as shown in fig. 3, the oblique square is the smallest circumscribed rectangle of the character connected domain, the long side of which indicates the character direction angle θ, but the visual direction of the character is the direction Fv indicated by the long side of the oblique square, and the direction Fn is referred to as the writing direction, i.e., the direction in which multiple characters remain aligned when writing and printing the character string.
In order to ensure the accuracy of extracting the subsequent character strings, when the direction angles obtained by some character feature vectors in the mechanical drawing do not accord with the character visual direction angles, the direction angles need to be compensated.
In an embodiment of the present invention, the obtaining the character direction angle of the character further includes compensating the character direction angle of the character:
b1, when the character is minus sign "-" and partial dot sign "-", correcting the direction to be the original direction +90 degrees;
b2, when the character is a non-directional character (such as standard degree and position degree)
Figure BDA0002648457580000051
Etc.), its character direction angle is not compensated;
b3, when the character is directional character and the direction of the smallest rectangle indicates the correct direction, not compensating the character direction angle, such as 2, 3, 6, 8, etc.
B4, when the character is a double arrow character with directional features and the smallest rectangular direction indicates the correct direction (such as Φ, t,
Figure BDA0002648457580000061
j, f, etc. ) And compensating the character direction angle:
and determining an angle compensation value of each character by using the trained SVM classifier, and correcting the character direction angle of the character into theta + by using the character direction angle.
The scheme is based on a character classification method of Hu invariant moment characteristics so as to determine an angle compensation value of each character. Firstly, training is carried out, M1, M2, M3 and M4 in each sample character Hu invariant moment are calculated as characteristics, and the characteristics are used as a data set ShX ═ x for one data point1,x2,x3,x4]T(ii) a And (4) identifying the angle needing to be compensated and the character not needing to be compensated through SVM training, and storing the weight parameters of the training.
In the correction process, the weight parameters are read, the class of the current character is identified by using a trained SVM classifier or the characteristics of the special symbol are used for obtaining the character to be compensated, and then the degree and the compensation mode of the special symbol to be compensated are obtained according to early-stage analysis.
The character angle compensation process is as follows: firstly inputting a character connected image, calculating a characteristic vector V of the character connected image, and judging whether the character connected image is a character corresponding to B1 and B2 or not according to the duty ratio d and the aspect ratio r of the character. If so, the angle is corrected to a corresponding angle value. If not, dividing the characters into B3 and B4 corresponding characters, and determining the character types and the corresponding compensation angles of the characters through an SVM classifier. Finally, the direction angle theta in the compensation angle correction V is theta +. Table 1 gives some examples of angle corrections for characters.
TABLE 1 sample character Angle correction
Figure BDA0002648457580000062
Figure BDA0002648457580000071
In step S2, a distance threshold is obtained, and according to the distance threshold, elements in the feature vector set are clustered by using the DBSCAN algorithm to form a plurality of clusters.
In an embodiment of the present invention, the method for obtaining the distance threshold includes:
calculating the Euclidean distance between characters in the mechanical drawing:
d(c(i),c(j))=((xc(i)-xc(j))2+(yc(i)-yc(j))2)1/2
wherein, c (i) and c (j) are the central points of the ith character and the jth character respectively; x is the number ofc(i)、yc(i)Coordinates of the center point c (i); x is the number ofc(j)、yc(j)Coordinates of the center point c (j); t is the number of characters in the drawing, i, j is 1,2, …, T, and i ≠ j.
Acquiring the optimal adjacent distance d (i) between the character and the adjacent K characters by adopting a KNN algorithm according to the Euclidean distance between the central point c (i) and the corresponding character and other characters;
the optimal adjacent distances d (i) of all characters in the mechanical drawing are arranged in a descending order to obtain a sequence f (k), and then second-order difference is carried out on the sequence f (k) to obtain a difference sequence fd(k):
fd(k)=f(k+1)+f(k-1)-2f(k)
Wherein k is 1,2, …, T;
find fd(k) Max { f ═ max (max) } max (max ═ max (max) }d(k) The maximum value MaxEI ═ max { f }is adoptedd(k) As a distance threshold.
The distance threshold is set by adopting the mode, so that the method can adapt to different characteristics and scales of each mechanical diagram, and the problem of inaccurate setting caused by manual setting of the threshold is avoided.
In the implementation, the method for clustering elements in the feature vector set by preferably adopting the DBSCAN algorithm in the scheme is as follows:
searching a domain of each element in the feature vector set within a distance threshold value to serve as an Eps neighborhood;
when the number of elements contained in an Eps neighborhood corresponding to the character is larger than the preset number, creating a cluster taking an element p as a core object;
and iteratively aggregating the objects with the direct density reachable by the element p, and merging the clusters with the reachable density until no new element is added to any cluster, thereby completing the clustering.
The preset number of DBSCAN algorithms is a parameter specified by the user. The preset number in the classical DBSCAN is usually set to a certain value larger than 1 in order to eliminate isolated noise points to be grouped into one class; in this scheme, the predetermined number (point threshold) is set to 0, so as to keep the labels of some single characters completely.
In step S3, determining whether the number of characters in each cluster is greater than or equal to a preset threshold, if so, clustering feature vectors in the clusters by using a DBSCAN algorithm according to a preset distance to form a plurality of clusters, and then entering step S4; otherwise, directly entering step S4;
as shown in fig. 4, the independent box and the large box containing a plurality of small boxes are the result of the first clustering (coarse clustering), and the first clustering may classify the strings into the same class, which may cause inaccurate character classification, so that the second clustering is performed on the basis of the result of the first clustering.
If the number n of characters in the ith class after the first clusteringdIf more character strings are contained in the class, the character strings are clustered secondarily (clustered minutely) to reduce the number of the character strings in the class, so that the character strings can be conveniently divided into the following character stringsAnd (6) processing.
In the scheme, when the DBSCAN is clustered for the second time, the point threshold value is zero, the preset distance is 0.39, and the EPS2 is determined by experiments. And e.g. the clustering result with the preset distance of 0.39 when the small box in the large box in fig. 4 is clustered for the second time.
Compared with the first clustering result, the second clustering result can subdivide the wrongly-divided clusters after the first clustering again. However, there may still be a large class that is misclassified, i.e., a situation where multiple annotation strings are clustered together, and therefore further processing is required, i.e., the step S4 needs to be continued.
In step S4, a decimal value is reserved according to the original camber value and the original camber value of the character azimuth in each cluster, whether the cluster contains multiple character strings with different string directions is determined, if yes, step S5 is performed, otherwise, step S6 is performed.
In implementation, the method for preferably judging whether a cluster contains different character strings in multiple string directions includes:
acquiring an original radian value Rad of a character direction angle theta in each cluster and a value Rad of a reserved one-digit decimal number of the original radian value;
record the maximum primary radian value rad of the frequency1And the primary camber value rad of the second highest frequency2(number rad)2_numAnd the arc value Rad with the highest frequency in the Rad values1Sum frequency sub-high radian value Rad2
Record the maximum original camber value radmaxAnd minimum primary camber value radminAnd calculating the radian difference value rad of the current clusterdiff=radmax-radmin
Judging whether the current cluster meets any one of preset conditions, if so, judging that the current cluster contains different character strings in multiple string directions, otherwise, judging that the current cluster does not contain different character strings in multiple string directions; the preset conditions include:
a1, when formula (1) and formula (2) are satisfied simultaneously, and either formula (3) or formula (4) is satisfied:
0.05<raddiff<3 (1) rad2_num>2 (2) |rad1-Rad2|>0.3 (3)
1.5<|rad1-rad2|<3AND|rad1-Rad2|>0.1 (4);
a2, the number of characters in the cluster is the same as the number of character direction angles;
a3, the number of characters in the cluster is less than 3.
In step S5, according to the type of the character in each cluster, an expansion strategy is selected to expand each character in the direction perpendicular to the character until all the characters in each cluster are expanded, thereby completing the extraction of the corresponding character string in each cluster.
The types of the characters comprise non-directional characters with the height h equal to the width w, double-arrow characters and directional characters with non-directional symbols and double-arrow symbols removed; the extension strategy comprises the following steps:
when the character is a non-directional character, the upper part, the lower part, the left part and the right part of the character are expanded by alpha times of the width w; when the characters are double-arrow characters, the width w is expanded to the direction of one side of the double-arrow by beta times; when the character is a directional character, the character is expanded by a width W along both sides of the whole character stringmγ times of said width WmIs the average width of all characters in the mechanical drawing.
As shown in fig. 5, a is a schematic diagram of character strings in different directions not being expanded, where when the character in fig. 5(a) is expanded in step S5, if the expansion is too large, multiple character strings will be merged into one character string, as shown in fig. 5(b), and if the expansion factor is too small, characters will be not merged together, as shown in fig. 5(c), and each character is appropriately expanded by using the information, so that character strings in different directions in a class can be better divided, and as a result, the character string is shown in fig. 5 (d). The expansion strategy provided by the scheme well solves the problem that the character strings in different directions cannot be extracted when each cluster contains the character strings in different directions.
If the characters in the cluster do not satisfy the expansion condition of step S5, it indicates that the directions of the characters in the cluster are the same, but it cannot be guaranteed that all of them are the same character string, and in the case shown in fig. 6, 6(a) includes three parallel reference character strings and two perpendicular reference character strings in the box, and therefore, it is necessary to divide them by morphological dilation processing.
In step S6, the original radian value with the highest frequency in each cluster is selected as the overall direction of all characters in the current cluster, and a two-dimensional matrix of structural elements perpendicular to the overall direction of the current cluster is constructed as a character expansion kernel.
In an embodiment of the present invention, the step S6 further includes:
selecting the original radian value rad with the highest frequency in the cluster1As the overall direction η of all characters in the cluster, the width W is adoptedmω times as the nuclear length Len;
and constructing one-dimensional vectors X and Y according to the overall direction eta and the kernel length Len:
Figure BDA0002648457580000111
wherein x and y are both intermediate parameters;
according to the one-dimensional vectors X and Y, constructing a two-dimensional matrix of structural elements with the size of M X N:
Figure BDA0002648457580000112
calculating an index position vector IDX ═ M × (X + X) + (Y + 1);
and when the element index position in the structural element two-dimensional matrix is in the IDX, setting the value of the corresponding element as 1, otherwise, setting the value of the corresponding element as 0, and adopting the structural element two-dimensional matrix after element updating as a character expansion core. Fig. 7 schematically shows a character expansion core of 0 °, 30 °, 45 °, 90 °, and a core length Len of 5.
In step S7, the character expansion core is used to expand all the characters in the corresponding cluster until all the characters in each cluster have been expanded, thereby completing the extraction of the corresponding character string in each cluster.
After the character expansion check is adopted to expand the character, the character strings of a plurality of parallel lines of different strings are divided into a plurality of connected domains to obtain the divided label strings, as shown in fig. 6(b), it can be seen that after the character expansion check is obtained by adopting the above method, based on the expansion of the character in the character expansion check, the problem that when the character strings are combined by simply utilizing a clustering method, two horizontally labeled character strings which are closely adjacent up and down may be merged into one character string can be well solved.
The following describes in detail the effect of the method for extracting a character string from a mechanical drawing according to the present disclosure with reference to specific examples:
experimental data and environment
In order to evaluate the performance of the method proposed by the scheme, 4 typical mechanical drawing images are selected as experimental samples, wherein 3 (numbered md1, md2 and md3) are standard mechanical drawings, and a mechanical drawing (md4) is a thin line drawing and is not in a standard format. Because of copyright and management requirements, mechanical drawings are designed by CAD firstly, then converted into pdf electronic documents for distribution, and finally converted into tif format images for analysis. Since the resolution of the image file is large and it is not convenient to display visually, the basic information and the basic features of these figures are given below, respectively, see table 2.
Table 2 is the basic information of the sample graph
Figure BDA0002648457580000121
Fig. 8(a) - (e) show the normalized statistics of the width w, height h, duty ratio d, character direction rad, and character distance d (i) of the characters in 4 sample drawings, respectively.
The test environment is a hardware environment: CPU Intel (R) core (TM) i7-4790 CPU @3.60 GHz; 16GB RAM; software environment: operating system 64-bit Windows 10; VS2017+ OpenCV 3.4.1.
The parameters required to be set in the experiment are as follows, the number n of characters of DBSCAN fine clusteringdNot less than 14, the preset distance EPS2 is not less than 0.39, the number of characters in the character string counted from Table 2 is not more than 79, and the average number is 49, so that K in KNN is not less than 49 and not more than 79. The division type determination parameter for the directional growth of the character is set according to the given parameters in the formulas (1) to (3). The character directional expansion coefficient alpha is 1/3, gamma is selected from 1.5 ≦ gamma ≦ 2.5, and beta is 1/2. Character expansion middle coreThe coefficient ω of the long Len is 2.4.
Results of the experiment
The results of the annotation string extraction experiment are shown in fig. 9, where fig. 9(a) is a part of a standard mechanical drawing original, fig. 9(b) is a character after text separation, and fig. 9(c) is an annotation string after character cluster extraction. Fig. 9(d) shows the result of labeling the original drawing with a string, and the portion in the rectangular frame is labeled with the character string to be extracted.
It can be seen from fig. 9(d) that the algorithm of the present scheme can not only extract the labels of the character strings in different directions well, but also segment the parallel character strings in multiple rows. The corresponding course of the experimental treatment and the clustering results under different parameters are shown in table 3.
TABLE 3 character extraction Algorithm accuracy and time consumption at various stages on mechanical drawings
Figure BDA0002648457580000131
Column 5 "md 1-3 average" in table 3 represents the average index of three standard mechanical diagrams, and it can be seen from table 3 that the average accuracy of the first clustering (coarse clustering) is only 37.31%, and the maximum is 47.32%, and the average accuracy of the second clustering (fine clustering) is only about 5% higher than that of the coarse clustering, but it subdivides each class to facilitate the subsequent character expansion and segmentation based on dilation, so that fine clustering is also necessary, and the final accuracy is formed by character expansion and segmentation based on dilation.
The average accuracy of character string extraction in the standard mechanical drawing is 97.20%; the accuracy rate is 88.14% in a non-standard mechanical drawing (single pixel), the running speed is also faster, and the average time is 10 s.
TABLE 4 influence of too small or too large character expansion factor on the final accuracy
Figure BDA0002648457580000132
Column 5 of table 4, "md 1-3 average" represents the average index of three standard mechanical diagrams, and it can also be seen from table 4 that the expansion multiple in character expansion has an obvious effect on the result, when the expansion multiple is too small, a case where one character string is divided into several parts occurs, the average accuracy of character expansion is 84.67%, and compared with an appropriate multiple, the accuracy is reduced by 12.53%; similarly, when the character expansion multiple is too large, several character strings in the same class are merged together, the average accuracy is 90.05%, and compared with a proper multiple, the accuracy is reduced by 7.2%; the best results of character expansion can be achieved with the appropriate multiple.

Claims (8)

1. The method for extracting the label string in the mechanical drawing is characterized by comprising the following steps:
s1, separating characters and drawings in the mechanical drawings by adopting a graph-text separation algorithm, then respectively extracting a feature vector of each character, and forming a feature vector set by adopting feature vectors of all characters;
s2, obtaining a distance threshold, and clustering elements in the feature vector set by adopting a DBSCAN algorithm to form a plurality of clusters according to the distance threshold;
s3, judging whether the number of characters in each cluster is larger than or equal to a preset threshold value, if so, clustering the feature vectors in the clusters by adopting a DBSCAN algorithm according to a preset distance to form a plurality of clusters, and then entering the step S4; otherwise, directly entering step S4;
s4, reserving a decimal value according to the original camber value and the original camber value of the character direction angle in each cluster, judging whether the cluster contains multiple strings of character strings with different directions, if so, entering the step S5, otherwise, entering the step S6;
s5, according to the type of the characters in each cluster, selecting an expansion strategy to expand each character in the direction vertical to the character until all the characters in each cluster are expanded, and completing extraction of the corresponding character strings in each cluster;
s6, selecting the original radian value with the highest frequency in each cluster as the overall direction of all characters of the current cluster, and constructing a structural element two-dimensional matrix perpendicular to the overall direction of the current cluster as a character expansion core;
and S7, expanding all the characters in the corresponding clusters by adopting the character expansion core until all the characters in each cluster are expanded, and finishing the extraction of the corresponding character strings in each cluster.
2. The method for extracting the labeled string in the mechanical drawing according to claim 1, wherein the method for judging whether the cluster contains the character strings with different string directions comprises the following steps:
acquiring an original radian value Rad of a character direction angle theta in each cluster and a value Rad of a reserved one-digit decimal number of the original radian value;
record the maximum primary radian value rad of the frequency1And the primary camber value rad of the second highest frequency2(number rad)2_numAnd the arc value Rad with the highest frequency in the Rad values1Sum frequency sub-high radian value Rad2
Record the maximum original camber value radmaxAnd minimum primary camber value radminAnd calculating the radian difference value rad of the current clusterdiff=radmax-radmin
Judging whether the current cluster meets any one of preset conditions, if so, judging that the current cluster contains different character strings in multiple string directions, otherwise, judging that the current cluster does not contain different character strings in multiple string directions; the preset conditions include:
a1, when formula (1) and formula (2) are satisfied simultaneously, and either formula (3) or formula (4) is satisfied:
0.05<raddiff<3(1)rad2_num>2(2)|rad1-Rad2|>0.3 (3)
1.5<|rad1-rad2|<3AND|rad1-Rad2|>0.1 (4);
a2, the number of characters in the cluster is the same as the number of character direction angles;
a3, the number of characters in the cluster is less than 3.
3. The method for extracting the labeled string in the mechanical drawing as claimed in claim 1, wherein the types of the characters include a non-directional character with a height h equal to a width w, a double-arrow character, and a directional character with a non-directional symbol and a double-arrow symbol removed; the extension strategy comprises the following steps:
when the character is a non-directional character, the upper part, the lower part, the left part and the right part of the character are expanded by alpha times of the width w; when the characters are double-arrow characters, the width w is expanded to the direction of one side of the double-arrow by beta times; when the character is a directional character, the character is expanded by a width W along both sides of the whole character stringmγ times of said width WmIs the average width of all characters in the mechanical drawing.
4. The method for extracting the labeled string in the mechanical drawing as claimed in claim 1, wherein said step S6 further comprises:
selecting the original radian value rad with the highest frequency in the cluster1As the overall direction η of all characters in the cluster, the width W is adoptedmω times as the nuclear length Len;
and constructing one-dimensional vectors X and Y according to the overall direction eta and the kernel length Len:
Figure FDA0002648457570000031
wherein x and y are both intermediate parameters;
according to the one-dimensional vectors X and Y, constructing a two-dimensional matrix of structural elements with the size of M X N:
Figure FDA0002648457570000032
calculating an index position vector IDX ═ M × (X + X) + (Y + 1);
and when the element index position in the structural element two-dimensional matrix is in the IDX, setting the value of the corresponding element as 1, otherwise, setting the value of the corresponding element as 0, and adopting the structural element two-dimensional matrix after element updating as a character expansion core.
5. The method for extracting the labeled string in the mechanical drawing according to claim 1, wherein the method for obtaining the distance threshold value comprises:
calculating the Euclidean distance between characters in the mechanical drawing:
d(c(i),c(j))=((xc(i)-xc(j))2+(yc(i)-yc(j))2)1/2
wherein, c (i) and c (j) are the central points of the ith character and the jth character respectively; x is the number ofc(i)、yc(i)Coordinates of the center point c (i); x is the number ofc(j)、yc(j)Coordinates of the center point c (j); t is the number of characters in the drawing, i, j is 1,2, …, T, and i ≠ j.
Acquiring the optimal adjacent distance d (i) between the character and the adjacent K characters by adopting a KNN algorithm according to the Euclidean distance between the central point c (i) and the corresponding character and other characters;
the optimal adjacent distances d (i) of all characters in the mechanical drawing are arranged in a descending order to obtain a sequence f (k), and then second-order difference is carried out on the sequence f (k) to obtain a difference sequence fd(k):
fd(k)=f(k+1)+f(k-1)-2f(k)
Wherein k is 1,2, …, T;
find fd(k) Max { f ═ max (max) } max (max ═ max (max) }d(k) The maximum value MaxEI ═ max { f }is adoptedd(k) As a distance threshold.
6. The method for extracting the labeled string in the mechanical drawing according to claim 5, wherein the method for clustering the elements in the feature vector set by using the DBSCAN algorithm comprises the following steps:
searching a domain of each element in the feature vector set within a distance threshold value to serve as an Eps neighborhood;
when the number of elements contained in an Eps neighborhood corresponding to the character is larger than the preset number, creating a cluster taking an element p as a core object;
and iteratively aggregating the objects with the direct density reachable by the element p, and merging the clusters with the reachable density until no new element is added to any cluster, thereby completing the clustering.
7. According to claim 1-6. the method for extracting a string labeled in a mechanical drawing as set forth in any one of claims, wherein a feature vector V of the character is [ x, y, h, w, r, a, d, θ ═ x, y, h, w, r, a, d, θ]Wherein x and y are coordinates of a central point c (x, y) of the character connected region, and h and w are the height and the width of the character connected region respectively; a. r is the area h x w and the width-to-height ratio h/w of the character communication area respectively; d is the duty cycle, i.e. the proportion n of character pixels in the character communication regionp/a,npThe number of pixels in a character connected region; theta is the direction angle of the character connection region, namely the character direction angle, which is the included angle between Fv in the long side direction and the positive direction of the x axis, and theta belongs to (-90 DEG, 90 DEG)]。
8. The method for extracting the labeled string in the mechanical drawing as claimed in claim 7, further comprising compensating for a character direction angle of the character:
b1, when the characters are minus sign "-" and partial dot sign "-", correcting the direction to be the original direction theta +90 degrees;
b2, when the character is a non-directional character, the character direction angle is not compensated;
b3, when the character is a directional character and the direction of the smallest rectangle indicates the correct direction, the character direction angle is not compensated;
b4, when the character is a double-arrow character and has directional features and the smallest rectangular direction indicates the correct direction, the character direction angle is compensated:
and determining an angle compensation value of each character by using the trained SVM classifier, and correcting the character direction angle of the character into theta + by using the character direction angle.
CN202010862023.9A 2020-08-25 2020-08-25 Method for extracting labeled strings in mechanical diagram Active CN111814801B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010862023.9A CN111814801B (en) 2020-08-25 2020-08-25 Method for extracting labeled strings in mechanical diagram

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010862023.9A CN111814801B (en) 2020-08-25 2020-08-25 Method for extracting labeled strings in mechanical diagram

Publications (2)

Publication Number Publication Date
CN111814801A true CN111814801A (en) 2020-10-23
CN111814801B CN111814801B (en) 2022-03-15

Family

ID=72860695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010862023.9A Active CN111814801B (en) 2020-08-25 2020-08-25 Method for extracting labeled strings in mechanical diagram

Country Status (1)

Country Link
CN (1) CN111814801B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112417826A (en) * 2020-11-24 2021-02-26 济南智学承远信息技术有限公司 PDF online editing method and device, electronic equipment and readable storage medium
CN112966318A (en) * 2021-04-12 2021-06-15 青矩技术股份有限公司 Method for displaying characters in CAD file and terminal equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000172783A (en) * 1998-12-02 2000-06-23 Ricoh Co Ltd Character string recognizing method and storage medium
CN108171237A (en) * 2017-12-08 2018-06-15 众安信息技术服务有限公司 A kind of line of text image individual character cutting method and device
CN110472543A (en) * 2019-08-05 2019-11-19 电子科技大学 One kind is based on the matched mechanical drawing control methods of local connection features
US20200013161A1 (en) * 2019-09-16 2020-01-09 Bikram Baidya Iterative supervised identification of non-dominant clusters
CN110728260A (en) * 2019-10-23 2020-01-24 北京天工矩阵信息技术有限公司 Method and device for identifying electrical construction drawing
CN111507353A (en) * 2020-04-17 2020-08-07 新分享科技服务(深圳)有限公司 Chinese field detection method and system based on character recognition

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000172783A (en) * 1998-12-02 2000-06-23 Ricoh Co Ltd Character string recognizing method and storage medium
CN108171237A (en) * 2017-12-08 2018-06-15 众安信息技术服务有限公司 A kind of line of text image individual character cutting method and device
CN110472543A (en) * 2019-08-05 2019-11-19 电子科技大学 One kind is based on the matched mechanical drawing control methods of local connection features
US20200013161A1 (en) * 2019-09-16 2020-01-09 Bikram Baidya Iterative supervised identification of non-dominant clusters
CN110728260A (en) * 2019-10-23 2020-01-24 北京天工矩阵信息技术有限公司 Method and device for identifying electrical construction drawing
CN111507353A (en) * 2020-04-17 2020-08-07 新分享科技服务(深圳)有限公司 Chinese field detection method and system based on character recognition

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
ANDREA MORICHETTA等: "CLUE:Clustering for Mining Web URLs", 《2016 28TH INTERNATIONAL TELETRAFFIC CONGRESS(ITC 28)》 *
孙金花: "自然场景下的混合文本定位研究", 《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》 *
闫文辉等: "基于改进DBSCAN聚类算法的雷暴单体三维结构识别技术介绍", 《热带气象学报》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112417826A (en) * 2020-11-24 2021-02-26 济南智学承远信息技术有限公司 PDF online editing method and device, electronic equipment and readable storage medium
CN112966318A (en) * 2021-04-12 2021-06-15 青矩技术股份有限公司 Method for displaying characters in CAD file and terminal equipment

Also Published As

Publication number Publication date
CN111814801B (en) 2022-03-15

Similar Documents

Publication Publication Date Title
CN108537146B (en) Print form and handwriting mixed text line extraction system
CN110648322B (en) Cervical abnormal cell detection method and system
CN110399878B (en) Form format recovery method, computer readable medium and computer
JP5492205B2 (en) Segment print pages into articles
CN105701519A (en) Realogram scene analysis of images: superpixel scene analysis
JP7270013B2 (en) Information processing method, information processing device, electronic device and storage medium
CN110717492B (en) Method for correcting direction of character string in drawing based on joint features
CN113158808A (en) Method, medium and equipment for Chinese ancient book character recognition, paragraph grouping and layout reconstruction
CN111814801B (en) Method for extracting labeled strings in mechanical diagram
CN109145964B (en) Method and system for realizing image color clustering
CN115346227B (en) Method for vectorizing electronic file based on layout file
CN109460735A (en) Document binary processing method, system, device based on figure semi-supervised learning
CN109213886B (en) Image retrieval method and system based on image segmentation and fuzzy pattern recognition
CN111091124A (en) Spine character recognition method
CN116824608A (en) Answer sheet layout analysis method based on target detection technology
CN110598581B (en) Optical music score recognition method based on convolutional neural network
CN108288061A (en) A method of based on the quick positioning tilt texts in natural scene of MSER
CN111340032A (en) Character recognition method based on application scene in financial field
CN114581928A (en) Form identification method and system
CN111553361B (en) Pathological section label identification method
CN106056575B (en) A kind of image matching method based on like physical property proposed algorithm
CN112348026A (en) Magnetic hard disk sequence code identification method based on machine vision
JP5347793B2 (en) Character recognition device, character recognition program, and character recognition method
CN108197663B (en) Calligraphy work image classification method based on dual set multi-label learning
CN116503622A (en) Data acquisition and reading method based on computer vision image

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