CN112508136A - Label conversion method and device - Google Patents

Label conversion method and device Download PDF

Info

Publication number
CN112508136A
CN112508136A CN202110150601.0A CN202110150601A CN112508136A CN 112508136 A CN112508136 A CN 112508136A CN 202110150601 A CN202110150601 A CN 202110150601A CN 112508136 A CN112508136 A CN 112508136A
Authority
CN
China
Prior art keywords
point
vector
points
converted
conversion
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
CN202110150601.0A
Other languages
Chinese (zh)
Other versions
CN112508136B (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.)
Changzhou Weiyizhi Technology Co Ltd
Original Assignee
Changzhou Weiyizhi Technology 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 Changzhou Weiyizhi Technology Co Ltd filed Critical Changzhou Weiyizhi Technology Co Ltd
Priority to CN202110150601.0A priority Critical patent/CN112508136B/en
Publication of CN112508136A publication Critical patent/CN112508136A/en
Application granted granted Critical
Publication of CN112508136B publication Critical patent/CN112508136B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

The invention provides a label conversion method and a device, wherein the method comprises the following steps: s1, acquiring a fold line marking file; s2, analyzing the marking data from the fold line marking file, wherein the marking data comprises the coordinates and marking line width of each endpoint in the fold line; s3, taking the end points of the fold lines as points to be converted, and determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the sequence from the start point to the end point of the fold line and the marking data; s4, sequencing a plurality of first target conversion points corresponding to the plurality of points to be converted according to the sequence from the fold line starting point to the fold line ending point to obtain a first ordered point set, and sequencing a plurality of second target conversion points corresponding to the plurality of points to be converted according to the sequence from the fold line ending point to the starting point to obtain a second ordered point set; and S5, combining the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file. The invention can conveniently and quickly obtain the polygon marking data.

Description

