Method and device for determining line segment connection relation of interlocking logic diagram
By automatically processing the line segment coordinates in the interlocking logic diagram, the line segment connection relationship of the interlocking logic diagram is determined, which solves the error risk and inefficiency problems of manual interpretation of paper design drawings, and achieves more efficient and accurate line segment connection relationship determination.
Patent Information
- Application Number
- CN202411949915.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-03-25
AI Technical Summary
In the prior art, manual interpretation of paper design drawings is carried out to determine the line segment connection relationship of the interlocking logic diagram, which has a risk of error and is inefficient.
By obtaining the coordinates of the line segments in the interlocking logic diagram, the types of line segments (horizontal and vertical lines) are automatically determined, the segment list is divided, the approximate line segments are determined, and the final line segment is converted to determine the segment connection relationship of the interlocking logic diagram.
The efficiency and accuracy of the determination of the line segment connection relationship of the interlocking logic diagram are improved, and the confusion of the connection relationship caused by excessive or complex line segments is reduced.
Smart Images

Figure CN119691948A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of process industry technology, and in particular to a method and device for determining a line segment connection relationship of an interlocking logic diagram. Background Art
[0002] In the petrochemical industry, safety interlock control is crucial. In order to ensure the safety and stability of the production process, interlock logic diagrams are usually used to illustrate the complex relationship of safety interlock control. Interlock logic diagrams describe in detail the logical relationship between each input condition and output response through line connection relationships, which directly determine the behavior and effect of safety interlock control. Therefore, the line connection relationship of the interlock logic diagram is particularly important.
[0003] Currently, the designer provides paper design drawings of the interlocking logic to the control system manufacturer, and the control system manufacturer needs to manually interpret the paper design drawings and determine the line segment connection relationship of the interlocking logic diagram.
[0004] However, the manual interpretation of paper design drawings and determination of line segment connection relationships increases the risk of errors and is inefficient. Summary of the invention
[0005] In view of the above problems, the present application provides a method and device for determining the line segment connection relationship of an interlocking logic diagram, in order to improve the efficiency and accuracy of determining the line segment connection relationship of an interlocking logic diagram. The specific scheme is as follows:
[0006] A first aspect of the present application provides a method for determining a line segment connection relationship of an interlocking logic diagram, comprising:
[0007] Obtaining x-axis coordinates of the starting points of multiple line segments in the interlocking logic diagram, x-axis coordinates of the end points of multiple line segments, y-axis coordinates of the starting points of multiple line segments, and y-axis coordinates of the end points of multiple line segments;
[0008] For each line segment, based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment, the type of the line segment is determined, wherein the line segment includes two types: a horizontal line and a vertical line;
[0009] Based on the types of the line segments, the line segments are divided to obtain a line segment list, wherein the line segment list includes a horizontal line list and a vertical line list;
[0010] For each line segment in each of the line segment lists, determine an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment;
[0011] The line segment connection relationship of the interlocking logic diagram is determined based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.
[0012] In a possible implementation, before determining, for each of the line segments, the type of the line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment, the method further includes:
[0013] For each of the line segments, determining a slope of the line segment based on an x-axis coordinate of a starting point of the line segment, an x-axis coordinate of an end point of the line segment, a y-axis coordinate of a starting point of the line segment, and a y-axis coordinate of an end point of the line segment;
[0014] Determining whether the slope of the line segment falls within a preset slope range;
[0015] If the slope of the line segment belongs to the slope range, the line segment is deleted.
[0016] In a possible implementation, the process of determining the approximate line segment of the target line segment in each line segment list includes:
[0017] In the case where the line segment list is the horizontal line list, calculating the first algebraic difference absolute value of the x-axis coordinate of the starting point of each other horizontal line in the horizontal line list and the x-axis coordinate of the starting point of the target horizontal line in the horizontal line list, the second algebraic difference absolute value of the x-axis coordinate of the end point of each other horizontal line and the x-axis coordinate of the end point of the target horizontal line, and the third algebraic difference absolute value of the y-axis coordinate of each other horizontal line and the y-axis coordinate of the target horizontal line;
[0018] Determine other horizontal lines whose absolute value of the first algebraic difference is less than a preset first precision value, whose absolute value of the second algebraic difference is less than a preset second precision value, and whose absolute value of the third algebraic difference is less than a preset third precision value as horizontal lines near the target horizontal line;
[0019] Determine an approximate horizontal line of the target horizontal line from horizontal lines near the target horizontal line based on the first algebraic difference absolute value, the second algebraic difference absolute value and the third algebraic difference absolute value;
[0020] In the case where the line segment list is the vertical line list, calculating the fourth algebraic difference absolute value between the y-axis coordinate of the starting point of each other vertical line in the vertical line list and the y-axis coordinate of the starting point of the target vertical line in the line segment list, the fifth algebraic difference absolute value between the y-axis coordinate of the end point of each other vertical line and the y-axis coordinate of the end point of the target vertical line, and the sixth algebraic difference absolute value between the x-axis coordinate of each other vertical line and the x-axis coordinate of the target vertical line;
[0021] Determine other vertical lines whose absolute value of the fourth algebraic difference is less than a preset fourth precision value, whose absolute value of the fifth algebraic difference is less than a preset fifth precision value, and whose absolute value of the sixth algebraic difference is less than a preset sixth precision value as vertical lines near the target vertical line;
[0022] An approximate vertical line of the target vertical line is determined from vertical lines near the target vertical line based on the fourth algebraic difference absolute value, the fifth algebraic difference absolute value, and the sixth algebraic difference absolute value.
[0023] In a possible implementation, the process of determining the approximate line segment of the target line segment in each line segment list further includes:
[0024] In the case where the line segment list is the horizontal line list, if there is no other horizontal line whose absolute value of the first algebraic difference is less than the first precision value, whose absolute value of the second algebraic difference is less than the second precision value, and whose absolute value of the third algebraic difference is less than the third precision value, then calculate the seventh algebraic difference absolute value between the x-axis coordinate of the starting point of the target horizontal line and the x-axis coordinate of the end point of the target horizontal line, the eighth algebraic difference absolute value between the x-axis coordinate of the starting point of each of the other horizontal lines and the x-axis coordinate of its own end point, and the ninth algebraic difference absolute value between the y-axis coordinate of the target horizontal line and the y-axis coordinate of each of the other horizontal lines;
[0025] Determine other horizontal lines whose absolute value of the seventh algebraic difference is not equal to the absolute value of the eighth algebraic difference and whose absolute value of the ninth algebraic difference is less than the preset seventh precision value as approximate horizontal lines of the target horizontal line;
[0026] In the case where the line segment list is the vertical line list, if there are no other vertical lines whose fourth algebraic difference absolute value is less than the fourth precision value, whose fifth algebraic difference absolute value is less than the fifth precision value, and whose sixth algebraic difference absolute value is less than the sixth precision value, then calculate the tenth algebraic difference absolute value between the y-axis coordinate of the starting point of the target vertical line and the y-axis coordinate of the end point of the target vertical line, the eleventh algebraic difference absolute value between the y-axis coordinate of the starting point of each of the other vertical lines and the y-axis coordinate of its own end point, and the twelfth algebraic difference absolute value between the x-axis coordinate of the target vertical line and the x-axis coordinate of each of the other vertical lines;
[0027] Other vertical lines whose tenth algebraic difference absolute value is not equal to the eleventh algebraic difference absolute value and whose twelfth algebraic difference absolute value is smaller than the preset eighth precision value are determined as approximate vertical lines of the target vertical line.
[0028] In a possible implementation, after determining, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes:
[0029] Obtain the x-axis coordinate of the right edge of the module where the input bit number of the interlocking logic diagram is located and the x-axis coordinate of the left edge of the module where the output bit number is located;
[0030] For each of the final line segments, determine whether the x-axis coordinate of the starting point of the final line segment is less than the x-axis coordinate of the right edge of the module where the input bit number is located, and whether the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located;
[0031] If the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, or the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located, the final line segment will be deleted.
[0032] In a possible implementation, the final line segment includes a final horizontal line and a final vertical line. After determining, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes:
[0033] Obtaining x-axis coordinates of the starting points of multiple horizontal border lines of each module of the interlocking logic diagram, x-axis coordinates of the end points of multiple horizontal border lines, y-axis coordinates of multiple horizontal border lines, y-axis coordinates of the starting points of multiple vertical border lines, y-axis coordinates of the end points of multiple vertical border lines, and x-axis coordinates of multiple vertical border lines;
[0034] For each of the final horizontal lines, calculate the thirteenth algebraic difference absolute value between the x-axis coordinate of the starting point of the final horizontal line and the x-axis coordinate of the starting point of each of the horizontal border lines, the fourteenth algebraic difference absolute value between the x-axis coordinate of the end point of the final horizontal line and the x-axis coordinate of the end point of each of the horizontal border lines, and the fifteenth algebraic difference absolute value between the y-axis coordinate of the final horizontal line and the y-axis coordinate of each of the horizontal border lines;
[0035] If the thirteenth algebraic difference absolute value is less than the preset ninth precision value, the fourteenth algebraic difference absolute value is less than the preset tenth precision value, and the fifteenth algebraic difference absolute value is less than the preset eleventh precision value, then the final horizontal line is deleted;
[0036] For each of the final vertical lines, calculate the sixteenth algebraic difference absolute value between the y-axis coordinate of the starting point of the final vertical line and the y-axis coordinate of the starting point of each of the vertical border lines, the seventeenth algebraic difference absolute value between the y-axis coordinate of the end point of the final vertical line and the y-axis coordinate of the end point of each of the vertical border lines, and the eighteenth algebraic difference absolute value between the x-axis coordinate of the final vertical line and the x-axis coordinate of each of the vertical border lines;
[0037] If the absolute value of the sixteenth algebraic difference is less than the preset twelfth precision value, the absolute value of the seventeenth algebraic difference is less than the preset thirteenth precision value, and the absolute value of the eighteenth algebraic difference is less than the preset fourteenth precision value, the final vertical line is deleted.
[0038] In a possible implementation, after determining, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes:
[0039] A plurality of candidate input vertical lines and a plurality of candidate output vertical lines are screened out from the final vertical lines, wherein the x-axis coordinate of each candidate input vertical line is greater than the x-axis coordinate of the right edge of the module where the input bit number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate input vertical line and the x-axis coordinate of the right edge of the module where the input bit number is located is less than a preset fifteenth precision value, and the x-axis coordinate of each candidate output vertical line is less than the x-axis coordinate of the left edge of the module where the output bit number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate output vertical line and the x-axis coordinate of the left edge of the module where the output bit number is located is less than a preset sixteenth precision value;
[0040] Dividing the plurality of candidate input vertical lines into a plurality of groups of candidate input vertical lines, and dividing the plurality of candidate output vertical lines into a plurality of groups of candidate output vertical lines, wherein the x-axis coordinates of the candidate input vertical lines in each group of candidate input vertical lines are the same, and the x-axis coordinates of the candidate output vertical lines in each group of candidate output vertical lines are the same;
[0041] Filtering out a target group of candidate input vertical lines from the multiple groups of candidate input vertical lines, and deleting the target group of candidate input vertical lines, wherein the number of candidate input vertical lines among the target group of candidate input vertical lines is the largest;
[0042] A target group of candidate output vertical lines is selected from the plurality of groups of candidate output vertical lines, and the target group of candidate output vertical lines is deleted, wherein the number of candidate output vertical lines in the target group of candidate output vertical lines is the largest.
[0043] In a possible implementation, determining the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each of the final line segments, the x-axis coordinate of the end point of each of the final line segments, the y-axis coordinate of the starting point of each of the final line segments, and the y-axis coordinate of the end point of each of the final line segments includes:
[0044] For each of the final line segments, based on the x-axis coordinate of the starting point of the final line segment, the x-axis coordinate of the end point of the final line segment, the y-axis coordinate of the starting point of the final line segment, and the y-axis coordinate of the end point of the final line segment, calculate the midpoint coordinate of the final line segment;
[0045] Based on the midpoint coordinates of the final line segments, the final line segments are sorted to obtain a final line segment list;
[0046] According to the order of each final line segment in the final line segment list, based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment, the connection relationship of each final line segment is determined, and the connection relationship of each final line segment is used as the line segment relationship of the interlocking logic diagram.
[0047] In a possible implementation, after determining the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment, and the y-axis coordinate of the end point of each final line segment, the method further includes:
[0048] According to the order of the final line segments in the final line segment list, based on the x-axis coordinates of the starting points of the final line segments, the x-axis coordinates of the end points of the final line segments, the y-axis coordinates of the starting points of the final line segments, and the y-axis coordinates of the end points of the final line segments, the disconnection relationship of the final line segments is determined;
[0049] The disconnection relationship of each of the final line segments is converted to obtain the conversion connection relationship of each of the final line segments, and the connection relationship of each of the final line segments and the conversion connection relationship of each of the final line segments are used as the line segment relationship of the interlocking logic diagram.
[0050] A second aspect of the present application provides a device for determining a line segment connection relationship of an interlocking logic diagram, comprising:
[0051] An acquisition unit, used to acquire x-axis coordinates of the starting points of multiple line segments, x-axis coordinates of the end points of multiple line segments, y-axis coordinates of the starting points of multiple line segments, and y-axis coordinates of the end points of multiple line segments in the interlocking logic diagram;
[0052] a first determining unit, configured to determine, for each of the line segments, a type of the line segment based on an x-axis coordinate of a starting point of the line segment, an x-axis coordinate of an end point of the line segment, a y-axis coordinate of a starting point of the line segment, and a y-axis coordinate of an end point of the line segment, wherein the line segments include horizontal lines and vertical lines;
[0053] A dividing unit, configured to divide each of the line segments based on the type of each of the line segments to obtain a line segment list, wherein the line segment list includes a horizontal line list and a vertical line list;
[0054] A conversion unit, configured to determine, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment;
[0055] The second determination unit is used to determine the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.
[0056] By means of the above technical scheme, the present application provides a method and device for determining the line segment connection relationship of an interlocking logic diagram, the method comprising: obtaining the coordinates of multiple line segments in the interlocking logic diagram, and for each of the line segments, determining the type of the line segment based on the coordinates of the line segment, the line segments comprising two types: horizontal lines and vertical lines; based on the type of each of the line segments, dividing each of the line segments to obtain a line segment list, the line segment list comprising a horizontal line list and a vertical line list; for each line segment in each of the line segment lists, determining the approximate line segment of the line segment, and converting the line segment and the approximate line segment of the line segment into a final line segment; based on the coordinates of each of the final line segments, determining the line segment connection relationship of the interlocking logic diagram. This solution automatically determines the type of line segment based on obtaining the coordinates of the line segment in the interlocking logic diagram, and then determines the final line segment with the help of precise coordinate data and algorithm judgment. The number of line segments is greatly reduced, avoiding confusion in connection relationships caused by too many or complex line segments. Finally, the connection relationship of the line segments of the interlocking logic diagram is determined according to the coordinates of the final line segment, thereby improving the efficiency and accuracy of determining the connection relationship of the line segments of the interlocking logic diagram. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0058] Figure 1 A schematic flow chart of a method for determining a line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application;
[0059] Figure 2 A schematic diagram of an interlocking logic diagram provided in an embodiment of the present application;
[0060] Figure 3 A schematic diagram of a T-shaped line provided in an embodiment of the present application;
[0061] Figure 4 A schematic diagram of another interlocking logic diagram provided in an embodiment of the present application;
[0062] Figure 5 A schematic diagram of a disconnection provided in an embodiment of the present application;
[0063] Figure 6 A schematic diagram of a line segment connection tree provided in an embodiment of the present application;
[0064] Figure 7 A schematic diagram of a disconnection situation provided in an embodiment of the present application;
[0065] Figure 8 A schematic diagram of another disconnection situation provided in an embodiment of the present application;
[0066] Fig. 9 A schematic diagram of another disconnection situation provided in an embodiment of the present application;
[0067] Fig.10 A schematic diagram of another disconnection situation provided in an embodiment of the present application;
[0068] Fig.11 A schematic diagram of a flow chart of a method for deleting a line segment provided in an embodiment of the present application;
[0069] Fig.12 A flowchart of a method for deleting a final line segment provided in an embodiment of the present application;
[0070] Fig.13 A schematic diagram of a module of an interlocking logic diagram provided in an embodiment of the present application;
[0071] Fig.14 A flowchart of another method for deleting a final line segment provided in an embodiment of the present application;
[0072] Fig.15 A schematic diagram of the residual image of the border line of a module of an interlocking logic diagram provided in an embodiment of the present application;
[0073] Fig.16 A flowchart of another method for deleting a final line segment provided in an embodiment of the present application;
[0074] Fig.17A schematic diagram of a dotted line in an interlocking logic diagram provided in an embodiment of the present application;
[0075] Fig.18 A schematic diagram of the structure of a device for determining a line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application;
[0076] Fig.19 A schematic diagram of the hardware structure of a device for determining the line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0078] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0079] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0080] In order to improve the efficiency and accuracy of determining the line segment connection relationship of an interlocking logic diagram, the present application provides a method for determining the line segment connection relationship of an interlocking logic diagram. The method for determining the line segment relationship of an interlocking logic diagram provided by the present application is further described in detail below in combination with the accompanying drawings and specific implementation methods.
[0081] Please refer to the attached Figure 1 , Figure 1 A flow chart of a method for determining a line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application. The method may include the following steps:
[0082] Step S101: obtaining x-axis coordinates of the starting points of multiple line segments in an interlocking logic diagram, x-axis coordinates of the end points of multiple line segments, y-axis coordinates of the starting points of multiple line segments, and y-axis coordinates of the end points of multiple line segments.
[0083] In this application, a high-precision image recognition algorithm is used to scan and identify the interlocking logic diagram, and the initial coordinates of all line segments connecting the modules in the interlocking logic diagram are extracted. These coordinates are usually expressed in floating point form and contain high-precision information. Figure 2 , Figure 2 A schematic diagram of an interlocking logic diagram provided in an embodiment of the present application. The interlocking logic diagram is a diagram obtained by an AI image recognition algorithm. The line segments within and between modules in the diagram are relatively messy. The method of this embodiment mainly simplifies the line segments between modules, sorts out valid line segments, and filters invalid line segments.
[0084] In order to unify the processing and simplify the calculation, it is necessary to adjust the precision of these initial coordinates. Since the image recognition algorithm is accurate, the x-axis distance between the interlocking logic diagram line segment and the module is within one thousandth of the image, so the precision value can be set to 0.001. For each line segment, the initial x-axis coordinate of the starting point of the line segment, the initial x-axis coordinate of the end point of the line segment, the initial y-axis coordinate of the starting point of the line segment, and the initial y-axis coordinate of the end point of the line segment are divided by the precision value and rounded, and then multiplied by the precision value to obtain the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment;
[0085] In the image recognition process, due to factors such as system errors, recognition algorithm accuracy or image resolution, even if the line segment is visually completely vertical or horizontal, there may be slight differences in the coordinates of its start and end points. These differences may cause the line segment to be misclassified in subsequent processing. Through the above operation, these slight differences can also be effectively eliminated, making the representation of the line segment in the coordinate space more neat and consistent.
[0086] Take a line segment as an example, its initial coordinates are (0.123456789, 0.54321) to (0.12345890, 0.876543). Process according to the above steps: divide by the precision value 0.001 to get (123.456789, 543.21) to (123.4589, 876.543); round to get (123, 543) to (123, 876). Multiply by the precision value 0.001 to get (0.123, 0.543) to (0.123, 0.876).
[0087] Step S102: For each line segment, the type of the line segment is determined based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment. The line segments include horizontal lines and vertical lines.
[0088] In this application, for each line segment, the x-axis coordinate of the starting point of the line segment and the x-axis coordinate of the end point of the line segment can be compared first. If the two x-axis coordinates are equal (or very close, a small tolerance value can be set considering possible calculation errors or precision problems), the line segment can be determined to be a vertical line. The y-axis coordinate of the starting point of the line segment and the y-axis coordinate of the end point of the line segment, if the two y-axis coordinates are equal (or within the tolerance range), the line segment can be determined to be a horizontal line.
[0089] Taking a line segment as an example, its coordinates are (0.123, 0.543) to (0.123, 0.876), the x-axis coordinate 0.123 of the starting point of the line segment is equal to the x-axis coordinate 0.123 of the end point of the line segment, the y-axis coordinate 0.543 of the starting point of the line segment is not equal to the y-axis coordinate 0.876 of the end point of the line segment (not within the tolerance range), the line segment has no significant extension in the x-axis direction, and has significant extension in the y-axis direction, then the line segment is determined to be a vertical line.
[0090] Step S103: based on the types of the line segments, the line segments are divided to obtain a line segment list, which includes a horizontal line list and a vertical line list.
[0091] In this application, two empty lists are first created, one for storing horizontal lines, namely the horizontal line list; the other for storing vertical lines, namely the vertical line list. All line segments are traversed and added to the corresponding list according to the type of the line segment.
[0092] In order to facilitate subsequent processing, the horizontal lines in the horizontal line list and the vertical lines in the vertical line list can be sorted separately, and different sorting principles can be used for the horizontal lines and the vertical lines. For the horizontal lines, the sorting principle can be to first sort them mainly according to the size of the x-axis coordinate of the starting point of the line segment, and if the size of the x-axis coordinate of the starting point of the line segment is the same, then sort them secondarily according to the size of the y-axis coordinate of the starting point of the line segment. For the vertical lines, the sorting principle can be to first sort them mainly according to the size of the y-axis coordinate of the starting point of the line segment, and if the size of the y-axis coordinate of the starting point of the line segment is the same, then sort them secondarily according to the size of the x-axis coordinate of the starting point of the line segment.
[0093] To make it easier to understand, here are some examples:
[0094] List of horizontal lines: horizontal line 1: (0.1, 0.5) to (0.4, 0.5), horizontal line 2: (0.2, 0.3) and (0.2, 0.7), and horizontal line 3: (0.1, 0.1) and (0.6, 0.1). According to the horizontal line sorting principle, the sorted horizontal line list is horizontal line 3, horizontal line 1, and horizontal line 2. List of vertical lines: vertical line 1: (0.2, 0.1) to (0.2, 0.8), vertical line 2: (0.1, 0.5) to (0.1, 0.9), and vertical line 3: (0.3, 0.3) to (0.3, 0.7). According to the vertical line sorting principle, the sorted vertical line list is vertical line 2, vertical line 1, and vertical line 3.
[0095] Step S104: for each line segment in each line segment list, determine an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment.
[0096] In the present application, due to the characteristics of the image recognition algorithm, the identified line segments are the edge parts of the line segments, and each actual line segment is composed of multiple identified line segments. Therefore, it is necessary to determine which identified line segments actually belong to the same line segment, that is, for each line segment in each line segment list, determine the approximate line segment of the line segment.
[0097] When the line segment list is a horizontal line list, the process of determining the approximate horizontal line of the target horizontal line in each horizontal line list includes:
[0098] Calculate the first algebraic difference absolute value between the x-axis coordinates of the starting points of the other horizontal lines in the horizontal line list and the x-axis coordinates of the starting points of the target horizontal line in the horizontal line list, the second algebraic difference absolute value between the x-axis coordinates of the end points of the other horizontal lines and the x-axis coordinates of the end points of the target horizontal line, and the third algebraic difference absolute value between the y-axis coordinates of the other horizontal lines and the y-axis coordinates of the target horizontal line. Determine other horizontal lines whose first algebraic difference absolute value is less than a preset first precision value, whose second algebraic difference absolute value is less than a preset second precision value, and whose third algebraic difference absolute value is less than a preset third precision value as nearby horizontal lines of the target horizontal line. Based on the first algebraic difference absolute value, the second algebraic difference absolute value, and the third algebraic difference absolute value, determine an approximate horizontal line of the target horizontal line from the nearby horizontal lines of the target horizontal line.
[0099] It should be noted that other horizontal lines in the horizontal line list whose x-axis coordinates of the starting point of the target horizontal line, the x-axis coordinates of the end point of the target horizontal line, and the y-axis coordinates of the target horizontal line all meet the preset requirements are regarded as the nearby horizontal lines of the target horizontal line. Among the nearby horizontal lines of the target horizontal line, it is necessary to further calculate the sum of the absolute value of the first algebraic difference, the absolute value of the second algebraic difference, and the absolute value of the third algebraic difference, and the nearby horizontal line of the target horizontal line with the smallest sum is regarded as the approximate horizontal line of the target horizontal line.
[0100] In this case, the target horizontal line and the approximate horizontal line of the target horizontal line can be converted into a final horizontal line. Specifically, firstly, the x-axis coordinate of the starting point of the target horizontal line and the x-axis coordinate of the starting point of the approximate horizontal line of the target horizontal line are compared, and the x-axis coordinate of the smallest starting point is used as the x-axis coordinate of the starting point of the final horizontal line. Then, the x-axis coordinate of the end point of the target horizontal line and the x-axis coordinate of the end point of the approximate horizontal line of the target horizontal line are compared, and the x-axis coordinate of the largest end point is used as the x-axis coordinate of the end point of the final horizontal line. Then, the average value of the y-axis coordinate of the target horizontal line and the y-axis coordinate of the approximate horizontal line of the target horizontal line is calculated, and the average value is used as the y-axis coordinate of the final horizontal line. Finally, the target horizontal line and the approximate horizontal line of the target horizontal line in the horizontal line list are deleted to avoid duplication.
[0101] If there is no other horizontal line whose first algebraic difference absolute value is less than the first precision value, whose second algebraic difference absolute value is less than the second precision value, and whose third algebraic difference absolute value is less than the third precision value, then calculate the seventh algebraic difference absolute value between the x-axis coordinate of the starting point of the target horizontal line and the x-axis coordinate of the end point of the target horizontal line, the eighth algebraic difference absolute value between the x-axis coordinate of the starting point of each other horizontal line and the x-axis coordinate of its own end point, and the ninth algebraic difference absolute value between the y-axis coordinate of the target horizontal line and the y-axis coordinate of each other horizontal line. Determine other horizontal lines whose seventh algebraic difference absolute value is not equal to the eighth algebraic difference absolute value and whose ninth algebraic difference absolute value is less than the preset seventh precision value as approximate horizontal lines of the target horizontal line.
[0102] It should be noted that if there is no nearby horizontal line that meets the preset conditions of the target horizontal line, it means that the image recognizes a T-shaped line, which will cause the line segment that should have been merged to be incorrectly split into multiple lines. In order to deal with this situation, different strategies need to be adopted to determine which line segments are approximate horizontal lines of the target horizontal line. That is, other horizontal lines in the horizontal line list that are longer than the target horizontal line and whose y-axis coordinate distance from the target horizontal line meets the preset requirements, or other horizontal lines in the horizontal line list that are shorter than the target horizontal line and whose y-axis coordinate distance from the target horizontal line meets the preset requirements can be used as approximate horizontal lines of the target horizontal line.
[0103] For easier understanding, please refer to Figure 3 , Figure 3 A schematic diagram of a T-shaped line provided in an embodiment of the present application. According to the above logic, if there is no nearby horizontal line that meets the preset condition horizontal line A, then horizontal lines B and C can be found to be shorter than the length of horizontal line A and whose y-axis coordinate distances from horizontal line A meet the preset requirements, so horizontal lines B and C can be used as approximate horizontal lines of the target horizontal line.
[0104] In this case, the target horizontal line and the approximate horizontal line of the target horizontal line can be converted into a final horizontal line. Specifically, first compare the absolute value of the seventh algebraic difference and the absolute value of the eighth algebraic difference, then use the horizontal line corresponding to the largest algebraic difference absolute value as the approximate horizontal line of the target horizontal line, and finally delete the horizontal line corresponding to the algebraic difference absolute value that is not the largest from the horizontal line list to avoid duplication. For ease of understanding, please refer to Figure 3 , horizontal line A is used as the approximate horizontal line of the target horizontal line, and horizontal lines B and C are deleted from the horizontal line list.
[0105] When the line segment list is a vertical line list, the process of determining the approximate vertical line of the target vertical line in each vertical line list includes:
[0106] Calculate the fourth algebraic difference absolute value of the y-axis coordinate of the starting point of each other vertical line in the vertical line list and the y-axis coordinate of the starting point of the target vertical line in the line segment list, the fifth algebraic difference absolute value of the y-axis coordinate of the end point of each other vertical line and the y-axis coordinate of the end point of the target vertical line, and the sixth algebraic difference absolute value of the x-axis coordinate of each other vertical line and the x-axis coordinate of the target vertical line. Determine other vertical lines whose fourth algebraic difference absolute value is less than the preset fourth precision value, whose fifth algebraic difference absolute value is less than the preset fifth precision value, and whose sixth algebraic difference absolute value is less than the preset sixth precision value as the neighboring vertical lines of the target vertical line. Based on the fourth algebraic difference absolute value, the fifth algebraic difference absolute value and the sixth algebraic difference absolute value, determine the approximate vertical line of the target vertical line from the neighboring vertical lines of the target vertical line.
[0107] It should be noted that other vertical lines in the vertical line list whose distances from the y-axis coordinate of the starting point of the target vertical line, the y-axis coordinate of the end point of the target vertical line, and the x-axis coordinate of the target vertical line all meet the preset requirements are regarded as the nearby vertical lines of the target vertical line. Among the nearby vertical lines of the target vertical line, it is necessary to further calculate the sum of the absolute value of the third algebraic difference, the absolute value of the fourth algebraic difference, and the absolute value of the fifth algebraic difference, and the nearby vertical line of the target vertical line with the smallest sum is regarded as the approximate vertical line of the target vertical line.
[0108] In this case, the target vertical line and the approximate vertical line of the target vertical line can be converted into a final vertical line. Specifically, first, the y-axis coordinate of the starting point of the target vertical line and the y-axis coordinate of the starting point of the approximate vertical line of the target vertical line are compared, and the y-axis coordinate of the smallest starting point is used as the y-axis coordinate of the starting point of the final vertical line. Then, the y-axis coordinate of the end point of the target vertical line and the y-axis coordinate of the end point of the approximate vertical line of the target vertical line are compared, and the y-axis coordinate of the largest end point is used as the y-axis coordinate of the end point of the final vertical line. Then, the average value of the x-axis coordinate of the target vertical line and the x-axis coordinate of the approximate vertical line of the target vertical line is calculated, and the average value is used as the x-axis coordinate of the final vertical line. Finally, the target vertical line and the approximate vertical line of the target vertical line in the vertical line list are deleted to avoid duplication.
[0109] If there is no other vertical line whose fourth algebraic difference absolute value is less than the fourth precision value, whose fifth algebraic difference absolute value is less than the fifth precision value, and whose sixth algebraic difference absolute value is less than the sixth precision value, then calculate the tenth algebraic difference absolute value between the y-axis coordinate of the starting point of the target vertical line and the y-axis coordinate of the end point of the target vertical line, the eleventh algebraic difference absolute value between the y-axis coordinate of the starting point of each other vertical line and the y-axis coordinate of its own end point, and the twelfth algebraic difference absolute value between the y-axis coordinate of the target vertical line and the y-axis coordinate of each other vertical line. Other vertical lines whose tenth algebraic difference absolute value is not equal to the eleventh algebraic difference absolute value, and whose twelfth algebraic difference absolute value is less than the preset eighth precision value, are determined as approximate vertical lines of the target vertical line.
[0110] It should be noted that if there is no vertical line near the target vertical line that meets the preset conditions, it means that the image recognizes a T-shaped line, which will cause the line segment that should have been merged to be incorrectly split into multiple lines. In order to deal with this situation, different strategies need to be adopted to determine which line segments are approximate vertical lines of the target vertical line. That is, other vertical lines in the vertical line list that are longer than the target vertical line and whose x-axis coordinate distance from the target vertical line meets the preset requirements, or other vertical lines in the vertical line list that are shorter than the target vertical line and whose x-axis coordinate distance from the target vertical line meets the preset requirements can be used as approximate vertical lines of the target vertical line.
[0111] In this case, the target vertical line and the approximate vertical line of the target vertical line can be converted into a final vertical line. Specifically, first, the absolute value of the tenth algebraic difference and the absolute value of the eleventh algebraic difference are compared, and then the vertical line corresponding to the largest algebraic difference absolute value is used as the approximate vertical line of the target vertical line. Finally, the vertical line corresponding to the algebraic difference absolute value that is not the largest is deleted from the vertical line list to avoid duplication.
[0112] The multiple identified line segments that actually belong to the same line segment are processed, and each line segment in the horizontal line list and the vertical line list (excluding the line segments deleted during the quasi-conversion process) is converted into a final line segment. At this time, the interlocking logic diagram can be specifically referred to Figure 4 , Figure 4 A schematic diagram of another interlocking logic diagram provided in an embodiment of the present application.
[0113] Step S105: Determine the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinates of the starting points of each final line segment, the x-axis coordinates of the end points of each final line segment, the y-axis coordinates of the starting points of each final line segment, and the y-axis coordinates of the end points of each final line segment.
[0114] It should be noted that the line segment connection rules of the interlocking logic diagram are as follows:
[0115] (1) The line segments in the interlocking logic diagram represent the direction of data or signal flow. This directionality usually follows the principle of left to right, which means that the input signal enters from the left side of the interlocking logic diagram, and after a series of processing or judgment, the output signal leaves from the right side of the interlocking logic diagram.
[0116] (2) If two line segments cross in the interlocking logic diagram, in order to avoid confusion and misunderstanding of the signal flow direction, the vertical line (i.e. the vertical line segment) should be disconnected, while the horizontal line (i.e. the horizontal line segment) should be kept unbroken. For easier understanding, please refer to Figure 5 , Figure 5 A schematic diagram of line breaking provided in an embodiment of the present application, wherein horizontal line b and horizontal line d should be disconnected, but horizontal line c should not be disconnected.
[0117] (3) The modules in the interlocking logic diagram are connected by one or more terminal segments. Each module is either the starting point (input) of a signal, or the end point (output) of a signal, or an intermediate node that both receives and sends signals. When these terminal segments are organized according to their connection relationships, they can form a tree-like structure.
[0118] Analyze the connections between the modules of the interlocking logic diagram. Each connection consists of a final horizontal line and a final vertical line, so multiple final horizontal lines and multiple final vertical lines are merged into a final list. The final list is sorted in ascending order of the x-axis coordinates of the midpoint coordinates of the final line segment and in ascending order of the y-axis coordinates. For each final line segment in the final list, traverse the final list in turn and find the adjacent line segments of the final line segment from the remaining final line segments according to preset conditions.
[0119] For easier understanding, please refer to Figure 6 , Figure 6 A schematic diagram of a line segment connection tree provided in an embodiment of the present application, wherein final line segment a and final line segment b meet preset conditions and are connected to form a line, final line segment b is the child node of final line segment a, and final line segment a is the parent node of final line segment b. The line is a line whose root (final line segment a) is a horizontal line and whose leaf (final line segment b) is a vertical line. Final line segment b does not have a final line segment that meets preset conditions. Final line segment d and final line segment e meet preset conditions and are connected to form a line. Therefore, the line segment connection tree is ab, c, and de.
[0120] In the present application, the midpoint coordinates of the final line segment can be calculated for each final line segment based on the x-axis coordinates of the starting point of the final line segment, the x-axis coordinates of the end point of the final line segment, the y-axis coordinates of the starting point of the final line segment, and the y-axis coordinates of the end point of the final line segment. Then, based on the midpoint coordinates of each final line segment, the final line segments are sorted to obtain a final line segment list. Finally, according to the order of each final line segment in the final line segment list, based on the x-axis coordinates of the starting point of each final line segment, the x-axis coordinates of the end point of each final line segment, the y-axis coordinates of the starting point of each final line segment, and the y-axis coordinates of the end point of each final line segment, the connection relationship of each final line segment is determined, and the connection relationship of each final line segment is used as the line segment relationship of the interlocking logic diagram.
[0121] Specifically, for each final horizontal line, if the absolute value of the algebraic difference between the coordinates of the end point of the final horizontal line and the coordinates of the starting points of other final horizontal lines satisfies the preset seventeenth precision value, then the other final horizontal line is an adjacent line segment of the final horizontal line; the distance between the coordinates of the end point of the final horizontal line and the end point of the final vertical line ( ) satisfies the preset eighteenth precision value, then the final vertical line is the adjacent line segment of the final horizontal line; for each final vertical line, the distance between the starting point of the final vertical line and the starting point of the final horizontal line satisfies the preset eighteenth precision value, then the final horizontal line is the adjacent line segment of the final vertical line; the distance between the starting point of the final vertical line and the starting point of the final horizontal line satisfies the preset nineteenth precision value, then the final horizontal line is the adjacent line segment of the final vertical line; the distance between the starting point of the final vertical line and the end point of other final vertical lines satisfies the preset twentieth precision value, then the other final vertical lines are the adjacent line segments of the final vertical line; the distance between the end point of the final vertical line and the starting point of the final horizontal line satisfies the preset twenty-first precision value, then the final horizontal line is the adjacent line segment of the final vertical line; the distance between the end point of the final vertical line and the starting point of other final vertical lines satisfies the preset twenty-second precision value, then the other final vertical lines are the adjacent line segments of the final vertical line.
[0122] For ease of understanding, an example is given below: The coordinates of the end point A of the final horizontal line (x a ,y a ) and the coordinates of the end point B of the final vertical line (x b ,y b ) = [(x a -x b )+(y a -y b )] 1 / 2. Further, the disconnection relationship of each final line segment can also be determined according to the order of each final line segment in the final line segment list, based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment, and the y-axis coordinate of the end point of each final line segment. The disconnection relationship of each final line segment is converted to obtain the conversion connection relationship of each final line segment, and the connection relationship of each final line segment and the conversion connection relationship of each final line segment are used as the line segment relationship of the interlocking logic diagram.
[0123] Specifically, in order to handle the situation where the line is disconnected, the following steps can be performed in a loop until the line segment connection tree no longer changes:
[0124] (1) Since the data of one module is transmitted to another module, it must be connected from a horizontal line to another horizontal line. There will be no situation where the vertical line is a leaf. When a leaf is a vertical line, it means that the link is missing data. Therefore, we can find all the vertical lines with leaves and all the vertical lines with roots in the line segment connection tree. For each vertical line with leaves, determine whether the vertical line with leaves and all the vertical lines with roots have the same horizontal coordinate. If so, connect the vertical line with roots to the tree of vertical lines with leaves. For details, please refer to Figure 7 .
[0125] (2) For the case where there is a horizontal line connected to another horizontal line, the center point of the two horizontal lines is the connection point of the broken line. Connect the connection with the vertical line as the root to the next layer of the connection tree of the horizontal line. For details, please refer to Figure 8 .
[0126] (3) When a vertical line is inserted into a horizontal line, connect the line with the vertical line as the root to the next level of the horizontal line connection tree. For details, please refer to Fig. 9 .
[0127] (4) For the case where a horizontal line is connected to a vertical line, find all independent horizontal lines and determine whether the starting point of the horizontal line is at the ends of the line whose leaves are vertical lines. If so, connect the independent horizontal line to the tree whose leaves are vertical lines. For details, please refer to Fig.10 .
[0128] After the above steps, a sound segment connection tree can be established. According to the above example, the sound segment connection tree is abde and c. This tree structure reflects the connection relationship between the segments, that is, it determines the segment connection relationship of the interlocking logic diagram.
[0129] In summary, the present application provides a method for determining the line segment connection relationship of an interlocking logic diagram, the method comprising: obtaining the coordinates of multiple line segments in the interlocking logic diagram, and for each line segment, determining the type of the line segment based on the coordinates of the line segment, the line segment includes two types: horizontal line and vertical line. Based on the type of each line segment, each line segment is divided to obtain a line segment list, and the line segment list includes a horizontal line list and a vertical line list. For each line segment in each line segment list, an approximate line segment of the line segment is determined, and the line segment and the approximate line segment of the line segment are converted into a final line segment. Based on the coordinates of each final line segment, the line segment connection relationship of the interlocking logic diagram is determined. This scheme automatically determines the type of the line segment based on obtaining the coordinates of the line segment in the interlocking logic diagram, and then determines the final line segment with the help of accurate coordinate data and algorithm judgment, the number of line segments is greatly reduced, and the confusion of the connection relationship caused by too many or complex line segments is avoided. Finally, the line segment connection relationship of the interlocking logic diagram is determined according to the coordinates of the final line segment, and the determination efficiency and accuracy of the line segment connection relationship of the interlocking logic diagram are improved.
[0130] On the basis of the above-mentioned embodiments disclosed in the present application, in another embodiment of the present application, an implementation method for determining the type of each line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment is described in detail.
[0131] As an example of an implementation method, please see the attached Fig.11 , is a flow chart of a method for deleting a line segment disclosed in the present application. The method may include the following steps:
[0132] Step S201: for each line segment, determine the slope of the line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment.
[0133] In this application, the slope of each line segment can be calculated using the following formula:
[0134] The slope of a line segment = (the y-axis coordinate of the end point of the line segment − the y-axis coordinate of the starting point of the line segment) / (the x-axis coordinate of the end point of the line segment − the x-axis coordinate of the starting point of the line segment)
[0135] Note that if the x-axis coordinate of the end point of the line segment is the same as the x-axis coordinate of the starting point of the line segment (i.e. a horizontal line), then the slope will be undefined (because the denominator is zero). In this case, special handling can be done, such as treating the slope of the line segment as zero or infinite.
[0136] Step S202: Determine whether the slope of the line segment falls within a preset slope range.
[0137] It should be noted that the preset slope range can be set based on specific application requirements or standards. For example, if it is necessary to retain those almost vertical or horizontal line segments, a slope range corresponding to an angle of 10° to 80° can be set.
[0138] If the slope of a line segment falls within the slope range (that is, the slope is neither very small nor very large), then the line segment is not an almost vertical or horizontal line segment; if the slope of a line segment does not fall within the slope range (that is, the slope is very small or very large, close to zero or infinity), then the line segment is an almost vertical or horizontal line segment.
[0139] When the slope of the line segment belongs to the slope range, step S203 is executed.
[0140] Step S203: Delete the line segment.
[0141] In the present application, if the line segment is not an almost vertical or horizontal line segment, it may be a marked line, an indicator line, or a point in the interlocking logic diagram, so the line segment should be deleted. In summary, the method for deleting a line segment provided in an embodiment of the present application can more accurately identify and retain the almost vertical or horizontal line segments in the interlocking logic diagram by clearly setting the slope range and accurately judging the slope of the line segment, and delete the line segments that are not almost vertical or horizontal in the interlocking logic diagram, so that the interlocking logic diagram is clearer and more accurate, which is helpful for subsequent analysis based on the interlocking logic diagram.
[0142] Based on the above-mentioned embodiments disclosed in the present application, in another embodiment of the present application, a detailed description is given of the implementation method of determining the approximate line segment of each line segment in each line segment list, and converting the line segment and the approximate line segment of the line segment into a final line segment.
[0143] As an example of an implementation method, please see the attached Fig.12 , is a flow chart of a method for deleting a final line segment disclosed in the present application. The method may include the following steps:
[0144] Step S301: Obtain the x-axis coordinate of the right edge of the module where the input bit number of the interlocking logic diagram is located and the x-axis coordinate of the left edge of the module where the output bit number is located.
[0145] It should be noted that the input bit number is usually located on the left side of the interlocking logic diagram, so the coordinates of its right edge are the key to determining the range of the valid line segment start point, and the x-axis coordinate of the right edge of the module where the input bit number is located represents the rightmost horizontal coordinate of the module where the input bit number is located. The output bit number is usually located on the right side of the interlocking logic diagram, so the coordinates of its left edge are the key to determining the range of the valid line segment end point, and the x-axis coordinate of the left edge of the module where the output bit number is located represents the leftmost horizontal coordinate of the module where the output bit number is located. For ease of understanding, please refer to Fig.13 , Fig.13 A schematic diagram of a module of an interlocking logic diagram provided by an embodiment of the present application is shown in the figure, in which the input bit number, the output bit number, the right edge of the module where the input bit number is located, and the left edge of the module where the output bit number is located are marked.
[0146] Step S302: For each final line segment, determine whether the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, and whether the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located.
[0147] In the present application, it is determined whether each final line segment is located in a valid area between an input bit number and an output bit number.
[0148] If the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, or the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located, it means that the final line segment is not within the valid area between the input bit number and the output bit number.
[0149] If the x-axis coordinate of the starting point of the final line segment is not less than the x-axis coordinate of the right edge of the module where the input bit number is located, and the x-axis coordinate of the end point of the final line segment is not greater than the x-axis coordinate of the left edge of the module where the output bit number is located, then it means that the final line segment is within the valid area between the input bit number and the output bit number.
[0150] When the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, or the x-axis coordinate of the end point of the final line segment is larger than the x-axis coordinate of the left edge of the module where the output bit number is located, step S303 is executed.
[0151] Step S303: Delete the final line segment.
[0152] In this application, if the final line segment is not within the valid area between the input bit number and the output bit number, then this line segment is considered invalid and should be deleted. For example: Fig.13 The final segment 1 and final segment 2 in should be deleted.
[0153] To sum up, the embodiment of the present application provides a method for deleting the final line segment, which combines the position information of the input bit number and the output bit number to automatically identify and delete those miscellaneous lines that are not within the valid range, thereby simplifying the visual presentation of the interlocking logic diagram and providing clearer and more accurate chart information for subsequent data analysis.
[0154] Based on the above-mentioned embodiments disclosed in the present application, in another embodiment of the present application, the final line segment includes a final horizontal line and a final vertical line, and a detailed description is given of the implementation method of determining the approximate line segment of each line segment in each line segment list, and converting the line segment and the approximate line segment of the line segment into a final line segment.
[0155] As an example of an implementation method, please see the attached Fig.14 , is a flow chart of another method for deleting the final line segment disclosed in the present application. The method may include the following steps:
[0156] Step S401: Obtain the x-axis coordinates of the starting points of multiple horizontal border lines of each module of the interlocking logic diagram, the x-axis coordinates of the end points of multiple horizontal border lines, the y-axis coordinates of the starting points of multiple vertical border lines, the y-axis coordinates of the end points of multiple vertical border lines, and the x-axis coordinates of multiple vertical border lines.
[0157] In the present application, the coordinates of multiple horizontal border lines and multiple vertical border lines of each module in the interlocking logic diagram can be obtained from the image recognition results. The coordinates of each horizontal border line include: the x-axis coordinate of the starting point of the horizontal border line, the x-axis coordinate of the end point of the horizontal border line, and the y-axis coordinate of the horizontal border line; the coordinates of each vertical border line include: the y-axis coordinate of the starting point of the vertical border line, the y-axis coordinate of the end point of the vertical border line, and the x-axis coordinate of the vertical border line.
[0158] Step S402: For each final horizontal line, calculate the thirteenth algebraic difference absolute value of the x-axis coordinate of the starting point of the final horizontal line and the x-axis coordinate of the starting point of each horizontal border line, the fourteenth algebraic difference absolute value of the x-axis coordinate of the end point of the final horizontal line and the x-axis coordinate of the end point of each horizontal border line, and the fifteenth algebraic difference absolute value of the y-axis coordinate of the final horizontal line and the y-axis coordinate of each horizontal border line.
[0159] In the present application, for each final horizontal line, the difference between its coordinates and those of all horizontal border lines is calculated. The difference in the x-axis coordinate of the starting point of the final horizontal line is calculated based on the x-axis coordinate of the starting point of each horizontal border line, that is, the thirteenth algebraic difference absolute value; the difference in the x-axis coordinate of the end point of the final horizontal line is calculated based on the x-axis coordinate of the end point of each horizontal border line, that is, the fourteenth algebraic difference absolute value; the difference in the y-axis coordinate of the final horizontal line is calculated based on the y-axis coordinate of the final horizontal line, that is, the fifteenth algebraic difference absolute value.
[0160] Step S403: If the absolute value of the thirteenth algebraic difference is less than the preset ninth precision value, the absolute value of the fourteenth algebraic difference is less than the preset tenth precision value, and the absolute value of the fifteenth algebraic difference is less than the preset eleventh precision value, then the final horizontal line is deleted.
[0161] In this application, if the above three calculated differences all meet the preset conditions, that is, the absolute value of the thirteenth algebraic difference is less than the preset ninth precision value, the absolute value of the fourteenth algebraic difference is less than the preset tenth precision value, and the absolute value of the fifteenth algebraic difference is less than the preset eleventh precision value, then it is considered that this final horizontal line is close to the horizontal border of the module and may be the afterimage of the horizontal border line, so it is deleted. For ease of understanding, please refer to Fig.15 , Fig.15 A schematic diagram of the afterimage of the border line of a module of an interlocking logic diagram provided in an embodiment of the present application.
[0162] Step S404: For each final vertical line, calculate the sixteenth algebraic difference absolute value of the y-axis coordinate of the starting point of the final vertical line and the y-axis coordinate of the starting point of each vertical border line, the seventeenth algebraic difference absolute value of the y-axis coordinate of the end point of the final vertical line and the y-axis coordinate of the end point of each vertical border line, and the eighteenth algebraic difference absolute value of the x-axis coordinate of the final vertical line and the x-axis coordinate of each vertical border line.
[0163] In the present application, for each final vertical line, the difference between its coordinates and those of all vertical border lines is calculated. The difference between the y-axis coordinate of the starting point of the final vertical line and the y-axis coordinate of the starting point of each vertical border line is calculated based on the y-axis coordinate of the starting point, that is, the absolute value of the sixteenth algebraic difference; the difference between the y-axis coordinate of the end point of the final vertical line and the y-axis coordinate of the end point of each vertical border line is calculated based on the y-axis coordinate of the end point of the final vertical line, that is, the absolute value of the seventeenth algebraic difference; the difference between the x-axis coordinate of the final vertical line and the x-axis coordinate of each vertical border line is calculated based on the x-axis coordinate of the final vertical line and the x-axis coordinate of each vertical border line, that is, the absolute value of the eighteenth algebraic difference.
[0164] Step S405: If the absolute value of the sixteenth algebraic difference is less than the preset twelfth precision value, the absolute value of the seventeenth algebraic difference is less than the preset thirteenth precision value, and the absolute value of the eighteenth algebraic difference is less than the preset fourteenth precision value, then the final vertical line is deleted.
[0165] In the present application, if the gaps obtained by the above three calculations all meet the preset conditions, that is, the absolute value of the sixteenth algebraic difference is less than the preset twelfth precision value, and the absolute value of the seventeenth algebraic difference is less than the preset thirteenth precision value, and the absolute value of the eighteenth algebraic difference is less than the preset fourteenth precision value, then it is considered that this final vertical line is close to the vertical border of the module, and may be the afterimage of the vertical border line, so it is deleted.
[0166] In summary, another method for deleting the final line segment provided by the embodiment of the present application is a series of steps to remove those that may be. By calculating the coordinate difference between the line and the module border line and comparing it with the preset accuracy value, the residual image of the module border generated by the image recognition process can be identified and deleted, thereby simplifying the subsequent data analysis work and helping to improve processing accuracy and efficiency.
[0167] Based on the above-mentioned embodiments disclosed in the present application, in another embodiment of the present application, a detailed description is given of the implementation method of determining the approximate line segment of each line segment in each line segment list, and converting the line segment and the approximate line segment of the line segment into a final line segment.
[0168] As an example of an implementation method, please see the attached Fig.16 , is a flowchart of another method for deleting the final line segment disclosed in the present application. The method may include the following steps:
[0169] Step S501: Filter out multiple candidate input vertical lines and multiple candidate output vertical lines from each final vertical line, the x-axis coordinate of each candidate input vertical line is greater than the x-axis coordinate of the right edge of the module where the input position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate input vertical line and the x-axis coordinate of the right edge of the module where the input position number is located is less than the preset fifteenth precision value, the x-axis coordinate of each candidate output vertical line is less than the x-axis coordinate of the left edge of the module where the output position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate output vertical line and the x-axis coordinate of the left edge of the module where the output position number is located is less than the preset sixteenth precision value.
[0170] In the present application, all final vertical lines are traversed, and for each final vertical line, it is determined whether the x-axis coordinate of the final vertical line is greater than the x-axis coordinate of the right edge of the module where the input position number is located, whether the absolute value of the algebraic difference between the x-axis coordinate of the final vertical line and the x-axis coordinate of the right edge of the module where the input position number is located is less than the preset fifteenth precision value, whether the x-axis coordinate of the final vertical line is less than the x-axis coordinate of the left edge of the module where the output position number is located, and whether the absolute value of the algebraic difference between the x-axis coordinate of the final vertical line and the x-axis coordinate of the left edge of the module where the output position number is located is less than the preset sixteenth precision value. If If the x-axis coordinate of the final vertical line is greater than the x-axis coordinate of the right edge of the module where the input position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the final vertical line and the x-axis coordinate of the right edge of the module where the input position number is located is less than the preset fifteenth precision value, then the final vertical line is determined as a candidate input vertical line; if the x-axis coordinate of the final vertical line is less than the x-axis coordinate of the left edge of the module where the output position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the final vertical line and the x-axis coordinate of the left edge of the module where the output position number is located is less than the preset sixteenth precision value, then the final vertical line is determined as a candidate output vertical line.
[0171] Step S502: divide multiple candidate input vertical lines into multiple groups of candidate input vertical lines, and divide multiple candidate output vertical lines into multiple groups of candidate output vertical lines, wherein the x-axis coordinates of the candidate input vertical lines in each group of candidate input vertical lines are the same, and the x-axis coordinates of the candidate output vertical lines in each group of candidate output vertical lines are the same.
[0172] In the present application, multiple candidate input vertical lines are traversed, and candidate input vertical lines with the same x-axis coordinate are grouped together. The same traversal and grouping operation is performed on the candidate output vertical line list, and candidate output vertical lines with the same x-axis coordinate are grouped together.
[0173] Step S503: selecting target group candidate input vertical lines from multiple groups of candidate input vertical lines, and deleting the target group candidate input vertical lines, wherein the number of candidate input vertical lines in the target group candidate input vertical lines is the largest.
[0174] In this application, dotted lines may be mistakenly recognized as multiple solid line segments in image recognition, resulting in an abnormal increase in the number of vertical lines. Therefore, among the candidate input vertical lines after grouping, the group with the largest number of vertical lines can be found as the target group, and all candidate input vertical lines in the target group can be deleted. For ease of understanding, please refer to Fig.17 , Fig.17 A schematic diagram of a dotted line in an interlocking logic diagram provided in an embodiment of the present application.
[0175] Step S504: selecting target group candidate output vertical lines from multiple groups of candidate output vertical lines, and deleting the target group candidate output vertical lines, wherein the number of candidate output vertical lines among the target group candidate output vertical lines is the largest.
[0176] In the present application, dotted lines may be mistakenly identified as multiple solid line segments during image recognition, resulting in an abnormally increased number of vertical lines. Therefore, among the grouped candidate output vertical lines, the group with the largest number of vertical lines can be found as the target group, and all candidate output vertical lines in the target group can be deleted to reduce the risk of dotted lines being mistakenly identified as multiple solid lines, thereby improving the accuracy and reliability of data processing.
[0177] A method for determining a line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application is introduced above. A device for determining a line segment connection relationship of an interlocking logic diagram that executes the above will be introduced below.
[0178] See also Fig.18 , Fig.18 This is a schematic diagram of a structure of a device for determining a line segment connection relationship of an interlocking logic diagram provided in an embodiment of the present application. Fig.18 As shown, the device for determining the line segment connection relationship of the interlocking logic diagram includes:
[0179] The acquisition unit 11 is used to acquire the x-axis coordinates of the starting points of multiple line segments in the interlocking logic diagram, the x-axis coordinates of the end points of multiple line segments, the y-axis coordinates of the starting points of multiple line segments, and the y-axis coordinates of the end points of multiple line segments.
[0180] The first determination unit 12 is used to determine the type of each line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment and the y-axis coordinate of the end point of the line segment, wherein the line segments include horizontal lines and vertical lines.
[0181] The dividing unit 13 is used to divide each of the line segments based on the type of each of the line segments to obtain a line segment list, wherein the line segment list includes a horizontal line list and a vertical line list.
[0182] The conversion unit 14 is used to determine, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment.
[0183] The second determination unit 15 is used to determine the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.
[0184] In a possible implementation, the device further includes:
[0185] The third determination unit is used to determine the slope of each line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment.
[0186] The first judging unit is used to judge whether the slope of the line segment belongs to a preset slope range.
[0187] The first deleting unit is configured to delete the line segment if the slope of the line segment belongs to the slope range.
[0188] In a possible implementation, the device further includes:
[0189] The first calculation unit is used to calculate, when the line segment list is the horizontal line list, the first algebraic difference absolute value of the x-axis coordinate of the starting point of each other horizontal line in the horizontal line list and the x-axis coordinate of the starting point of the target horizontal line in the horizontal line list, the second algebraic difference absolute value of the x-axis coordinate of the end point of each other horizontal line and the x-axis coordinate of the end point of the target horizontal line, and the third algebraic difference absolute value of the y-axis coordinate of each other horizontal line and the y-axis coordinate of the target horizontal line.
[0190] The fourth determination unit is used to determine other horizontal lines whose absolute value of the first algebraic difference is less than a preset first precision value, whose absolute value of the second algebraic difference is less than a preset second precision value, and whose absolute value of the third algebraic difference is less than a preset third precision value as nearby horizontal lines of the target horizontal line.
[0191] A fifth determining unit is configured to determine an approximate horizontal line of the target horizontal line from horizontal lines near the target horizontal line based on the first algebraic difference absolute value, the second algebraic difference absolute value, and the third algebraic difference absolute value.
[0192] a second calculation unit, for calculating, when the line segment list is the vertical line list, fourth algebraic difference absolute values of the y-axis coordinates of the starting points of each other vertical line in the vertical line list and the y-axis coordinates of the starting point of the target vertical line in the line segment list, fifth algebraic difference absolute values of the y-axis coordinates of the end points of each other vertical line and the y-axis coordinates of the end points of the target vertical line, and sixth algebraic difference absolute values of the x-axis coordinates of each other vertical line and the x-axis coordinate of the target vertical line.
[0193] The sixth determination unit is used to determine other vertical lines whose absolute value of the fourth algebraic difference is less than a preset fourth precision value, whose absolute value of the fifth algebraic difference is less than a preset fifth precision value, and whose absolute value of the sixth algebraic difference is less than a preset sixth precision value as vertical lines near the target vertical line.
[0194] A seventh determining unit is configured to determine an approximate vertical line of the target vertical line from vertical lines near the target vertical line based on the fourth algebraic difference absolute value, the fifth algebraic difference absolute value, and the sixth algebraic difference absolute value.
[0195] In a possible implementation, the device further includes:
[0196] The third calculation unit is used to calculate the seventh algebraic difference absolute value of the x-axis coordinate of the starting point of the target horizontal line and the x-axis coordinate of the end point of the target horizontal line, the eighth algebraic difference absolute value of the x-axis coordinate of the starting point of each of the other horizontal lines and the x-axis coordinate of its own end point, and the ninth algebraic difference absolute value of the y-axis coordinate of the target horizontal line and the y-axis coordinate of each of the other horizontal lines, if there are no other horizontal lines whose absolute value of the first algebraic difference is less than the first precision value, whose absolute value of the second algebraic difference is less than the second precision value, and whose absolute value of the third algebraic difference is less than the third precision value, when the line segment list is the horizontal line list.
[0197] The eighth determination unit is used to determine other horizontal lines whose absolute value of the seventh algebraic difference is not equal to the absolute value of the eighth algebraic difference and whose absolute value of the ninth algebraic difference is less than a preset seventh precision value as approximate horizontal lines of the target horizontal line.
[0198] A fourth calculation unit is used to calculate, when the line segment list is the vertical line list, the tenth absolute value of the algebraic difference between the y-axis coordinate of the starting point of the target vertical line and the y-axis coordinate of the end point of the target vertical line, the eleventh absolute value of the algebraic difference between the y-axis coordinate of the starting point of each of the other vertical lines and the y-axis coordinate of its own end point, and the twelfth absolute value of the algebraic difference between the x-axis coordinate of the target vertical line and the x-axis coordinate of each of the other vertical lines if there are no other vertical lines whose fourth algebraic difference absolute value is less than the fourth precision value, whose fifth algebraic difference absolute value is less than the fifth precision value, and whose sixth algebraic difference absolute value is less than the sixth precision value.
[0199] The ninth determining unit is used to determine other vertical lines whose absolute value of the tenth algebraic difference is not equal to the absolute value of the eleventh algebraic difference and whose absolute value of the twelfth algebraic difference is less than the preset eighth precision value as approximate vertical lines of the target vertical line.
[0200] In a possible implementation, the device further includes:
[0201] The first coordinate acquisition unit is used to acquire the x-axis coordinate of the right edge of the module where the input bit number of the interlocking logic diagram is located and the x-axis coordinate of the left edge of the module where the output bit number is located.
[0202] The second judgment unit is used to judge, for each of the final line segments, whether the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input position number is located, and whether the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output position number is located.
[0203] The second deletion unit is used to delete the final line segment if the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, or the x-axis coordinate of the end point of the final line segment is larger than the x-axis coordinate of the left edge of the module where the output bit number is located.
[0204] In a possible implementation, the final line segment includes a final horizontal line and a final vertical line, and the apparatus further includes:
[0205] The second coordinate acquisition unit is used to obtain the x-axis coordinates of the starting points of multiple horizontal border lines of each module of the interlocking logic diagram, the x-axis coordinates of multiple end points of the horizontal border lines, the y-axis coordinates of multiple horizontal border lines, the y-axis coordinates of the starting points of multiple vertical border lines, the y-axis coordinates of multiple end points of the vertical border lines and the x-axis coordinates of multiple vertical border lines.
[0206] The fifth calculation unit is used to calculate, for each of the final horizontal lines, the thirteenth algebraic difference absolute value of the x-axis coordinate of the starting point of the final horizontal line and the x-axis coordinate of the starting point of each of the horizontal border lines, the fourteenth algebraic difference absolute value of the x-axis coordinate of the end point of the final horizontal line and the x-axis coordinate of the end point of each of the horizontal border lines, and the fifteenth algebraic difference absolute value of the y-axis coordinate of the final horizontal line and the y-axis coordinate of each of the horizontal border lines.
[0207] The third deleting unit is used to delete the final horizontal line if the absolute value of the thirteenth algebraic difference is less than the preset ninth precision value, the absolute value of the fourteenth algebraic difference is less than the preset tenth precision value, and the absolute value of the fifteenth algebraic difference is less than the preset eleventh precision value.
[0208] The sixth calculation unit is used to calculate, for each of the final vertical lines, the sixteenth algebraic difference absolute value of the y-axis coordinate of the starting point of the final vertical line and the y-axis coordinate of the starting point of each of the vertical border lines, the seventeenth algebraic difference absolute value of the y-axis coordinate of the end point of the final vertical line and the y-axis coordinate of the end point of each of the vertical border lines, and the eighteenth algebraic difference absolute value of the x-axis coordinate of the final vertical line and the x-axis coordinate of each of the vertical border lines.
[0209] The fourth deleting unit is used to delete the final vertical line if the absolute value of the sixteenth algebraic difference is less than the preset twelfth precision value, the absolute value of the seventeenth algebraic difference is less than the preset thirteenth precision value, and the absolute value of the eighteenth algebraic difference is less than the preset fourteenth precision value.
[0210] In a possible implementation, the device further includes:
[0211] A first screening unit is used to screen out multiple candidate input vertical lines and multiple candidate output vertical lines from each of the final vertical lines, wherein the x-axis coordinate of each candidate input vertical line is greater than the x-axis coordinate of the right edge of the module where the input position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate input vertical line and the x-axis coordinate of the right edge of the module where the input position number is located is less than a preset fifteenth precision value, and the x-axis coordinate of each candidate output vertical line is less than the x-axis coordinate of the left edge of the module where the output position number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate output vertical line and the x-axis coordinate of the left edge of the module where the output position number is located is less than a preset sixteenth precision value.
[0212] The vertical line division unit is used to divide the multiple candidate input vertical lines into multiple groups of candidate input vertical lines, and divide the multiple candidate output vertical lines into multiple groups of candidate output vertical lines, the x-axis coordinates of the candidate input vertical lines in each group of candidate input vertical lines are the same, and the x-axis coordinates of the candidate output vertical lines in each group of candidate output vertical lines are the same.
[0213] The second screening unit is configured to screen out a target group of candidate input vertical lines from the plurality of groups of candidate input vertical lines, and delete the target group of candidate input vertical lines, wherein the number of candidate input vertical lines in the target group of candidate input vertical lines is the largest.
[0214] The third screening unit is configured to screen out target group candidate output vertical lines from the plurality of groups of candidate output vertical lines, and delete the target group candidate output vertical lines, wherein the number of candidate output vertical lines in the target group candidate output vertical lines is the largest.
[0215] In a possible implementation, the second determining unit 15 includes:
[0216] A calculation subunit is used to calculate the midpoint coordinates of each final line segment based on the x-axis coordinate of the starting point of the final line segment, the x-axis coordinate of the end point of the final line segment, the y-axis coordinate of the starting point of the final line segment, and the y-axis coordinate of the end point of the final line segment.
[0217] The sorting subunit is used to sort the final line segments based on the midpoint coordinates of the final line segments to obtain a final line segment list.
[0218] A determination subunit is used to determine the connection relationship of each final line segment in the final line segment list according to the order of each final line segment, based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment, and use the connection relationship of each final line segment as the line segment relationship of the interlocking logic diagram.
[0219] In a possible implementation, the device further includes:
[0220] The tenth determination unit is used to determine the disconnection relationship of each final line segment in the final line segment list based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.
[0221] The eleventh determination unit is used to convert the disconnection relationship of each of the final line segments to obtain the conversion connection relationship of each of the final line segments, and use the connection relationship of each of the final line segments and the conversion connection relationship of each of the final line segments as the line segment relationship of the interlocking logic diagram.
[0222] The present application also provides an electronic device in an embodiment. Fig.19As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Fig.19 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0223] like Fig.19 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1902 or a program loaded from a storage device 1908 to a random access memory (RAM) 1903. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 1903. The processing device 1901, the ROM 1902, and the RAM 1903 are connected to each other via a bus 1904. An input / output (I / O) interface 1905 is also connected to the bus 1904.
[0224] Typically, the following devices may be connected to the I / O interface 1905: an input device 1906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1908 including, for example, a memory card, a hard disk, etc.; and a communication device 1909. The communication device 1909 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Fig.19 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0225] Also provided in an embodiment of the present application is a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements a method for determining a line segment connection relationship of any interlocking logic diagram provided in an embodiment of the present application.
[0226] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement a method for determining a line segment connection relationship of any interlocking logic diagram provided in an embodiment of the present application.
[0227] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0228] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0229] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0230] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for determining the line segment connection relationship of an interlocking logic diagram, characterized in that: include: Obtaining x-axis coordinates of the starting points of multiple line segments in the interlocking logic diagram, x-axis coordinates of the end points of multiple line segments, y-axis coordinates of the starting points of multiple line segments, and y-axis coordinates of the end points of multiple line segments; For each line segment, based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment, the type of the line segment is determined, wherein the line segment includes two types: a horizontal line and a vertical line; Based on the types of the line segments, the line segments are divided to obtain a line segment list, wherein the line segment list includes a horizontal line list and a vertical line list; For each line segment in each of the line segment lists, determine an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment; The line segment connection relationship of the interlocking logic diagram is determined based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.
2. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 1, characterized in that: Before determining the type of each line segment based on the x-axis coordinate of the starting point of the line segment, the x-axis coordinate of the end point of the line segment, the y-axis coordinate of the starting point of the line segment, and the y-axis coordinate of the end point of the line segment, the method further includes: For each of the line segments, determining a slope of the line segment based on an x-axis coordinate of a starting point of the line segment, an x-axis coordinate of an end point of the line segment, a y-axis coordinate of a starting point of the line segment, and a y-axis coordinate of an end point of the line segment; Determining whether the slope of the line segment falls within a preset slope range; If the slope of the line segment belongs to the slope range, the line segment is deleted.
3. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 1, characterized in that: The process of determining the approximate line segment of the target line segment in each line segment list includes: In the case where the line segment list is the horizontal line list, calculating the first algebraic difference absolute value of the x-axis coordinate of the starting point of each other horizontal line in the horizontal line list and the x-axis coordinate of the starting point of the target horizontal line in the horizontal line list, the second algebraic difference absolute value of the x-axis coordinate of the end point of each other horizontal line and the x-axis coordinate of the end point of the target horizontal line, and the third algebraic difference absolute value of the y-axis coordinate of each other horizontal line and the y-axis coordinate of the target horizontal line; Determine other horizontal lines whose absolute value of the first algebraic difference is less than a preset first precision value, whose absolute value of the second algebraic difference is less than a preset second precision value, and whose absolute value of the third algebraic difference is less than a preset third precision value as horizontal lines near the target horizontal line; Determine an approximate horizontal line of the target horizontal line from horizontal lines near the target horizontal line based on the first algebraic difference absolute value, the second algebraic difference absolute value and the third algebraic difference absolute value; In the case where the line segment list is the vertical line list, calculating the fourth algebraic difference absolute value between the y-axis coordinate of the starting point of each other vertical line in the vertical line list and the y-axis coordinate of the starting point of the target vertical line in the line segment list, the fifth algebraic difference absolute value between the y-axis coordinate of the end point of each other vertical line and the y-axis coordinate of the end point of the target vertical line, and the sixth algebraic difference absolute value between the x-axis coordinate of each other vertical line and the x-axis coordinate of the target vertical line; Determine other vertical lines whose absolute value of the fourth algebraic difference is less than a preset fourth precision value, whose absolute value of the fifth algebraic difference is less than a preset fifth precision value, and whose absolute value of the sixth algebraic difference is less than a preset sixth precision value as vertical lines near the target vertical line; An approximate vertical line of the target vertical line is determined from vertical lines near the target vertical line based on the fourth algebraic difference absolute value, the fifth algebraic difference absolute value, and the sixth algebraic difference absolute value.
4. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 3, characterized in that: The process of determining the approximate line segment of the target line segment in each line segment list further includes: In the case where the line segment list is the horizontal line list, if there is no other horizontal line whose absolute value of the first algebraic difference is less than the first precision value, whose absolute value of the second algebraic difference is less than the second precision value, and whose absolute value of the third algebraic difference is less than the third precision value, then calculate the seventh algebraic difference absolute value between the x-axis coordinate of the starting point of the target horizontal line and the x-axis coordinate of the end point of the target horizontal line, the eighth algebraic difference absolute value between the x-axis coordinate of the starting point of each of the other horizontal lines and the x-axis coordinate of its own end point, and the ninth algebraic difference absolute value between the y-axis coordinate of the target horizontal line and the y-axis coordinate of each of the other horizontal lines; Determine other horizontal lines whose absolute value of the seventh algebraic difference is not equal to the absolute value of the eighth algebraic difference and whose absolute value of the ninth algebraic difference is less than the preset seventh precision value as approximate horizontal lines of the target horizontal line; In the case where the line segment list is the vertical line list, if there are no other vertical lines whose fourth algebraic difference absolute value is less than the fourth precision value, whose fifth algebraic difference absolute value is less than the fifth precision value, and whose sixth algebraic difference absolute value is less than the sixth precision value, then calculate the tenth algebraic difference absolute value between the y-axis coordinate of the starting point of the target vertical line and the y-axis coordinate of the end point of the target vertical line, the eleventh algebraic difference absolute value between the y-axis coordinate of the starting point of each of the other vertical lines and the y-axis coordinate of its own end point, and the twelfth algebraic difference absolute value between the x-axis coordinate of the target vertical line and the x-axis coordinate of each of the other vertical lines; Other vertical lines whose tenth algebraic difference absolute value is not equal to the eleventh algebraic difference absolute value and whose twelfth algebraic difference absolute value is smaller than the preset eighth precision value are determined as approximate vertical lines of the target vertical line.
5. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 1, characterized in that: After determining an approximate line segment of each line segment in each line segment list and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes: Obtain the x-axis coordinate of the right edge of the module where the input bit number of the interlocking logic diagram is located and the x-axis coordinate of the left edge of the module where the output bit number is located; For each of the final line segments, determine whether the x-axis coordinate of the starting point of the final line segment is less than the x-axis coordinate of the right edge of the module where the input bit number is located, and whether the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located; If the x-axis coordinate of the starting point of the final line segment is smaller than the x-axis coordinate of the right edge of the module where the input bit number is located, or the x-axis coordinate of the end point of the final line segment is greater than the x-axis coordinate of the left edge of the module where the output bit number is located, the final line segment will be deleted.
6. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 5, characterized in that: The final line segment includes a final horizontal line and a final vertical line. After determining an approximate line segment of each line segment in each line segment list and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes: Obtaining x-axis coordinates of the starting points of multiple horizontal border lines of each module of the interlocking logic diagram, x-axis coordinates of the end points of multiple horizontal border lines, y-axis coordinates of multiple horizontal border lines, y-axis coordinates of the starting points of multiple vertical border lines, y-axis coordinates of the end points of multiple vertical border lines, and x-axis coordinates of multiple vertical border lines; For each of the final horizontal lines, calculate the thirteenth algebraic difference absolute value between the x-axis coordinate of the starting point of the final horizontal line and the x-axis coordinate of the starting point of each of the horizontal border lines, the fourteenth algebraic difference absolute value between the x-axis coordinate of the end point of the final horizontal line and the x-axis coordinate of the end point of each of the horizontal border lines, and the fifteenth algebraic difference absolute value between the y-axis coordinate of the final horizontal line and the y-axis coordinate of each of the horizontal border lines; If the thirteenth algebraic difference absolute value is less than the preset ninth precision value, the fourteenth algebraic difference absolute value is less than the preset tenth precision value, and the fifteenth algebraic difference absolute value is less than the preset eleventh precision value, then the final horizontal line is deleted; For each of the final vertical lines, calculate the sixteenth algebraic difference absolute value between the y-axis coordinate of the starting point of the final vertical line and the y-axis coordinate of the starting point of each of the vertical border lines, the seventeenth algebraic difference absolute value between the y-axis coordinate of the end point of the final vertical line and the y-axis coordinate of the end point of each of the vertical border lines, and the eighteenth algebraic difference absolute value between the x-axis coordinate of the final vertical line and the x-axis coordinate of each of the vertical border lines; If the absolute value of the sixteenth algebraic difference is less than the preset twelfth precision value, the absolute value of the seventeenth algebraic difference is less than the preset thirteenth precision value, and the absolute value of the eighteenth algebraic difference is less than the preset fourteenth precision value, the final vertical line is deleted.
7. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 6, characterized in that: After determining an approximate line segment of each line segment in each line segment list and converting the line segment and the approximate line segment of the line segment into a final line segment, the method further includes: A plurality of candidate input vertical lines and a plurality of candidate output vertical lines are screened out from the final vertical lines, wherein the x-axis coordinate of each candidate input vertical line is greater than the x-axis coordinate of the right edge of the module where the input bit number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate input vertical line and the x-axis coordinate of the right edge of the module where the input bit number is located is less than a preset fifteenth precision value, and the x-axis coordinate of each candidate output vertical line is less than the x-axis coordinate of the left edge of the module where the output bit number is located, and the absolute value of the algebraic difference between the x-axis coordinate of the candidate output vertical line and the x-axis coordinate of the left edge of the module where the output bit number is located is less than a preset sixteenth precision value; Dividing the plurality of candidate input vertical lines into a plurality of groups of candidate input vertical lines, and dividing the plurality of candidate output vertical lines into a plurality of groups of candidate output vertical lines, wherein the x-axis coordinates of the candidate input vertical lines in each group of candidate input vertical lines are the same, and the x-axis coordinates of the candidate output vertical lines in each group of candidate output vertical lines are the same; Filtering out a target group of candidate input vertical lines from the multiple groups of candidate input vertical lines, and deleting the target group of candidate input vertical lines, wherein the number of candidate input vertical lines among the target group of candidate input vertical lines is the largest; A target group of candidate output vertical lines is selected from the plurality of groups of candidate output vertical lines, and the target group of candidate output vertical lines is deleted, wherein the number of candidate output vertical lines in the target group of candidate output vertical lines is the largest.
8. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 1, characterized in that: Determining the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment, and the y-axis coordinate of the end point of each final line segment includes: For each of the final line segments, based on the x-axis coordinate of the starting point of the final line segment, the x-axis coordinate of the end point of the final line segment, the y-axis coordinate of the starting point of the final line segment, and the y-axis coordinate of the end point of the final line segment, calculate the midpoint coordinate of the final line segment; Based on the midpoint coordinates of the final line segments, the final line segments are sorted to obtain a final line segment list; According to the order of each final line segment in the final line segment list, based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment, the connection relationship of each final line segment is determined, and the connection relationship of each final line segment is used as the line segment relationship of the interlocking logic diagram.
9. The method for determining the line segment connection relationship of the interlocking logic diagram according to claim 1, characterized in that: After determining the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment, and the y-axis coordinate of the end point of each final line segment, the method further includes: According to the order of the final line segments in the final line segment list, based on the x-axis coordinates of the starting points of the final line segments, the x-axis coordinates of the end points of the final line segments, the y-axis coordinates of the starting points of the final line segments, and the y-axis coordinates of the end points of the final line segments, the disconnection relationship of the final line segments is determined; The disconnection relationship of each of the final line segments is converted to obtain the conversion connection relationship of each of the final line segments, and the connection relationship of each of the final line segments and the conversion connection relationship of each of the final line segments are used as the line segment relationship of the interlocking logic diagram.
10. A device for determining the line segment connection relationship of an interlocking logic diagram, characterized in that: include: An acquisition unit, used to acquire x-axis coordinates of the starting points of multiple line segments, x-axis coordinates of the end points of multiple line segments, y-axis coordinates of the starting points of multiple line segments, and y-axis coordinates of the end points of multiple line segments in the interlocking logic diagram; a first determining unit, configured to determine, for each of the line segments, a type of the line segment based on an x-axis coordinate of a starting point of the line segment, an x-axis coordinate of an end point of the line segment, a y-axis coordinate of a starting point of the line segment, and a y-axis coordinate of an end point of the line segment, wherein the line segments include horizontal lines and vertical lines; A dividing unit, configured to divide each of the line segments based on the type of each of the line segments to obtain a line segment list, wherein the line segment list includes a horizontal line list and a vertical line list; A conversion unit, configured to determine, for each line segment in each of the line segment lists, an approximate line segment of the line segment, and convert the line segment and the approximate line segment of the line segment into a final line segment; The second determination unit is used to determine the line segment connection relationship of the interlocking logic diagram based on the x-axis coordinate of the starting point of each final line segment, the x-axis coordinate of the end point of each final line segment, the y-axis coordinate of the starting point of each final line segment and the y-axis coordinate of the end point of each final line segment.