A calculation method and device for conversion relationship of similar legend
By calculating the mean point and direction bounding box of similar legends, a coordinate system is constructed to determine the legend conversion relationship, which solves the problem of conversion relationship between similar legends, ensuring that the replaced legend direction is consistent, and improving the accuracy and user experience of engineering quantity calculation.
Patent Information
- Application Number
- CN202111544490.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-12-16
AI Technical Summary
The prior art is difficult to determine the conversion relationship between similar legends with subtle differences, resulting in the replacement legend being unable to maintain the direction of the original legend, affecting the accuracy of business such as engineering quantity calculation.
By calculating the mean points and direction bounding boxes of the target legend and similar legends, a corresponding coordinate system is constructed to determine the conversion relationship between the legends, including the rotation angle and the mirror relationship, to ensure that the replaced legend remains in the direction of the original legend.
It improves the accuracy of engineering quantity calculation and other services, meets users' actual needs for processing similar legends, and improves user experience.
Smart Images

Figure CN114255171B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer-aided design, and particularly relates to a method and device for calculating the conversion relationship between similar legends. Background Art
[0002] Legends are an important part of engineering design drawings. Taking municipal design drawings as an example, traffic markings and lines in the city are clearly marked on the drawings. For example, Figure 1 as shown, these markings are legends. Legends can not only be used to represent traffic markings and lines, but also any entity that wants to be represented. In actual projects, there is only one specification for one type of legend. However, in actual municipal design drawings, this specification is not necessarily met. For example, Figure 1 for the two left-turn arrow legends in Figure 2 as shown, they seem to be exactly the same. If these two left-turn arrows are stacked together, it will be found that they only belong to two similar legends, but are not exactly the same.
[0003] In actual business operations such as engineering quantity calculation, users actually want to consider multiple similar legends as the same legend. In municipal quantity calculation software, the legend needs to be recognized first before the quantity can be calculated. For example, after a user recognizes one of the legends in Figure 1 and finds that there is another legend that has not been recognized. At this time, the user will continue to recognize the legend. There are some slight differences between the two recognized legends, but they generally look similar. However, the user still wants to classify these two legends into the same component. Since there can only be one legend for one component, the previously recognized legend needs to be replaced with the later recognized legend. However, since the above two legends are different legends, the rotation angle between them cannot be calculated through rigid matrix transformation, which results in the direction of the replaced legend not being able to maintain the original legend's direction, thereby affecting the accuracy of business operations such as engineering quantity calculation. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method and device for calculating the conversion relationship between similar legends to solve the problem in the prior art that it is difficult to determine the conversion relationship between similar legends with slight differences, which affects the accuracy of subsequent engineering operations.
[0005] According to the first aspect, an embodiment of the present invention provides a method for calculating the conversion relationship between similar legends, including:
[0006] Obtaining a target legend and a first legend similar to the target legend;
[0007] Calculating the mean point and the direction bounding box of the target legend and the first legend respectively, where the coordinates of the mean point are the average of the coordinates of the endpoints of all the legend lines that make up the legend;
[0008] Based on the mean points and directional bounding boxes of the target legend and the first legend, respectively construct the first coordinate system corresponding to the target legend and the second coordinate system corresponding to the first legend;
[0009] Based on the coordinate axes of the first coordinate system and the second coordinate system, determine the transformation relationship between the first legend and the target legend.
[0010] Optionally, the calculating the mean points and directional bounding boxes of the target legend and the first legend respectively includes:
[0011] Obtain all the legend lines that make up the current legend;
[0012] Extract the end points of each legend line to form a legend point set;
[0013] Based on the legend point set, calculate the mean point and directional bounding box corresponding to the current legend.
[0014] Optionally, the calculating the mean point and directional bounding box corresponding to the current legend based on the legend point set includes:
[0015] Calculate the average value of the coordinates of all the end points in the legend point set to determine the mean point;
[0016] Calculate the convex hull of the legend point set;
[0017] Based on the directional bounding box of the convex hull, determine the directional bounding box corresponding to the current legend.
[0018] Optionally, the constructing the first coordinate system corresponding to the target legend and the second coordinate system corresponding to the first legend respectively based on the mean points and directional bounding boxes of the target legend and the first legend includes:
[0019] Obtain the current center point of the current legend corresponding to the current directional bounding box;
[0020] Based on the current center point, determine the coordinate system origin of the current coordinate system corresponding to the current legend;
[0021] Based on the direction of the side of the current directional bounding box, determine the direction vector of the current directional bounding box;
[0022] Based on the positional relationship between the direction vector and the position of the current mean point of the current legend, determine the Y-axis vector of the current coordinate system;
[0023] Rotate the Y-axis of the current coordinate system by 90 degrees to obtain a first direction vector;
[0024] Determine the X-axis vector of the current coordinate system based on the positional relationship between the first direction vector and the current mean point.
[0025] Optionally, the determining the transformation relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system includes:
[0026] Obtain the first Y-axis vector and the first X-axis vector corresponding to the first coordinate system, and the second Y-axis vector and the second X-axis vector corresponding to the second coordinate system;
[0027] Calculate the included angle between the first Y-axis vector and the second Y-axis vector to determine the rotation angle of the first legend and the target legend;
[0028] Determine the mirror image relationship between the first legend and the target legend based on the relationship between the first Y-axis vector, the first X-axis vector, the second Y-axis vector, and the second X-axis vector.
[0029] Optionally, the determining the mirror image relationship between the first legend and the target legend based on the relationship between the first Y-axis vector, the first X-axis vector, the second Y-axis vector, and the second X-axis vector includes:
[0030] Calculate the cross product of the first Y-axis vector and the first X-axis vector to obtain a first vector;
[0031] Calculate the cross product of the second Y-axis vector and the second X-axis vector to obtain a second vector;
[0032] Calculate the dot product of the first vector and the second vector;
[0033] When the dot product is greater than 0, determine that the first legend and the target legend are mirror images of each other.
[0034] Optionally, the determining the Y-axis vector of the current coordinate system based on the positional relationship between the direction vector and the current mean point corresponding to the current legend includes:
[0035] Perform a dot product calculation on the direction vector and the current mean point to obtain a first value;
[0036] When the first value is greater than 0, determine the direction vector as the Y-axis vector of the current coordinate system;
[0037] When the first value is not greater than 0, determine the reverse direction of the direction vector as the Y-axis vector of the current coordinate system.
[0038] Optionally, the determining the X-axis vector of the current coordinate system based on the positional relationship between the first direction vector and the current mean point includes:
[0039] Perform a dot product calculation on the first direction vector and the current mean point to obtain a second value;
[0040] When the second value is greater than 0, determine the first direction vector as the X-axis vector of the current coordinate system;
[0041] When the second value is not greater than 0, determine the opposite direction of the first direction vector as the X-axis vector of the current coordinate system.
[0042] According to a second aspect, an embodiment of the present invention provides a calculation device for conversion relationships between similar legends, including:
[0043] An acquisition module, configured to acquire a target legend and a first legend similar to the target legend;
[0044] A first processing module, configured to calculate the mean point and the direction bounding box of the target legend and the first legend respectively, where the coordinates of the mean point are the average of the coordinates of the legend line endpoints that make up all the legends;
[0045] A second processing module, configured to respectively construct a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend based on the mean point and the direction bounding box of the target legend and the first legend;
[0046] A third processing module, configured to determine the conversion relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system.
[0047] According to a third aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, where the non-transitory computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described in the first aspect of the present invention and any of its optional implementations is implemented.
[0048] According to a fourth aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, where the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to execute the method described in the first aspect of the present invention and any of its optional implementations.
[0049] The technical solution of the present invention has the following advantages:
[0050] An embodiment of the present invention provides a method and device for calculating the conversion relationship between similar legends. By obtaining a target legend and a first legend similar to the target legend; calculating the mean point and the directional bounding box of the target legend and the first legend respectively, where the coordinates of the mean point are the average of the coordinates of the endpoints of the legend lines that make up all the legends; based on the mean point and the directional bounding box of the target legend and the first legend, constructing a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend respectively; determining the conversion relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system. Thus, by calculating the directional bounding boxes and mean points of similar legends respectively and establishing corresponding coordinate systems to determine the conversion relationship between similar legends, the conversion relationship can be used to uniformly replace similar legends, and ensure that the replaced legends can still maintain the original direction of the legends, thereby improving the accuracy of operations such as engineering quantity calculation, and meeting the actual needs of users for processing similar legends, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0052] Figure 1 Schematic diagram of two similar legends in an embodiment of the present invention;
[0053] Figure 2 Schematic diagram of the stacked comparison of two similar legends in an embodiment of the present invention;
[0054] Figure 3 Flowchart of the method for calculating the conversion relationship between similar legends in an embodiment of the present invention;
[0055] Figure 4 Schematic diagram of the directional bounding box and the mean point corresponding to the legend in an embodiment of the present invention;
[0056] Figure 5 Schematic diagram of the mean point corresponding to another legend in an embodiment of the present invention;
[0057] Figure 6 Schematic diagram of the structure of the device for calculating the conversion relationship between similar legends in an embodiment of the present invention;
[0058] Figure 7 Schematic diagram of the structure of the electronic device in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0059] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0060] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0061] In actual engineering quantity calculation and other operations, users actually want to consider multiple similar legends as the same legend. In municipal quantity calculation software, it is necessary to identify the legend first and then calculate the quantity. For example: after the user identifies one of the legends in the software and finds that there is another legend that has not been identified. At this time, the user will continue to identify the legend. There are some slight differences in the local parts of the two identified legends, but they generally look similar. However, the user still wants to classify these two legends into the same component. Since there can only be one legend for one component, it is necessary to replace the previously identified legend with the later identified legend. However, since the above two legends are different legends, the rotation angle between them cannot be calculated through a rigid matrix transformation, which results in the direction of the replaced legend not being able to maintain the original legend's direction, thereby affecting the accuracy of engineering quantity calculation and other operations. Figure 1 Based on the above problems, the embodiments of the present invention provide a calculation method for the conversion relationship of similar legends. As shown in
[0062] The calculation method for the conversion relationship of similar legends specifically includes the following steps: Figure 3 As shown in
[0063] Step S101: Obtain a target legend and a first legend similar to the target legend.
[0064] Exemplarily, as shown in Figure 1 The two "left turn arrow" legends in Figure 1 are two similar legends, which are the first legend and the target legend respectively. As shown in Figure 2 These two legends have similar basic shapes, only with some slight differences in the local parts. These two legends are two similar legends. In actual engineering design software, such similar legends essentially belong to the same component.
[0065] Step S102: Calculate the mean points and direction bounding boxes of the target legend and the first legend respectively.
[0066] Among them, the coordinates of the mean point are the average of the endpoint coordinates of all the legend lines that make up the legend. The oriented bounding box is the smallest rectangle that contains the object and has an arbitrary orientation relative to the coordinate axes. Abbreviated as the OBB bounding box, its greatest feature is the arbitrariness of its orientation, which enables it to enclose the object as tightly as possible according to the shape characteristics of the enclosed object, but at the same time makes its intersection test complex. Since the legends in actual engineering drawings can have arbitrary rotation directions, therefore, using the oriented bounding box, no matter how the legend rotates, the size of its tight bounding box is fixed, only the direction is different, so that the subsequent calculation of the conversion relationship between legends can be effectively carried out.
[0067] Step S103: Based on the mean point and the oriented bounding box of the target legend and the first legend, respectively construct the first coordinate system corresponding to the target legend and the second coordinate system corresponding to the first legend.
[0068] Step S104: Determine the conversion relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system.
[0069] Among them, the conversion relationship includes the rotation angle between two similar legends and their mirror image relationship.
[0070] By performing the above steps, the method for calculating the conversion relationship between similar legends provided by the embodiments of the present invention calculates the oriented bounding boxes and mean points of the similar legends respectively, and establishes the corresponding coordinate systems to determine the conversion relationship between the similar legends, so that the similar legends can be uniformly replaced by using this conversion relationship, and it is ensured that the replaced legend can still maintain the original direction of the legend, thereby improving the accuracy of operations such as engineering quantity calculation, and meeting the actual needs of users for processing similar legends, and improving the user experience.
[0071] Specifically, in one embodiment, the above step S102 specifically includes the following steps:
[0072] Step S201: Obtain all the legend lines that make up the current legend.
[0073] Exemplarily, for the legend of the "left-turn arrow" as Figure 1 shown, it is composed of several lines connected end to end in sequence, and these lines are the legend lines that make up the "left-turn arrow". In practical applications, the legend lines can be directly obtained through the geometric data of the legend in the design drawing.
[0074] Step S202: Extract the endpoints of each legend line to form a legend point set.
[0075] Specifically, in order to improve the calculation efficiency, in the embodiments of the present invention, all the legend lines are discretized into straight-edge representations, and then the endpoints of each straight edge are a legend point, and the set of endpoints of all the straight edges is the legend point set.
[0076] Step S203: Calculate the mean point and the directional bounding box corresponding to the current legend based on the legend point set.
[0077] Specifically, the above-mentioned step S203 specifically determines the mean point by calculating the average value of all endpoint coordinates in the legend point set; calculates the convex hull of the legend point set; and determines the directional bounding box corresponding to the current legend based on the directional bounding box of the convex hull.
[0078] Among them, the directional bounding box of the current legend is the directional bounding box of the convex hull. Exemplarily, as Figure 4 shown, from the perspective of the "mean point" and the "centroid of the legend polygon" in the figure, both are "biased" towards one side of the directional bounding box, and are "not centered" whether from the long side or the short side. Thus, its direction and mirror image data can be established by using its "biased" characteristic in the subsequent process. In actual engineering, the selected legend may not necessarily be a closed polygon legend, so the "mean point" is used to calculate its "bias", because all legends can ultimately be discretized into point sets for representation, and then its "bias" can be calculated.
[0079] Specifically, in one embodiment, the above-mentioned step S103 specifically includes the following steps:
[0080] Step S301: Obtain the current center point of the current legend corresponding to the current directional bounding box.
[0081] Step S302: Determine the coordinate system origin of the current legend corresponding to the current coordinate system based on the current center point.
[0082] Exemplarily, Figure 4 the center point of the bounding box in is the coordinate system origin of the coordinate system corresponding to the legend.
[0083] Step S303: Determine the direction vector of the current directional bounding box based on the direction of the side of the current directional bounding box.
[0084] Specifically, the direction vector of the directional bounding box can be the direction of any side of the directional bounding box, which can be either the short side direction as in Figure 4 or the long side direction. In the embodiment of the present invention, the long side direction of the rectangular frame of the directional bounding box is used as the direction vector of the directional bounding box for illustration. Only for this example, the present invention is not limited thereto.
[0085] Step S304: Determine the Y-axis vector of the current coordinate system based on the positional relationship between the direction vector and the current mean point of the current legend.
[0086] Specifically, in step S304 above, a dot product calculation is performed on the direction vector and the current mean point to obtain a first value; when the first value is greater than 0, the direction vector is determined as the Y-axis vector of the current coordinate system; when the first value is not greater than 0, the opposite direction of the direction vector is determined as the Y-axis vector of the current coordinate system. Thus, the Y-axis of the constructed coordinate system faces the side of the mean point, so as to embody the above-mentioned "bias".
[0087] Because the direction bounding box has a certain "bias", and its "bias" depends on the shape of the legend. For example, Figure 5 for the "straight arrow" legend in, although this legend is symmetric up and down and located on the central symmetry line of the legend, after calculating its direction bounding box, the mean point does not coincide with the center point of the tightly enclosing box. The "mean point" has a "bias" whether it is on the long side or the short side of the direction bounding box. Then, by establishing the two-dimensional coordinate systems of the two legends, the rotation angles and mirror image data of the two legends can be calculated. Since the direction characteristics and mean point characteristics of the tightly enclosing boxes of two similar legends are relatively similar, the rotation angles can be calculated through such abstract geometric characteristics.
[0088] Step S305: Rotate the Y-axis of the current coordinate system by 90 degrees to obtain a first direction vector.
[0089] Step S306: Determine the X-axis vector of the current coordinate system based on the positional relationship between the first direction vector and the current mean point.
[0090] Specifically, in step S306 above, a dot product calculation is performed on the first direction vector and the current mean point to obtain a second value; when the second value is greater than 0, the first direction vector is determined as the X-axis vector of the current coordinate system; when the second value is not greater than 0, the opposite direction of the first direction vector is determined as the X-axis vector of the current coordinate system. Thus, the X-axis of the constructed coordinate system faces the side of the mean point, so as to embody the above-mentioned "bias". Based on the above origin coordinates, Y-axis vector, and X-axis vector, the construction of the corresponding coordinate system can be completed.
[0091] Specifically, in one embodiment, step S104 above specifically includes the following steps:
[0092] Step S401: Obtain the first Y-axis vector, first X-axis vector corresponding to the first coordinate system, and the second Y-axis vector, second X-axis vector corresponding to the second coordinate system.
[0093] Step S402: Calculate the included angle between the first Y-axis vector and the second Y-axis vector, and determine the rotation angle between the first legend and the target legend.
[0094] Specifically, the included angle between two known vectors can be calculated using existing technologies, which will not be elaborated here. It should be noted that the rotation angle is the above-mentioned included angle plus the rotation direction. For example, taking clockwise rotation as positive, assuming the rotation angle is 30 degrees, it means that the target legend can be obtained by rotating the target legend clockwise by 30 degrees. Assuming the rotation angle is -30 degrees, it means that the target legend can be obtained by rotating the target legend counterclockwise by 30 degrees.
[0095] Step S403: Determine the mirror image relationship between the first legend and the target legend based on the relationship between the first Y-axis vector, the first X-axis vector, the second Y-axis vector, and the second X-axis vector.
[0096] Specifically, the above step S403 specifically obtains the first vector by calculating the cross product of the first Y-axis vector and the first X-axis vector; obtains the second vector by calculating the cross product of the second Y-axis vector and the second X-axis vector; calculates the dot product of the first vector and the second vector; when the dot product is greater than 0, it is determined that the first legend and the target legend are mirror images of each other; when the dot product is not greater than 0, it is determined that the first legend and the target legend are not mirror image relationships.
[0097] Specifically, in actual design, there may be cases where legends are mirror images of each other, and it is impossible to simply perform legend conversion through the rotation angle. Therefore, it is necessary to determine whether similar legends are mirror images of each other. Exemplarily, calculate the cross product of the X-axis and Y-axis of coordinate system 1 to obtain vector P1, calculate the cross product of the X-axis and Y-axis of coordinate system 2 to obtain vector P2, and then perform the dot product of these two vectors. If it is greater than 0, it means that the first legend and the target legend are not mirror images, otherwise it means that the first legend and the target legend are mirror images of each other.
[0098] By determining the rotation angle and mirror image relationship between the first legend and the target legend through the above process, the target legend can be processed according to the rotation angle and mirror image relationship and then replace the first legend, so as to realize the unified description of similar legends, and the replaced legend still maintains the same direction as the first legend.
[0099] By performing the above steps, the method for calculating the conversion relationship between similar legends provided by the embodiments of the present invention determines the conversion relationship between similar legends by calculating the direction bounding boxes and mean points of similar legends respectively and establishing corresponding coordinate systems, so that the conversion relationship can be used to uniformly replace similar legends and ensure that the replaced legends can still maintain the direction of the original legends, thereby improving the accuracy of operations such as engineering quantity calculation and meeting the actual needs of users for processing similar legends, and improving the user experience.
[0100] The embodiments of the present invention also provide a device for calculating the conversion relationship between similar legends, as Figure 6 shown. The device for calculating the conversion relationship between similar legends specifically includes:
[0101] An acquisition module 101, configured to acquire a target legend and a first legend similar to the target legend. For the detailed content, refer to the relevant description of step S101 in the above method embodiment, which will not be elaborated here.
[0102] A first processing module 102, configured to calculate the mean point and the directional bounding box of the target legend and the first legend respectively. The coordinates of the mean point are the average of the coordinates of the legend line endpoints that make up all the legends. For the detailed content, refer to the relevant description of step S102 in the above method embodiment, which will not be elaborated here.
[0103] A second processing module 103, configured to construct a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend respectively based on the mean point and the directional bounding box of the target legend and the first legend. For the detailed content, refer to the relevant description of step S103 in the above method embodiment, which will not be elaborated here.
[0104] A third processing module 104, configured to determine the conversion relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system. For the detailed content, refer to the relevant description of step S104 in the above method embodiment, which will not be elaborated here.
[0105] The further function descriptions of the above respective modules are the same as those in the corresponding method embodiments above, which will not be elaborated here.
[0106] Through the collaborative cooperation of the above respective components, the calculation device for the conversion relationship between similar legends provided by the embodiment of the present invention calculates the directional bounding boxes and mean points of the similar legends respectively, and establishes the corresponding coordinate systems to determine the conversion relationship between the similar legends, so that the conversion relationship can be used to uniformly replace the similar legends, and ensure that the direction of the replaced legend remains the same as the original legend, thereby improving the accuracy of operations such as engineering quantity calculation, and meeting the actual needs of users for processing similar legends, and improving the user experience.
[0107] The embodiment of the present invention also provides an electronic device, as Figure 7 shown. The electronic device may include a processor 901 and a memory 902, where the processor 901 and the memory 902 may be connected through a bus or other means, Figure 7 Taking the connection through the bus as an example.
[0108] The processor 901 may be a Central Processing Unit (CPU). The processor 901 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., or a combination of the above types of chips.
[0109] As a non-transitory computer-readable storage medium, the memory 902 can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of the present invention. The processor 901 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions, and modules stored in the memory 902, that is, the above method is implemented.
[0110] The memory 902 may include a program storage area and a data storage area. Among them, the program storage area can store an operating device and application programs required for at least one function; the data storage area can store data created by the processor 901, etc. In addition, the memory 902 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory 902 may optionally include a memory remotely provided with respect to the processor 901, and these remote memories can be connected to the processor 901 through a network. Examples of the above networks include but are not limited to the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0111] One or more modules are stored in the memory 902 and, when executed by the processor 901, execute the above method.
[0112] For specific details of the above electronic device, reference may be made to the corresponding related descriptions and effects in the above method embodiments for understanding, and details are not described herein again.
[0113] Those skilled in the art can understand that to implement all or part of the processes in the above-described embodiment methods, it can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-described method embodiments. Among them, the storage medium can be a magnetic disk, an optical disc, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memories.
[0114] The above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications or equivalent replacements can still be made to the specific implementation manners of the present invention, and any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of the claims of the present invention.
Claims
1. A calculation method for the conversion relationship of similar legends, characterized in that, Unified replacement applied to similar legends, including: Obtain a target legend and a first legend similar to the target legend; Calculate the mean point and the directional bounding box of the target legend and the first legend respectively. The coordinates of the mean point are the average of the endpoint coordinates of all the legend lines that make up the legend; Based on the mean point and the directional bounding box of the target legend and the first legend, construct a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend respectively; Based on the coordinate axes of the first coordinate system and the second coordinate system, determine the conversion relationship between the first legend and the target legend; Among them, the constructing a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend respectively based on the mean point and the directional bounding box of the target legend and the first legend includes: Obtain the current center point of the current legend corresponding to the current directional bounding box; Based on the current center point, determine the coordinate system origin of the current legend corresponding to the current coordinate system; Based on the direction of the side in the current directional bounding box, determine the direction vector of the current directional bounding box; Perform a dot product calculation on the direction vector and the current mean point corresponding to the current legend to obtain a first value; When the first value is greater than 0, determine the direction vector as the Y-axis vector of the current coordinate system; When the first value is not greater than 0, determine the reverse direction of the direction vector as the Y-axis vector of the current coordinate system; Rotate the Y-axis of the current coordinate system by 90 degrees to obtain a first direction vector; Perform a dot product calculation on the first direction vector and the current mean point to obtain a second value; When the second value is greater than 0, determine the first direction vector as the X-axis vector of the current coordinate system; When the second value is not greater than 0, determine the reverse direction of the first direction vector as the X-axis vector of the current coordinate system.
2. The method according to claim 1, wherein The calculating the mean point and the directional bounding box of the target legend and the first legend respectively includes: Obtain all the legend lines that make up the current legend; Extract the endpoints of each legend line to form a legend point set; Based on the legend point set, calculate the mean point and the directional bounding box corresponding to the current legend.
3. The method according to claim 2, characterized in that, The calculating the mean point and the directional bounding box corresponding to the current legend based on the legend point set includes: Calculate the average of all the endpoint coordinates in the legend point set to determine the mean point; Calculate the convex hull of the legend point set; Based on the directional bounding box of the convex hull, determine the directional bounding box corresponding to the current legend.
4. The method according to claim 1, characterized in that, The determining the conversion relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system includes: Obtain the first Y-axis vector, the first X-axis vector corresponding to the first coordinate system, the second Y-axis vector, and the second X-axis vector corresponding to the second coordinate system; Calculate the included angle between the first Y-axis vector and the second Y-axis vector to determine the rotation angle between the first legend and the target legend; Determine the mirror image relationship between the first legend and the target legend based on the relationships between the first Y-axis vector, the first X-axis vector, the second Y-axis vector, and the second X-axis vector.
5. The method according to claim 4, characterized in that, The determining the mirror image relationship between the first legend and the target legend based on the relationships between the first Y-axis vector, the first X-axis vector, the second Y-axis vector, and the second X-axis vector includes: Calculate the cross product of the first Y-axis vector and the first X-axis vector to obtain a first vector; Calculate the cross product of the second Y-axis vector and the second X-axis vector to obtain a second vector; Calculate the dot product of the first vector and the second vector; When the dot product is greater than 0, determine that the first legend and the target legend are mirror images of each other.
6. A calculation device for conversion relationship of similar legends, characterized in that The unified replacement applied to similar legends includes: An acquisition module for acquiring a target legend and a first legend similar to the target legend; A first processing module for respectively calculating the mean point and the direction bounding box of the target legend and the first legend, where the coordinates of the mean point are the average of the coordinates of the legend line endpoints of all component legends; A second processing module for respectively constructing a first coordinate system corresponding to the target legend and a second coordinate system corresponding to the first legend based on the mean point and the direction bounding box of the target legend and the first legend; A third processing module for determining the transformation relationship between the first legend and the target legend based on the coordinate axes of the first coordinate system and the second coordinate system; Among them, the second processing module is specifically used for: obtaining the current center point of the current legend corresponding to the current direction bounding box; determining the coordinate system origin of the current legend corresponding to the current coordinate system based on the current center point; determining the direction vector of the current direction bounding box based on the direction of the sides in the current direction bounding box; performing a dot product calculation on the direction vector and the current mean point corresponding to the current legend to obtain a first value; when the first value is greater than 0, determining the direction vector as the Y-axis vector of the current coordinate system; when the first value is not greater than 0, determining the reverse direction of the direction vector as the Y-axis vector of the current coordinate system; rotating the Y-axis of the current coordinate system by 90 degrees to obtain a first direction vector; performing a dot product calculation on the first direction vector and the current mean point to obtain a second value; when the second value is greater than 0, determining the first direction vector as the X-axis vector of the current coordinate system; when the second value is not greater than 0, determining the reverse direction of the first direction vector as the X-axis vector of the current coordinate system.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method described in any one of claims 1-5 is implemented.
8. An electronic device, characterized in that, Including: A memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to execute the method described in any one of claims 1-5.
Citation Information
Patent Citations
Character rendering method, device and equipment and storage medium
CN112132941A