Label conversion method and device
Technical Field
The invention relates to the technical field of image annotation, in particular to an annotation conversion method, an annotation conversion device, computer equipment and a non-transitory computer-readable storage medium.
Background
In the field of product detection, a deep learning semantic segmentation technology is often used, and a target in a product image to be detected needs to be labeled to obtain model training data. Currently, commonly used labeling modes mainly include circular labeling, broken line labeling (namely, multi-section straight line labeling), polygonal labeling and the like, and different labeling modes can meet different scene requirements or model precision requirements.
For a slender linear object, such as a sample of slender line segment type, multi-segment line segment type or curve type, there is also a need for polygon labeling. However, in the actual labeling, the time cost consumed by adopting the polygon labeling is far higher than that of the straight line labeling, especially the requirement on the number of semantic segmentation training samples is usually large and can reach more than 1 ten thousand, and if the large amount of data is labeled according to the traditional polygon labeling mode, the method is a not small challenge for an algorist who needs data training urgently and a labeling staff who is in an urgent need.
Disclosure of Invention
The invention provides a label conversion method and a label conversion device for solving the technical problems, and polygonal label data can be conveniently and quickly obtained, so that the development period of a deep learning algorithm is favorably shortened.
The technical scheme adopted by the invention is as follows:
a label conversion method comprises the following steps: s1, acquiring a fold line marking file; s2, analyzing marking data from the fold line marking file, wherein the marking data comprise coordinates and marking line width of each endpoint in the fold line; s3, taking the end points of the fold lines as points to be converted, and determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the sequence from the start point to the end point of the fold line according to the label data; s4, sequencing the first target conversion points corresponding to the conversion points to be converted according to the sequence from the fold line starting point to the fold line ending point to obtain a first ordered point set, and sequencing the second target conversion points corresponding to the conversion points to be converted according to the sequence from the fold line ending point to the starting point to obtain a second ordered point set; and S5, combining the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file.
Step S3 specifically includes: converting each line segment in the broken line into a corresponding vector, wherein the direction of each vector is the direction of a path from the starting point of the broken line to the end point of the broken line; selecting any vector where the point to be converted is located, taking the point to be converted as a middle point and the marked line width as a length, and making a line segment perpendicular to the selected vector, wherein two end points of the made line segment are used as two target conversion points on two sides of the point to be converted; calculating coordinates of two end points of the line segment according to the marked line width, the vector starting point coordinates and the vector end point coordinates of the selected vector; and judging that each end point of the line segment is positioned at the first side or the second side of the selected vector according to the coordinates of the two end points of the line segment, the vector starting point coordinate and the vector end point coordinate of the selected vector, taking the end point of the line segment positioned at the first side of the selected vector as a first target conversion point at the first side of the point to be converted, and taking the end point of the line segment positioned at the second side of the selected vector as a second target conversion point at the second side of the point to be converted.
Wherein, the calculation judgment amount is:
Figure 139304DEST_PATH_IMAGE001
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector;
if the judgment quantity is larger than 0, judging that the end point of the line segment is positioned at the first side of the selected vector; and if the judgment quantity is less than 0, judging that the end point of the line segment is positioned at the second side of the selected vector.
An annotation conversion apparatus comprising: the acquisition module is used for acquiring the fold line marking file; the analysis module is used for analyzing the marking data from the fold line marking file, wherein the marking data comprises the coordinate and the marking line width of each endpoint in the fold line; the conversion module is used for determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the labeling data by taking an end point in the fold line as the point to be converted according to the sequence from the start point of the fold line to the end point of the fold line; the sequencing module is used for sequencing a plurality of first target conversion points corresponding to the plurality of points to be converted according to the sequence from the broken line starting point to the broken line ending point to obtain a first ordered point set, and sequencing a plurality of second target conversion points corresponding to the plurality of points to be converted according to the sequence from the broken line ending point to the starting point to obtain a second ordered point set; and the combination module is used for combining the first ordered point set and the second ordered point set to obtain an ordered polygon labeling file.
The conversion module is specifically configured to: converting each line segment in the broken line into a corresponding vector, wherein the direction of each vector is the direction of a path from the starting point of the broken line to the end point of the broken line; selecting any vector where the point to be converted is located, taking the point to be converted as a middle point and the marked line width as a length, and making a line segment perpendicular to the selected vector, wherein two end points of the made line segment are used as two target conversion points on two sides of the point to be converted; calculating coordinates of two end points of the line segment according to the marked line width, the vector starting point coordinates and the vector end point coordinates of the selected vector; and judging that each end point of the line segment is positioned at the first side or the second side of the selected vector according to the coordinates of the two end points of the line segment, the vector starting point coordinate and the vector end point coordinate of the selected vector, taking the end point of the line segment positioned at the first side of the selected vector as a first target conversion point at the first side of the point to be converted, and taking the end point of the line segment positioned at the second side of the selected vector as a second target conversion point at the second side of the point to be converted.
Wherein, the conversion module calculates the judgment quantity:
Figure 240990DEST_PATH_IMAGE002
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector;
if the judgment quantity is larger than 0, the conversion module judges that the end point of the line segment is positioned on the first side of the selected vector; if the judgment quantity is less than 0, the conversion module judges that the end point of the line segment is positioned at the second side of the selected vector.
A computer device comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the label conversion method.
A non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the annotation conversion method described above.
The invention has the beneficial effects that:
the invention analyzes the marked data from the fold line marked file, takes the end point in the fold line as the point to be converted, and according to the sequence from the starting point to the end point of the fold line, determining a first target transition point on the first side and a second target transition point on the second side of each point to be transitioned according to the annotation data, and then sequentially moving the first target transition point and the second target transition point from the start point to the end point of the polyline, sequencing a plurality of first target conversion points corresponding to a plurality of points to be converted to obtain a first ordered point set, and according to the sequence from the fold line terminal point to the starting point, sequencing a plurality of second target conversion points corresponding to a plurality of points to be converted to obtain a second ordered point set, finally combining the first ordered point set and the second ordered point set to obtain an ordered polygon marking file, therefore, the polygon labeling data can be conveniently and quickly obtained, and the development period of the deep learning algorithm is favorably shortened.
Drawings
FIG. 1 is a flowchart of a label conversion method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an object to be labeled according to an embodiment of the present invention;
FIG. 3 is a schematic view of a fold line marking according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the contents of a polyline markup file according to an embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating conversion of a polyline tag into a vector according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of polygon labeling according to an embodiment of the present invention;
FIG. 7 is a block diagram of a label conversion apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, the annotation conversion method according to the embodiment of the present invention includes the following steps:
and S1, acquiring the fold line marking file.
For a slender linear target in a product image to be detected, when defect analysis is carried out by utilizing a deep learning voice segmentation technology, firstly, marking can be carried out in a broken line marking mode, and a broken line marking file is obtained. The polyline markup file can be in xml or json and the like.
Taking the scratch on the metal product shown in fig. 2 as an example, the corresponding fold line is marked as shown in fig. 3. The polyline markup document of one embodiment of the present invention is shown in FIG. 4.
And S2, analyzing the marking data from the fold line marking file, wherein the marking data comprises the coordinates and marking line width of each endpoint in the fold line.
As shown in fig. 4, "line" indicates that the labeling manner is a polyline label, "xi" and "yi" respectively indicate the horizontal and vertical coordinates of the end points in the polyline in the image, "i" is the end point number, four end points are shown in fig. 4, and "width" indicates the line width, i.e., the width of the polyline.
And S3, taking the end points in the polyline as the points to be converted, and determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the annotation data in the sequence from the starting point to the end point of the polyline.
Specifically, a polyline start point and a polyline end point may be determined, for example, one end of the polyline is randomly determined to be the polyline start point, and the other end of the polyline is randomly determined to be the polyline end point, and each line segment in the polyline is converted into a corresponding vector, wherein the direction of each vector is the path direction from the polyline start point to the polyline end point. As shown in fig. 5, the polyline markup in fig. 3 can be converted into six vectors, and the endpoints in the polyline are marked from the polyline start point to the polyline end point, the vector start point of the first vector a1 is the polyline start point, the vector end point is the second endpoint in the polyline, the vector start point of the second vector a2 is the second endpoint in the polyline, the vector end point is the third endpoint in the polyline, …, the vector start point of the sixth vector a6 is the sixth endpoint in the polyline, and the vector end point is the polyline end point.
Then, any vector where the point to be converted is located is selected, the point to be converted is taken as a middle point, the marked line width is taken as a length, a line segment perpendicular to the selected vector is made, and two end points of the made line segment are taken as two target conversion points on two sides of the point to be converted. In an embodiment of the present invention, two target transition points corresponding to each point to be transitioned may be obtained according to an order from a starting point of the polyline to an ending point of the polyline, where a selected vector corresponding to the starting point of the polyline is a first vector a1, and a selected vector corresponding to a second end point of the polyline may be a first vector a1, or a second vector a2, and so on.
Further, the coordinates of the two end points of the line segment may be calculated based on the labeled line width, the vector start point coordinates and the vector end point coordinates of the selected vector based on a mathematical method, wherein the vector start point coordinates and the vector end point coordinates of the selected vector are both the coordinates of the end points in the broken line analyzed in step S2.
And finally, judging that each end point of the line segment is positioned at the first side or the second side of the selected vector according to the coordinates of the two end points of the line segment, the vector starting point coordinate and the vector end point coordinate of the selected vector, taking the end point of the line segment positioned at the first side of the selected vector as a first target conversion point of the first side of the point to be converted, and taking the end point of the line segment positioned at the second side of the selected vector as a second target conversion point of the second side of the point to be converted. Specifically, the judgment amount can be calculated:
Figure 493854DEST_PATH_IMAGE003
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector.
And if the judgment quantity is greater than 0, judging that the end point of the line segment is positioned on the first side of the selected vector, and if the judgment quantity is less than 0, judging that the end point of the line segment is positioned on the second side of the selected vector. The first side of the selected vector is the left side with the vector direction as the forward direction, and the second side of the fixed vector is the right side with the vector direction as the forward direction.
S4, according to the sequence from the broken line starting point to the broken line terminal point, sequencing a plurality of first target conversion points corresponding to the plurality of conversion points to be converted to obtain a first ordered point set, and according to the sequence from the broken line terminal point to the starting point, sequencing a plurality of second target conversion points corresponding to the plurality of conversion points to be converted to obtain a second ordered point set.
As shown in FIG. 6, the first ordered set of points can include the illustrated points L1-L7, and the second ordered set of points can include the illustrated points R1-R7.
And S5, combining the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file.
As shown in FIG. 6, the combined point sets are L1-L7 and R1-R7, and the points in the combined point sets are connected in sequence to form a closed ordered polygon, i.e., the ordered polygon label is obtained.
After all the fold line marking files are processed according to the steps, all the point sets after combination are stored in the marking files to obtain corresponding ordered polygon marking files which are used as model training data in deep learning voice segmentation, and therefore available data are provided for deep learning models for product defect detection.
According to the label conversion method of the embodiment of the invention, by analyzing the label data from the fold line label file, and the end points in the broken line are taken as points to be converted, according to the sequence from the starting point of the broken line to the end point of the broken line, determining a first target transition point on the first side and a second target transition point on the second side of each point to be transitioned according to the annotation data, and then sequentially moving the first target transition point and the second target transition point from the start point to the end point of the polyline, sequencing a plurality of first target conversion points corresponding to a plurality of points to be converted to obtain a first ordered point set, and according to the sequence from the fold line terminal point to the starting point, sequencing a plurality of second target conversion points corresponding to a plurality of points to be converted to obtain a second ordered point set, finally combining the first ordered point set and the second ordered point set to obtain an ordered polygon marking file, therefore, the polygon labeling data can be conveniently and quickly obtained, and the development period of the deep learning algorithm is favorably shortened.
The invention also provides a label conversion device corresponding to the label conversion method of the embodiment.
As shown in fig. 7, the annotation conversion apparatus according to the embodiment of the present invention includes an obtaining module 10, a parsing module 20, a converting module 30, a sorting module 40, and a combining module 50. The obtaining module 10 is configured to obtain a fold line annotation file; the analyzing module 20 is configured to analyze the labeled data from the fold line labeled file, where the labeled data includes coordinates and labeled line width of each endpoint in the fold line; the conversion module 30 is configured to determine, according to the sequence from the starting point to the ending point of the polyline, a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the label data, with the end points in the polyline as the points to be converted; the sorting module 40 is configured to sort, according to a sequence from a polyline starting point to a polyline ending point, a plurality of first target conversion points corresponding to the plurality of points to be converted to obtain a first ordered point set, and sort, according to a sequence from the polyline ending point to the starting point, a plurality of second target conversion points corresponding to the plurality of points to be converted to obtain a second ordered point set; the combining module 50 is configured to combine the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file.
For a slender linear target in a product image to be detected, when defect analysis is carried out by utilizing a deep learning voice segmentation technology, firstly, marking can be carried out in a broken line marking mode, and a broken line marking file is obtained. The polyline markup file can be in xml or json and the like.
Taking the scratch on the metal product shown in fig. 2 as an example, the corresponding fold line is marked as shown in fig. 3. The polyline markup document of one embodiment of the present invention is shown in FIG. 4.
As shown in fig. 4, "line" indicates that the labeling manner is a polyline label, "xi" and "yi" respectively indicate the horizontal and vertical coordinates of the end points in the polyline in the image, "i" is the end point number, four end points are shown in fig. 4, and "width" indicates the line width, i.e., the width of the polyline.
The conversion module 30 may first determine a polyline start point and a polyline end point, and then convert each line segment in the polyline into a corresponding vector, where the direction of each vector is the direction of a path from the polyline start point to the polyline end point. As shown in fig. 5, the polyline markup in fig. 3 can be converted into six vectors, and the endpoints in the polyline are marked from the polyline start point to the polyline end point, the vector start point of the first vector a1 is the polyline start point, the vector end point is the second endpoint in the polyline, the vector start point of the second vector a2 is the second endpoint in the polyline, the vector end point is the third endpoint in the polyline, …, the vector start point of the sixth vector a6 is the sixth endpoint in the polyline, and the vector end point is the polyline end point.
Then, the conversion module 30 selects any vector where the point to be converted is located, takes the point to be converted as a middle point and the marked line width as a length, and makes a line segment perpendicular to the selected vector, and two end points of the made line segment are used as two target conversion points on two sides of the point to be converted. In an embodiment of the present invention, two target transition points corresponding to each point to be transitioned may be obtained according to an order from a starting point of the polyline to an ending point of the polyline, where a selected vector corresponding to the starting point of the polyline is a first vector a1, and a selected vector corresponding to a second end point of the polyline may be a first vector a1, or a second vector a2, and so on.
Further, the conversion module 30 may calculate coordinates of two end points of the line segment according to the marked line width, the vector start point coordinate and the vector end point coordinate of the selected vector based on a mathematical method, where the vector start point coordinate and the vector end point coordinate of the selected vector are both coordinates of end points in the polygonal line analyzed by the analysis module 20.
Finally, the conversion module 30 may determine, according to the coordinates of the two end points of the line segment, the vector start point coordinate of the selected vector, and the vector end point coordinate of the selected vector, that each end point of the line segment is located on the first side or the second side of the selected vector, take the end point of the line segment located on the first side of the selected vector as the first target conversion point of the first side of the point to be converted, and take the end point of the line segment located on the second side of the selected vector as the second target conversion point of the second side of the point to be converted. Specifically, the conversion module 30 may calculate the judgment quantity:
Figure 893784DEST_PATH_IMAGE004
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector.
If the judgment amount is greater than 0, the conversion module 30 judges that the end point of the line segment is located at the first side of the selected vector, and if the judgment amount is less than 0, the conversion module 30 judges that the end point of the line segment is located at the second side of the selected vector. The first side of the selected vector is the left side with the vector direction as the forward direction, and the second side of the fixed vector is the right side with the vector direction as the forward direction.
As shown in FIG. 6, the first ordered set of points can include the illustrated points L1-L7, and the second ordered set of points can include the illustrated points R1-R7.
As shown in FIG. 6, the combined point sets are L1-L7 and R1-R7, and the points in the combined point sets are connected in sequence to form a closed ordered polygon, i.e., the ordered polygon label is obtained.
After all the fold line marking files are processed, all the point sets after combination are stored in the marking files to obtain corresponding ordered polygon marking files which are used as model training data in deep learning voice segmentation, and therefore available data are provided for deep learning models for product defect detection.
According to the label conversion device of the embodiment of the invention, by analyzing the label data from the fold line label file, and the end points in the broken line are taken as points to be converted, according to the sequence from the starting point of the broken line to the end point of the broken line, determining a first target transition point on the first side and a second target transition point on the second side of each point to be transitioned according to the annotation data, and then sequentially moving the first target transition point and the second target transition point from the start point to the end point of the polyline, sequencing a plurality of first target conversion points corresponding to a plurality of points to be converted to obtain a first ordered point set, and according to the sequence from the fold line terminal point to the starting point, sequencing a plurality of second target conversion points corresponding to a plurality of points to be converted to obtain a second ordered point set, finally combining the first ordered point set and the second ordered point set to obtain an ordered polygon marking file, therefore, the polygon labeling data can be conveniently and quickly obtained, and the development period of the deep learning algorithm is favorably shortened.
The invention further provides a computer device corresponding to the embodiment.
The computer device according to the embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the label conversion method according to the above-described embodiment of the present invention can be implemented.
According to the computer device of the embodiment of the invention, when the processor executes the computer program stored on the memory, the processor analyzes the label data from the fold line label file, takes the end point in the fold line as the point to be converted, determines the first target conversion point on the first side and the second target conversion point on the second side of each point to be converted according to the label data according to the sequence from the starting point of the fold line to the end point of the fold line, then sorts a plurality of first target conversion points corresponding to the plurality of points to be converted according to the sequence from the starting point of the fold line to the end point of the fold line to obtain a first ordered point set, and sorts a plurality of second target conversion points corresponding to the plurality of points to be converted according to the sequence from the end point of the fold line to the starting point to obtain a second ordered point set, and finally combines the first ordered point set and the second ordered point set to obtain the ordered polygon label file And polygon marking data are obtained quickly, so that the development period of the deep learning algorithm is shortened.
The invention also provides a non-transitory computer readable storage medium corresponding to the above embodiment.
A non-transitory computer-readable storage medium of an embodiment of the present invention has a computer program stored thereon, and when the computer program is executed by a processor, the method for label conversion according to the above-described embodiment of the present invention can be implemented.
According to the non-transitory computer-readable storage medium of an embodiment of the present invention, when the processor executes the computer program stored thereon, the processor parses annotation data from the polyline annotation file, and takes an end point in the polyline as a point to be converted, determines a first target conversion point on a first side and a second target conversion point on a second side of each point to be converted according to the annotation data in an order from a polyline start point to a polyline end point, then sorts a plurality of first target conversion points corresponding to a plurality of points to be converted according to the order from the polyline start point to the polyline end point to obtain a first ordered point set, and sorts a plurality of second target conversion points corresponding to a plurality of points to be converted according to the order from the polyline end point to the start point to obtain a second ordered point set, and finally combines the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file, thereby, the method can conveniently and quickly obtain the polygon marking data, thereby being beneficial to shortening the development period of the deep learning algorithm.
In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The meaning of "plurality" is two or more unless specifically limited otherwise.
In the present invention, unless otherwise expressly stated or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally formed; can be mechanically or electrically connected; either directly or indirectly through intervening media, either internally or in any other relationship. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In the present invention, unless otherwise expressly stated or limited, the first feature "on" or "under" the second feature may be directly contacting the first and second features or indirectly contacting the first and second features through an intermediate. Also, a first feature "on," "over," and "above" a second feature may be directly or diagonally above the second feature, or may simply indicate that the first feature is at a higher level than the second feature. A first feature being "under," "below," and "beneath" a second feature may be directly under or obliquely under the first feature, or may simply mean that the first feature is at a lesser elevation than the second feature.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.

