Template generation method, device, electronic device and storage medium
By responding to user edge drawing operations on the interactive interface, combining the drawing edge and the first edge extracted from the edge, determining the second edge and generating a template, the problem of inaccurate template generation in the prior art is solved, and the accuracy and efficiency of object pose detection are improved.
Patent Information
- Application Number
- CN202411654530.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-11-18
AI Technical Summary
In the prior art, it is difficult to generate accurate templates in the process of determining the object position, especially when there are processing traces or textures in the object, resulting in low detection accuracy and prone to missed detection or missed detection.
By displaying the image of the target object in the interactive interface, in response to the user's edge drawing operation, combining the drawing edge and the first edge extracted by the edge, a second edge is determined, and a template of the target object is generated based on the second edge.
This method can more accurately determine the real edge of the target object, reduce the impact of interference information in the image on template generation, improve the accuracy of the template, and thus improve the accuracy and efficiency of object pose detection.
Smart Images

Figure CN119152074B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to a template generation method, device, electronic device and storage medium. Background Art
[0002] Machine vision technology is involved in automated industrial production, for example, capturing images of objects to be inspected and determining the object's position and posture.
[0003] In the prior art, based on the template of the object, an object matching the template of the object is usually determined in the image of the object, and then the position and posture of the object are determined. Therefore, the template of the object is crucial in the process of determining the position and posture of the object, and an accurate template of the object needs to be generated. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a template generation method, device, electronic device and storage medium to generate an accurate template of a target object. The specific technical solution is as follows:
[0005] According to one aspect of an embodiment of the present application, a template generation method is provided, the method comprising:
[0006] Displaying a first image of the target object on the interactive interface;
[0007] In response to an edge drawing operation on a target object in a first image displayed on the interactive interface, determining a second edge of the target object in the first image based on a drawn edge drawn by the edge drawing operation and / or a first edge of the target object extracted from the first image;
[0008] Based on the second edge, a template of the target object is generated.
[0009] In one embodiment of the present application, the edge drawing operation is responded to in the following manner:
[0010] In response to a line drawing operation of a touch object on a first image displayed on the interactive interface, collecting a touch point of the touch object on the first image;
[0011] Obtaining a curve generated based on the collected touch points as the drawing edge of the target object;
[0012] The drawn edge is displayed in the interactive interface.
[0013] In one embodiment of the present application, obtaining a curve generated based on the collected touch points as a drawn edge of the target object includes:
[0014] An object contour line generated based on the collected touch points is obtained as a drawing edge of the target object, wherein the object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve.
[0015] In one embodiment of the present application, before collecting the touch point of the touch object on the first image in response to the line drawing operation of the touch object on the first image displayed on the interactive interface, the method further includes:
[0016] Determine a target contour shape corresponding to a selected target control among contour shape controls displayed on the interactive interface;
[0017] The step of obtaining a curve generated based on the collected touch points as a drawing edge of the target object includes:
[0018] A curve of the target contour shape is generated according to the collected touch points as a drawn edge of the target object.
[0019] In one embodiment of the present application, the edge drawing operation is responded to in the following manner:
[0020] In response to a structural diagram selection operation on a target object in a first image displayed on the interactive interface, loading a contour line in the structural diagram of the target object;
[0021] According to the position and posture of the target object in the first image, the loaded contour line is adjusted, the adjusted contour line is displayed in the interactive interface, and the adjusted contour line is used as the drawing edge of the target object.
[0022] In one embodiment of the present application, adjusting the loaded contour line according to the position and posture of the target object in the first image, and displaying the adjusted contour line in the interactive interface includes:
[0023] Adjusting the loaded contour line to a target posture, wherein the target posture is: a posture of the target object such that an edge of the target object in the first image and the loaded contour line meet a matching condition;
[0024] The upper layer of the first image displayed on the interactive interface displays the adjusted contour line.
[0025] In one embodiment of the present application, adjusting the loaded contour line according to the position and posture of the target object in the first image, and displaying the adjusted contour line in the interactive interface includes:
[0026] Obtaining a first scale of the structural diagram;
[0027] Obtaining a second scale between the target object in the first image and the target object in the actual scene;
[0028] Based on the first scale and the second scale, the loaded contour line is scaled;
[0029] According to the position and posture of the target object in the first image, the adjusted loaded contour line is displayed on the interactive interface.
[0030] In one embodiment of the present application, determining a second edge of the target object in the first image based on the drawn edge drawn by the edge drawing operation and / or the first edge of the target object extracted from the first image includes:
[0031] Based on the drawn edge, generating a first mask image of the drawn edge;
[0032] Obtaining an edge polarity of an edge point corresponding to the drawn edge in the first mask image along a set direction as a first edge polarity, wherein the edge polarity represents a direction in which grayscale values of pixel points on both sides of the edge point along the set direction change;
[0033] Obtaining an edge polarity of an edge point corresponding to the first edge in a second mask image along a set direction as a second edge polarity, wherein the second mask image is: a mask image obtained by performing edge extraction on the first image;
[0034] Determining a target edge point in the drawn edge based on the obtained first edge polarity and second edge polarity, wherein the first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge;
[0035] Based on the determined target edge point, a second edge of the target object in the first image is obtained.
[0036] In one embodiment of the present application, determining a second edge of the target object in the first image based on the drawn edge drawn by the edge drawing operation and / or the first edge of the target object extracted from the first image includes:
[0037] Determine matching edge point pairs in the drawn edge and the first edge, wherein each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge;
[0038] For a first type of edge point pair, edge points in the first type of edge point pair belonging to the drawn edge are determined as edge points in a second edge of the target object in the first image, wherein the first type of edge point pair is: a matching edge point pair in which a distance between two edge points is less than a preset distance threshold;
[0039] For the second type of edge point pairs, edge points belonging to the first edge in the second type of edge point pairs are used to correct edge points belonging to the drawn edge to obtain corrected points as edge points in the second edge of the target object in the first image, wherein the second type of edge point pairs are: edge point pairs in the determined matching edge point pairs except the first type of edge points.
[0040] According to another aspect of an embodiment of the present application, a template generation device is provided, the device comprising:
[0041] A first image display module, used to display a first image of a target object on an interactive interface;
[0042] A second edge determination module, configured to determine, in response to an edge drawing operation on the target object in the first image displayed on the interactive interface, a second edge of the target object in the first image based on a drawing edge drawn by the edge drawing operation and / or a first edge of the target object extracted from the first image;
[0043] A template generating module is used to generate a template of the target object based on the second edge.
[0044] In one embodiment of the present application, the second edge determination module is specifically used to respond to the edge drawing operation in the following manner: in response to the line drawing operation of the touch object on the first image displayed on the interactive interface, collect the touch points of the touch object on the first image; a curve acquisition unit is used to obtain a curve generated based on the collected touch points as the drawing edge of the target object; a drawing edge display unit is used to display the drawing edge in the interactive interface;
[0045] In one embodiment of the present application, the second edge determination module is specifically used to obtain an object contour line generated based on the collected touch points as a drawing edge of the target object, wherein the object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve;
[0046] In one embodiment of the present application, the second edge determination module is further used to determine a target contour shape corresponding to a selected target control in the contour shape control displayed on the interactive interface; specifically, to generate a curve of the target contour shape according to the collected touch points as a drawing edge of the target object;
[0047] In one embodiment of the present application, the second edge determination module is specifically used to respond to the edge drawing operation in the following manner: in response to the structural diagram selection operation of the target object in the first image displayed on the interactive interface, load the contour line in the structural diagram of the target object; adjust the loaded contour line according to the posture of the target object in the first image, display the adjusted contour line in the interactive interface, and use the adjusted contour line as the drawing edge of the target object;
[0048] In one embodiment of the present application, the second edge determination module is specifically used to adjust the loaded contour line to a target posture, wherein the target posture is: a posture of the target object such that the edge of the target object in the first image and the loaded contour line meet a matching condition; and the adjusted contour line is displayed on the upper layer of the first image displayed on the interactive interface;
[0049] In one embodiment of the present application, the second edge determination module is specifically used to obtain a first scale of the structural diagram; obtain a second scale between the target object in the first image and the target object in the actual scene; scale-adjust the loaded contour line based on the first scale and the second scale; and display the adjusted loaded contour line on the interactive interface according to the position and posture of the target object in the first image;
[0050] In one embodiment of the present application, the second edge determination module is specifically used to: generate a first mask image of the drawn edge based on the drawn edge; obtain the edge polarity of the edge point corresponding to the drawn edge in the first mask image along a set direction as the first edge polarity, wherein the edge polarity represents the direction of change of the grayscale value of the pixel points on both sides of the edge point along the set direction; obtain the edge polarity of the edge point corresponding to the first edge in the second mask image along the set direction as the second edge polarity, wherein the second mask image is: the mask image obtained by edge extraction of the first image; determine the target edge point in the drawn edge based on the obtained first edge polarity and second edge polarity, wherein the first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge; obtain the second edge of the target object in the first image based on the determined target edge point;
[0051] In one embodiment of the present application, the second edge determination module is specifically used to: determine matching edge point pairs in the drawn edge and the first edge, wherein each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge; for a first type of edge point pairs, determine the edge points in the first type of edge point pairs belonging to the drawn edge as edge points in the second edge of the target object in the first image, wherein the first type of edge point pairs are: matching edge point pairs in which the distance between the two edge points is less than a preset distance threshold; for a second type of edge point pairs, use the edge points in the second type of edge point pairs belonging to the first edge to correct the edge points belonging to the drawn edge to obtain corrected points as edge points in the second edge of the target object in the first image, wherein the second type of edge point pairs are: edge point pairs in the determined matching edge point pairs excluding the first type of edge points.
[0052] According to another aspect of the embodiments of the present application, there is provided an electronic device, including:
[0053] Memory, used to store computer programs;
[0054] The processor is used to implement any of the above-mentioned template generation methods when executing the program stored in the memory.
[0055] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned template generation methods is implemented.
[0056] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned template generation methods.
[0057] Beneficial effects of the embodiments of the present application:
[0058] As can be seen from the above, in the solution provided in the embodiment of the present application, the second edge is used to generate the template of the target object, and the second edge is determined based on the drawn edge and the first edge, wherein the first edge is obtained by edge extraction, and the drawn edge is obtained by the edge drawing operation of the target object in the first image displayed on the interactive interface. Therefore, based on the drawn edge, the position of the real edge of the target object can be more accurately determined, and the influence of interference information in the first image of the target object on the template generation can be reduced. The second edge determined by combining the drawn edge and the first edge can more accurately characterize the real edge of the target object. The second edge combines the edge information provided by both the drawn edge and the first edge, and then based on the second edge, an accurate template of the target object can be generated.
[0059] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0061] Figure 1a A schematic diagram of the structure of the first object provided in an embodiment of the present application;
[0062] Figure 1b A schematic diagram of a first template provided in an embodiment of the present application;
[0063] Figure 1c A schematic diagram of the structure of a second object provided in an embodiment of the present application;
[0064] Figure 1d A schematic diagram showing a comparison between a first template and a second object provided in an embodiment of the present application;
[0065] Figure 2 A schematic diagram of a template generation method flow provided in an embodiment of the present application;
[0066] Figure 3a A schematic diagram of a target object provided in an embodiment of the present application;
[0067] Figure 3b A schematic diagram of a first image provided in an embodiment of the present application;
[0068] Figure 4 A schematic diagram of a second edge determination method flow chart provided in an embodiment of the present application;
[0069] Figure 5 A schematic flow chart of another second edge determination method provided in an embodiment of the present application;
[0070] Figure 6a A schematic diagram of a touch point provided in an embodiment of the present application;
[0071] Figure 6b A schematic diagram of a closed outer contour line of a target object provided in an embodiment of the present application;
[0072] Figure 6c A schematic diagram of a closed outer contour line and a non-closed inner contour line of a target object provided in an embodiment of the present application;
[0073] Figure 6dA schematic diagram of an outline shape displayed on an interactive interface provided in an embodiment of the present application;
[0074] Figure 7a A schematic diagram of a template of a target object provided in an embodiment of the present application;
[0075] Figure 7b A schematic diagram of another template of a target object provided in an embodiment of the present application;
[0076] Figure 8 A schematic diagram of the structure of a template generation device provided in an embodiment of the present application;
[0077] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0078] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0079] The application scenarios and prior art of the embodiments of the present application are described below.
[0080] In automated industrial production, machine vision technology is used to perform various inspections on objects to be inspected. For example, in the process of automated production on assembly lines, it is usually necessary to perform quality inspections, quantity inspections, etc. on objects to be inspected in the assembly line. Alternatively, the position and posture of objects to be inspected installed in preset positions can also be inspected.
[0081] When performing various tests on an object to be detected, it is necessary to collect an image of the object to be detected, and then determine the object that matches the template in the image of the object based on the template of the object, so as to determine the position, scale and other information of the object. The template of the object is usually obtained based on an image of the object, for example, see Figure 1a The structure diagram of the first object provided, if based on Figure 1a The image of the first object shown in the figure is used to obtain the template of the object. Then, we can get Figure 1b A schematic diagram of the first template is provided showing the first template.
[0082] However, the same object to be detected may have different scratches, residues, and other processing marks on each object due to the processing method, or the same object to be detected may have different textures, etc. Therefore, it may be difficult to detect objects in other objects' images using a template of an object obtained based on an image of one object. Figure 1b When the first template shown is used to determine an object matching the template in an image containing other objects, it may be difficult to detect the existence of an object matching the first template in the image containing other objects. Figure 1c The structure diagram of the second object provided, Figure 1c The second object shown and Figure 1a The first object shown is the same object to be detected, using Figure 1b As a template to determine Figure 1c When providing objects in the image, it may be due to Figure 1b The position of the circles in the template shown is consistent with Figure 1c The positions of the circles in are different, resulting in Figure 1c The second object in Figure 1b The first template matching degree shown is lower than the preset matching degree threshold, and the detection result obtained is: Figure 1c The object to be detected does not exist in the provided image. For example, see Figure 1d A comparison diagram of the first template and the second object provided. Figure 1d It can be clearly seen that the positions of the circles are different. It can be seen that object detection based on such a first template will lead to problems such as missed detection and false detection.
[0083] The execution subject of the embodiment of the present application is described below.
[0084] The solution provided in the embodiment of the present application can be applied to electronic devices such as desktop computers, laptop computers, tablet computers, and smart phones. Specifically, a client can be installed in the above electronic devices, and the template generation method provided in the embodiment of the present application can also be applied to the above client. For ease of description, the execution subject of the template generation method provided in the embodiment of the present application is collectively referred to as a template generation device.
[0085] The template generation method provided in the embodiment of the present application is described below in conjunction with specific embodiments.
[0086] In one embodiment of the present application, see Figure 2 A schematic flow chart of a template generation method is provided, wherein the method comprises the following steps S201-S203.
[0087] Step S201: displaying a first image of a target object on an interactive interface.
[0088] The interactive interface is an interface for interacting with a user. The first image is an image used to generate a template of a target object. The first image may be an image of a target object. In the case where the target object is a circular object, see Figure 3a A schematic diagram of a target object is provided. Figure 3a The multiple target objects shown in FIG. 1 are arranged in sequence, and different irregular lines exist in the circles of the target objects. For such target objects, the first image may be based on Figure 3a An image of a target object in the provided target object. Figure 3a Take a target object in the dashed box as an example, see Figure 3b A schematic diagram of a first image is provided. In addition, the screen displayed by the template generation device on the interactive interface can be Figure 3b First image provided.
[0089] The following describes a method for obtaining the first image.
[0090] Specifically, if the template generation device can obtain the first image, then the template generation device can directly display the obtained first image on the interactive interface. If the image obtained by the template generation device is an image to be processed of multiple target objects, or there is interference from other content in the image to be processed of the obtained target object, the above-mentioned image to be processed can also be displayed in the interactive interface, and in response to a cropping operation on the image displayed on the interactive interface, the above-mentioned image to be processed is cropped to obtain the first image, and the obtained first image is displayed on the interactive interface.
[0091] Step S202: In response to an edge drawing operation on a target object in a first image displayed on an interactive interface, determine a second edge of the target object in the first image based on a drawn edge drawn by the edge drawing operation and / or a first edge of the target object extracted from the first image.
[0092] The first edge is specifically generated in the following manner: the template generating device can use an edge extraction algorithm to extract the edge of the first image. For example, the edge extraction algorithm may be a Canny edge detection algorithm (a multi-level edge detection algorithm) and an edge operator algorithm.
[0093] In addition, the template generating device may display a drawn edge drawn in response to the edge drawing operation, and then determine a second edge of the target object in the first image based on the drawn edge and the first edge in response to the displayed drawn edge satisfying the drawing requirement.
[0094] The following describes the situation where the displayed drawing edge meets the drawing requirements.
[0095] In one case, a drawing confirmation button may be set in the interactive interface. If the user clicks the drawing confirmation button in the interactive interface, that is, after the template generating device detects that the drawing confirmation button is triggered, it determines that the displayed drawing edge meets the drawing requirements.
[0096] In another case, if the template generating device detects that the user has not performed an edge drawing operation on the target object in the first image displayed on the interactive interface for a period of time greater than a preset operation time, it is determined that the displayed drawing edge meets the drawing requirement.
[0097] The implementation method of drawing the edge of the display edge drawing operation in step S202 is described in the following embodiments and will not be described in detail here.
[0098] The following describes the method of determining the second edge in step S202.
[0099] In one implementation, the template generation device may determine overlapping edge points between the drawn edge and the first edge, and then determine an overlapping edge line based on the overlapping edge points as the second edge of the target object in the first image. Specifically, the method for determining the overlapping edge based on the overlapping edge points may adopt a discrete point interpolation method, a curve fitting method, and the like.
[0100] Other implementations of step S202 for determining the second edge are described in the following embodiments and are not described in detail here.
[0101] Step S203: Generate a template of the target object based on the second edge.
[0102] Specifically, the template generating device generates a mask image of the second edge based on the second edge, and uses the mask image of the second edge as the template of the target object.
[0103] As can be seen from the above, in the solution provided in the embodiment of the present application, the second edge is used to generate the template of the target object, and the second edge is determined based on the drawn edge and the first edge, wherein the first edge is obtained by edge extraction, and the drawn edge is obtained by the edge drawing operation of the target object in the first image displayed on the interactive interface. Therefore, based on the drawn edge, the position of the real edge of the target object can be more accurately determined, and the influence of interference information in the first image of the target object on the template generation can be reduced. The second edge determined by combining the drawn edge and the first edge can more accurately characterize the real edge of the target object. The second edge combines the edge information provided by both the drawn edge and the first edge, and then based on the second edge, an accurate template of the target object can be generated.
[0104] The template generated by the solution provided in the embodiment of the present application is more accurate. The position and posture of the target object are determined based on the template of the target object, which can improve the accuracy and efficiency of determining the target object that matches the template of the template object in the image, and can reduce the cases of missed detection and false detection of the target object. Figure 1a The image of the first object provided, the shape of the template of the generated target object is only a triangular outline, excluding the outline of the middle circle, and thus in the process of determining the target object matching the template of the template object in the image, it can avoid the situation where there are a large number of contour points of the target object in the image that cannot be matched with the model. Also, because the second edge combines the information of the drawn edge and the first edge, the edge that is difficult to extract by edge extraction can also be supplemented by combining the edge information in the drawn edge, so that the template of the generated target object can include the edges that are difficult to extract by conventional edge extraction, further improving the accuracy of the generated template of the target object.
[0105] Moreover, for objects of any shape, or objects with interfering contours such as scratches and residues, the solution provided in the embodiments of the present application can be used to generate templates. The solution provided in the embodiments of the present application has higher scene adaptability.
[0106] Other implementations of determining the second edge in step S202 are described below.
[0107] In one embodiment of the present application, see Figure 4 A schematic flow chart of a second edge determination method is provided, the method comprising the following steps S401-S405.
[0108] Step S401: Based on the drawn edge, a first mask image of the drawn edge is generated.
[0109] The drawn edge is an edge obtained by performing an edge drawing operation on the target object in the first image displayed on the interactive interface. Then, a first mask image of the drawn edge can be generated according to the position of the drawn edge in the first image. Specifically, in the generated first mask image of the drawn edge, the value of the pixel position belonging to the drawn edge can be 1, and the value of other pixel positions can be 0.
[0110] Step S402: obtaining edge polarity of edge points corresponding to the drawn edge in the first mask image along a set direction as a first edge polarity.
[0111] The edge polarity represents the direction of change of the grayscale values of the pixels on both sides of the edge point along the set direction. The edge polarity can be positive or negative. A positive edge polarity represents that the grayscale values of the pixels on both sides of the edge point along the set direction change as an increasing change, and a negative edge polarity represents that the grayscale values of the pixels on both sides of the edge point along the set direction change as a decreasing change.
[0112] Specifically, for each edge point of the drawn edge, the template generating device detects the change in grayscale values of the pixel points on both sides of each edge point along the set direction, and then determines that the first edge polarity of the edge point with an increasing grayscale value change is positive, and determines that the first edge polarity of the edge point with a decreasing grayscale value change is negative.
[0113] The template generation device detects the change value of the gray value of the pixel point in the mask image, and can determine that the point with a value of 1 in the mask image is black, and the point with a value of 0 in the mask image is white, and then determine that the gray value with a value of 1 in the image is the lowest value, and determine that the gray value with a value of 0 in the image is the highest value. The set direction can be a search direction for detecting edge points, for example, the set direction can include from left to right, from right to left, from top to bottom, from bottom to top, etc. in the mask image.
[0114] Step S403: obtaining the edge polarity of the edge point corresponding to the first edge in the second mask image along the set direction as the second edge polarity.
[0115] The second mask image is: a mask image obtained by performing edge extraction on the first image.
[0116] Specifically, for each edge point of the first edge, the template generating device detects the change in grayscale values of the pixel points on both sides of each edge point along the set direction, and then determines that the second edge polarity of the edge point with an increasing grayscale value change is positive, and determines that the second edge polarity of the edge point with a decreasing grayscale value change is negative.
[0117] The description of edge polarity, gray value and setting direction may refer to the content in step S402.
[0118] Step S404: Based on the obtained first edge polarity and second edge polarity, determine a target edge point in the drawn edge.
[0119] The first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge.
[0120] Specifically, the template generation device determines the target edge point in the drawn edge with opposite first edge polarity and second edge polarity according to the first edge polarity of the edge point in the drawn edge obtained in step S402 and the second edge polarity of the edge point in the first edge obtained in step S403. For example, if the first edge polarity of the edge point in the drawn edge is positive, and the second edge polarity of the corresponding edge point in the first edge of the edge point is negative, then the edge point in the drawn edge is the target edge point. Similarly, if the first edge polarity of the edge point in the drawn edge is negative, and the second edge polarity of the corresponding edge point in the first edge of the edge point is positive, then the edge point in the drawn edge is also the target edge point.
[0121] The following describes a method for determining the edge points in the first edge corresponding to the edge points in the drawn edge in step S404.
[0122] In one implementation, the template generating device determines, based on the position of each edge point in the drawn edge in the first image and the position of each edge point in the first edge in the first image, an edge point in the first edge that is closest to the position of the edge point in the drawn edge as the corresponding edge point in the first edge of the edge point in the drawn edge.
[0123] In another implementation, the template generating device determines, based on the position of each edge point in the drawn edge in the first image and the position of each edge point in the first edge in the first image, an edge point in the first edge with the same position as the edge point in the drawn edge as the corresponding edge point in the first edge of the edge point in the drawn edge.
[0124] In another implementation, the template generation device may detect the nearest edge point in the first edge along the horizontal direction from the edge point in the drawn edge as the corresponding edge point in the first edge of the edge point in the drawn edge. The template generation device may detect the nearest edge point in the first edge along the vertical direction from the edge point in the drawn edge as the corresponding edge point in the first edge of the edge point in the drawn edge.
[0125] Step S405: Based on the determined target edge point, obtain a second edge of the target object in the first image.
[0126] In one implementation, a curve fitting may be performed on the target edge point based on the determined target edge point, and the fitted curve may be obtained as the second edge.
[0127] In another implementation, a discrete point interpolation method may be used to interpolate the determined target edge points. After a preset number of interpolations, a curve fitting is performed on the target edge points and the interpolation points to obtain a fitted curve as the second edge.
[0128] From the above, it can be seen that the target edge point is an edge point whose first edge polarity is opposite to the second edge polarity of the corresponding edge point in the first edge. In this way, by respectively drawing the edge polarity of the edge and the edge polarity of the first edge, the edge characteristics of the drawn edge and the first edge can be combined to more accurately generate the second edge, thereby generating a more accurate template of the target object.
[0129] Another implementation manner of determining the second edge in step S202 is described below.
[0130] In one embodiment of the present application, see Figure 5 A schematic flow chart of another second edge determination method is provided, wherein the method comprises the following steps S501-S503.
[0131] Step S501: Determine matching edge point pairs in the drawn edge and the first edge.
[0132] Each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge.
[0133] The method of determining the matching edge point pair in step S501 is similar to the method of determining the corresponding edge point in the first edge of the edge point in the drawn edge in step S404, and the difference is only in the name. For example, the edge point in the drawn edge and the corresponding edge point in the first edge of the corresponding edge point in the first edge determined according to the edge point in the drawn edge in step S404 can be used as the matching edge point pair.
[0134] Step S502: for the first type of edge point pairs, edge points belonging to the drawn edge in the first type of edge point pairs are determined as edge points in the second edge of the target object in the first image.
[0135] The first type of edge point pair is a matching edge point pair whose distance between the two edge points is less than a preset distance threshold. That is to say, the two edge points in the first type of edge point pair are close enough, indicating that the drawn edge drawn at the edge point position is similar to the first edge obtained by identification, and also indicating that the edge point in the drawn edge is more accurate, so it can be determined that the edge point belonging to the drawn edge in the first type of edge point pair is determined as the edge point in the second edge of the target object in the first image.
[0136] Step S503: for the second type of edge point pairs, edge points belonging to the first edge in the second type of edge point pairs are used to correct edge points belonging to the drawn edge, and corrected points are obtained as edge points in the second edge of the target object in the first image.
[0137] Among them, the second type of edge point is: the edge point pair of the determined matching edge point pair except the first type of edge point pair. In other words, the distance between the two edge points in the second type of edge point pair is too far, indicating that the drawn edge drawn at the edge point position is quite different from the first edge obtained by recognition, then, the drawn edge may be wrong, and the edge point belonging to the drawn edge needs to be corrected. The corrected point is used as the edge point in the second edge of the target object in the first image.
[0138] The following describes a method for correcting edge points belonging to a drawn edge.
[0139] In one implementation, the midpoint of a line connecting an edge point belonging to the first edge and an edge point belonging to the drawn edge in the second type edge point pair may be used as the correction point.
[0140] In another implementation, a value at which the distance between the edge point belonging to the first edge and the edge point belonging to the drawn edge in the second type of edge point pair exceeds a preset distance threshold may be determined as the first value. Then, the edge point belonging to the drawn edge is moved by the first value in the direction of the line connecting the edge point belonging to the first edge and the edge point belonging to the drawn edge in the second type of edge point pair, in a direction toward the edge point of the first edge, as the correction point.
[0141] As can be seen from the above, in this way, when the difference between the drawn edge and the first edge is too large, the edge point of the drawn edge can be corrected, reducing the impact of the deviation of the drawn edge on the second edge, improving the accuracy of the second edge determined based on the drawn edge and the first edge, and then improving the accuracy of the generated template of the target object.
[0142] The following describes the implementation method of displaying the drawn edge in the interactive interface in response to the edge drawing operation in step S202.
[0143] In one embodiment of the present application, the drawn edge can be displayed in the interactive interface in the following manner: in response to the line drawing operation of the touch object on the first image displayed on the interactive interface, the touch points of the touch object on the first image are collected; a curve generated based on the collected touch points is obtained as the drawn edge of the target object; and the drawn edge is displayed in the interactive interface.
[0144] Among them, the edge drawing operation can include a line drawing operation, and the touch object can be a finger or a brush that draws a line on the touch screen of the template generation device. If the template generation device is an electronic device such as a computer or a laptop, the touch object can also be a mouse or an object that draws a line on a touchpad.
[0145] The following is an example of touch points.
[0146] by Figure 3b Taking the first image shown in the figure as an example, after the first image is displayed in the interactive interface, the user can use the touch object to draw a line on the first image displayed in the interactive interface according to the circle in the figure, for example, see Figure 6a A schematic diagram of a touch point is provided. Figure 6a The circles surrounding the figure are the collected touch points of the touch object on the first image.
[0147] The method of generating the curve based on the collected touch points is similar to the implementation method of obtaining the second edge based on the target edge point in step S405, and the difference is only in the name, which will not be described in detail here.
[0148] In this way, the first image displayed on the interactive interface enables the user to clearly see the image used to generate the template, and the user can obtain a more accurate drawing edge by drawing a line on the first image displayed on the interactive interface through a touch object in the interactive interface. Combined with the more accurate drawing edge and the first edge drawn by the user using the touch object, interference in the first image can be reduced, thereby generating a more accurate template for the target object.
[0149] The following describes a method for obtaining a curve generated based on the collected touch points as an implementation of drawing an edge of a target object.
[0150] In one implementation, an object contour line generated based on the collected touch points is obtained as a drawing edge of the target object.
[0151] The object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve.
[0152] The outer contour line may be a contour line that is not completely included by other closed curves, and the inner contour line may include contour lines other than the outer contour line.
[0153] For example, in determining the Figure 6a After the curve generated by the touch points is a closed curve, we can get the following Figure 6b A schematic diagram of a closed outer contour line of a target object is provided. The bold lines in the figure are the outer contour lines, which are closed curves. Figure 6b The outline shown is relatively simple.
[0154] For some objects with complex outlines, you can obtain the drawing edge of the target object by drawing the outer and inner contours of the object. Figure 6cA schematic diagram of a closed outer contour line and a non-closed inner contour line of a target object is provided, and the bold lines in the figure are contour lines. In this way, closed or non-closed outer contour lines and inner contour lines can be drawn for complex and diverse objects as the drawing edges of the target objects, and then it can be used in a variety of drawing scenes to draw contours that are more in line with the actual situation, and the accuracy of the information obtained from the drawing edges can also be improved.
[0155] In this way, the closed shape and / or non-closed shape contour of the object can be flexibly drawn, and such curve generation can adapt to the outer contour and / or inner contour of objects of more shapes, simplifying the difficulty of line drawing operations and improving the convenience of template generation. In addition, drawing the outer contour and inner contour of the object can more accurately characterize the contour features of the object, and the obtained drawing edge is more accurate, thereby improving the accuracy of generating the template of the target object.
[0156] Another implementation method of obtaining a curve generated based on the collected touch points as a drawing edge of the target object is described below.
[0157] In response to the line drawing operation of the touch object on the first image displayed on the interactive interface, before collecting the touch points of the touch object on the first image, the template generation device can determine the target contour shape corresponding to the selected target control in the contour shape controls displayed on the interactive interface. Then, according to the collected touch points, a curve of the target contour shape is generated as the drawing edge of the target object.
[0158] The following describes a method for determining a target contour shape corresponding to a selected target control in a contour shape control displayed on an interactive interface.
[0159] Specifically, various contour shape controls can be preset, and then the user can display the target contour shape in the contour shape control displayed on the interactive interface that matches the contour of the target object. Then, according to the target contour shape and the collected touch points, a target contour shape curve is generated.
[0160] For example, see Figure 6d A schematic diagram of the contour shape displayed by an interactive interface is provided. Figure 6d The left side of the interactive interface shown is the selectable contour shape control. It can be seen that Figure 6dThe contour in the first image displayed in the interactive interface shown is a circle. Then, a button representing a circular contour shape control can be found from the selectable contour shape controls, and then the button can be selected to determine that the target contour shape is a circle. Then, a circle fitting is performed for the collected touch points to obtain a circular curve as the drawing edge of the target object. In addition, the contour shape control can also include non-closed contours and closed contours. For example, a non-closed contour can include a non-closed arc, a straight line, etc., and a closed contour can include a circle, a trapezoid, and a rectangle, etc.
[0161] Furthermore, after selecting the contour shape control, the user can drag the selected target contour shape to the position corresponding to the outer contour of the target object in the first image displayed on the interactive interface, and adjust the size of the target contour shape so that the target contour shape matches the outer contour of the target object. In this way, the template generation device can generate a curve of the target contour shape as the drawing edge of the target object based on the touch points within the preset range of the target contour shape adjusted by the user.
[0162] Among them, the method of generating a curve based on touch points can use a discrete point interpolation method, a curve fitting method, and the like.
[0163] In this way, users can use the contour shape controls displayed in the interactive interface to complete line drawing operations more quickly and conveniently. In addition, the shapes of the preset contour shape controls are more accurate. When the contour of the target object is a standard geometric shape such as a circle, ellipse, rectangle, etc., the contour of the target object can be drawn quickly and accurately, thereby improving the accuracy of the drawn edge and thus improving the accuracy of the generated target object model.
[0164] Another implementation of step S202 of displaying the drawn edge in the interactive interface in response to the edge drawing operation is described below.
[0165] In one embodiment of the present application, the drawn edge can be displayed in the interactive interface in the following manner: in response to a structural diagram selection operation for the target object in the first image displayed on the interactive interface, the contour line in the structural diagram of the target object is loaded; according to the posture of the target object in the first image, the loaded contour line is adjusted, the adjusted contour line is displayed in the interactive interface, and the adjusted contour line is used as the drawn edge of the target object.
[0166] The edge drawing operation may include a structure diagram selection operation, and the structure diagram of the target object may be a design diagram, a CAD diagram, etc. of the target object.
[0167] Specifically, a loading structure diagram button may be provided in the interactive interface. After the user triggers the loading structure diagram button, the structure diagram corresponding to the target object is selected to implement the structure diagram selection operation for the target object in the first image displayed on the interactive interface.
[0168] The following describes an implementation method for adjusting the loaded contour line according to the position and posture of the target object in the first image.
[0169] In one implementation, the loaded contour line is adjusted to the target posture, and the adjusted contour line is displayed on the upper layer of the first image displayed on the interactive interface.
[0170] The target posture is: the posture of the target object such that the edge of the target object in the first image and the loaded contour line meet the matching condition.
[0171] The method of determining the target posture is described below.
[0172] In one method, the loaded contour line can be displayed in the upper layer of the first image displayed in the interactive interface. A position adjustment button, a posture adjustment button and a scale adjustment button can be set for the loaded contour line. In response to the adjustment instructions of the above-mentioned position adjustment button and posture adjustment button, the position and posture scale of the loaded contour line are adjusted, and the adjusted position and posture are used as the target posture.
[0173] In another way, edge extraction may be performed on the first image to obtain a first edge, the first edge and the loaded contour line may be matched, and the pose of the loaded contour line with the highest matching degree may be determined as the target pose.
[0174] In this way, the loaded contour line can be adjusted to a target posture that matches the edge of the target object, thereby improving the accuracy of the contour line displayed in the interactive interface, improving the accuracy of the obtained drawn edge, and thus improving the accuracy of the template generated for the target object.
[0175] Another implementation method of adjusting the loaded contour line according to the position and posture of the target object in the first image is described below.
[0176] A first scale of the structure diagram is obtained; a second scale between the target object in the first image and the target object in the actual scene is obtained. Based on the first scale and the second scale, the scale of the loaded contour line is adjusted. According to the position and posture of the target object in the first image, the adjusted loaded contour line is displayed on the interactive interface.
[0177] Specifically, the structure diagram of the target object will be marked with a first scale that represents the scale of the target object in the structure diagram and the scale of the target object in the actual scene, and the template generation device can load the first scale from the attribute information of the structure diagram. When the image acquisition device acquires the first image, a calibration plate can be used to calibrate the scale of the target object in the acquired first image and the second scale of the scale of the target object in the actual scene, and record them. In this way, the scale of the target object in the actual scene will not change. Then, the template generation device can establish a proportional relationship between the target object in the first image and the target object in the structure diagram through the first scale and the second scale, and then adjust the scale of the loaded contour line to adjust the loaded contour line to the same scale as the target object in the first image.
[0178] In this way, the scale of the loaded contour line can be adjusted more conveniently, which simplifies the user's operation and enables the user to generate a template of the target object more conveniently.
[0179] In this way, the contour line of the target object's structural diagram can be selected as the drawing edge of the target object. The contour line of the target object's structural diagram is more accurate, and the drawing edge of the target object can be drawn more quickly and accurately. The second edge generated using such a drawing edge is more accurate, thereby improving the accuracy of generating the template of the target object.
[0180] In one embodiment of the present application, Figure 3b Taking the first image provided as an example, if the edge of the image is directly extracted and the extracted edge is used as the template of the target object, the obtained template can be seen in Figure 7a A template diagram of a target object is provided. It can be seen that Figure 7a Since the edge traces at the intersection of the two circles are not obvious, it is difficult to extract the edge lines of the target object around the intersection with other circular target objects. In addition, other interferences of the target object in the first image will cause too many interference edge lines in the template of the target object, such as Figure 7a Messy lines in the middle.
[0181] If the scheme provided in the embodiment of the present application is used to generate a template, the obtained template can be referred to Figure 7b Another schematic diagram of a template of a target object is provided. It can be seen that the template of the target object drawn is more accurate in areas with weak edge strength and can also avoid other interferences of the target object in the first image.
[0182] Corresponding to the above template generation method, the present application embodiment provides a template generation device, see Figure 8 A schematic diagram of the structure of a template generation device is provided, the device comprising:
[0183] A first image display module 801, used to display a first image of a target object on an interactive interface;
[0184] A second edge determination module 802 is configured to determine, in response to an edge drawing operation on the target object in the first image displayed on the interactive interface, a second edge of the target object in the first image based on a drawing edge drawn by the edge drawing operation and / or a first edge of the target object extracted from the first image;
[0185] The template generating module 803 is used to generate a template of the target object based on the second edge.
[0186] As can be seen from the above, in the solution provided in the embodiment of the present application, the second edge is used to generate the template of the target object, and the second edge is determined based on the drawn edge and the first edge, wherein the first edge is obtained by edge extraction, and the drawn edge is obtained by the edge drawing operation of the target object in the first image displayed on the interactive interface. Therefore, based on the drawn edge, the position of the real edge of the target object can be more accurately determined, and the influence of interference information in the first image of the target object on the template generation can be reduced. The second edge determined by combining the drawn edge and the first edge can more accurately characterize the real edge of the target object. The second edge combines the edge information provided by both the drawn edge and the first edge, and then based on the second edge, an accurate template of the target object can be generated.
[0187] In one embodiment of the present application, the second edge determination module is specifically used to respond to the edge drawing operation in the following manner: in response to the line drawing operation of the touch object on the first image displayed on the interactive interface, the touch points of the touch object on the first image are collected; the curve acquisition unit is used to obtain the curve generated based on the collected touch points as the drawn edge of the target object; the drawn edge display unit is used to display the drawn edge in the interactive interface.
[0188] In this way, the first image displayed on the interactive interface enables the user to clearly see the image used to generate the template, and the user can obtain a more accurate drawing edge by drawing a line on the first image displayed on the interactive interface through a touch object in the interactive interface. Combined with the more accurate drawing edge and the first edge drawn by the user using the touch object, interference in the first image can be reduced, thereby generating a more accurate template for the target object.
[0189] In one embodiment of the present application, the second edge determination module is specifically used to obtain an object contour line generated based on the collected touch points as the drawing edge of the target object, wherein the object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve.
[0190] In this way, the closed shape and / or non-closed shape contour of the object can be flexibly drawn, and such curve generation can adapt to the outer contour and / or inner contour of objects of more shapes, simplifying the difficulty of line drawing operations and improving the convenience of template generation. In addition, drawing the outer contour and inner contour of the object can more accurately characterize the contour features of the object, and the obtained drawing edge is more accurate, thereby improving the accuracy of generating the template of the target object.
[0191] In one embodiment of the present application, the second edge determination module is also used to determine the target contour shape corresponding to the selected target control in the contour shape control displayed on the interactive interface; specifically, it is used to generate a curve of the target contour shape according to the collected touch points as the drawing edge of the target object.
[0192] In this way, users can use the contour shape controls displayed in the interactive interface to complete line drawing operations more quickly and conveniently. In addition, the shapes of the preset contour shape controls are more accurate. When the contour of the target object is a standard geometric shape such as a circle, ellipse, rectangle, etc., the contour of the target object can be drawn quickly and accurately, thereby improving the accuracy of the drawn edge and thus improving the accuracy of the generated target object model.
[0193] In one embodiment of the present application, the second edge determination module is specifically used to respond to the edge drawing operation in the following manner: in response to the structural diagram selection operation of the target object in the first image displayed on the interactive interface, load the contour line in the structural diagram of the target object; adjust the loaded contour line according to the posture of the target object in the first image, display the adjusted contour line in the interactive interface, and use the adjusted contour line as the drawing edge of the target object.
[0194] In this way, the contour line of the target object's structural diagram can be selected as the drawing edge of the target object. The contour line of the target object's structural diagram is more accurate, and the drawing edge of the target object can be drawn more quickly and accurately. The second edge generated using such a drawing edge is more accurate, thereby improving the accuracy of generating the template of the target object.
[0195] In one embodiment of the present application, the second edge determination module is specifically used to adjust the loaded contour line to a target posture, wherein the target posture is: the posture of the target object such that the edge of the target object in the first image satisfies a matching condition with the loaded contour line; and the adjusted contour line is displayed on the upper layer of the first image in the interactive interface.
[0196] In this way, the loaded contour line can be adjusted to a target posture that matches the edge of the target object, thereby improving the accuracy of the contour line displayed in the interactive interface, improving the accuracy of the obtained drawn edge, and thus improving the accuracy of the template generated for the target object.
[0197] In one embodiment of the present application, the second edge determination module is specifically used to obtain a first scale of the structural diagram; obtain a second scale between the target object in the first image and the target object in the actual scene; based on the first scale and the second scale, scale the loaded contour line; according to the posture of the target object in the first image, display the adjusted loaded contour line on the interactive interface.
[0198] In this way, the scale of the loaded contour line can be adjusted more conveniently, which simplifies the user's operation and enables the user to generate a template of the target object more conveniently.
[0199] In one embodiment of the present application, a second edge determination module is specifically used to: generate a first mask image of the drawn edge based on the drawn edge; obtain the edge polarity of the edge point corresponding to the drawn edge in the first mask image along a set direction as the first edge polarity, wherein the edge polarity represents the direction of change of the grayscale value of the pixel points on both sides of the edge point along the set direction; obtain the edge polarity of the edge point corresponding to the first edge in the second mask image along the set direction as the second edge polarity, wherein the second mask image is: a mask image obtained by edge extraction of the first image; determine the target edge point in the drawn edge based on the obtained first edge polarity and second edge polarity, wherein the first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge; obtain the second edge of the target object in the first image based on the determined target edge point.
[0200] From the above, it can be seen that the target edge point is an edge point whose first edge polarity is opposite to the second edge polarity of the corresponding edge point in the first edge. In this way, by respectively drawing the edge polarity of the edge and the edge polarity of the first edge, the edge characteristics of the drawn edge and the first edge can be combined to more accurately generate the second edge, thereby generating a more accurate template of the target object.
[0201] In one embodiment of the present application, the second edge determination module is specifically used to: determine matching edge point pairs in the drawn edge and the first edge, wherein each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge; for the first type of edge point pairs, determine the edge points in the first type of edge point pairs belonging to the drawn edge as edge points in the second edge of the target object in the first image, wherein the first type of edge point pairs are: matching edge point pairs in which the distance between the two edge points is less than a preset distance threshold; for the second type of edge point pairs, use the edge points in the second type of edge point pairs belonging to the first edge to correct the edge points belonging to the drawn edge to obtain corrected points as edge points in the second edge of the target object in the first image, wherein the second type of edge point pairs are: edge point pairs in the determined matching edge point pairs excluding the first type of edge points.
[0202] As can be seen from the above, in this way, when the difference between the drawn edge and the first edge is too large, the edge point of the drawn edge can be corrected, reducing the impact of the deviation of the drawn edge on the second edge, improving the accuracy of the second edge determined based on the drawn edge and the first edge, and then improving the accuracy of the generated template of the target object.
[0203] The present application also provides an electronic device, such as Fig. 9 As shown, including:
[0204] Memory 901, used for storing computer programs;
[0205] The processor 902 is used to implement the template generation method in any of the above embodiments when executing the program stored in the memory 901.
[0206] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 902, the communication interface, and the memory 901 communicate with each other via the communication bus.
[0207] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0208] The communication interface is used for communication between the above electronic device and other devices.
[0209] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0210] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0211] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned template generation methods are implemented.
[0212] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any template generation method in the above embodiments.
[0213] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0214] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0215] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0216] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A template generation method, characterized in that: The method comprises: Displaying a first image of the target object on the interactive interface; In response to an edge drawing operation on a target object in a first image displayed on the interactive interface, a second edge of the target object in the first image is determined based on a drawn edge drawn by the edge drawing operation and a first edge of the target object extracted from the first image, wherein the edge drawing operation includes: a line drawing operation performed by a user on the first image displayed on the interactive interface, and the second edge is: an edge determined by combining edge information of the drawn edge and edge information of the first edge; Based on the second edge, a template of the target object is generated.
2. The method according to claim 1, characterized in that Respond to the edge drawing operation as follows: In response to a line drawing operation of a touch object on a first image displayed on the interactive interface, collecting a touch point of the touch object on the first image; Obtaining a curve generated based on the collected touch points as the drawing edge of the target object; The drawn edge is displayed in the interactive interface.
3. The method according to claim 2, characterized in that The step of obtaining a curve generated based on the collected touch points as a drawing edge of the target object includes: An object contour line generated based on the collected touch points is obtained as a drawing edge of the target object, wherein the object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve.
4. The method according to claim 2, characterized in that: Before collecting the touch point of the touch object on the first image in response to the line drawing operation of the touch object on the first image displayed on the interactive interface, the method further includes: Determine a target contour shape corresponding to a selected target control among contour shape controls displayed on the interactive interface; The step of obtaining a curve generated based on the collected touch points as a drawing edge of the target object includes: A curve of the target contour shape is generated according to the collected touch points as a drawn edge of the target object.
5. The method according to claim 1, characterized in that: Respond to the edge drawing operation as follows: In response to a structural diagram selection operation on a target object in a first image displayed on the interactive interface, loading a contour line in the structural diagram of the target object; According to the position and posture of the target object in the first image, the loaded contour line is adjusted, the adjusted contour line is displayed in the interactive interface, and the adjusted contour line is used as the drawing edge of the target object.
6. The method according to claim 5, characterized in that The step of adjusting the loaded contour line according to the position and posture of the target object in the first image, and displaying the adjusted contour line in the interactive interface includes: Adjusting the loaded contour line to a target posture, wherein the target posture is: a posture of the target object such that an edge of the target object in the first image and the loaded contour line meet a matching condition; The upper layer of the first image displayed on the interactive interface displays the adjusted contour line.
7. The method according to claim 5, characterized in that The step of adjusting the loaded contour line according to the position and posture of the target object in the first image, and displaying the adjusted contour line in the interactive interface includes: Obtaining a first scale of the structural diagram; Obtaining a second scale between the target object in the first image and the target object in the actual scene; Based on the first scale and the second scale, the loaded contour line is scaled; According to the position and posture of the target object in the first image, the adjusted loaded contour line is displayed on the interactive interface.
8. The method according to any one of claims 1 to 7, characterized in that The determining a second edge of the target object in the first image based on the drawn edge drawn by the edge drawing operation and / or the first edge of the target object extracted from the first image comprises: Based on the drawn edge, generating a first mask image of the drawn edge; Obtaining an edge polarity of an edge point corresponding to the drawn edge in the first mask image along a set direction as a first edge polarity, wherein the edge polarity represents a direction in which grayscale values of pixel points on both sides of the edge point along the set direction change; Obtaining an edge polarity of an edge point corresponding to the first edge in a second mask image along a set direction as a second edge polarity, wherein the second mask image is: a mask image obtained by performing edge extraction on the first image; Determining a target edge point in the drawn edge based on the obtained first edge polarity and second edge polarity, wherein the first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge; Based on the determined target edge point, a second edge of the target object in the first image is obtained.
9. The method according to any one of claims 1 to 7, characterized in that: The determining a second edge of the target object in the first image based on the drawn edge drawn by the edge drawing operation and / or the first edge of the target object extracted from the first image comprises: Determine matching edge point pairs in the drawn edge and the first edge, wherein each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge; For a first type of edge point pair, edge points in the first type of edge point pair belonging to the drawn edge are determined as edge points in a second edge of the target object in the first image, wherein the first type of edge point pair is: a matching edge point pair in which a distance between two edge points is less than a preset distance threshold; For the second type of edge point pairs, edge points belonging to the first edge in the second type of edge point pairs are used to correct edge points belonging to the drawn edge to obtain corrected points as edge points in the second edge of the target object in the first image, wherein the second type of edge point pairs are: edge point pairs in the determined matching edge point pairs except the first type of edge points.
10. A template generating device, characterized in that: The device comprises: A first image display module, used to display a first image of a target object on an interactive interface; A second edge determination module is configured to determine, in response to an edge drawing operation on a target object in a first image displayed on the interactive interface, a second edge of the target object in the first image based on a drawn edge drawn by the edge drawing operation and a first edge of the target object extracted from the first image, wherein the edge drawing operation includes: a line drawing operation performed by a user on the first image displayed on the interactive interface, and the second edge is: an edge determined by combining edge information of the drawn edge and edge information of the first edge; A template generating module is used to generate a template of the target object based on the second edge.
11. The device according to claim 10, characterized in that The second edge determination module is specifically configured to respond to the edge drawing operation in the following manner: in response to a line drawing operation of a touch object on a first image displayed on the interactive interface, collect touch points of the touch object on the first image; A curve obtaining unit, used to obtain a curve generated based on the collected touch points as a drawing edge of the target object; A drawing edge display unit, used to display the drawing edge in the interactive interface; and / or The second edge determination module is specifically used to obtain an object contour line generated based on the collected touch points as a drawing edge of the target object, wherein the object contour line includes: an outer contour line and / or an inner contour line of the target object, and the object contour line includes: a closed curve and / or a non-closed curve; and / or The second edge determination module is further used to determine a target contour shape corresponding to a selected target control in the contour shape control displayed on the interactive interface; specifically, to generate a curve of the target contour shape as a drawing edge of the target object according to the collected touch points; and / or The second edge determination module is specifically configured to respond to the edge drawing operation in the following manner: in response to a structural diagram selection operation for a target object in a first image displayed on the interactive interface, load a contour line in the structural diagram of the target object; adjust the loaded contour line according to the position and posture of the target object in the first image, display the adjusted contour line in the interactive interface, and use the adjusted contour line as a drawing edge of the target object; and / or The second edge determination module is specifically used to adjust the loaded contour line to a target posture, wherein the target posture is: the posture of the target object such that the edge of the target object in the first image and the loaded contour line meet a matching condition; and the adjusted contour line is displayed on the upper layer of the first image displayed on the interactive interface; and / or The second edge determination module is specifically used to obtain a first scale of the structural diagram; obtain a second scale between the target object in the first image and the target object in the actual scene; scale-adjust the loaded contour line based on the first scale and the second scale; and display the adjusted loaded contour line on the interactive interface according to the position and posture of the target object in the first image; and / or The second edge determination module is specifically used to: generate a first mask image of the drawn edge based on the drawn edge; obtain the edge polarity of the edge point corresponding to the drawn edge in the first mask image along a set direction as the first edge polarity, wherein the edge polarity represents the direction of change of the grayscale value of the pixel points on both sides of the edge point along the set direction; obtain the edge polarity of the edge point corresponding to the first edge in the second mask image along the set direction as the second edge polarity, wherein the second mask image is: a mask image obtained by edge extraction of the first image; determine the target edge point in the drawn edge based on the obtained first edge polarity and second edge polarity, wherein the first edge polarity of the target edge point is opposite to the second edge polarity of the corresponding edge point in the first edge; obtain the second edge of the target object in the first image based on the determined target edge point; and / or The second edge determination module is specifically used to: determine the matching edge point pairs in the drawn edge and the first edge, wherein each matching edge point pair includes an edge point in the drawn edge and an edge point in the first edge; for the first type of edge point pairs, determine the edge points in the first type of edge point pairs belonging to the drawn edge as edge points in the second edge of the target object in the first image, wherein the first type of edge point pairs are: matching edge point pairs whose distance between two edge points is less than a preset distance threshold; for the second type of edge point pairs, use the edge points in the second type of edge point pairs belonging to the first edge to correct the edge points belonging to the drawn edge, and obtain corrected points as edge points in the second edge of the target object in the first image, wherein the second type of edge point pairs are: edge point pairs in the determined matching edge point pairs excluding the first type of edge points.
12. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-9 when executing a program stored in a memory.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Chip template calibration method and device, electronic equipment and storage medium
CN114359192A
Workpiece contour fitting positioning method and device and storage medium
CN116958515A