A method and apparatus for determining an association line, and an electronic device
By determining the minimum bounding rectangle and pseudo start and end points of the graphics in the image, the search space is reduced, solving the problem of low efficiency in the existing technology and achieving efficient and accurate determination of the correlation line.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies are inefficient in determining the connection line between two graphics in an image, especially for graphics with complex shapes and large rotation angles, where path search algorithms and neural network methods are time-consuming.
By determining the minimum bounding rectangles of the first and second figures in the image respectively, using pseudo-starting and pseudo-ending points to determine the inflection points of the associated lines, and performing path search, the search space is reduced, and a simple and easy-to-understand algorithm process is adopted.
It improves the efficiency of determining the connection line, has a wide range of applications, high accuracy, and is simple and easy to operate, suitable for graphics of various shapes and rotation angles.
Smart Images

Figure CN116934834B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of image processing, and particularly relates to a method and device for determining an association line and an electronic device. BACKGROUND
[0002] When processing an image, it is sometimes necessary to determine an association line between two graphics included in the image. For example, in the field of machine vision, after an image including at least two operator nodes is obtained, an association line between different operator nodes can be determined; in the field of medical image processing, an association line between different organs or lesion sites in an organ image can be determined to better show the connection and difference between different organs or lesion sites. The association line between two graphics refers to the shortest path formed by at least one line segment between the two graphics along a vertical direction and / or along a parallel direction. Referring to the example image shown in the figure, the image includes a rectangle and a rounded rectangle, and according to the requirements of image processing, the starting point of the association line is set to be located at the uppermost side of the rectangle, and the end point of the association line is set to be located at the uppermost side of the rounded rectangle. The line connected by the arrows between the two graphics is the association line, which is composed of the following line segments between the rectangle and the rounded rectangle: line segment ① along the vertical direction, line segment ② along the parallel direction, line segment ③ along the vertical direction, line segment ④ along the parallel direction, and line segment ⑤ along the vertical direction. The intersection point of line segment ① and the rectangle is the starting point of the association line, and the intersection point of line segment ⑤ and the rounded rectangle is the end point of the association line. Figure 1
[0003] Currently, the association line between two graphics is determined by the following two methods. The first method is to determine the association line by a path search algorithm (such as A* algorithm), which takes the entire image containing the two graphics as a search space and determines the association line by sequentially searching each pixel point included in the search space. The second method is a neural network algorithm, which pre-trains a neural network with a large number of training data sets and then determines the association line by the trained neural network.
[0004] However, the first method has the defect that it takes a long time to determine the association line because it needs to search a large number of pixel points in the process of determining the association line. In particular, for graphics with complex shapes and large rotation angles, this defect is particularly evident. The second method also has the defect that it takes a long time to determine the association line because it needs to train the neural network, and the training process also takes a lot of time. SUMMARY
[0005] The present application provides a method and device for determining an association line and an electronic device to solve the problem of low efficiency in determining the association line in the prior art.
[0006] In a first aspect, the present application provides a method for determining an association line, comprising:
[0007] determining a first minimum circumscribed rectangle of a first pattern in an image and a second minimum circumscribed rectangle of a second pattern in the image, wherein each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is either a vertical direction or a parallel direction, the vertical direction is perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction is parallel to the coordinate axis;
[0008] determining a pseudo starting point according to a real starting point in the first pattern and the first minimum circumscribed rectangle, and determining a pseudo ending point according to a real ending point in the second pattern and the second minimum circumscribed rectangle, wherein a line between the pseudo starting point and the real starting point is either a vertical direction or a parallel direction, and a line between the pseudo ending point and the real ending point is either a vertical direction or a parallel direction;
[0009] determining a turning point corresponding to the first pattern and the second pattern according to the pseudo starting point and the pseudo ending point;
[0010] performing path search through the turning point to determine an association line between the first pattern and the second pattern.
[0011] In a feasible design, the determination of the pseudo starting point according to the real starting point in the first pattern and the first minimum circumscribed rectangle comprises:
[0012] determining whether the real starting point intersects with the first minimum circumscribed rectangle;
[0013] if yes, determining the intersection point of the real starting point and the first minimum circumscribed rectangle as the pseudo starting point;
[0014] if no, determining a pseudo starting point in the first minimum circumscribed rectangle, wherein a line between the pseudo starting point in the first minimum circumscribed rectangle and the real starting point is either a vertical direction or a parallel direction;
[0015] the determination of the pseudo ending point according to the real ending point in the first pattern and the second minimum circumscribed rectangle comprises:
[0016] determining whether the real ending point intersects with the second minimum circumscribed rectangle;
[0017] if yes, determining the intersection point of the real ending point and the second minimum circumscribed rectangle as the pseudo ending point;
[0018] If not, a pseudo end point in the second minimum circumscribed rectangle is determined, a line between the pseudo end point and the real end point is in a vertical direction or a parallel direction, and the second target point is the pseudo end point.
[0019] In a possible design, the pseudo start point is determined according to the real start point in the first graph and the first minimum circumscribed rectangle, including:
[0020] A first peripheral rectangle of a periphery of the first minimum circumscribed rectangle is determined, and a minimum distance between each side of the first peripheral rectangle and each side of the first minimum circumscribed rectangle is a first preset distance.
[0021] The pseudo start point on the first peripheral rectangle is determined, and a line between the pseudo start point on the first peripheral rectangle and the real start point is in a vertical direction or a parallel direction.
[0022] The pseudo end point is determined according to the real end point in the first graph and the second minimum circumscribed rectangle, including:
[0023] A second peripheral rectangle of a periphery of the second minimum circumscribed rectangle is determined, and a minimum distance between each side of the second peripheral rectangle and each side of the second minimum circumscribed rectangle is a second preset distance.
[0024] The pseudo end point on the second peripheral rectangle is determined, and a line between the pseudo end point on the second peripheral rectangle and the real end point is in a vertical direction or a parallel direction, and the second target point is the pseudo end point.
[0025] In a possible design, the corresponding inflection point of the first graph and the second graph is determined according to the pseudo start point and the pseudo end point, including:
[0026] A third minimum circumscribed rectangle, a fourth minimum circumscribed rectangle and a first target rectangle are respectively determined, wherein the third minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo end point and the first minimum circumscribed rectangle, the fourth minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo start point and the second minimum circumscribed rectangle, and the first target rectangle is a rectangle composed of the pseudo end point and the pseudo start point.
[0027] Four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle are respectively determined.
[0028] A first set of the four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle is determined, and each of the vertices included in the first set is the corresponding inflection point of the first graph and the second graph.
[0029] In an implementation, the determining the inflection point corresponding to the first graph and the second graph according to the pseudo-start point and the pseudo-end point comprises:
[0030] determining a fifth minimum circumscribed rectangle, a sixth minimum circumscribed rectangle and a second target rectangle respectively, wherein the fifth minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo-end point and the first peripheral rectangle, the sixth minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo-start point and the second peripheral rectangle, and the second target rectangle is a rectangle composed of the pseudo-end point and the pseudo-start point;
[0031] determining four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively;
[0032] determining a second union set of the four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively, wherein each of the vertices included in the second union set is an inflection point corresponding to the first graph and the second graph.
[0033] In an implementation, the determining the associated line between the first graph and the second graph by searching the path through the inflection point comprises:
[0034] taking the real start point as a start point, searching for a next hop node of the start point from the inflection points, wherein the cost of the next hop node is less than the cost of other inflection points;
[0035] determining whether the next hop node is the real end point, and if so, determining that the line between the real start point, each hop node and the real end point is the associated line between the first graph and the second graph;
[0036] if the next hop node is not the real end point, taking the next hop node as a new start point, searching for a new next hop node from the inflection points, and determining whether the new next hop node is the real end point again, wherein the cost of the new next hop node is less than the cost of other inflection points.
[0037] In an implementation, the cost of the next hop node is a weighted sum of a first parameter and a second parameter, wherein the first parameter is the actual distance between the next hop node and the real start point, and the second parameter is the actual distance between the next hop node and the real end point.
[0038] In a second aspect, the present application provides an associated line determination device, which comprises:
[0039] a rectangle determining module configured to determine a first minimum enclosing rectangle of a first graph in an image and a second minimum enclosing rectangle of a second graph in the image, wherein each side of the first minimum enclosing rectangle and the second minimum enclosing rectangle is in a vertical direction or a parallel direction, the vertical direction being perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction being parallel to the coordinate axis;
[0040] a pseudo-start point and a pseudo-end point determining module configured to determine a pseudo-start point according to a real start point in the first graph and the first minimum enclosing rectangle, and determine a pseudo-end point according to a real end point in the second graph and the second minimum enclosing rectangle, wherein a line between the pseudo-start point and the real start point is in the vertical direction or the parallel direction, and a line between the pseudo-end point and the real end point is in the vertical direction or the parallel direction;
[0041] a turning point determining module configured to determine a turning point corresponding to the first graph and the second graph according to the pseudo-start point and the pseudo-end point;
[0042] a correlation line determining module configured to determine a correlation line between the first graph and the second graph by path searching through the turning point.
[0043] In a third aspect, the present application provides an electronic device, which comprises:
[0044] a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method in any one of the first aspect.
[0045] In a fourth aspect, the present application provides a computer storage medium, which stores a computer program or instructions, and when the computer program or instructions are executed, the method in any one of the first aspect is executed.
[0046] In the first method in the prior art, the whole image is taken as a search space for path searching, while the scheme of the present application only performs path searching on each turning point, thus compared with the first method in the prior art, the scheme of the present application reduces the search space in the path searching process and can improve the efficiency of determining the correlation line. In addition, the scheme of the present application does not need to train the neural network, thus compared with the second method in the prior art, the scheme of the present application can also reduce the time consumption and improve the efficiency of determining the correlation line.
[0047] Further, the scheme provided by the application firstly determines a first minimum circumscribed rectangle of the first graph and a second minimum circumscribed rectangle of the second graph, determines the associated line through the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and the edges of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle are in the vertical direction or the parallel direction, so that the associated line can be determined based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle for the first graph and the second graph of various shapes. Therefore, the associated line can be determined by the scheme provided by the application even when the first graph and the second graph are irregular shapes or have a large rotation angle, that is, the scheme provided by the application has high efficiency in determining the associated line and has a wide range of applications.
[0048] In addition, since the scheme provided by the application determines the associated line based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and the edges of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle are in the vertical direction or the parallel direction, the scheme provided by the application fully considers the rotation angle of the first graph and the second graph, that is, the associated line can be accurately determined even when the rotation angle of the first graph and the second graph is large, that is, the scheme provided by the application accurately determines the associated line.
[0049] When the associated line is determined by the second method in the prior art, since the neural network needs a large amount of training data set for training, it is not easy to implement and operate. However, the algorithm process adopted by the scheme provided by the application is simple and easy to understand, so it also has good operability. BRIEF DESCRIPTION OF DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0051] Figure 1 It is a schematic diagram of an associated line;
[0052] Figure 2 It is a schematic diagram of the working process of the associated line determination method provided by the embodiment of the application;
[0053] Figure 3 It is an example diagram of the first graph and the first minimum circumscribed rectangle in the associated line determination method provided by the embodiment of the application;
[0054] Figure 4 It is an example diagram of the pseudo starting point in the associated line determination method provided by the embodiment of the application;
[0055] Figure 5FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0056] Figure 6 FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0057] Figure 7 FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0058] FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0059] FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0060] Figure 9 FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application;
[0061] Figure 10 FIG. 8(a) is an example diagram of a fifth minimum bounding rectangle, a sixth minimum bounding rectangle and a second target rectangle in a method for determining an association line according to an embodiment of the present application; DETAILED DESCRIPTION
[0062] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
[0063] The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to be limiting of the present application. As used in the specification and the appended claims of the application, the singular forms "a," "an" and "the" are intended to include both the singular and the plural forms, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises", "comprising", "includes" and / or "including", as used herein, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. In addition, it should also be understood that, in the following embodiments of the present application, "at least one" and "one or more" refer to one, two or more than two. The term "and / or", used to describe the association relationship of the associated objects, means that there can be three relationships; for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it.
[0064] Reference to "one embodiment" or "some embodiments" or "one implementation" or "some implementations" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. The appearances of the phrase "in one embodiment" or "in some embodiments" or "in other embodiments" or "in still other embodiments" or other similar phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily referring to some, but not all, embodiments. The terms "including," "comprising," "having," and variations thereof are meant to encompass the items listed thereafter, but do not exclude other items from also being present. The terms "a" and "an" and "the" and similar reference used in conjunction with an item means that at least one of the item is present, but does not exclude the presence of two or more of the same item. The term "about" means that quantities, dimensions, notations, and other applied numeric values and such values are approximately or around the stated value, but do not exclude the stated value or ranges thereof and further that variations are to be within manufacturing and production tolerances and variations are to be within experimental errors for the particular measurement technique at hand.
[0065] To make the scheme provided by the present application clear, the scheme provided by the present application is introduced and explained through various embodiments in combination with the drawings.
[0066] To solve the problem of long time consumption and low efficiency in determining the associated line in the prior art, the present embodiment provides a method for determining an associated line.
[0067] Referring to Figure 2 The method for determining an associated line provided by the present embodiment comprises the following steps:
[0068] In step S11, a first minimum circumscribed rectangle of a first figure in an image is determined, and a second minimum circumscribed rectangle of a second figure in the image is determined. Each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is either a vertical direction or a parallel direction. The vertical direction is a direction perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction is a direction parallel to the coordinate axis.
[0069] The first figure and the second figure are located in the same image, and the first figure and the second figure can be diversified shapes. If the first figure is a rectangle, the first minimum circumscribed rectangle is the first figure. Correspondingly, if the second figure is a rectangle, the second minimum circumscribed rectangle is the second figure.
[0070] In actual image processing, the first figure and the second figure are sometimes complex shapes, and at least one line segment constituting the associated line is a line segment along a vertical or parallel direction. Therefore, in order to obtain the associated line of figures of various shapes, in the present application, each side of the determined first minimum circumscribed rectangle and the second minimum circumscribed rectangle is either a vertical direction or a parallel direction, so that the associated line can be determined based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle for the first figure and the second figure of various shapes. In various embodiments provided by the present application, if a line is along a vertical direction or a parallel direction, it means that the line is perpendicular or parallel to any coordinate axis in the image coordinate system.
[0071] In the present application, the image coordinate system is a two-dimensional rectangular coordinate system, and the two coordinate axes of the coordinate system can be referred to as the x-axis and the y-axis, that is, the x-axis and the y-axis are perpendicular. In addition, if the image in which the image coordinate system is located is a rectangle, the two coordinate axes of the coordinate system are usually parallel to the two edges of the image in different directions.
[0072] In a feasible design, the origin of the image coordinate system can be the center point of the image. Of course, the origin of the image coordinate system can also be a point at other positions in the image, which is not limited in the present application.
[0073] In addition, in this step, the first minimum circumscribed rectangle and the second minimum circumscribed rectangle can be determined by the minAreaRect method of opencv, or can be obtained by the boundingRect() method of Qt. Of course, the first minimum circumscribed rectangle and the second minimum circumscribed rectangle can also be obtained by other methods, which are not limited in the embodiments of the present application.
[0074] Referring to Figure 3 An example is shown in the figure, in which the first graph is irregularly shaped, and the rectangle around the first graph is the first minimum circumscribed rectangle corresponding to the first graph.
[0075] Step S12, determining a pseudo starting point according to the real starting point in the first graph and the first minimum circumscribed rectangle, and determining a pseudo ending point according to the real ending point in the second graph and the second minimum circumscribed rectangle.
[0076] In which, the line between the pseudo starting point and the real starting point is perpendicular or parallel to the coordinate axis, and the line between the pseudo ending point and the real ending point is perpendicular or parallel to the coordinate axis.
[0077] In addition, in the embodiments of the present application, the real starting point and the real ending point are the starting point and the ending point set in advance according to actual needs. For example, in the field of medical image processing, sometimes it is necessary to determine the associated line of the lesion site existing in different organs. In this case, after obtaining the image containing different organs, the position of the lesion site in a certain organ in the image can be set as the real starting point, and the position of the lesion site in another organ in the image can be determined as the real ending point.
[0078] Step S13, determining the inflection point corresponding to the first graph and the second graph according to the pseudo starting point and the pseudo ending point.
[0079] In which, the inflection point can be the turning point of the associated line, so in this step, the corresponding inflection point can be determined according to the pseudo starting point and the pseudo ending point.
[0080] Step S14, searching a path through the inflection point to determine the association line between the first figure and the second figure.
[0081] In this step, each inflection point is taken as a search space in the path search process, and each inflection point is searched to determine the association line composed of the inflection points.
[0082] Through the operations of steps S11 to S14, the inflection points corresponding to the first figure and the second figure can be determined based on the minimum circumscribed rectangles corresponding to the first figure and the second figure respectively, and each inflection point is taken as a search space to determine the association line between the first figure and the second figure.
[0083] In the first method in the prior art, the entire image is taken as a search space for path search, while the scheme of the present application only searches the path for each inflection point, so compared with the first method in the prior art, the search space in the path search process is reduced, and the efficiency of determining the association line can be improved. In addition, the scheme of the present application does not need to train the neural network, so compared with the second method in the prior art, the time-consuming can also be reduced, and the efficiency of determining the association line can be improved.
[0084] Further, the scheme of the present application first determines the first minimum circumscribed rectangle of the first figure and the second minimum circumscribed rectangle of the second figure, and determines the association line through the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is in the vertical direction or the parallel direction, so that for various shapes of the first figure and the second figure, the association line can be determined based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle subsequently. Therefore, when the first figure and the second figure are irregular shapes or have a large rotation angle, the association line can also be determined by the scheme of the present application, that is, the scheme of the present application not only has high efficiency in determining the association line, but also has a wide range of application.
[0085] In addition, since the scheme of the present application determines the association line based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is in the vertical direction or the parallel direction, the scheme of the present application fully considers the rotation angle of the first figure and the second figure, that is, even if the rotation angle of the first figure and the second figure is large, the association line can be accurately determined, that is, the scheme of the present application accurately determines the association line.
[0086] When the association line is determined by the second method in the prior art, the neural network needs a large amount of training data set for training, so it is not easy to implement and operate. The algorithm flow adopted by the scheme of the present application is simple and easy to understand, so it also has good operability.
[0087] In the scheme provided by the embodiments of the present application, the operation of determining the pseudo starting point according to the real starting point in the first graph and the first minimum circumscribed rectangle is disclosed, and the operation of determining the terminal starting point according to the real terminal point in the first graph and the second minimum circumscribed rectangle is disclosed. In order to describe how to determine the pseudo starting point and the pseudo terminal point in detail, as Figure 2 In the method, the present application provides another embodiment.
[0088] The embodiment provides a scheme for determining a pseudo starting point and a pseudo terminal point. In the embodiment, the operation of determining the pseudo starting point according to the real starting point in the first graph and the first minimum circumscribed rectangle comprises the following steps.
[0089] Firstly, it is determined whether the real starting point intersects with the first minimum circumscribed rectangle. If the real starting point intersects with the first minimum circumscribed rectangle, the intersection point of the real starting point and the first minimum circumscribed rectangle is determined as the pseudo starting point. In addition, if the real starting point does not intersect with the first minimum circumscribed rectangle, a pseudo starting point in the first minimum circumscribed rectangle is determined, and the line between the real starting point and the pseudo starting point in the first minimum circumscribed rectangle is in a vertical direction or a parallel direction.
[0090] That is to say, in the scheme provided by the embodiments of the present application, the pseudo starting point is in the first minimum circumscribed rectangle. If the real starting point intersects with the first minimum circumscribed rectangle, the intersection point is preferentially selected as the pseudo starting point. If the real starting point does not intersect with the first minimum circumscribed rectangle, a line in a vertical direction or a parallel direction is drawn from the real starting point, and the intersection point of the line and the first minimum circumscribed rectangle is the pseudo starting point.
[0091] In addition, since the associated line does not pass through the first graph, the line in the vertical direction or the parallel direction drawn from the real starting point usually has only the real starting point as the intersection point with the first graph, so as to avoid the line passing through the first graph.
[0092] In order to clearly describe the pseudo starting point obtained by the present application, an example is provided, as shown in the example graph in FIG. 1. Figure 4 In the example, the first graph is an irregular graph, the first graph comprises a real starting point, the first minimum circumscribed rectangle comprises a pseudo starting point, and the line between the real starting point and the pseudo starting point is perpendicular to the long side of the first minimum circumscribed rectangle.
[0093] Correspondingly, in the embodiment, the operation of determining the terminal starting point according to the real terminal point in the first graph and the second minimum circumscribed rectangle comprises the following steps.
[0094] Firstly, it is determined whether the real terminal point intersects with the second minimum circumscribed rectangle.
[0095] if the intersection exists, determining the intersection of the real end point and the second minimum circumscribed rectangle as the pseudo end point;
[0096] if the intersection does not exist, determining a pseudo end point located in the second minimum circumscribed rectangle, a line connecting the pseudo end point and the real end point being in a vertical direction or a parallel direction, and the second target point being the pseudo end point.
[0097] That is, in the scheme provided by the embodiment of the present application, the pseudo end point is located in the second minimum circumscribed rectangle, if the intersection exists, the intersection is selected as the pseudo end point, and if the intersection does not exist, a line in a vertical direction or a parallel direction is drawn from the real end point, and the intersection of the line and the second minimum circumscribed rectangle is the pseudo end point.
[0098] In addition, since the associated line does not pass through the second graphic, the line in a vertical direction or a parallel direction drawn from the real end point usually has only the real end point as the intersection with the second graphic, so as to avoid the line passing through the second graphic.
[0099] Through the scheme of the embodiment of the present application, the pseudo start point located in the first minimum circumscribed rectangle and the pseudo end point located in the second minimum circumscribed rectangle can be determined.
[0100] The present application can also determine the pseudo start point and the pseudo end point in other ways, and therefore, another embodiment is disclosed. In the embodiment, the pseudo start point is determined according to the real start point in the first graphic and the first minimum circumscribed rectangle, and the method comprises:
[0101] determining a first peripheral rectangle of the periphery of the first minimum circumscribed rectangle, each side of the first peripheral rectangle having a minimum distance of a first preset distance from each side of the first minimum circumscribed rectangle;
[0102] determining the pseudo start point located on the first peripheral rectangle, a line connecting the pseudo start point and the real start point being in a vertical direction or a parallel direction
[0103] That is, in the scheme provided by the embodiment of the present application, the pseudo start point is located in the first peripheral rectangle, the first peripheral rectangle is located in the periphery of the first minimum circumscribed rectangle, and each side of the first peripheral rectangle has a minimum distance of a first preset distance from each side of the first minimum circumscribed rectangle. Since the associated line does not pass through the first graphic, in this embodiment, the line connecting the pseudo start point and the real start point usually does not pass through the first graphic.
[0104] In the present application, the pseudo starting point and the pseudo ending point can be determined as the inflection points in the subsequent steps, and the inflection points can be the turning points in the correlation line. Therefore, if the pseudo starting point is close to the real starting point, it will cause part of the line segment in the correlation line to be close to the first graph, affecting the aesthetic degree. In order to avoid this problem, in this embodiment, a first peripheral rectangle is arranged on the periphery of the first minimum circumscribed rectangle, and the pseudo starting point is located in the first peripheral rectangle, so that part of the line segment in the correlation line can be combined with the first graph, and the aesthetic degree is improved.
[0105] In addition, the minimum distance between each side of the first peripheral rectangle and each side of the first minimum circumscribed rectangle is a first preset distance, which can be preset according to actual needs, for example, can be set to 20 pixels or 60 pixels, etc., and the present embodiment is not limited thereto.
[0106] In order to clearly define the pseudo starting point obtained by the present application, an example is provided, as shown in the example graph Figure 5 The example graph includes a first graph, a first minimum circumscribed rectangle and a first peripheral rectangle, and the pseudo starting point is located in the first peripheral rectangle. The first graph includes a real starting point, and the line between the real starting point and the pseudo starting point is perpendicular to the long side of the first minimum circumscribed rectangle.
[0107] Correspondingly, in this embodiment, the pseudo ending point is determined according to the real ending point in the first graph and the second minimum circumscribed rectangle, comprising:
[0108] A second peripheral rectangle on the periphery of the second minimum circumscribed rectangle is determined, and the minimum distance between each side of the second peripheral rectangle and each side of the second minimum circumscribed rectangle is a second preset distance.
[0109] The pseudo ending point located on the second peripheral rectangle is determined, and the line between the pseudo ending point located on the second peripheral rectangle and the real ending point is in a perpendicular direction or a parallel direction, and the second target point is the pseudo ending point.
[0110] That is, in the scheme provided in the present embodiment, the pseudo ending point is located in the second peripheral rectangle, the second peripheral rectangle is located on the periphery of the second minimum circumscribed rectangle, and the minimum distance between each side of the second peripheral rectangle and each side of the second minimum circumscribed rectangle is a first preset distance. Since the correlation line will not pass through the first graph, in this embodiment, the line between the pseudo ending point and the real ending point will not generally pass through the second graph.
[0111] In the present application, the pseudo starting point and the pseudo ending point can be determined as the inflection points in the subsequent steps, and the inflection points can be the turning points in the association line. Therefore, if the pseudo ending point is close to the real ending point, part of the line segment in the association line will be combined with the second figure, affecting the aesthetic degree. In order to avoid this problem, in this embodiment, a second peripheral rectangle is arranged on the periphery of the second minimum circumscribed rectangle, and the pseudo ending point is located in the second peripheral rectangle, so that part of the line segment in the association line can be combined with the second figure, and the aesthetic degree is improved.
[0112] In addition, the minimum distance between each side of the second peripheral rectangle and each side of the second minimum circumscribed rectangle is a second preset distance, which can be preset according to actual needs, for example, can be set to 20 pixels or 60 pixels, etc. Moreover, the first preset distance and the second preset distance can be equal, or the first preset distance and the second preset distance can also be unequal, and the present embodiment does not limit this.
[0113] In the above embodiment, different schemes for determining the pseudo starting point and the pseudo ending point are disclosed, and in the scheme provided in the present embodiment, the inflection points can also be determined by different schemes. Accordingly, the present application discloses another embodiment, in which the pseudo starting point is located in the first minimum circumscribed rectangle, and the pseudo ending point is located in the second minimum circumscribed rectangle. Referring to the workflow diagram shown in the figure, in this embodiment, the determination of the inflection points corresponding to the first figure and the second figure according to the pseudo starting point and the pseudo ending point comprises: Figure 6
[0114] Step S131, respectively determining a third minimum circumscribed rectangle, a fourth minimum circumscribed rectangle and a first target rectangle.
[0115] Among them, the third minimum circumscribed rectangle is the minimum circumscribed rectangle surrounding the pseudo ending point and the first minimum circumscribed rectangle, the fourth minimum circumscribed rectangle is the minimum circumscribed rectangle surrounding the pseudo starting point and the second minimum circumscribed rectangle, and the first target rectangle is the rectangle composed of the pseudo ending point and the pseudo starting point.
[0116] Step S132, determining four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle respectively.
[0117] Since the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle each have four vertices, twelve vertices can be determined in this step.
[0118] Step S133, determining the first union set of the four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle respectively, and each vertex included in the first union set is the inflection point corresponding to the first figure and the second figure.
[0119] That is, in this step, the four vertices of the third minimum circumscribed rectangle, the four vertices of the fourth minimum circumscribed rectangle and the four vertices of the first target rectangle are obtained respectively, and then the twelve vertices obtained are de-duplicated, that is, if two or more vertices are the same pixel point, the pixel point is taken as an inflection point, and other different vertices are also taken as inflection points.
[0120] Through the scheme provided by the embodiment of the present application, the corresponding inflection points can be determined in the case that the pseudo starting point is located in the first minimum circumscribed rectangle and the pseudo ending point is located in the second minimum circumscribed rectangle.
[0121] In another case, the pseudo starting point is located in the first peripheral rectangle and the pseudo ending point is located in the second peripheral rectangle. For how to determine the inflection points corresponding to the first graph and the second graph according to the pseudo starting point and the pseudo ending point in this case, the present application provides another embodiment. Referring to Figure 7 The working flow diagram shown in the figure, in this embodiment, the inflection points corresponding to the first graph and the second graph are determined according to the pseudo starting point and the pseudo ending point, including:
[0122] Step S134, respectively determine the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle.
[0123] Among them, the fifth minimum circumscribed rectangle is the minimum circumscribed rectangle surrounding the pseudo ending point and the first peripheral rectangle, the sixth minimum circumscribed rectangle is the minimum circumscribed rectangle surrounding the pseudo starting point and the second peripheral rectangle, and the second target rectangle is the rectangle composed of the pseudo ending point and the pseudo starting point.
[0124] Step S135, determine the four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively.
[0125] Since the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle have four vertices respectively, twelve vertices can be determined in this step.
[0126] Step S136, determine the second union set of the four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively, and each vertex included in the second union set is an inflection point corresponding to the first graph and the second graph.
[0127] That is, in this step, the four vertices of the fifth minimum circumscribed rectangle, the four vertices of the sixth minimum circumscribed rectangle and the four vertices of the second target rectangle are obtained respectively, and then the twelve vertices obtained are de-duplicated, and the corresponding inflection points are obtained.
[0128] By the scheme provided in the embodiments of the present application, the corresponding inflection point can be determined in the case that the pseudo starting point is located in the first peripheral rectangle and the pseudo ending point is located in the second peripheral rectangle.
[0129] In order to clarify the inflection point determined in this embodiment, one example is disclosed as follows. Referring to the example diagram shown in FIG. 8(a), in the example, the first minimum circumscribed rectangle, the second minimum circumscribed rectangle, the first peripheral rectangle, the second peripheral rectangle, the pseudo starting point located on the first peripheral rectangle, the pseudo ending point located on the second peripheral rectangle, the fifth minimum circumscribed rectangle determined by the pseudo ending point and the first peripheral rectangle, and the sixth minimum circumscribed rectangle determined by the pseudo starting point and the second peripheral rectangle are included.
[0130] In addition, referring to the example diagram shown in FIG. 8(b), in the example, the first minimum circumscribed rectangle, the second minimum circumscribed rectangle, the first peripheral rectangle, the second peripheral rectangle, the pseudo starting point located on the first peripheral rectangle, the pseudo ending point located on the second peripheral rectangle, and the second target rectangle composed of the pseudo ending point and the pseudo starting point are included. The inflection point is each vertex included in the second union set of the four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle, and the second target rectangle respectively.
[0131] After the inflection point is determined, the associated line between the first graph and the second graph can be determined by performing path search on the inflection point. In the path search performed by the embodiments of the present application, various path search algorithms can be used. In the scheme provided in the embodiments of the present application, the inflection point is used as the search space in the path search, and compared with the prior art, the search space is reduced. Therefore, in the path search performed by various path search algorithms, the scheme provided in the embodiments of the present application can improve the efficiency.
[0132] In one possible implementation, the A* algorithm is used to perform the path search by the present application, referring to the workflow schematic diagram shown in FIG. 9(a). In this implementation, the path search is performed on the inflection point to determine the associated line between the first graph and the second graph, including the following steps. Figure 9
[0133] Step S141, taking the real starting point as the starting point, searching for the next hop node of the starting point from the inflection points, and the cost of the next hop node is less than the cost of other inflection points.
[0134] In one possible design, the cost of the next hop node is the weighted sum of the first parameter and the second parameter, the first parameter is the actual distance between the next hop node and the real starting point, and the second parameter is the actual distance between the next hop node and the real ending point.
[0135] Step S142, judging whether the next hop node is the real end point, if not, performing the operation of step S143, if yes, performing the operation of step S144.
[0136] Step S143, if the next hop node is not the real end point, taking the next hop node as a new starting point, searching a new next hop node from the inflection points, wherein the cost of the new next hop node is less than the cost of other inflection points. Then, returning to perform the operation of step S142.
[0137] Step S144, if the next hop node is the real end point, determining the real starting point, the connection line between each hop node and the real end point as the association line between the first graph and the second graph.
[0138] That is, in the embodiment of the present application, first taking the real starting point as a starting point, searching the next hop node of the starting point from the inflection points through the cost of each inflection point, then judging whether the next hop node is the real end point, if not, taking the next hop node as a new starting point, repeating the above operation until the determined next hop node is the real end point, then determining the real starting point, the connection line between each hop node and the real end point as the association line.
[0139] Through the above operation, the path search can be realized based on the inflection points, the association line between the first graph and the second graph is determined, and compared with the prior art, the search space is reduced, and the efficiency of determining the association line can be improved, because each inflection point is taken as a search space in the path search process.
[0140] The following is an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.
[0141] The embodiment of the present application discloses an association line determination device, referring to the structural schematic diagram shown in Figure 10 The device comprises a rectangle determination module 110, a pseudo starting point and pseudo end point determination module 120, an inflection point determination module 130 and an association line determination module 140.
[0142] The rectangle determination module 110 is configured to determine a first minimum circumscribed rectangle of a first graph in an image and a second minimum circumscribed rectangle of a second graph in the image respectively, each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is a vertical direction or a parallel direction, the vertical direction is a direction perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction is a direction parallel to the coordinate axis.
[0143] The pseudo starting point and pseudo ending point determination module 120 is configured to determine a pseudo starting point according to a real starting point in the first graph and the first minimum bounding rectangle, and determine a pseudo ending point according to a real ending point in the second graph and the second minimum bounding rectangle, wherein a line connecting the pseudo starting point and the real starting point is in a vertical direction or a parallel direction, and a line connecting the pseudo ending point and the real ending point is in a vertical direction or a parallel direction.
[0144] The inflection point determination module 130 is configured to determine an inflection point corresponding to the first graph and the second graph according to the pseudo starting point and the pseudo ending point.
[0145] The associated line determination module 140 is configured to determine an associated line between the first graph and the second graph by path searching through the inflection point.
[0146] In a possible design, the pseudo starting point and pseudo ending point determination module 120 is configured to determine whether there is an intersection point between the real starting point and the first minimum bounding rectangle; if there is, determine the intersection point between the real starting point and the first minimum bounding rectangle as the pseudo starting point; if there is not, determine a pseudo starting point located in the first minimum bounding rectangle, and a line connecting the pseudo starting point located in the first minimum bounding rectangle and the real starting point is in a vertical direction or a parallel direction.
[0147] Further, the pseudo starting point and pseudo ending point determination module 120 is configured to determine whether there is an intersection point between the real ending point and the second minimum bounding rectangle.
[0148] If there is, determine the intersection point between the real ending point and the second minimum bounding rectangle as the pseudo ending point.
[0149] If there is not, determine a pseudo ending point located in the second minimum bounding rectangle, a line connecting the pseudo ending point located in the second minimum bounding rectangle and the real ending point is in a vertical direction or a parallel direction, and the second target point is the pseudo ending point.
[0150] In another possible design, the pseudo starting point and pseudo ending point determination module 120 is configured to determine a first peripheral rectangle of a periphery of the first minimum bounding rectangle, each side of the first peripheral rectangle has a first preset minimum distance from each side of the first minimum bounding rectangle; and determine the pseudo starting point located on the first peripheral rectangle, and a line connecting the pseudo starting point located on the first peripheral rectangle and the real starting point is in a vertical direction or a parallel direction.
[0151] Further, the pseudo starting point and pseudo ending point determination module 120 is configured to determine a second peripheral rectangle of a periphery of the second minimum bounding rectangle, each side of the second peripheral rectangle has a second preset minimum distance from each side of the second minimum bounding rectangle.
[0152] determining the pseudo end point located on the second bounding rectangle, a line between the pseudo end point and the real end point being in a vertical direction or a horizontal direction, and the second target point being the pseudo end point.
[0153] In one possible design, the inflection point determination module 130 can be configured to perform the following operations:
[0154] determining a third minimum bounding rectangle, a fourth minimum bounding rectangle, and a first target rectangle, respectively, wherein the third minimum bounding rectangle is a minimum bounding rectangle that encloses the pseudo end point and the first minimum bounding rectangle, the fourth minimum bounding rectangle is a minimum bounding rectangle that encloses the pseudo start point and the second minimum bounding rectangle, and the first target rectangle is a rectangle composed of the pseudo end point and the pseudo start point;
[0155] determining four vertices corresponding to the third minimum bounding rectangle, the fourth minimum bounding rectangle, and the first target rectangle, respectively;
[0156] determining a first union of the four vertices corresponding to the third minimum bounding rectangle, the fourth minimum bounding rectangle, and the first target rectangle, respectively, wherein each of the vertices included in the first union is an inflection point corresponding to the first graph and the second graph.
[0157] In another possible design, the inflection point determination module 130 can be configured to perform the following operations:
[0158] determining a fifth minimum bounding rectangle, a sixth minimum bounding rectangle, and a second target rectangle, respectively, wherein the fifth minimum bounding rectangle is a minimum bounding rectangle that encloses the pseudo end point and the first bounding rectangle, the sixth minimum bounding rectangle is a minimum bounding rectangle that encloses the pseudo start point and the second bounding rectangle, and the second target rectangle is a rectangle composed of the pseudo end point and the pseudo start point;
[0159] determining four vertices corresponding to the fifth minimum bounding rectangle, the sixth minimum bounding rectangle, and the second target rectangle, respectively;
[0160] determining a second union of the four vertices corresponding to the fifth minimum bounding rectangle, the sixth minimum bounding rectangle, and the second target rectangle, respectively, wherein each of the vertices included in the second union is an inflection point corresponding to the first graph and the second graph.
[0161] In one possible design, the associated line determination module 140 can be configured to perform the following operations:
[0162] The real starting point is taken as a starting point, and a next hop node of the starting point is searched from the inflection points, and a cost of the next hop node is less than a cost of other inflection points;
[0163] It is judged whether the next hop node is the real end point, and if so, it is determined that a connection line between the real starting point, each hop node and the real end point is an associated line between the first graph and the second graph;
[0164] If the next hop node is not the real end point, the next hop node is taken as a new starting point, a new next hop node is searched from the inflection points, and it is again judged whether the next hop node is the real end point, and a cost of the new next hop node is less than a cost of other inflection points.
[0165] Exemplarily, the cost of the next hop node is a weighted sum of a first parameter and a second parameter, the first parameter is an actual distance between the next hop node and the real starting point, and the second parameter is an actual distance between the next hop node and the real end point.
[0166] The device provided in the embodiments of the present application only performs path searching on each inflection point, and therefore, compared with the first method in the prior art, the search space in the path searching process is reduced, and the efficiency of determining the associated line can be improved. In addition, the device provided in the embodiments of the present application does not need to train the neural network, and therefore, compared with the second method in the prior art, the time consumption can also be reduced, and the efficiency of determining the associated line can be improved.
[0167] Further, the device provided in the embodiments of the present application first determines a first minimum circumscribed rectangle of the first graph and a second minimum circumscribed rectangle of the second graph, and determines the associated line based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is in a vertical direction or a parallel direction, so that the associated line can be determined based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle for various shapes of the first graph and the second graph. Therefore, when the first graph and the second graph are irregular shapes or have a large rotation angle, the associated line can also be determined by the scheme of the present application, that is, the scheme of the present application not only has high efficiency in determining the associated line, but also has a wide range of application.
[0168] In addition, since the device provided in the embodiments of the present application determines the associated line based on the first minimum circumscribed rectangle and the second minimum circumscribed rectangle, and each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is in a vertical direction or a parallel direction, the device provided in the embodiments of the present application fully considers the rotation angle of the first graph and the second graph, that is, even if the rotation angle of the first graph and the second graph is large, the associated line can also be accurately determined, that is, the scheme of the present application accurately determines the associated line.
[0169] In the second method in the prior art, it is difficult to implement and operate because the neural network needs a large training data set for training. The device provided in the embodiments of the present application has a simple and easy-to-understand algorithm process, and thus has good operability.
[0170] Correspondingly, the embodiments of the present application disclose an electronic device, which comprises:
[0171] a processor and a memory, wherein the memory is configured to store a computer program;
[0172] the processor is configured to call and execute the computer program stored in the memory, and when the computer program stored in the memory is executed by the processor, the host computer is caused to perform Figure 2 、 Figure 6 、 Figure 7 and Figure 9 all or part of the steps in the corresponding embodiments.
[0173] The electronic device of the embodiments of the present application can correspond to the electronic device in the corresponding embodiments of the above Figure 2 、 Figure 6 、 Figure 7 and Figure 9 , and the processor and the memory in the electronic device can implement the functions and / or various steps and methods implemented by the electronic device in the corresponding embodiments of Figure 2 、 Figure 6 、 Figure 7 and Figure 9 , and for the sake of brevity, they will not be described here.
[0174] Correspondingly, the embodiments of the present application also provide a computer storage medium, which stores a computer program or instructions, and when the computer program or instructions are executed, all or part of the steps in the corresponding embodiments of Figure 2 、 Figure 6 、 Figure 7 and Figure 9 can be implemented.
[0175] The various illustrative logical blocks, modules, and circuits described in connection with the embodiments disclosed herein can be implemented or performed with a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor can be a microprocessor, but, in the alternative, the general purpose processor can be any conventional processor, controller, microcontroller, or state machine. A processor can also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
[0176] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in Random Access Memory (RAM), flash memory, Read-only Memory (ROM), Erasable Programmable Read-only Memory (EPROM), registers, hard disk, a removable disk, a compact disc read-only memory (CD-ROM), or any other form of storage medium known in the art. An exemplary storage medium is tangible. In some embodiments, the storage medium is non-transitory. The storage medium can be coupled to the processor such the processor can read information from, and write information to, the storage medium. In alternative embodiments, the storage medium is integral to the processor. The processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC) in a user terminal (UE). Alternatively, the processor and the storage medium can also reside in different components in the UE.
[0177] It should be understood that, in various embodiments of the present application, the sequence of the processes does not mean the execution order, and the execution order of the processes should be determined according to the functions and the inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0178] In the embodiments described above, all or part can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed by a computer, the computer instructions generate all or part of the processes or functions described in the embodiments of the present application. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available medium can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), optical medium, or semiconductor medium (for example, solid state disk (SSD)), etc.
[0179] The same or similar parts between various embodiments of the present specification can be referred to each other, and each embodiment focuses on the difference from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the description in the method embodiment part.
[0180] Those skilled in the art can clearly understand that the technology in the embodiments of the present application can be realized by means of software and necessary general hardware platform. Based on such understanding, the technical solutions in the embodiments of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes a plurality of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute the method described in various embodiments or some parts of the embodiments of the present application.
[0181] The same or similar parts between various embodiments of the present specification can be referred to each other. In particular, for the embodiments of the road constraint determination device disclosed in the present application, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the description in the method embodiment part.
[0182] The above-described embodiments of the present application do not constitute a limitation on the scope of protection of the present application.
Claims
1. A method of determining an association line, characterized by, The method comprises the following steps: determining a first minimum circumscribed rectangle of a first figure in an image and a second minimum circumscribed rectangle of a second figure in the image, wherein each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is a vertical direction or a parallel direction, the vertical direction is perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction is parallel to the coordinate axis; determining a pseudo starting point according to a real starting point in the first figure and the first minimum circumscribed rectangle, and determining a pseudo ending point according to a real ending point in the second figure and the second minimum circumscribed rectangle, wherein a line between the pseudo starting point and the real starting point is a vertical direction or a parallel direction, a line between the pseudo ending point and the real ending point is a vertical direction or a parallel direction, the pseudo starting point is located in the first minimum circumscribed rectangle, and the pseudo ending point is located in the second minimum circumscribed rectangle; determining a turning point corresponding to the first figure and the second figure according to the pseudo starting point and the pseudo ending point; performing path search through the turning point to determine a connection line between the first figure and the second figure; the step of determining the turning point corresponding to the first figure and the second figure according to the pseudo starting point and the pseudo ending point comprises the following steps: determining a third minimum circumscribed rectangle, a fourth minimum circumscribed rectangle and a first target rectangle, wherein the third minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo ending point and the first minimum circumscribed rectangle, the fourth minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo starting point and the second minimum circumscribed rectangle, and the first target rectangle is a rectangle composed of the pseudo ending point and the pseudo starting point; determining four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle respectively; determining a first union set of the four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle respectively, wherein each vertex in the first union set is a turning point corresponding to the first figure and the second figure.
2. The method of claim 1, wherein, the step of determining the pseudo starting point according to the real starting point in the first figure and the first minimum circumscribed rectangle comprises the following steps: determining whether there is an intersection point between the real starting point and the first minimum circumscribed rectangle; if there is, determining that the intersection point between the real starting point and the first minimum circumscribed rectangle is the pseudo starting point; if there is not, determining a pseudo starting point located in the first minimum circumscribed rectangle, wherein a line between the pseudo starting point located in the first minimum circumscribed rectangle and the real starting point is a vertical direction or a parallel direction; the step of determining the pseudo ending point according to the real ending point in the second figure and the second minimum circumscribed rectangle comprises the following steps: determining whether there is an intersection point between the real ending point and the second minimum circumscribed rectangle; if there is, determining that the intersection point between the real ending point and the second minimum circumscribed rectangle is the pseudo ending point; if there is not, determining a pseudo ending point located in the second minimum circumscribed rectangle, wherein a line between the pseudo ending point located in the second minimum circumscribed rectangle and the real ending point is a vertical direction or a parallel direction, and the second target point is the pseudo ending point.
3. The method of claim 1, wherein, The determining the pseudo starting point according to the real starting point in the first graph and the first minimum circumscribed rectangle comprises: determining a first periphery rectangle of a periphery of the first minimum circumscribed rectangle, each side of the first periphery rectangle having a minimum distance from each side of the first minimum circumscribed rectangle being a first preset distance; determining the pseudo starting point on the first periphery rectangle, a line between the pseudo starting point on the first periphery rectangle and the real starting point being a perpendicular direction or a parallel direction; The determining the pseudo starting point according to the real ending point in the second graph and the second minimum circumscribed rectangle comprises: determining a second periphery rectangle of a periphery of the second minimum circumscribed rectangle, each side of the second periphery rectangle having a minimum distance from each side of the second minimum circumscribed rectangle being a second preset distance; determining the pseudo ending point on the second periphery rectangle, a line between the pseudo ending point on the second periphery rectangle and the real ending point being a perpendicular direction or a parallel direction, and the second target point being the pseudo ending point.
4. The method of claim 3, wherein, The determining the inflection point corresponding to the first graph and the second graph according to the pseudo starting point and the pseudo ending point further comprises: respectively determining a fifth minimum circumscribed rectangle, a sixth minimum circumscribed rectangle and a second target rectangle, wherein the fifth minimum circumscribed rectangle is a minimum circumscribed rectangle enclosing the pseudo ending point and the first periphery rectangle, the sixth minimum circumscribed rectangle is a minimum circumscribed rectangle enclosing the pseudo starting point and the second periphery rectangle, and the second target rectangle is a rectangle composed of the pseudo ending point and the pseudo starting point; determining four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively; determining a second union set of the four vertices corresponding to the fifth minimum circumscribed rectangle, the sixth minimum circumscribed rectangle and the second target rectangle respectively, each of the vertices included in the second union set being the inflection point corresponding to the first graph and the second graph.
5. The method of claim 1, wherein, The determining the associated line between the first graph and the second graph through the path search of the inflection point comprises: taking the real starting point as a starting point, finding a next hop node of the starting point from the inflection points, the cost of the next hop node being less than the cost of other inflection points; judging whether the next hop node is the real ending point, if yes, determining a line between the real starting point, each hop node and the real ending point as the associated line between the first graph and the second graph; if the next hop node is not the real ending point, taking the next hop node as a new starting point, finding a new next hop node from the inflection points, and judging again whether the new next hop node is the real ending point, the cost of the new next hop node being less than the cost of other inflection points.
6. The method of claim 5, wherein: the cost of the next hop node is a weighted sum of a first parameter and a second parameter, the first parameter being an actual distance between the next hop node and the real starting point, and the second parameter being an actual distance between the next hop node and the real ending point.
7. An association line determination apparatus characterized by comprising: The device comprises: The rectangular determination module is configured to determine a first minimum circumscribed rectangle of a first graph in an image and a second minimum circumscribed rectangle of a second graph in the image, wherein each side of the first minimum circumscribed rectangle and the second minimum circumscribed rectangle is in a vertical direction or a parallel direction, the vertical direction is perpendicular to a coordinate axis in an image coordinate system of the image, and the parallel direction is parallel to the coordinate axis; The pseudo-start point and pseudo-end point determination module is configured to determine a pseudo-start point according to a real start point in the first graph and the first minimum circumscribed rectangle, and determine a pseudo-end point according to a real end point in the second graph and the second minimum circumscribed rectangle, wherein a line between the pseudo-start point and the real start point is in the vertical direction or the parallel direction, a line between the pseudo-end point and the real end point is in the vertical direction or the parallel direction, the pseudo-start point is located in the first minimum circumscribed rectangle, and the pseudo-end point is located in the second minimum circumscribed rectangle; The inflection point determination module is configured to determine an inflection point corresponding to the first graph and the second graph according to the pseudo-start point and the pseudo-end point; The associated line determination module is configured to determine an associated line between the first graph and the second graph through path searching based on the inflection point; The inflection point determination module is configured to determine an inflection point corresponding to the first graph and the second graph according to the pseudo-start point and the pseudo-end point, including: The third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle are determined respectively, wherein the third minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo-end point and the first minimum circumscribed rectangle, the fourth minimum circumscribed rectangle is a minimum circumscribed rectangle surrounding the pseudo-start point and the second minimum circumscribed rectangle, and the first target rectangle is a rectangle composed of the pseudo-end point and the pseudo-start point; Four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle are determined respectively; A first union set of the four vertices corresponding to the third minimum circumscribed rectangle, the fourth minimum circumscribed rectangle and the first target rectangle is determined, and each vertex in the first union set is an inflection point corresponding to the first graph and the second graph.
8. An electronic device, comprising: The electronic device includes: The memory stores a computer program, and the processor executes the computer program to implement the method in any one of claims 1 to 6.
9. A computer storage medium, characterized in that The computer storage medium stores a computer program or instructions, and when the computer program or instructions are executed, the method in any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Connecting line path construction method and device, computer equipment and readable storage medium
CN113421316A
Method and system for transforming handwritten text to digital ink
US20200065601A1