Claims (8)

1. A label conversion method is characterized by comprising the following steps:
s1, acquiring a fold line marking file;
s2, analyzing marking data from the fold line marking file, wherein the marking data comprise coordinates and marking line width of each endpoint in the fold line;
s3, taking the end points of the fold lines as points to be converted, and determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the sequence from the start point to the end point of the fold line according to the label data;
s4, sequencing the first target conversion points corresponding to the conversion points to be converted according to the sequence from the fold line starting point to the fold line ending point to obtain a first ordered point set, and sequencing the second target conversion points corresponding to the conversion points to be converted according to the sequence from the fold line ending point to the starting point to obtain a second ordered point set;
and S5, combining the first ordered point set and the second ordered point set to obtain an ordered polygon annotation file.
2. The annotation conversion method according to claim 1, wherein step S3 specifically includes:
converting each line segment in the broken line into a corresponding vector, wherein the direction of each vector is the direction of a path from the starting point of the broken line to the end point of the broken line;
selecting any vector where the point to be converted is located, taking the point to be converted as a middle point and the marked line width as a length, and making a line segment perpendicular to the selected vector, wherein two end points of the made line segment are used as two target conversion points on two sides of the point to be converted;
calculating coordinates of two end points of the line segment according to the marked line width, the vector starting point coordinates and the vector end point coordinates of the selected vector;
and judging that each end point of the line segment is positioned at the first side or the second side of the selected vector according to the coordinates of the two end points of the line segment, the vector starting point coordinate and the vector end point coordinate of the selected vector, taking the end point of the line segment positioned at the first side of the selected vector as a first target conversion point at the first side of the point to be converted, and taking the end point of the line segment positioned at the second side of the selected vector as a second target conversion point at the second side of the point to be converted.
3. The label conversion method according to claim 2, wherein the calculation judgment amount:
Figure 335261DEST_PATH_IMAGE001
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector;
if the judgment quantity is larger than 0, judging that the end point of the line segment is positioned at the first side of the selected vector;
and if the judgment quantity is less than 0, judging that the end point of the line segment is positioned at the second side of the selected vector.
4. An annotation conversion apparatus, comprising:
the acquisition module is used for acquiring the fold line marking file;
the analysis module is used for analyzing the marking data from the fold line marking file, wherein the marking data comprises the coordinate and the marking line width of each endpoint in the fold line;
the conversion module is used for determining a first target conversion point on the first side and a second target conversion point on the second side of each point to be converted according to the labeling data by taking an end point in the fold line as the point to be converted according to the sequence from the start point of the fold line to the end point of the fold line;
the sequencing module is used for sequencing a plurality of first target conversion points corresponding to the plurality of points to be converted according to the sequence from the broken line starting point to the broken line ending point to obtain a first ordered point set, and sequencing a plurality of second target conversion points corresponding to the plurality of points to be converted according to the sequence from the broken line ending point to the starting point to obtain a second ordered point set;
and the combination module is used for combining the first ordered point set and the second ordered point set to obtain an ordered polygon labeling file.
5. The annotation conversion device of claim 4, wherein the conversion module is specifically configured to:
converting each line segment in the broken line into a corresponding vector, wherein the direction of each vector is the direction of a path from the starting point of the broken line to the end point of the broken line;
selecting any vector where the point to be converted is located, taking the point to be converted as a middle point and the marked line width as a length, and making a line segment perpendicular to the selected vector, wherein two end points of the made line segment are used as two target conversion points on two sides of the point to be converted;
calculating coordinates of two end points of the line segment according to the marked line width, the vector starting point coordinates and the vector end point coordinates of the selected vector;
and judging that each end point of the line segment is positioned at the first side or the second side of the selected vector according to the coordinates of the two end points of the line segment, the vector starting point coordinate and the vector end point coordinate of the selected vector, taking the end point of the line segment positioned at the first side of the selected vector as a first target conversion point at the first side of the point to be converted, and taking the end point of the line segment positioned at the second side of the selected vector as a second target conversion point at the second side of the point to be converted.
6. The annotation conversion apparatus according to claim 5, wherein the conversion module calculates a judgment amount:
Figure 721112DEST_PATH_IMAGE002
wherein y is the judgment quantity, (x0, y0) is the coordinate of the end point of the line segment, (x1, y1) is the vector start point coordinate of the selected vector, and (x2, y2) is the vector end point coordinate of the selected vector;
if the judgment quantity is larger than 0, the conversion module judges that the end point of the line segment is positioned on the first side of the selected vector;
if the judgment quantity is less than 0, the conversion module judges that the end point of the line segment is positioned at the second side of the selected vector.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the annotation conversion method according to any one of claims 1 to 3 when executing the computer program.
8. A non-transitory computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the annotation conversion method according to any one of claims 1 to 3.
CN202110150601.0A 2021-02-04 2021-02-04 Label conversion method and device Active CN112508136B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110150601.0A CN112508136B (en) 2021-02-04 2021-02-04 Label conversion method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110150601.0A CN112508136B (en) 2021-02-04 2021-02-04 Label conversion method and device

