Method, device, equipment and readable storage medium for extracting image label information
By extracting the image label area, the technical problems of image labels in the prior art are solved, and the recognition accuracy and efficiency of image labels are achieved.
Patent Information
- Application Number
- CN202210161786.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-22
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-02-22
AI Technical Summary
The existing technology reduces the OCR recognition performance when converting vector drawings into pictures due to the influence of resolution, and the interference of the table background makes it difficult to ensure the recognition accuracy of the label information.
By extracting line graphics and text graphics in the label area of the vector drawing, restoring the label table based on their positional relationship, constructing the label table and extracting the label information, and using the preset knowledge base to filter the information to determine the accurate label information.
The recognition accuracy and efficiency of the label information are improved, the interference of the table background is avoided, the construction accuracy of the label is ensured and the recognition efficiency is improved.
Smart Images

Figure CN116682130B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vector drawing recognition, and in particular to a method, device, equipment and readable storage medium for extracting graphic label information. Background Art
[0002] At present, corresponding labels are usually designed on vector drawings to provide relevant explanations for the drawings. When the vector drawings need to be adjusted accordingly, the labels on them need to be modified accordingly. However, the labels are usually extracted based on the OCR technology based on target detection. However, when the vector drawings are converted into pictures, the OCR recognition performance will be reduced due to the influence of resolution. In addition, for vector drawings such as instructions, they often have table backgrounds, which will also interfere with OCR recognition, making it difficult to ensure the recognition accuracy of the label information. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method, apparatus, device, and readable storage medium for extracting image label information to solve the problem of difficulty in ensuring the recognition accuracy of image label information.
[0004] According to the first aspect, an embodiment of the present invention provides a method for extracting label information, including: obtaining a target vector drawing, determining the label area of the target vector drawing; extracting line primitives and text primitives in the label area; restoring the label table based on the positional relationship between the line primitives and the text primitives; and extracting the label information in the label table.
[0005] The method for extracting label information provided by an embodiment of the present invention obtains a label area in a target vector drawing, extracts line primitives and text primitives in the label area, and restores the label table based on the positional relationship between the line primitives and text primitives, thereby extracting the label information in the label table. This method restores the label table by extracting the line primitives and text primitives in the label area, thereby ensuring the accuracy of the label table construction and preventing the table background from affecting label recognition. The label table is constructed based on the line primitives and text primitives corresponding to the label to determine the label information corresponding to the label table. This allows direct identification of the label information in the label table, improving the accuracy and efficiency of label information recognition.
[0006] In combination with the first aspect, in the first implementation of the first aspect, the extraction of the label information in the label table includes: obtaining the label key field and the label key field value; filtering the label table information based on the matching relationship between the label key field and the label key field value, and determining the label information corresponding to the label table.
[0007] In combination with the first embodiment of the first aspect, in the second embodiment of the first aspect, the label table is filtered based on the label key field and the label key field value to determine the label information corresponding to the label table, including: judging whether the label key field and the label key field value are in the same cell in the label table; when the label key field and the label key field value are not in the same cell in the label table, judging whether the label key field exists in the label table; when the label key field exists in the label table, determining the first candidate cell corresponding to the label key field based on a preset label knowledge base; based on the first candidate cell corresponding to the label key field, determining the second candidate cell corresponding to the label key field value; filtering the second candidate cell based on the label key field value to obtain a target cell, and using the label key field value of the target cell as the label information; wherein, the preset label knowledge base is constructed based on the label features in the vector drawing.
[0008] In combination with the second embodiment of the first aspect, in the third embodiment of the first aspect, the tag table is filtered based on the tag key field and the tag key field value to determine the tag information corresponding to the tag table, and also includes: when the tag key field and the tag key field value are in the same cell in the tag table, judging whether the tag key field and the tag key field value match based on the tag knowledge base; when the tag key field and the tag key field value match, determining the tag key field and the tag key field value as the tag information.
[0009] In combination with the second embodiment of the first aspect, in the fourth embodiment of the first aspect, the method also includes: when the image tag key field does not exist in the image tag table, determining whether the image tag key field value in the image tag table has a corresponding matching value in the preset image tag knowledge base; if the image tag key field value in the image tag table has a corresponding matching value in the preset image tag knowledge base, using the image tag key field value as the image tag information.
[0010] The method for extracting label information provided by the embodiment of the present invention filters the label table information through the matching relationship between the label key fields and the label key field values, and then determines the label information contained in the label table, thereby ensuring the accuracy of label information extraction.
[0011] In combination with the first aspect, in the fifth implementation of the first aspect, the extraction of line primitives and text primitives in the label area includes: extracting the layer information of the target vector drawing, determining the target layer where the label area is located; obtaining each primitive contained in the target layer; and determining the line primitives and text primitives belonging to the label based on the position information and type information of each primitive.
[0012] The method for extracting label information provided by an embodiment of the present invention extracts the layer information of the target vector drawing, determines the target layer where the label area is located, obtains the various graphic elements contained in the target layer, and determines the line graphic elements and text graphic elements belonging to the label based on the position information and type information of each graphic element. This realizes the determination of the relevant graphic elements, line graphic elements and text graphic elements of the label based on the position information, type information and layer information of the graphic elements, thereby avoiding the influence of the drawing resolution and drawing background on the label recognition.
[0013] In combination with the first aspect, in the sixth implementation of the first aspect, the restoration of the label table based on the positional relationship between the line primitive and the text primitive includes: obtaining the coordinate information of the line segment corresponding to the line primitive, and determining the intersecting line primitive; generating a table frame based on the intersecting line primitive, and determining the cell coordinates of the table frame; based on the coordinate information of the text corresponding to the text primitive and the cell coordinates, inserting the text primitive into the cell in the table frame to obtain the label table.
[0014] In combination with the sixth embodiment of the first aspect, in the seventh embodiment of the first aspect, generating a table frame based on the intersection line primitive includes: extracting the horizontal and vertical lines corresponding to the intersection line primitives; and generating the table frame based on the first coordinate value corresponding to the horizontal line and the second coordinate value corresponding to the vertical line.
[0015] The method for extracting label information provided by an embodiment of the present invention obtains the coordinate information of the line segments corresponding to the line primitives, determines the intersecting line primitives, and generates a table frame based on the intersecting line primitives to obtain the cell coordinates corresponding to each cell in the table frame. Then, based on the coordinate information of the text corresponding to the text primitives and the cell coordinates corresponding to each cell, the text primitives are inserted into each cell in the table frame to obtain a label table, thereby realizing the correlation between the content of the label table and the coordinates, improving the restoration accuracy of the label table, and thus ensuring the recognition accuracy of the label information.
[0016] According to the second aspect, an embodiment of the present invention provides a device for extracting label information, including: an acquisition module for acquiring a target vector drawing and determining the label area of the target vector drawing; a first extraction module for extracting line primitives and text primitives in the label area; a restoration module for restoring a label table based on the positional relationship between the line primitives and the text primitives; and a second extraction module for extracting label information from the label table.
[0017] According to the third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the method for extracting image signature information described in the first aspect or any embodiment of the first aspect by executing the computer instructions.
[0018] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the method for extracting image signature information described in the first aspect or any embodiment of the first aspect.
[0019] It should be noted that, for the corresponding beneficial effects of the image signature information extraction device, electronic device and computer-readable storage medium provided in the embodiments of the present invention, please refer to the description of the corresponding contents in the image signature information extraction method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 is a flowchart of a method for extracting image tag information according to an embodiment of the present invention;
[0022] Figure 2 is another flow chart of a method for extracting image tag information according to an embodiment of the present invention;
[0023] Figure 3 is another flow chart of a method for extracting image tag information according to an embodiment of the present invention;
[0024] Figure 4 is a schematic diagram of a label according to an embodiment of the present invention;
[0025] Figure 5 is another schematic diagram of a label according to an embodiment of the present invention;
[0026] Figure 6 is another schematic diagram of a label according to an embodiment of the present invention;
[0027] Figure 7 is a structural block diagram of a device for extracting image signature information according to an embodiment of the present invention;
[0028] Figure 8 It is a schematic diagram of the hardware structure of the electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0030] Vector drawings are usually designed with corresponding labels to provide relevant explanations for the drawings. When the vector drawings need to be adjusted accordingly, the labels on them need to be modified accordingly. However, currently, label extraction is usually performed based on OCR technology based on target detection. However, when vector drawings are converted into images, the OCR recognition performance will be reduced due to the influence of resolution. In addition, for vector drawings such as instructions, they often have table backgrounds, which will also interfere with OCR recognition, making it difficult to ensure the recognition accuracy of the label information.
[0031] Based on this, the technical solution of the present invention restores the label table by extracting the line graphics and text graphics in the label area, thereby ensuring the construction accuracy of the label table, and then extracting the label information from the label table, avoiding the influence of the table background on label recognition, and improving the recognition accuracy and efficiency of the label information.
[0032] According to an embodiment of the present invention, an embodiment of a method for extracting image label information is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] In this embodiment, a method for extracting image signature information is provided, which can be used in electronic devices such as mobile phones, computers, tablet computers, etc. Figure 1 FIG. 1 is a flow chart of a method for extracting image tag information according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0034] S11, obtaining a target vector drawing and determining a label area of the target vector drawing.
[0035] The target vector drawing is the DWG drawing to be identified. The target vector drawing can be read from a mobile storage device, such as a mobile hard disk or a USB flash drive. The target vector drawing can also be read from the local storage space of the electronic device. Of course, it can also be obtained in other ways. The method of obtaining the target vector drawing is not limited here, and those skilled in the art can determine it according to actual needs.
[0036] The label area is the area of the target vector drawing where the label is located. The label is a label column on the target vector drawing that indicates the draftsman's information, including the design unit, design time, project name, and other information. The electronic device identifies the target vector drawing, performs data analysis on the target vector drawing, extracts the label features contained in the target vector drawing, and delineates the label's location in the target vector drawing based on the extracted label features, for example, delineating the lower left side of the target vector drawing as the label area or the lower right side of the target vector drawing as the label area.
[0037] S12, extracting line primitives and text primitives in the label area.
[0038] Line primitives are line segment data that constitute the label, and text primitives are text data that constitute the label. The electronic device can analyze all data contained in the label area and determine the line primitives and text primitives contained in the label area based on the characteristics of the line segment data and text data.
[0039] S13, restoring the label table based on the positional relationship between the line primitive and the text primitive.
[0040] The electronic device determines the line graphic element corresponding to the label from all the line graphic elements it recognizes in the label area based on the label features, and then generates a table frame based on the horizontal and vertical lines corresponding to the line graphic elements. Then, combined with the coordinate information of the text graphic element in the label area and the coordinate information of each cell, the text graphic element is merged into the corresponding cell in the table frame to obtain the label table.
[0041] S14, extracting the label information in the label table.
[0042] After the electronic device completes the restoration of the label table based on the line primitives and text primitives, it can obtain the information of each cell in the restored label table. At this time, the electronic device can identify the information of each cell in the label table based on the label category corresponding to the label, and obtain the label information corresponding to the label table. Among them, the label category is the field to be identified, including the drawing name, drawing number, major, project name, date, sub-item name, and scale, and the value corresponding to the label category is determined. The label category and its corresponding value are determined as the label information. For example, if the label category is scale, then the label table is identified to determine the possible value corresponding to the scale of 1:200, and the corresponding element set {1:200, scale 1:200} can be obtained.
[0043] The method for extracting label information provided in this embodiment restores the label table by extracting the line graphics and text graphics in the label area, thereby ensuring the accuracy of label table construction and avoiding the influence of the table background on label recognition; constructing the label table based on the line graphics and text graphics corresponding to the label to determine the label information corresponding to the label table, thereby being able to directly identify the label information in the label table, thereby improving the recognition accuracy and efficiency of the label information.
[0044] In this embodiment, a method for extracting image signature information is provided, which can be used in electronic devices such as mobile phones, computers, tablet computers, etc. Figure 2 FIG. 1 is a flow chart of a method for extracting image tag information according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0045] S21, obtaining a target vector drawing and determining a label area of the target vector drawing. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.
[0046] S22: extracting line primitives and text primitives from the label area. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.
[0047] S23, restoring the label table based on the positional relationship between the line primitive and the text primitive. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.
[0048] S24, extracting the label information in the label table.
[0049] Specifically, the above step S24 may include:
[0050] S241, obtaining the key field of the image label and the value of the key field of the image label.
[0051] The key fields of a label are used to represent the label category, such as the drawing name, drawing number, discipline, project name, date, sub-item name, and scale. The key field value of the label is the value corresponding to the label category, for example, the value corresponding to the drawing name is "Architectural Space Layout" and the date is "XX Year X Month X Day". Specifically, the key fields of the label and the key field values of the label can be determined by identifying the text elements in the label area.
[0052] S242 , filtering the image tag table based on the matching relationship between the image tag key fields and the image tag key field values, and determining the image tag information corresponding to the image tag table.
[0053] There is a specific matching relationship between the key fields and the values of the key fields of the image tag, that is, there is a one-to-one correspondence between the image tag category and its corresponding value. The electronic device filters and matches the information contained in the image tag table based on the matching relationship between the key fields and the values of the image tag key fields, thereby extracting the image tag information from the image tag table.
[0054] Specifically, the above step S242 may include:
[0055] (1) Determine whether the key field of the label and the value of the key field of the label are in the same cell in the label table.
[0056] The electronic device determines the coordinates of each cell based on the restored image tag table, and then combines the coordinates of the image tag key field and the image tag key field value to determine whether the image tag key field and the image tag key field value are in the same cell, and further determines the image tag key field and the image tag key field value in the same cell in the image tag table. When the image tag keyword and the corresponding value of the image tag keyword are not in the same cell in the image tag table, step (2) is executed, otherwise step (6) is executed.
[0057] (2) Determine whether there is a key field for the label in the label table.
[0058] When the label keyword and the corresponding value of the label keyword are not in the same cell in the label table, the electronic device can identify the text element information in the label table to determine whether there is a label key field in the label table. When the label key field exists in the label table, execute step (3), otherwise execute step (8).
[0059] (3) Determine the first candidate cell corresponding to the key field of the image label based on the preset image label knowledge base.
[0060] The preset image signature knowledge base is constructed based on the image signature features in the vector drawings. Specifically, the electronic device can pre-analyze the vector drawings to extract the image signature features that need to be recognized in the vector drawings and add them to the image signature knowledge base. For example, if the electronic device recognizes the image signature category as scale, it can first extract the interference information knowledge that needs to be deleted from the vector drawings, then extract the name corresponding to the scale category, and extract the knowledge that the name and value of the scale category are in the same cell, thus completing the construction of the scale category knowledge base.
[0061] The first candidate cell is a possible cell where the key field of the image signature is located. The electronic device can construct a coordinate system of the image signature table, determine the coordinate information of the grid where the key field of the image signature is located and the coordinate information of other cells, and calculate the distance between the grid where the key field of the image signature is located and the remaining cells based on the coordinate information of the grid where the key field of the image signature is located and the coordinate information of each other cell, and determine the N cells closest to the grid where the key field of the image signature is located, for example, the N cells closest to the bottom and right side of the grid where the key field of the image signature is located, where N can be determined based on data analysis of the image signature table. The electronic device can query the preset image signature knowledge base, filter the image signature table according to the key field of the image signature, and determine the N cells closest to the grid where the key field of the image signature is located as the first candidate cell.
[0062] (4) Based on the first candidate cell corresponding to the key field of the image signature, determine the second candidate cell corresponding to the value of the key field of the image signature.
[0063] The second candidate cell is a possible cell where the image signature key field value is located. The electronic device identifies the image signature key field, searches a preset image signature knowledge base based on the image signature key field to determine the image signature key field value corresponding to the image signature key field, and then screens the first candidate cell based on the image signature key field value to determine the second candidate cell corresponding to the image signature key field value.
[0064] (5) Filter the second candidate cells based on the key field value of the image signature to obtain the target cell, and use the key field value of the image signature of the target cell as the image signature information.
[0065] When determining the second candidate cell, the electronic device can parse the information it contains, filter the text information in the candidate cell according to the signature key field value, determine the target cell whose signature key field matches the signature key field value, and determine the signature key field corresponding to the target cell as the signature information.
[0066] (6) Based on the preset tag knowledge base, determine whether the tag key field matches the tag key field value.
[0067] Since the styles of the same image tag key field and its image tag key field value are different, the two may be in different cells or in the same cell. When the image tag key field and the image tag key field value are in the same cell in the image tag table, the electronic device can query the preset image tag knowledge base to determine whether the image tag key field and the image tag key field value match. When the image tag key field and the image tag key field value match, step (7) is executed, otherwise the cell where the image tag key field is located is determined according to the image tag key field, and the preset image tag knowledge base is searched according to the image tag key field to determine the candidate set of the image tag key field value corresponding to the image tag key field. If the image tag key field value in the candidate set has a corresponding matching value in the preset image tag knowledge base, the image tag key field value is used as the image tag information.
[0068] (7) The key field of the image tag and the value of the key field of the image tag are determined as the image tag information.
[0069] When the tag key field and the tag key field value match, it means that the tag key field and the current tag key field value in the same cell are one-to-one corresponding. At this time, the tag key field and the tag key field value can be determined as the tag information.
[0070] (8) When the image label table does not have the image label key field, determine whether the image label key field value in the image label table has a corresponding matching value in the preset image label knowledge base.
[0071] When the image signature key field does not exist in the image signature table, the electronic device may query the preset image signature knowledge base based on the image signature key field value to determine whether the image signature key field value has a corresponding matching value in the preset image signature knowledge base. If the image signature key field value in the image signature table has a corresponding matching value in the preset image signature knowledge base, step (9) is executed; otherwise, the image signature key field value is deleted.
[0072] (9) The key field value of the image tag is used as the image tag information.
[0073] If the tag key field value in the tag table has a corresponding matching value in the preset tag knowledge base, it means that the style corresponding to the tag keyword value exists in the preset tag knowledge base. At this time, the tag key field value can be used as the tag information.
[0074] like Figures 4 to 6 As shown in the figure, take the identification of the key field "design stage" as an example, based on Figures 4 to 6 As can be seen from the label, the label key field "Design Stage" and the label key field value "Conclusion" can be in the same cell, such as Figure 4 As shown, they can also be in two cells, such as Figure 5As shown, of course, it is also possible to only have the drawing label keyword field value "structural construction drawing" (here, the drawing label keyword field "design stage" is used as the key, and the drawing label keyword field value "structural construction drawing" is used as the value). Specifically, the steps to identify the drawing label keyword field "design stage" are as follows:
[0075] 1) Obtain the information contained in the restored drawing label table, which includes all cell coordinates and all cell values in the drawing label table;
[0076] 2) Initially filter the drawing label table according to the interference information of the drawing label keyword field "design stage" in the preset drawing label knowledge base to filter out the interference information, such as Figure 4 "Drawing type: structural construction drawing" in the corresponding drawing;
[0077] 3) As Figure 4 shown in the style, identify the situation where the drawing label keyword field "design stage" and the drawing label keyword field value "structural construction drawing" are in the same cell. Specifically, match the information where the key and value are in the same cell according to the preset drawing label knowledge base. If a match is found, it is used as the drawing label information;
[0078] 4) As[[ID=I7]] Figure 5 shown in the style, identify the situation where the cell where the drawing label keyword field "design stage" is located and the drawing label keyword field value "structural construction drawing" are in different cells. Specifically, match the information in the drawing label table according to the key information in the preset drawing label knowledge base. If a match is found, the coordinate information of the cell where the drawing label keyword field "design stage" is located is obtained, and the suspected cell of the drawing label keyword field value is recalled based on the coordinate information of the cell where the drawing label keyword field "design stage" is located and used as the candidate cell;
[0079] 5) Screen the above candidate cells. If it can match the value in the preset drawing label knowledge base, it is retained as the drawing label information; otherwise, it is deleted from the candidate cells;
[0080] 6) As Figure 6 shown in the style, when there is no drawing label keyword field "design stage" or the candidate cell is empty, a key-free search needs to be performed. Specifically, match the text primitive according to the value in the preset drawing label knowledge base. If a match is found, it is used as the drawing label information.
[0081] The method for extracting drawing label information provided in this embodiment filters the information in the drawing label table through the matching relationship between the drawing label keyword field and the drawing label keyword field value, and then determines the drawing label information contained in the drawing label table, thereby ensuring the accuracy of the extraction of the drawing label information.
[0082] In this embodiment, a method for extracting image signature information is provided, which can be used in electronic devices such as mobile phones, computers, tablet computers, etc. Figure 3 FIG. 1 is a flow chart of a method for extracting image tag information according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0083] S31, obtaining a target vector drawing and determining a label area of the target vector drawing. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.
[0084] S32, extracting line primitives and text primitives in the label area.
[0085] Specifically, the above step S32 may include:
[0086] S321, extracting the layer information of the target vector drawing and determining the target layer where the label area is located.
[0087] The target vector drawing is a drawing obtained by stacking multiple layers in a certain order. The layer information contains text information or graphic information corresponding to the target vector drawing. The electronic device can determine the target layer where the label is located based on the label area.
[0088] S322: Obtain each graphic element contained in the target layer.
[0089] The target layer includes line primitives and text primitives for generating label. The electronic device can extract the text information or graphic information in the target layer, and then determine the various primitives included in the target layer based on the text information or graphic information.
[0090] S323: Based on the position information and type information of each graphic element, determine the line graphic element and text graphic element belonging to the graphic label.
[0091] The position information is the position of each primitive in the label area, which can be represented by coordinates. The type information includes information such as line segments, text, arcs, polygons, etc. used to characterize the category of primitives. Specifically, the electronic device constructs a coordinate system based on the label area to obtain the coordinate values of each primitive in the label area, and then filters out background interference primitives based on the coordinate values corresponding to each primitive, and combines the type information of each primitive to determine the line primitives and text primitives belonging to the label.
[0092] S33, restoring the label table based on the positional relationship between the line graphic element and the text graphic element.
[0093] Specifically, the above step S33 may include:
[0094] S331, obtain the coordinate information of the line segment corresponding to the line primitive and determine the intersecting line primitive.
[0095] The electronic device can identify all line segments corresponding to the line graphic element, obtain the coordinate information of each line segment in the label area, and sort the line segments according to the coordinate information of all line segments. For any vertical line, it finds the horizontal line closest to its upper and lower sides and intersecting with it. For any horizontal line, it finds the vertical line closest to its left and right sides and intersecting with it, that is, the intersecting line graphic element.
[0096] S332, generating a table frame based on the intersection line primitives, and determining the cell coordinates of the table frame.
[0097] According to the intersection between the intersecting line primitives, a table frame containing multiple cells can be generated. Specifically, for any vertical line a, the electronic device can find the vertical line b closest to it from the line primitives, and then find the intersecting line primitives corresponding to the vertical line a and the vertical line b respectively. Based on this, the cell corresponding to the vertical line a can be constructed, and then multiple cells can be constructed in sequence. The combination of multiple cells can obtain a table frame, and then the electronic device can obtain the cell coordinates of each cell in the table frame in the label area.
[0098] Specifically, the step of generating a table frame based on the intersection line primitives may include:
[0099] (1) Extract the horizontal and vertical lines corresponding to the intersecting line primitives.
[0100] The intersecting line primitives are composed of line primitives having an intersecting relationship, and the electronic device can determine the corresponding horizontal and vertical lines based on the intersecting line primitives.
[0101] (2) Generate a table frame based on the first coordinate value corresponding to the horizontal line and the second coordinate value corresponding to the vertical line.
[0102] The first coordinate value is the ordinate corresponding to each horizontal line, and the second coordinate value is the abscissa corresponding to each vertical line. The electronic device can sort the horizontal lines according to the ordinate from small to large, and sort the vertical lines according to the abscissa from small to large, thereby establishing a table framework.
[0103] S333: Based on the coordinate information of the text corresponding to the text primitive and the cell coordinates, the text primitive is inserted into the cell in the table frame to obtain a label table.
[0104] The electronic device can determine the coordinate range covered by the cell based on the first coordinate value and the second coordinate value constituting the cell, and then compare the coordinate information of the text in the text primitive with the coordinates of the cell to determine whether the coordinate range covered by the cell can cover the coordinate information of the text in the text primitive. If the coordinate range covered by the cell can cover the coordinate information of the text in the text primitive, the text corresponding to the text primitive is inserted into the corresponding cell in the table frame, thereby obtaining a label table.
[0105] S34, extracting the image label information in the image label table. Detailed descriptions refer to the corresponding descriptions of the above embodiments, which will not be repeated here.
[0106] The method for extracting label information provided in this embodiment extracts the layer information of the target vector drawing, determines the target layer where the label area is located, obtains the various primitives contained in the target layer, and determines the line primitives and text primitives belonging to the label based on the position information, type information and layer information of each primitive, thereby achieving the determination of the relevant line primitives and text primitives of the label based on the position information, type information and layer information of the primitives, thereby avoiding the influence of the drawing resolution and drawing background on the label recognition. By obtaining the coordinate information of the line segment corresponding to the line primitive, determining the intersecting line primitive, and generating a table frame based on the intersecting line primitives, obtaining the cell coordinates corresponding to each cell in the table frame, and then inserting the text primitives into each cell in the table frame based on the coordinate information of the text corresponding to the text primitive and the cell coordinates corresponding to each cell, obtaining a label table, thereby achieving the correlation between the label table content and the coordinates, improving the restoration accuracy of the label table, and thus ensuring the recognition accuracy of the label information.
[0107] In this embodiment, a device for extracting image tag information is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation by hardware, or a combination of software and hardware, is also possible and conceivable.
[0108] This embodiment provides a device for extracting image signature information. Figure 7 Shown, including:
[0109] The acquisition module 41 is used to acquire the target vector drawing and determine the label area of the target vector drawing. Detailed descriptions can be found in the corresponding descriptions of the above method embodiments, which will not be repeated here.
[0110] The first extraction module 42 is used to extract line primitives and text primitives in the label area. Detailed descriptions refer to the corresponding descriptions of the above method embodiments, which will not be repeated here.
[0111] The restoration module 43 is used to restore the label table based on the positional relationship between the line primitive and the text primitive. Detailed descriptions can be found in the corresponding descriptions of the above method embodiments, which will not be repeated here.
[0112] The second extraction module 44 is used to extract the label information from the label table. Detailed descriptions can be found in the corresponding descriptions of the above method embodiments, which will not be repeated here.
[0113] The device for extracting label information provided in this embodiment restores the label table by extracting the line graphics and text graphics in the label area, thereby ensuring the accuracy of label table construction and avoiding the influence of the table background on label recognition; constructs a label table based on the line graphics and text graphics corresponding to the label to determine the label information corresponding to the label table, thereby being able to directly identify the label information in the label table, thereby improving the recognition accuracy and efficiency of the label information.
[0114] The device for extracting the image signature information in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0115] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.
[0116] An embodiment of the present invention further provides an electronic device having Figure 7 The device for extracting the label information shown.
[0117] See also Figure 8 , Figure 8 is a structural diagram of an electronic device provided by an optional embodiment of the present invention, such as Figure 8 As shown, the electronic device may include: at least one processor 501, such as a CPU (Central Processing Unit), at least one communication interface 503, a memory 504, and at least one communication bus 502. The communication bus 502 is used to realize the connection and communication between these components. The communication interface 503 may include a display screen (Display), a keyboard (Keyboard), and the optional communication interface 503 may also include a standard wired interface and a wireless interface. The memory 504 may be a high-speed RAM memory (Random Access Memory, volatile random access memory) or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 504 may optionally be at least one storage device located away from the aforementioned processor 501. The processor 501 may be combined with Figure 7 In the described apparatus, the memory 504 stores an application program, and the processor 501 calls the program code stored in the memory 504 to execute any of the above method steps.
[0118] The communication bus 502 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 502 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0119] Among them, the memory 504 may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviated: RAM); the memory may also include non-volatile memory (English: non-volatile memory), such as flash memory (English: flash memory), hard disk drive (English: hard disk drive, abbreviated: HDD) or solid-state drive (English: solid-state drive, abbreviated: SSD); the memory 504 may also include a combination of the above types of memory.
[0120] The processor 501 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.
[0121] The processor 501 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0122] Optionally, the memory 504 is also used to store program instructions. The processor 501 can call the program instructions to implement the application Figures 1 to 3The method for extracting image label information shown in the embodiment.
[0123] An embodiment of the present invention further provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the processing method of the method for extracting the image signature information in any of the above method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.
[0124] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention. Such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for extracting image label information, characterized in that: include: Acquire a target vector drawing and determine a label area of the target vector drawing; Extracting line primitives and text primitives in the label area; Restoring the label table based on the positional relationship between the line primitive and the text primitive; Extracting the image tag information from the image tag table includes: obtaining an image tag key field and an image tag key field value; filtering the image tag table based on a matching relationship between the image tag key field and the image tag key field value to determine the image tag information corresponding to the image tag table; Wherein, based on the tag key field and the tag key field value, the tag table is filtered to determine the tag information corresponding to the tag table, including: judging whether the tag key field and the tag key field value are in the same cell in the tag table; when the tag key field and the tag key field value are not in the same cell in the tag table, judging whether the tag key field exists in the tag table; when the tag key field exists in the tag table, determining a first candidate cell corresponding to the tag key field based on a preset tag knowledge base; based on the first candidate cell corresponding to the tag key field, determining a second candidate cell corresponding to the tag key field value; filtering the second candidate cell based on the tag key field value to obtain a target cell, and using the tag key field value of the target cell as the tag information; wherein, the preset tag knowledge base is constructed based on the tag features in the vector drawing.
2. The method according to claim 1, characterized in that The method further comprises: filtering the image tag table based on the image tag key field and the image tag key field value to determine the image tag information corresponding to the image tag table; When the image tag key field and the image tag key field value are in the same cell in the image tag table, determining whether the image tag key field and the image tag key field value match based on the preset image tag knowledge base; When the image tag key field and the image tag key field value match, the image tag key field and the image tag key field value are determined as the image tag information.
3. The method according to claim 1, characterized in that Also includes: When the image tag table does not contain the image tag key field, determining whether the image tag key field value in the image tag table has a corresponding matching value in the preset image tag knowledge base; If the image tag key field value in the image tag table has a corresponding matching value in the preset image tag knowledge base, the image tag key field value is used as the image tag information.
4. The method according to claim 1, wherein The extracting of line primitives and text primitives in the label area includes: Extracting the layer information of the target vector drawing and determining the target layer where the label area is located; Obtaining each graphic element contained in the target layer; Based on the position information and type information of each graphic element, the line graphic element and the text graphic element belonging to the graphic label are determined.
5. The method according to claim 1, wherein The restoring of the label table based on the positional relationship between the line primitive and the text primitive includes: Obtaining coordinate information of the line segments corresponding to the line primitives, and determining intersecting line primitives; Generate a table frame based on the intersection line primitives, and determine the cell coordinates of the table frame; Based on the coordinate information of the text corresponding to the text primitive and the cell coordinates, the text primitive is inserted into the cell in the table frame to obtain the label table.
6. The method according to claim 5, characterized in that The generating of a table framework based on the intersecting line primitives includes: Extracting the horizontal and vertical lines corresponding to the intersecting line primitives; The table frame is generated based on the first coordinate value corresponding to the horizontal line and the second coordinate value corresponding to the vertical line.
7. A device for extracting image label information, characterized in that: include: An acquisition module, configured to acquire a target vector drawing and determine a label area of the target vector drawing; A first extraction module is used to extract line primitives and text primitives in the label area; A restoration module, configured to restore the label table based on the positional relationship between the line primitive and the text primitive; The second extraction module is used to extract the image tag information in the image tag table, including: obtaining the image tag key field and the image tag key field value; filtering the image tag table based on the matching relationship between the image tag key field and the image tag key field value to determine the image tag information corresponding to the image tag table; wherein, filtering the image tag table based on the image tag key field and the image tag key field value to determine the image tag information corresponding to the image tag table includes: judging whether the image tag key field and the image tag key field value are in the same cell in the image tag table; when the image tag key field and the image tag key field value are not in the same cell, When the two cells are in the same cell in the label table, determine whether the label key field exists in the label table; when the label key field exists in the label table, determine the first candidate cell corresponding to the label key field based on the preset label knowledge base; based on the first candidate cell corresponding to the label key field, determine the second candidate cell corresponding to the label key field value; filter the second candidate cell based on the label key field value to obtain the target cell, and use the label key field value of the target cell as the label information; wherein, the preset label knowledge base is constructed based on the label features in the vector drawing.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for extracting the image label information according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for extracting image label information according to any one of claims 1 to 6.
Citation Information
Patent Citations
Title block identification method
CN101388079A
Nested table extraction method and device, and storage medium
CN112668289A