Publications (2)

Publication Number Publication Date
CN112508136A true CN112508136A (en) 2021-03-16
CN112508136B CN112508136B (en) 2021-05-11

Family

ID=74952912

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110150601.0A Active CN112508136B (en) 2021-02-04 2021-02-04 Label conversion method and device

Country Status (1)

Country Link
CN (1) CN112508136B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101458818A (en) * 2008-09-26 2009-06-17 深圳市路畅科技有限公司 Graphic data compression processing method based on folding line evacuating algorithm
US10204431B1 (en) * 2014-07-15 2019-02-12 Google Llc Polygon labeling by dominant shapes
CN109658402A (en) * 2018-12-17 2019-04-19 中山大学 Industry profile geometric dimension automatic testing method based on computer vision imaging
CN109785942A (en) * 2019-01-24 2019-05-21 邃蓝智能科技(上海)有限公司 The quick auxiliary mark and storage method and system of a kind of medical imaging data
CN110781639A (en) * 2019-10-12 2020-02-11 苏州浪潮智能科技有限公司 Method and device for automatic marking in PCB design
CN111241779A (en) * 2020-01-15 2020-06-05 苏州浪潮智能科技有限公司 Method for designing irregular parallel lines based on Cadence design software

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101458818A (en) * 2008-09-26 2009-06-17 深圳市路畅科技有限公司 Graphic data compression processing method based on folding line evacuating algorithm
US10204431B1 (en) * 2014-07-15 2019-02-12 Google Llc Polygon labeling by dominant shapes
CN109658402A (en) * 2018-12-17 2019-04-19 中山大学 Industry profile geometric dimension automatic testing method based on computer vision imaging
CN109785942A (en) * 2019-01-24 2019-05-21 邃蓝智能科技(上海)有限公司 The quick auxiliary mark and storage method and system of a kind of medical imaging data
CN110781639A (en) * 2019-10-12 2020-02-11 苏州浪潮智能科技有限公司 Method and device for automatic marking in PCB design
CN111241779A (en) * 2020-01-15 2020-06-05 苏州浪潮智能科技有限公司 Method for designing irregular parallel lines based on Cadence design software

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
卡菲吉斯: "WebGL-顶点和多边形", 《知乎:HTTPS://ZHUANLAN.ZHIHU.COM/P/157331922》 *

Also Published As

Publication number Publication date
CN112508136B (en) 2021-05-11

Similar Documents

Publication Publication Date Title
US10769487B2 (en) Method and device for extracting information from pie chart
CN110309824B (en) Character detection method and device and terminal
CN109886928B (en) Target cell marking method, device, storage medium and terminal equipment
CN111782839A (en) Image question-answering method, image question-answering device, computer equipment and medium
CN109739904B (en) Time sequence marking method, device, equipment and storage medium
CN112560355B (en) Method and device for predicting Mach number of wind tunnel based on convolutional neural network
CN107315989B (en) Text recognition method and device for medical data picture
CN108090211B (en) Hot news pushing method and device
CN108805180B (en) Target object detection method and device
CN110738046B (en) Viewpoint extraction method and apparatus
CN112465814A (en) Battery overlap calculation method and device based on deep learning
CN111639647A (en) Indicating lamp state identification method and device, computer equipment and storage medium
CN110110070B (en) Topic pushing method, device, server and storage medium
CN112597927A (en) Two-dimensional table identification method, device, equipment and system
CN112132131A (en) Measuring cylinder liquid level identification method and device
CN112070155A (en) Time series data labeling method and device
CN112508136B (en) Label conversion method and device
CN113505720A (en) Image processing method and device, storage medium and electronic device
CN111738259A (en) Tower state detection method and device
CN116645612A (en) Forest resource asset determination method and system
CN111627502A (en) Single cell data visualization method, system, device and storage medium
CN116468680A (en) Component reverse pole defect detection method, system, equipment and storage medium
KR20140053259A (en) Techniques for feature extraction
CN115147474A (en) Point cloud annotation model generation method and device, electronic equipment and storage medium
CN110647826B (en) Method and device for acquiring commodity training picture, computer 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