A contour matching method and device, electronic equipment and storage medium
By acquiring multiple template contour maps and calculating transformation parameters, the problem of inaccurate matching between template contour maps and scene contour maps is solved, achieving higher contour matching accuracy, which is suitable for component inspection in industrial scenarios.
Patent Information
- Application Number
- CN202311051615.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-08-18
AI Technical Summary
In the existing technology, the matching accuracy between the template outline and the scene outline is low, mainly because the target object may be deformed or scaled in the actual scene, resulting in outline mismatch.
Multiple template contour maps are obtained, including the standard contour map of the target object and its transformation map. The template contour map with the highest matching degree with the scene contour map is determined, the transformation parameters are calculated and transformed, and the matching contour map is obtained to extract the contour of the target object.
It improves the accuracy of contour matching, especially in industrial scenarios, enabling more accurate determination of whether parts are damaged or deformed.
Smart Images

Figure CN117115485B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision, and in particular to a contour matching method and device, an electronic device, and a storage medium. BACKGROUND
[0002] Contour matching refers to a process of retrieving all image regions similar to a template contour graph from a scene contour graph containing the contour of a target object in an actual scene. The template contour graph contains the contour of a standard target object. Subsequently, the retrieved image regions can be extracted from the scene contour graph and processed based on the extracted image regions.
[0003] For example, the scene contour graph contains the contour of a part in an industrial scene, and the template contour graph contains the contour of a standard target object. For each template contour graph, the template contour graph is matched with the scene contour graph to obtain an image region in the scene contour graph similar to the template contour graph, which is also the image region where the local contour of the part is located. Subsequently, each local contour of the part can be extracted from the scene contour graph and processed based on the extracted local contours, for example, the local dimensions of the part are measured based on the local contours to determine whether the part is damaged or deformed locally.
[0004] However, the contour in the template contour graph is of a standard target object, while the contour in the scene contour graph is of a target object in an actual scene. The target object in the actual scene may be deformed, and the collected scene contour graph may also be scaled. Therefore, the contour of the target object in the template contour graph may not be the same as the contour of the target object in the scene contour graph, and the contour matching based on the template contour graph is less accurate. SUMMARY
[0005] Embodiments of the present application provide a contour matching method, device, electronic device, and storage medium to improve the accuracy of contour matching. The specific technical solutions are as follows:
[0006] In a first aspect, to achieve the above-mentioned purpose, the present application provides a contour matching method, which comprises:
[0007] obtaining a plurality of preset template contour graphs; wherein the plurality of template contour graphs include a standard contour graph of a target object and contour graphs obtained by transforming the standard contour graph according to a preset transformation mode;
[0008] determining, from the plurality of template contour graphs, a template contour graph with the highest matching degree with a scene contour graph of the target object to obtain a contour graph to be processed;
[0009] calculating transformation parameters between the to-be-processed contour map and the scene contour map based on distances between contour points in the to-be-processed contour map and contour points of the scene contour map;
[0010] transforming the to-be-processed contour map according to the transformation parameters to obtain a matching contour map of the target object;
[0011] extracting a target contour map of the target object from the scene contour map according to the matching contour map.
[0012] Optionally, before the step of determining, from the plurality of template contour maps, a template contour map having the highest matching degree with the scene contour map of the target object to obtain a to-be-processed contour map, the method further comprises:
[0013] calculating, for each template contour map, a matching degree between the template contour map and the scene contour map based on a first preset formula; wherein the first preset formula is:
[0014]
[0015] wherein Score represents the matching degree between the template contour map and the scene contour map; K norm represents a preset coefficient; dy i represents a directional deviation of a vertical coordinate of an i-th contour point in the template contour map from a vertical coordinate of a corresponding contour point in the scene contour map; represents an average value of directional deviations of vertical coordinates of all contour points in the template contour map from vertical coordinates of corresponding contour points in the scene contour map;O num represents a number of contour points in the template contour map that overlap with contour points in the scene contour map;M num represents a number of contour points in the template contour map.
[0016] Optionally, the step of calculating transformation parameters between the to-be-processed contour map and the scene contour map based on distances between contour points in the to-be-processed contour map and contour points of the scene contour map comprises:
[0017] calculating, for each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map;
[0018] calculating a sum value of distances between all contour points in the to-be-processed contour map and corresponding contour points in the scene contour map to obtain a target distance;
[0019] calculating transformation parameters that minimize the target distance to obtain the transformation parameters between the to-be-processed contour map and the scene contour map.
[0020] Optionally, the calculating the distance between each contour point in the contour graph to be processed and the corresponding contour point in the scene contour graph comprises:
[0021] The distance between each contour point in the contour graph to be processed and the corresponding contour point in the scene contour graph is calculated based on a second preset formula; wherein the second preset formula is:
[0022] e = [S -1 R -1 (P s -t)-P m ]·n m
[0023] e represents the distance between the contour point P s in the contour graph to be processed and the corresponding contour point P m in the scene contour graph; S represents the scaling scale between the contour graph to be processed and the scene contour graph; R represents the rotation matrix between the contour graph to be processed and the scene contour graph; t represents the translation vector between the contour graph to be processed and the scene contour graph; n m represents the normal vector of the contour point P m in the scene contour graph.
[0024] Optionally, before the determining the template contour graph with the highest matching degree with the scene contour graph of the target object from the plurality of template contour graphs to obtain the contour graph to be processed, the method further comprises:
[0025] A plurality of scene contour subgraphs are determined from the scene contour graph according to a preset first sliding step;
[0026] The matching degree of each template contour graph with each scene contour subgraph is calculated;
[0027] The scene contour subgraph with the highest matching degree with the template contour graph is determined from each scene contour subgraph as a target contour subgraph;
[0028] The determining the template contour graph with the highest matching degree with the scene contour graph of the target object from the plurality of template contour graphs to obtain the contour graph to be processed comprises:
[0029] The template contour graph with the highest matching degree with each target contour subgraph in the scene contour graph is determined from the plurality of template contour graphs to obtain the contour graph to be processed corresponding to the target contour subgraph.
[0030] Optionally, the step of determining, from the scene contour subgraphs, a scene contour subgraph with the highest matching degree with the template contour graph as a target contour subgraph, comprises:
[0031] The step of determining, from the scene contour subgraphs, a scene contour subgraph with a matching degree greater than a preset threshold with the template contour graph as a candidate contour subgraph;
[0032] The step of determining, according to a preset second sliding step, a scene contour subgraph within a preset range of the candidate contour subgraph, and returning to execute the step of calculating, for each template contour graph, a matching degree between the template contour graph and each scene contour subgraph.
[0033] Optionally, the step of calculating, based on distances between the contour points in the contour graph to be processed and the contour points in the scene contour graph, a transformation parameter between the contour graph to be processed and the scene contour graph, comprises:
[0034] The step of calculating, for each target contour subgraph in the scene contour graph, a transformation parameter between a corresponding contour graph to be processed and the target contour subgraph based on distances between the contour points in the target contour subgraph and the contour points in the corresponding contour graph to be processed;
[0035] The step of transforming, according to the transformation parameter, the contour graph to be processed to obtain a matching contour graph of the target object, comprises:
[0036] The step of transforming, for each target contour subgraph in the scene contour graph, a corresponding contour graph to be processed according to the calculated transformation parameter to obtain a matching contour subgraph of the target object;
[0037] The step of extracting, according to the matching contour graph, a target contour graph of the target object from the scene contour graph, comprises:
[0038] The step of extracting, according to the matching contour subgraph, a target contour graph of a local part of the target object from the scene contour graph.
[0039] Optionally, the plurality of template contour graphs are stored in a preset database, and the database records a serial number of each contour point in each template contour graph and a vertical coordinate of each contour point.
[0040] In a second aspect, to achieve the above object, an embodiment of the present application provides a contour matching device, which comprises:
[0041] A template contour graph acquisition module is configured to acquire a plurality of preset template contour graphs; wherein the plurality of template contour graphs comprise a standard contour graph of a target object and contour graphs obtained by transforming the standard contour graph according to a preset transformation mode;
[0042] a to-be-processed contour map determination module, configured to determine, from the plurality of template contour maps, a template contour map with the highest matching degree with the scene contour map of the target object, to obtain a to-be-processed contour map;
[0043] a transformation parameter determination module, configured to calculate, based on distances between contour points in the to-be-processed contour map and contour points in the scene contour map, transformation parameters between the to-be-processed contour map and the scene contour map;
[0044] a matched contour map determination module, configured to transform the to-be-processed contour map according to the transformation parameters, to obtain a matched contour map of the target object;
[0045] a target contour map determination module, configured to extract, from the scene contour map, a target contour map of the target object according to the matched contour map.
[0046] Optionally, the device further comprises:
[0047] a first matching degree determination module, configured to, before the to-be-processed contour map determination module determines, from the plurality of template contour maps, a template contour map with the highest matching degree with the scene contour map of the target object, to obtain a to-be-processed contour map, calculate, for each template contour map, a matching degree between the template contour map and the scene contour map based on a first preset formula; wherein the first preset formula is:
[0048]
[0049] wherein Score represents the matching degree between the template contour map and the scene contour map; K norm represents a preset coefficient; dy i represents a directional deviation of a vertical coordinate of an i-th contour point in the template contour map from a vertical coordinate of a corresponding contour point in the scene contour map; represents an average value of directional deviations of vertical coordinates of all contour points in the template contour map from vertical coordinates of corresponding contour points in the scene contour map;O num represents a number of contour points in the template contour map that overlap with contour points in the scene contour map;M num represents a number of contour points in the template contour map.
[0050] Optionally, the transformation parameter determination module is specifically configured to calculate, for each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map;
[0051] calculate a sum value of distances between all contour points in the to-be-processed contour map and corresponding contour points in the scene contour map, to obtain a target distance;
[0052] calculate transformation parameters that minimize the target distance, to obtain the transformation parameters between the to-be-processed contour map and the scene contour map.
[0053] Optionally, the transformation parameter determination module is specifically configured to, for each contour point in the to-be-processed contour map, calculate a distance between the contour point and a corresponding contour point in the scene contour map based on a second preset formula; and the second preset formula is:
[0054] e = [S -1 R -1 (P s -t)-P m ]·n m
[0055] e represents the distance between the contour point P s in the to-be-processed contour map and the corresponding contour point P m in the scene contour map; S represents a scaling scale between the to-be-processed contour map and the scene contour map; R represents a rotation matrix between the to-be-processed contour map and the scene contour map; t represents a translation vector between the to-be-processed contour map and the scene contour map; and n m represents a normal vector of the contour point P m in the scene contour map.
[0056] Optionally, the device further comprises:
[0057] a scene contour sub-map determination module configured to, before the to-be-processed contour map determination module determines, from the plurality of template contour maps, a template contour map having the highest matching degree with the scene contour map of the target object, to obtain the to-be-processed contour map, determine a plurality of scene contour sub-maps from the scene contour map according to a preset first sliding step size;
[0058] a second matching degree determination module configured to, for each template contour map, calculate a matching degree between the template contour map and each scene contour sub-map;
[0059] a target contour sub-map determination module configured to, from each scene contour sub-map, determine a scene contour sub-map having the highest matching degree with the template contour map as a target contour sub-map;
[0060] the to-be-processed contour map determination module is specifically configured to, for each target contour sub-map in the scene contour map, determine, from the plurality of template contour maps, a template contour map having the highest matching degree with the target contour sub-map, to obtain a to-be-processed contour map corresponding to the target contour sub-map.
[0061] Optionally, the target contour subgraph determination module is specifically configured to determine, from the contour subgraphs of each scene, a contour subgraph of a scene whose matching degree with the template contour graph is greater than a preset threshold as a candidate contour subgraph.
[0062] According to a preset second sliding step, a contour subgraph of a scene is determined within a preset range of the candidate contour subgraph, and the step of calculating the matching degree of each template contour graph with each contour subgraph of a scene is executed again.
[0063] Optionally, the transformation parameter determination module is specifically configured to calculate, for each target contour subgraph in the contour subgraphs of the scene, a transformation parameter between the corresponding to-be-processed contour graph and the target contour subgraph based on the distance between the contour points in the target contour subgraph and the contour points of the corresponding to-be-processed contour graph.
[0064] The matching contour graph determination module is specifically configured to, for each target contour subgraph in the contour subgraphs of the scene, perform transformation on the to-be-processed contour graph corresponding to the target contour subgraph according to the calculated transformation parameter, to obtain a matching contour subgraph of the target object.
[0065] The target contour graph determination module is specifically configured to extract, from the contour subgraphs of the scene, a target contour graph of a local part of the target object according to the matching contour subgraph.
[0066] Optionally, the plurality of template contour graphs are stored in a preset database, and the database records the serial number of each contour point in each template contour graph and the ordinate of each contour point.
[0067] The embodiment of the present application further provides an electronic device, which comprises:
[0068] The memory is used for storing a computer program.
[0069] The processor is used for executing the program stored on the memory, to implement the contour matching method described above.
[0070] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the contour matching method described above.
[0071] The embodiment of the present application further provides a computer program product containing instructions, which, when running on a computer, causes the computer to execute the contour matching method described above.
[0072] The embodiment of the present application has the following beneficial effects:
[0073] The profile matching method provided in the embodiments of the present application comprises the following steps: obtaining a plurality of preset template profile images; the plurality of template profile images comprise a standard profile image of a target object and profile images obtained by transforming the standard profile image according to a preset transformation mode; determining a template profile image with the highest matching degree with a scene profile image of the target object from the plurality of template profile images, and obtaining a to-be-processed profile image; calculating transformation parameters between the to-be-processed profile image and the scene profile image based on distances between profile points in the to-be-processed profile image and profile points in the scene profile image; transforming the to-be-processed profile image according to the transformation parameters, and obtaining a matching profile image of the target object; and extracting a target profile image of the target object from the scene profile image according to the matching profile image.
[0074] Based on the above processing, the plurality of template profile images comprise the standard profile image of the target object and the profile images obtained by transforming the standard profile image according to the preset transformation mode. Accordingly, the plurality of template profile images comprise the profile image with a higher matching degree with the profile of the target object in the actual scene, and the profile matching based on the plurality of template profile images can improve the accuracy of the profile matching. Moreover, since there is a difference between the to-be-processed profile image and the profile of the target object in the actual scene, after the corresponding to-be-processed profile image is determined, the transformation parameters between the to-be-processed profile image and the scene profile image are determined, the to-be-processed profile image is transformed according to the transformation parameters, and the matching profile image matching the profile of the target object in the actual scene is obtained, the matching profile image is the same as the profile of the target object in the actual scene, and the target profile image representing the profile of the target object in the actual scene can be extracted from the scene profile image according to the matching profile image, and the accuracy of the profile matching can be further improved.
[0075] Of course, implementing any product or method of the present application does not necessarily require achieving all the advantages mentioned above at the same time. BRIEF DESCRIPTION OF DRAWINGS
[0076] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and other embodiments can also be obtained by those skilled in the art based on these drawings.
[0077] Figure 1 The flow chart of the first profile matching method provided in the embodiments of the present application;
[0078] Figure 2a The standard profile image of the target object provided in the embodiments of the present application;
[0079] Figure 2b The profile matching method provided in the embodiments of the present application; Figure 2aThe template profile diagram is obtained by transforming the standard profile diagram shown in the figure.
[0080] Figure 2c For the purpose of Figure 2a The template profile diagram is obtained by transforming the standard profile diagram shown in the figure.
[0081] Figure 3 The flow chart of the second profile matching method provided by the embodiment of the present application is shown in the figure.
[0082] Figure 4 The principle diagram of the profile matching provided by the embodiment of the present application is shown in the figure.
[0083] Figure 5 The flow chart of the third profile matching method provided by the embodiment of the present application is shown in the figure.
[0084] Figure 6a The test effect diagram of the first profile matching method provided by the embodiment of the present application is shown in the figure.
[0085] Figure 6b The test effect diagram of the second profile matching method provided by the embodiment of the present application is shown in the figure.
[0086] Figure 6c The test effect diagram of the third profile matching method provided by the embodiment of the present application is shown in the figure.
[0087] Figure 6d The test effect diagram of the fourth profile matching method provided by the embodiment of the present application is shown in the figure.
[0088] Figure 7 The flow chart of the fourth profile matching method provided by the embodiment of the present application is shown in the figure.
[0089] Figure 8 The structure diagram of a profile matching device provided by the embodiment of the present application is shown in the figure.
[0090] Figure 9 The structure diagram of an electronic device provided by the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0091] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art based on the present application belong to the scope of protection of the present application.
[0092] In the related art, the contour in the template contour map is the contour of a standard target object, and the contour in the scene contour map is the contour of a target object in an actual scene. The contour of the target object in the template contour map can be different from the contour of the target object in the scene contour map, and the contour matching accuracy based on the template contour map is low.
[0093] To solve the above problems, an embodiment of the present application provides a contour matching method applied to an electronic device. The electronic device acquires a plurality of preset template contour maps. The plurality of template contour maps include a standard contour map of a target object and contour maps obtained by transforming the standard contour map in a preset transformation manner. From the plurality of template contour maps, a template contour map with the highest matching degree with a scene contour map of the target object is determined to obtain a contour map to be processed. Based on the distance between the contour points in the contour map to be processed and the contour points in the scene contour map, the transformation parameters between the contour map to be processed and the scene contour map are calculated. The contour map to be processed is transformed according to the transformation parameters to obtain a matching contour map matching the target object. The target contour map of the target object is extracted from the scene contour map according to the matching contour map, which can improve the contour matching accuracy, that is, the accuracy of the determined target contour map. For an industrial scene, the target object is a part in the industrial scene, and the accuracy of subsequent determination of whether the part is damaged or locally deformed and the like can be improved.
[0094] Referring to Figure 1 , Figure 1 A flowchart of a contour matching method provided by an embodiment of the present application can include the following steps:
[0095] S101: Acquire a plurality of preset template contour maps.
[0096] The plurality of template contour maps include a standard contour map of a target object and contour maps obtained by transforming the standard contour map in a preset transformation manner.
[0097] S102: From the plurality of template contour maps, a template contour map with the highest matching degree with a scene contour map of the target object is determined to obtain a contour map to be processed.
[0098] S103: Based on the distance between the contour points in the contour map to be processed and the contour points in the scene contour map, the transformation parameters between the contour map to be processed and the scene contour map are calculated.
[0099] S104: The contour map to be processed is transformed according to the transformation parameters to obtain a matching contour map of the target object.
[0100] S105: The target contour map of the target object is extracted from the scene contour map according to the matching contour map.
[0101] Based on the contour matching method provided in the embodiments of the present application, the plurality of template contour images include a standard contour image of the target object, and contour images obtained by transforming the standard contour image according to a preset transformation manner. Correspondingly, the plurality of template contour images include contour images with a higher matching degree with the contour of the target object in the actual scene. The contour matching can be performed based on the plurality of template contour images, so that the accuracy of the contour matching can be improved. Moreover, since there is a difference between the contour of the target object in the actual scene and the contour of the to-be-processed contour image, after the corresponding to-be-processed contour image is determined, the transformation parameter between the to-be-processed contour image and the scene contour image is determined, and the to-be-processed contour image is transformed according to the transformation parameter, a matching contour image that matches the contour of the target object in the actual scene is obtained. Therefore, the matching contour image is the same as the contour of the target object in the actual scene, and the target contour image representing the contour of the target object in the actual scene can be extracted from the scene contour image according to the matching contour image, so that the accuracy of the contour matching can be further improved.
[0102] For step S101, the target object can be a part in an industrial scene. The plurality of template contour images of the target object can include partial contours of the target object. For example, the target object is a nut, and the plurality of template contour images can include partial threads of the nut. Alternatively, the plurality of template contour images can include the entire contour of the target object.
[0103] The standard contour image of the target object is an image containing a standard contour of the target object. In order to simulate the changes of the standard contour of the target object, the standard contour image can be transformed according to a preset transformation manner. Further, the plurality of template contour images including the standard contour image of the target object and contour images obtained by transforming the standard contour image according to the preset transformation manner can be obtained.
[0104] The preset transformation manner can be set by a technician according to requirements. For example, the preset transformation manner can include: performing scale transformation and bias transformation on the standard contour image according to different scale transformation parameters and bias transformation parameters. For example, the preset transformation manner includes: (1) performing equal scale transformation on the standard contour image; (2) performing scale transformation on the standard contour image along the horizontal direction; (3) performing scale transformation on the standard contour image along the vertical direction; and (4) performing scale transformation on the standard contour image along the horizontal direction and the vertical direction.
[0105] Referring to Figure 2a , Figure 2b and Figure 2c , Figure 2a a standard contour image of a target object provided in the embodiments of the present application. Figure 2b and Figure 2cAll are template outlines obtained by transforming the standard outline. The black lines represent the standard outline of the target object. The gray lines represent the template outline obtained by scaling the standard outline.
[0106] Figure 2b In the images, from left to right, the gray lines in the first image represent the template contour image obtained by scaling the standard contour image to the same scale. The gray lines in the second image represent the template contour image obtained by scaling the standard contour image horizontally. Figure 2c In the images, from left to right, the gray lines in the first image represent the template outline obtained by scaling the standard outline along the vertical direction. The gray lines in the second image represent the template outline obtained by scaling the standard outline along both the horizontal and vertical directions.
[0107] The template outline contains the outline of the target object, which is a contour line containing multiple contour points. For example... Figure 2a As shown, the template contour diagram uses x-coordinates horizontally and y-coordinates vertically. Each x-coordinate in the template contour diagram corresponds to only one y-coordinate in its column; the rest are invalid points. One x-coordinate and its corresponding y-coordinate represent a contour point. Accordingly, the template contour diagram can be represented as a one-dimensional array.
[0108] In some embodiments, multiple template contour maps are stored in a preset database, which records the serial number of each contour point in each template contour map, as well as the ordinate (i.e., y-coordinate) of each contour point.
[0109] For example, targeting Figure 2b The template outline shown contains three outline points for the target object. Figure 2b The coordinates of each contour point in the template contour diagram shown can be obtained by... Figure 2a The coordinates of each contour point in the template contour diagram shown are obtained by scaling and offset transformation. The coordinates of the first contour point (i.e., point A) in the standard contour diagram are (x10, y10), the coordinates of the second contour point (i.e., point B) are (x20, y20), and the coordinates of the third contour point (i.e., point C) are (x30, y30). Accordingly, according to the left-to-right arrangement of the contour points in the standard contour diagram, the standard contour diagram can be recorded as the following one-dimensional array: y10, y20, y30.
[0110] In the template contour map obtained by scaling the standard contour map to the same scale, the coordinates of the first contour point (i.e., point A1) are (x11, y11), the coordinates of the second contour point (i.e., point B1) are (x21, y21), and the coordinates of the third contour point (i.e., point C1) are (x31, y31). Accordingly, according to the left-to-right arrangement of the contour points in this template contour map, it can be recorded as the following one-dimensional array: y11, y21, y31.
[0111] In the template contour map obtained by scaling the standard contour map horizontally, the coordinates of the first contour point (i.e., point A2) are (x12, y12), the coordinates of the second contour point (i.e., point B2) are (x22, y22), and the coordinates of the third contour point (i.e., point C2) are (x32, y32). Correspondingly, according to the left-to-right arrangement of the contour points in this template contour map, it can be recorded as a one-dimensional array: y12, y22, y32.
[0112] against Figure 2c The template outline shown is as follows. Figure 2c The coordinates of each contour point in the template contour diagram shown can be obtained by... Figure 2a The coordinates of each contour point in the template contour diagram shown are obtained by scaling and offset transformation. In the template contour diagram obtained by scaling the standard contour diagram along the vertical direction, the coordinates of the first contour point (i.e., point A3) are (x13, y13), the coordinates of the second contour point (i.e., point B3) are (x23, y23), and the coordinates of the third contour point (i.e., point C3) are (x33, y33). Accordingly, according to the left-to-right arrangement of the contour points in this template contour diagram, the template contour diagram can be recorded as the following one-dimensional array: y13, y23, y33.
[0113] In the template contour map obtained by scaling the standard contour map horizontally and vertically, the coordinates of the first contour point (i.e., point A4) are (x14, y14), the coordinates of the second contour point (i.e., point B4) are (x24, y24), and the coordinates of the third contour point (i.e., point C4) are (x34, y34). Correspondingly, according to the left-to-right arrangement of the contour points in this template contour map, it can be recorded as a one-dimensional array: y14, y24, y34.
[0114] Based on the above processing, the template contour map is represented as a one-dimensional array. Subsequently, the scene contour map can also be represented as a one-dimensional array, and sliding matching can be performed based on this array. This reduces the search dimensionality during the sliding matching process and significantly improves the efficiency of contour matching.
[0115] For step S102, in an implementation, each of the plurality of template contour maps includes all contours of the target object. The scene contour map also includes all contours of the target object. Accordingly, the electronic device only needs to determine a template contour map with a higher matching degree with the scene contour map from the plurality of template contour maps, and then the electronic device can calculate the matching degrees of the plurality of template contour maps with the scene contour map respectively.
[0116] In some embodiments, before step S102, the method can further include the following step: for each template contour map, calculating a matching degree of the template contour map with the scene contour map based on a first preset formula.
[0117] wherein the first preset formula is:
[0118]
[0119] wherein Score represents the matching degree of the template contour map with the scene contour map; k norm represents a preset coefficient; dy i represents a directional deviation of a y coordinate of an i th contour point in the template contour map from a y coordinate of a corresponding contour point in the scene contour map; represents an average of directional deviations of y coordinates of all contour points in the template contour map from y coordinates of corresponding contour points in the scene contour map;O num represents a number of contour points in the template contour map that overlap with contour points in the scene contour map; M num represents a number of contour points in the template contour map.
[0120] In some embodiments, the template contour map is represented in a form of a one-dimensional array, and the scene contour map can also be represented in a form of a one-dimensional array when the scene contour map is obtained. For example, based on pixel coordinates of each contour point in the scene contour map in the scene contour map, physical coordinates of each contour point in space are determined. Then, a serial number of each contour point is obtained, and y coordinates of each contour point are obtained from the physical coordinates of each contour point in space, and the y coordinates of each contour point are recorded according to the serial numbers of each contour point in the scene contour map, so that a one-dimensional array representing the scene contour map can be obtained.
[0121] Further, the electronic device can calculate the matching degree of the scene contour map with the template contour map based on the one-dimensional array representing the scene contour map, the one-dimensional array representing the template contour map, and the above formula (1).
[0122] The directional deviation of the y coordinate of the contour point in the template contour map from the y coordinate of the corresponding contour point in the scene contour map is a difference between the y coordinate of the contour point in the template contour map and the y coordinate of the corresponding contour point in the scene contour map.
[0123] The profile point in the template profile map that overlaps with the profile point in the scene profile map refers to the profile point with the same serial number and the same y coordinate. For example, the y coordinate of the first profile point in the template profile map is the same as the y coordinate of the first profile point in the scene profile map, and the first profile point in the template profile map overlaps with the first profile point in the scene profile map.
[0124] Based on the above processing, when calculating the matching degree of the scene profile map and the template profile map, the overlap rate (i.e., the number of profile points in the template profile map that overlap with the profile points in the scene profile map) of the template profile map and the scene profile map is considered, and the matching degree of the scene profile map and the template profile map can be corrected. Only when the overlap rate is high and the standard deviation is small, a higher matching degree can be calculated. In the related art, the edge profile of the target object is extracted by using an edge extraction algorithm, and the matching degree is calculated based on the gradient and other information of the edge profile. Since the profile of the target object may include a circle and a straight line, the gradient characteristics of the symmetric profile such as the circle and the straight line are not obvious, and the accuracy of the calculated matching degree is low. The method provided in the embodiments of the present application can improve the accuracy of the calculated matching degree.
[0125] In addition, in the related art, the standard deviation of the coordinates of the template profile map and the scene profile map is normalized, and the square of the normalized result is taken as the matching degree. The template profile map needs to adapt to different overlap rates, and the matching degree at the position can be calculated only when there are effective profile points in the template profile map and the scene profile map. The scene profile map and the template profile map need to be as similar as possible, otherwise when there are few profile points in one of the profile maps, the matching degree of the two profile maps calculated will be high. The method provided in the embodiments of the present application can improve the accuracy of the calculated matching degree.
[0126] After the matching degrees of the plurality of template profile maps and the scene profile map of the target object are calculated, the electronic device can determine, from the plurality of template profile maps, a template profile map with the highest matching degree with the scene profile map of the target object, to obtain a to-be-processed profile map corresponding to the scene profile map.
[0127] In another implementation manner, the plurality of template profile maps include partial profiles of the target object. The scene profile map includes the entire profile of the target object. Correspondingly, for each template profile map, the electronic device needs to determine an image region (i.e., a matching profile sub-map) in the scene profile map that is the same as the template profile map, and then the electronic device can determine each scene profile sub-map in the scene profile map. For each template profile map, the electronic device calculates the matching degree of the template profile map and each scene profile sub-map.
[0128] Correspondingly, based on the above, Figure 1 and referring to Figure 3 Before step S102, the method can further include the following steps:
[0129] S106: Determine a plurality of scene contour subgraphs from the scene contour graph according to a preset first sliding step.
[0130] S107: Calculate the matching degree of each template contour graph and each scene contour subgraph.
[0131] S108: Determine, from each scene contour subgraph, a scene contour subgraph with the highest matching degree with the template contour graph as a target contour subgraph.
[0132] Correspondingly, step S102 can include the following steps:
[0133] S1021: For each target contour subgraph, determine a template contour graph with the highest matching degree with the target contour subgraph from a plurality of template contour graphs to obtain a to-be-processed contour graph corresponding to the target contour subgraph.
[0134] The electronic device can determine an image region with the same width as the template contour graph from the scene contour graph to obtain a first scene contour subgraph, taking the left end point of the scene contour graph as a first starting position. Then, the first starting position is moved to the right by a preset first sliding step to obtain a second starting position, and an image region with the same width as the template contour graph is determined from the scene contour graph to obtain a second scene contour subgraph. The second starting position is moved to the right by the preset first sliding step to obtain a third starting position, and an image region with the same width as the template contour graph is determined from the scene contour graph to obtain a third scene contour subgraph. Similarly, the plurality of scene contour subgraphs in the scene contour graph are obtained by moving the starting position to the right by the preset first sliding step until the right end point of the scene contour graph is reached.
[0135] The first sliding step can be set by a technician according to actual needs. For example, if the speed of determining the target contour graph is to be improved, the first sliding step can be set to a larger value. If the accuracy of the determined target contour graph is to be improved, the first sliding step can be set to a smaller value.
[0136] For example, referring to Figure 4 , Figure 4 The principle diagram for performing contour matching provided by the embodiments of the present application is shown. Figure 4 The model shown above is a template contour graph, and the template contour graph includes a local contour of a target object. The scene contour shown below is a scene contour graph.
[0137] The electronic device determines an image region with the same width as the template contour graph from the scene contour graph, taking the left end point (i.e., point 0) of the scene contour graph as a first starting position. Figure 4The model shown in the same image area, get a scene contour subgraph. Then, from left to right by pixel integer multiple sliding, pixel integer multiple is also the preset first sliding step, until sliding to the end position in the scene contour graph (that is, the right end point of the scene contour graph), at this time the scene width of the scene contour graph has been traversed, and a plurality of scene contour subgraphs in the scene contour graph can be obtained.
[0138] Further, for each template contour graph, the electronic device calculates the matching degree of the template contour graph and each scene contour subgraph. The way in which the electronic device calculates the matching degree of the template contour graph and the scene contour subgraph is similar to the way in which the electronic device calculates the matching degree of the template contour graph and the scene contour graph, and reference can be made to the related description of the foregoing embodiments.
[0139] In an implementation manner, the electronic device can directly determine, from each scene contour subgraph, a scene contour subgraph with the highest matching degree with the template contour graph as a target contour subgraph.
[0140] In another implementation manner, step S107 can include the following steps:
[0141] Step 1, from each scene contour subgraph, a scene contour subgraph with a matching degree greater than a preset threshold with the template contour graph is determined as a candidate contour subgraph.
[0142] Step 2, within a preset range of the candidate contour subgraph, a scene contour subgraph is determined according to a preset second sliding step, and the step of calculating, for each template contour graph, the matching degree of the template contour graph and each scene contour subgraph is returned to be executed.
[0143] The matching degree of the candidate contour subgraph and the template contour graph is greater than the preset threshold, and there may be a contour subgraph with the same template contour graph within the preset range of the candidate contour subgraph. For each candidate contour subgraph, the electronic device can determine a scene contour subgraph within a preset range of the candidate contour subgraph according to a preset second sliding step.
[0144] The preset range of a candidate contour subgraph can be an image area extending leftward from the candidate contour subgraph as a starting position and / or an image area extending rightward from the candidate contour subgraph as a starting position. The second sliding step is smaller than the first sliding step.
[0145] Then, the electronic device calculates the matching degree of the scene contour subgraph determined this time and the template contour graph, and so on until all image areas in the scene contour graph are traversed, to obtain the matching degree of the template contour graph and each scene contour subgraph. Further, the electronic device determines, from each scene contour subgraph, a scene contour subgraph with the highest matching degree with the template contour graph as a target contour subgraph.
[0146] Based on the above processing, the plurality of template contour maps are: a contour map set obtained by transforming the standard contour map according to different rotation angles and different scaling scales, and for each template contour map, a sliding matching is performed in the scene contour map. In the process of the sliding matching, a larger first sliding step is used to determine a candidate contour map with a higher matching degree. Then, a smaller second sliding step is used to perform a fine search in the vicinity of the candidate contour map, and if a higher matching degree appears, the previously determined candidate contour map is covered to be a new candidate contour map for the fine search. Compared with the contour matching based on a two-dimensional image in the prior art, in the method provided in the embodiment of the application, the contour map is represented as a one-dimensional array, and the one-dimensional sliding matching reduces the dimension of the search in the process of the sliding matching, and can significantly improve the efficiency of the contour matching.
[0147] After the plurality of target contour subgraphs are determined, for each target contour subgraph, the electronic device can determine, from the plurality of template contour maps, a template contour map with the highest matching degree with the target contour subgraph, to obtain a to-be-processed contour map corresponding to the target contour subgraph.
[0148] For step S103, the matching degree of the to-be-processed contour map and the scene contour map is high, but there can still be a difference between the contour of the to-be-processed contour map and the target object in the actual scene. Therefore, the electronic device can determine a transformation parameter between the to-be-processed contour map and the scene contour map. Subsequently, the to-be-processed contour map is transformed according to the determined transformation parameter, to obtain a matching contour map same as the target object.
[0149] In some embodiments, on the basis of Figure 1 , referring to Figure 5 , step S103 can include the following steps:
[0150] S1031: For each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map is calculated.
[0151] S1032: A sum value of distances between each contour point in the to-be-processed contour map and a corresponding contour point in the scene contour map is calculated, to obtain a target distance.
[0152] S1033: A transformation parameter that minimizes the target distance is calculated, to obtain a transformation parameter between the to-be-processed contour map and the scene contour map.
[0153] For each contour point in the to-be-processed contour map, the corresponding contour point in the scene contour map is: a contour point in the scene contour map with the same contour point serial number as the contour point.
[0154] In some embodiments, step S1031 can include the following step: for each contour point in the contour map to be processed, calculating the distance between the contour point and the corresponding contour point in the scene contour map based on a second preset formula.
[0155] wherein the second preset formula is:
[0156] e = [S -1 R -1 (P s -t)-P m ]·n m (2)
[0157] e represents the distance between the contour point P s and the corresponding contour point P m in the scene contour map; S represents the scaling scale between the contour map to be processed and the scene contour map; R represents the rotation matrix between the contour map to be processed and the scene contour map; t represents the translation vector between the contour map to be processed and the scene contour map; and n m represents the normal vector of the contour point P m in the scene contour map.
[0158] For each contour point in the contour map to be processed, the distance between the contour point and the corresponding contour point in the scene contour map can be represented as the above formula (2). In the above formula (2), S, R and t are all unknown transformation parameters.
[0159] Further, the electronic device calculates the sum of the distances between each contour point in the contour map to be processed and the corresponding contour point in the scene contour map to obtain a target distance. Correspondingly, the target distance can be represented as the following formula (3):
[0160]
[0161] E represents the target distance; e i represents the distance between the i-th contour point in the contour map to be processed and the corresponding contour point in the scene contour map; and N represents the number of contour points in the contour map to be processed.
[0162] Further, the electronic device solves the transformation parameters (i.e., S, R and t) that minimize the target distance (i.e., E in the above formula (3)) to obtain the transformation parameters between the contour map to be processed and the scene contour map.
[0163] Based on the above processing, the matching contour map of the target object can be determined based on the determined transformation parameters. By determining the transformation parameters in the above manner, different scaling types can be supported, and the accuracy of positioning the template contour map in the scene contour map can be improved.
[0164] For steps S104 and S105, since the contours of the to-be-processed contour graph and the target object in the actual scene can still be different, after determining the transformation parameters between the to-be-processed contour graph and the scene contour graph, the electronic device can transform the to-be-processed contour graph according to the determined transformation parameters to obtain a matching contour graph matched with the target object.
[0165] Since the matching contour graph is matched with the contour of the target object in the actual scene, the target contour graph of the target object, that is, the image of the entire contour of the target object in the actual scene, can be accurately extracted from the scene contour graph according to the matching contour graph. Subsequently, for an industrial scene, whether the target object is damaged or has other problems can be determined based on the target contour graph of the target object.
[0166] In some embodiments, in the case where the local contour of the target object is included in the plurality of template contour graphs, for each template contour graph, a target contour subgraph corresponding to the template contour graph can be determined from the scene contour graph, that is, a plurality of target contour subgraphs can be determined. For each target contour subgraph, the electronic device can determine the transformation parameters between the target contour subgraph and the corresponding to-be-processed contour graph.
[0167] Correspondingly, step S103 can include the following steps: for each target contour subgraph in the scene contour graph, based on the distance between the contour points in the target contour subgraph and the contour points of the corresponding to-be-processed contour graph, the transformation parameters between the corresponding to-be-processed contour graph and the target contour subgraph are calculated.
[0168] Correspondingly, step S104 can include the following steps: for each target contour subgraph in the scene contour graph, the to-be-processed contour graph corresponding to the target contour subgraph is transformed according to the calculated transformation parameters to obtain a matching contour subgraph of the target object.
[0169] Correspondingly, step S105 can include the following steps: according to the matching contour subgraph, the target contour graph of the local target object is extracted from the scene contour graph.
[0170] The manner in which the electronic device calculates the transformation parameters between the target contour subgraph and the corresponding to-be-processed contour graph is similar to the manner in which the electronic device calculates the transformation parameters between the scene contour graph and the corresponding to-be-processed contour graph, and can be referred to the related description of the foregoing embodiments.
[0171] Then, for each target contour subgraph, the electronic device transforms the target contour subgraph corresponding to the to-be-processed contour graph according to the calculated transformation parameter, to obtain a matching contour subgraph matched with the target contour subgraph. Further, the electronic device can extract the target contour graph of the local target object from the scene contour graph according to the matching contour subgraph, to obtain the target contour graph of the multiple local contours of the target object in the actual scene. Subsequently, for the industrial scene, the target object can be determined whether to have damage, local deformation, and the like based on the target contour graph of the multiple local target objects.
[0172] Referring to Figure 6a to Figure 6d , Figure 6a to Figure 6d A test effect diagram of a contour matching method provided by an embodiment of the present application.
[0173] Figure 6a The gray line in the left image in the figure represents the standard contour graph of the target object, and the black line represents the template contour graph obtained by scaling the standard contour graph in the same scale. Figure 6a The black line in the right image in the figure represents the matching contour graph of the target object matched.
[0174] Figure 6b The gray line in the left image in the figure represents the standard contour graph of the target object, and the black line represents the template contour graph obtained by scaling the standard contour graph in the horizontal direction. Figure 6b The black line in the right image in the figure represents the matching contour graph of the target object matched.
[0175] Figure 6c The gray line in the left image in the figure represents the standard contour graph of the target object, and the black line represents the template contour graph obtained by scaling the standard contour graph in the vertical direction. Figure 6c The black line in the right image in the figure represents the matching contour graph of the target object matched.
[0176] Figure 6d The gray line in the left image in the figure represents the standard contour graph of the target object, and the black line represents the template contour graph obtained by scaling the standard contour graph in the horizontal direction and the vertical direction. Figure 6d The black line in the right image in the figure represents the matching contour graph of the target object matched.
[0177] It can be seen that the contour matching method provided by the embodiment of the present application is not only suitable for the contour matching scene of scaling the standard contour graph in the same scale (i.e., in the same scale), but also suitable for the contour matching scene of scaling the standard contour graph in the x coordinate direction (i.e., in the horizontal direction), in the y coordinate direction (i.e., in the vertical direction), and in the x coordinate direction and the y coordinate direction with any scale.
[0178] Referring to Figure 7 , Figure 7 A flowchart of a contour matching method provided by an embodiment of the present application.
[0179] S701: input a model and a scene contour map.
[0180] In this step, the model is the template contour map in the foregoing embodiment, that is, the electronic device acquires the template contour map and the scene contour map of the target object.
[0181] S702: store the model and the scene contour map as a one-dimensional array.
[0182] In this step, based on different rotation angles and scaling scales, the standard contour map of the target object is rotated and scaled to obtain a plurality of template contour maps, and each template contour map is stored in the form of a one-dimensional array, the index of the one-dimensional array is the serial number of each contour point, the index can be represented by the horizontal coordinate of each contour point, and the data in the one-dimensional array is the vertical coordinate of each contour point. Similarly, the scene contour map is also stored in the form of a one-dimensional array.
[0183] S703: construct a score function.
[0184] In this step, the score function is the function for calculating the matching degree in the foregoing embodiment. That is, the electronic device constructs a function (i.e., formula (1)) for calculating the matching degree of the template contour map and the scene contour map.
[0185] S704: one-dimensional sliding coarse matching.
[0186] In this step, the template contour map contains the local contour of the target object. The electronic device performs one-dimensional sliding coarse matching in the scene contour map based on each template contour map, that is, the electronic device determines a scene contour sub-map in the scene contour map according to a preset first sliding step, and determines each target contour sub-map from each scene contour sub-map.
[0187] Specifically, the one-dimensional array representing the template contour map is slid on the one-dimensional array representing the scene contour map, and a designed robust score function (i.e., a function for calculating the matching degree of the template contour map and the scene contour map) is used to calculate the score (i.e., the matching degree) of the current position (i.e., the scene contour sub-map) slid to after each sliding. Accordingly, only sliding along the one-dimensional array is needed to find the position of the image region with the highest matching degree, and the image region with the highest matching degree is the target contour sub-map.
[0188] S705: scale ICP (iterative closest point) fine matching.
[0189] In this step, the obtained coarse matching result is refined by using scale ICP (Iterative Closest Point), and the coarse matching result is the determined to-be-processed contour graph. The final result is the transformation parameter from the template contour graph to the scene contour graph, and the target contour graph in the scene contour graph can be located.
[0190] That is, for each target contour subgraph, the electronic device calculates the transformation parameter between the target contour subgraph and the corresponding to-be-processed contour graph based on the distance between the contour points in the target contour subgraph and the corresponding to-be-processed contour graph. Then, the to-be-processed contour graph corresponding to the target contour subgraph is transformed according to the calculated transformation parameter to obtain a matching contour subgraph that locally matches the target object.
[0191] Based on the above processing, the coarse matching of the template contour graph and the scene contour graph is completed by using the sliding matching of the one-dimensional array representing the template contour graph on the one-dimensional array representing the scene contour graph, and the ICP algorithm supporting different scale scaling types is used to refine the coarse matching result to obtain the matching contour graph of the target object, which can be used for the positioning of the template contour graph in the scene contour graph. Moreover, unlike the template contour graph matching of the two-dimensional image, the contour effective information in the template contour graph is stored in the form of a one-dimensional array, and the sliding matching is performed on the one-dimensional array. The sliding freedom (i.e., the first sliding step) can be 1, which can reduce the time complexity of the search. In addition, for the contour of the target object, the contour contains a symmetric contour and a contour with inconspicuous features (such as a circle and a straight line), which leads to a lower contour matching accuracy, and the number of contour points in the template contour graph and the scene contour graph is required to be approximately high in the matching degree calculation. The matching degree is calculated based on the overlap rate of the contour points, which overcomes the above problems and can improve the accuracy of the contour matching.
[0192] With Figure 1 corresponding to the method embodiment of the present application, see Figure 8 , Figure 8 for a structural diagram of a contour matching device provided by the embodiment of the present application. The device comprises:
[0193] The template contour graph acquisition module 801 is configured to acquire a plurality of preset template contour graphs. The plurality of template contour graphs comprise a standard contour graph of a target object and a contour graph obtained by transforming the standard contour graph according to a preset transformation manner.
[0194] The to-be-processed contour graph determination module 802 is configured to determine, from the plurality of template contour graphs, a template contour graph with the highest matching degree with a scene contour graph of the target object to obtain a to-be-processed contour graph.
[0195] The transformation parameter determination module 803 is configured to calculate transformation parameters between the to-be-processed contour map and the scene contour map based on distances between contour points in the to-be-processed contour map and contour points in the scene contour map.
[0196] The matched contour map determination module 804 is configured to transform the to-be-processed contour map according to the transformation parameters to obtain a matched contour map of the target object.
[0197] The target contour map determination module 805 is configured to extract a target contour map of the target object from the scene contour map according to the matched contour map.
[0198] Optionally, the device further includes:
[0199] The first matching degree determination module is configured to, before the to-be-processed contour map determination module 802 determines the template contour map with the highest matching degree with the scene contour map of the target object from the plurality of template contour maps to obtain the to-be-processed contour map, calculate a matching degree between each template contour map and the scene contour map based on a first preset formula.
[0200]
[0201] wherein Score represents the matching degree between the template contour map and the scene contour map; K norm represents a preset coefficient; dy i represents a direction deviation of a vertical coordinate of an i-th contour point in the template contour map from a vertical coordinate of a corresponding contour point in the scene contour map; represents an average of direction deviations of vertical coordinates of all contour points in the template contour map from vertical coordinates of corresponding contour points in the scene contour map; O num represents a number of contour points in the template contour map that overlap with contour points in the scene contour map; M num represents a number of contour points in the template contour map.
[0202] Optionally, the transformation parameter determination module 803 is specifically configured to calculate, for each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map.
[0203] The sum of distances between all contour points in the to-be-processed contour map and corresponding contour points in the scene contour map is calculated to obtain a target distance.
[0204] The transformation parameters that minimize the target distance are calculated to obtain the transformation parameters between the to-be-processed contour map and the scene contour map.
[0205] Optionally, the transformation parameter determination module 803 is specifically configured to calculate, for each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map based on a second preset formula, where the second preset formula is:
[0206] e = [S -1 R -1 (P s -t)-P m ]·n m
[0207] e represents the distance between the contour point P s and the corresponding contour point P m in the scene contour map; S represents a scaling factor between the to-be-processed contour map and the scene contour map; R represents a rotation matrix between the to-be-processed contour map and the scene contour map; t represents a translation vector between the to-be-processed contour map and the scene contour map; and n m represents a normal vector of the contour point P m in the scene contour map.
[0208] Optionally, the device further comprises:
[0209] a scene contour sub-map determination module, configured to, before the to-be-processed contour map determination module 802 determines, from the plurality of template contour maps, a template contour map having the highest matching degree with the scene contour map of the target object, to obtain the to-be-processed contour map, determine a plurality of scene contour sub-maps from the scene contour map according to a preset first sliding step;
[0210] a second matching degree determination module, configured to calculate, for each template contour map, a matching degree between the template contour map and each scene contour sub-map;
[0211] a target contour sub-map determination module, configured to determine, from each scene contour sub-map, a scene contour sub-map having the highest matching degree with the template contour map as a target contour sub-map;
[0212] the to-be-processed contour map determination module 802 is specifically configured to, for each target contour sub-map in the scene contour map, determine, from the plurality of template contour maps, a template contour map having the highest matching degree with the target contour sub-map, to obtain a to-be-processed contour map corresponding to the target contour sub-map.
[0213] Optionally, the target contour sub-map determination module is specifically configured to determine, from each scene contour sub-map, a scene contour sub-map having a matching degree greater than a preset threshold with the template contour map as a candidate contour sub-map.
[0214] According to the preset second sliding step, scene contour subgraphs are determined within the preset range of the candidate contour subgraph, and the step of calculating the matching degree of each template contour graph with each scene contour subgraph is executed again.
[0215] Optionally, the transformation parameter determination module 803 is specifically configured to calculate, for each target contour subgraph in the scene contour graph, a transformation parameter between the corresponding to-be-processed contour graph and the target contour subgraph based on the distance between the contour points in the target contour subgraph and the contour points in the corresponding to-be-processed contour graph.
[0216] The matching contour graph determination module 804 is specifically configured to transform, for each target contour subgraph in the scene contour graph, the to-be-processed contour graph corresponding to the target contour subgraph according to the calculated transformation parameter, to obtain a matching contour subgraph of the target object.
[0217] The target contour graph determination module 805 is specifically configured to extract, from the scene contour graph, a target contour graph of the local target object according to the matching contour subgraph.
[0218] Optionally, the plurality of template contour graphs are stored in a preset database, and the database records the serial numbers of the contour points in each template contour graph and the longitudinal coordinates of the contour points.
[0219] Based on the contour matching device provided in the embodiments of the present application, the plurality of template contour graphs include a standard contour graph of the target object and contour graphs obtained by transforming the standard contour graph according to a preset transformation manner. Accordingly, the plurality of template contour graphs include contour graphs with high matching degrees with the contour of the target object in the actual scene. The contour matching can be performed based on the plurality of template contour graphs, so that the accuracy of the contour matching can be improved. Moreover, since there is a difference between the to-be-processed contour graph and the contour of the target object in the actual scene, after the corresponding to-be-processed contour graph is determined, the transformation parameter between the to-be-processed contour graph and the scene contour graph is determined, and the to-be-processed contour graph is transformed according to the transformation parameter, the matching contour graph that matches the contour of the target object in the actual scene is obtained. The matching contour graph is the same as the contour of the target object in the actual scene, so the target contour graph representing the contour of the target object in the actual scene can be extracted from the scene contour graph according to the matching contour graph, and the accuracy of the contour matching can be further improved.
[0220] The embodiments of the present application also provide an electronic device, as shown in the accompanying drawings, which comprises: Figure 9 as shown in the accompanying drawings, which comprises:
[0221] The memory 901 is configured to store a computer program.
[0222] The processor 902 is configured to implement the following steps when executing the program stored in the memory 901:
[0223] obtaining a plurality of preset template contour maps, wherein the plurality of template contour maps comprise a standard contour map of a target object and contour maps obtained by transforming the standard contour map according to a preset transformation mode;
[0224] determining, from the plurality of template contour maps, a template contour map with the highest matching degree with a scene contour map of the target object, to obtain a contour map to be processed;
[0225] calculating transformation parameters between the contour map to be processed and the scene contour map based on distances between contour points in the contour map to be processed and contour points in the scene contour map;
[0226] transforming the contour map to be processed according to the transformation parameters to obtain a matching contour map of the target object;
[0227] extracting a target contour map of the target object from the scene contour map according to the matching contour map.
[0228] The electronic device can further comprise a communication bus and / or a communication interface, and the processor 902, the communication interface and the memory 901 can communicate with each other through the communication bus.
[0229] The communication bus of the 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 the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0230] The communication interface is used for communication between the electronic device and other devices.
[0231] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.
[0232] The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0233] In another embodiment provided in the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the steps of any of the profile matching methods described above.
[0234] In another embodiment provided in the present application, a computer program product is provided, and the computer program product includes instructions. When the computer program product is executed on a computer, the computer is caused to perform any of the profile matching methods in the above embodiments.
[0235] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented 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, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can 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 can be transmitted 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 (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. 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. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a solid state disk (SSD) and the like.
[0236] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0237] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, computer-readable storage media, and computer program products are basically similar to the method embodiments, and therefore the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0238] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A profile matching method characterized by, The method comprises: acquiring a plurality of preset template contour maps; wherein the plurality of template contour maps comprise a standard contour map of a target object and contour maps obtained by transforming the standard contour map according to preset transformation modes; from the plurality of template contour maps, determining a template contour map with the highest matching degree with a scene contour map of the target object to obtain a contour map to be processed; based on distances between contour points in the contour map to be processed and contour points in the scene contour map, calculating transformation parameters between the contour map to be processed and the scene contour map; transforming the contour map to be processed according to the transformation parameters to obtain a matching contour map of the target object; according to the matching contour map, extracting a target contour map of the target object from the scene contour map; the method further comprises: for each contour point in the contour map to be processed, calculating a distance between the contour point and a corresponding contour point in the scene contour map; calculating a sum value of distances between each contour point in the contour map to be processed and a corresponding contour point in the scene contour map to obtain a target distance; calculating transformation parameters that minimize the target distance to obtain transformation parameters between the contour map to be processed and the scene contour map; the method further comprises: for each contour point in the contour map to be processed, based on a second preset formula, calculating a distance between the contour point and a corresponding contour point in the scene contour map; wherein the second preset formula is: ; e denotes a contour point in the contour map to be processed a contour point in the scene contour map the distance between; denotes a scaling factor between the contour map to be processed and the scene contour map; R denotes a rotation matrix between the contour map to be processed and the scene contour map; denotes a translation vector between the contour map to be processed and the scene contour map; a contour point in the scene contour map the normal vector of 2. The method of claim 1, wherein, before the step of determining a template contour map with the highest matching degree with a scene contour map of the target object from the plurality of template contour maps to obtain a contour map to be processed, the method further comprises: for each template contour map, based on a first preset formula, calculating a matching degree of the template contour map with the scene contour map; wherein the first preset formula is: ; wherein, represents a matching degree of the template profile map and the scene profile map; represents a preset coefficient; represents a direction deviation of a vertical coordinate of an i-th profile point in the template profile map and a vertical coordinate of a corresponding profile point in the scene profile map; represents a mean value of direction deviations of vertical coordinates of each profile point in the template profile map and vertical coordinates of corresponding profile points in the scene profile map; represents a number of profile points in the template profile map which overlap with profile points in the scene profile map; represents a number of profile points in the template profile map.
3. The method of claim 1, wherein, before the step of determining a template contour map with the highest matching degree with a scene contour map of the target object from the plurality of template contour maps to obtain a contour map to be processed, the method further comprises: according to a preset first sliding step, determining a plurality of scene contour sub-maps from the scene contour map; for each template contour map, calculating a matching degree of the template contour map with each scene contour sub-map; from each scene contour sub-map, determining a scene contour sub-map with the highest matching degree with the template contour map as a target contour sub-map; the step of determining a template contour map with the highest matching degree with a scene contour map of the target object from the plurality of template contour maps to obtain a contour map to be processed comprises: for each target contour sub-map in the scene contour map, determining a template contour map with the highest matching degree with the target contour sub-map from the plurality of template contour maps to obtain a contour map to be processed corresponding to the target contour sub-map.
4. The method of claim 3, wherein, The step of determining, from each scene contour subgraph, a scene contour subgraph with the highest matching degree with the template contour graph as a target contour subgraph, comprises: The step of determining, from each scene contour subgraph, a scene contour subgraph with a matching degree greater than a preset threshold with the template contour graph as a candidate contour subgraph, comprises: The step of determining, from each scene contour subgraph, a scene contour subgraph with a matching degree greater than a preset threshold with the template contour graph as a candidate contour subgraph, comprises:
5. The method of claim 3, wherein, The step of calculating, according to the distances between the contour points in the to-be-processed contour graph and the contour points in the scene contour graph, the transformation parameters between the to-be-processed contour graph and the scene contour graph, comprises: The step of calculating, according to the distances between the contour points in the to-be-processed contour graph and the contour points in the scene contour graph, the transformation parameters between the to-be-processed contour graph and the scene contour graph, comprises: The step of calculating, according to the distances between the contour points in the to-be-processed contour graph and the contour points in the scene contour graph, the transformation parameters between the to-be-processed contour graph and the scene contour graph, comprises: The step of calculating, according to the distances between the contour points in the to-be-processed contour graph and the contour points in the scene contour graph, the transformation parameters between the to-be-processed contour graph and the scene contour graph, comprises: The step of transforming the to-be-processed contour graph according to the transformation parameters to obtain a matching contour graph of the target object, comprises: The step of transforming the to-be-processed contour graph according to the transformation parameters to obtain a matching contour graph of the target object, comprises:
6. The method of claim 1, wherein, The step of transforming the to-be-processed contour graph according to the transformation parameters to obtain a matching contour graph of the target object, comprises:
7. A profile matching apparatus characterized by comprising: The step of transforming the to-be-processed contour graph according to the transformation parameters to obtain a matching contour graph of the target object, comprises: The step of extracting a target contour graph of the target object from the scene contour graph according to the matching contour subgraph, comprises: The step of extracting a target contour graph of the target object from the scene contour graph according to the matching contour subgraph, comprises: The plurality of template contour graphs are stored in a preset database, and the database records the serial numbers of the contour points in each template contour graph and the longitudinal coordinates of the contour points. The device comprises: A template contour graph acquisition module is configured to acquire a plurality of preset template contour graphs; wherein the plurality of template contour graphs comprise a standard contour graph of a target object and contour graphs obtained by transforming the standard contour graph according to a preset transformation manner; A to-be-processed contour graph determination module is configured to determine, from the plurality of template contour graphs, a template contour graph with the highest matching degree with a scene contour graph of the target object to obtain a to-be-processed contour graph; A transformation parameter determination module is configured to calculate, according to the distances between the contour points in the to-be-processed contour graph and the contour points in the scene contour graph, transformation parameters between the to-be-processed contour graph and the scene contour graph; A matching contour graph determination module is configured to transform the to-be-processed contour graph according to the transformation parameters to obtain a matching contour graph of the target object; A target contour graph determination module is configured to extract a target contour graph of the target object from the scene contour graph according to the matching contour graph; The transformation parameter determination module is specifically configured to calculate, for each contour point in the to-be-processed contour graph, a distance between the contour point and a corresponding contour point in the scene contour graph; The sum of the distances between the contour points in the to-be-processed contour graph and the corresponding contour points in the scene contour graph is calculated to obtain a target distance. The transformation parameter determination module is specifically configured to calculate, for each contour point in the to-be-processed contour map, a distance between the contour point and a corresponding contour point in the scene contour map based on a second preset formula, where the second preset formula is: The device further includes: ; e denotes a contour point in the contour map to be processed a contour point in the scene contour map the distance between; denotes a scaling scale between the contour map to be processed and the scene contour map; R denotes a rotation matrix between the contour map to be processed and the scene contour map; denotes a translation vector between the contour map to be processed and the scene contour map; a contour point in the scene contour map the normal vector of 8. The apparatus of claim 7, wherein, The first matching degree determination module is configured to, before the to-be-processed contour map determination module determines the to-be-processed contour map from the template contour maps, calculate, for each template contour map, a matching degree between the template contour map and the scene contour map based on a first preset formula, where the first preset formula is: The device further includes: ; wherein, represents a matching degree of the template profile map and the scene profile map; represents a preset coefficient; represents a direction deviation of a vertical coordinate of an i-th profile point in the template profile map and a vertical coordinate of a corresponding profile point in the scene profile map; represents a mean value of direction deviations of vertical coordinates of each profile point in the template profile map and vertical coordinates of corresponding profile points in the scene profile map; represents a number of profile points in the template profile map which overlap with profile points in the scene profile map; represents a number of profile points in the template profile map; The scene contour sub-map determination module is configured to, before the to-be-processed contour map determination module determines the to-be-processed contour map from the template contour maps, determine a plurality of scene contour sub-maps from the scene contour map according to a preset first sliding step. The second matching degree determination module is configured to, for each template contour map, calculate a matching degree between the template contour map and each scene contour sub-map. The target contour sub-map determination module is configured to determine, from each scene contour sub-map, a scene contour sub-map having a highest matching degree with the template contour map as a target contour sub-map. The to-be-processed contour map determination module is specifically configured to, for each target contour sub-map in the scene contour map, determine, from the template contour maps, a template contour map having a highest matching degree with the target contour sub-map as a to-be-processed contour map corresponding to the target contour sub-map. The target contour sub-map determination module is specifically configured to determine, from each scene contour sub-map, a scene contour sub-map having a matching degree greater than a preset threshold with the template contour map as a candidate contour sub-map. The target contour sub-map determination module is specifically configured to determine, from each scene contour sub-map, a scene contour sub-map having a matching degree greater than a preset threshold with the template contour map as a candidate contour sub-map. The target contour sub-map determination module is specifically configured to determine, from each scene contour sub-map, a scene contour sub-map having a matching degree greater than a preset threshold with the template contour map as a candidate contour sub-map. The target contour sub-map determination module is specifically configured to determine, from each scene contour sub-map, a scene contour sub-map having a matching degree greater than a preset threshold with the template contour map as a candidate contour sub-map. The transformation parameter determination module is specifically configured to, for each target contour sub-map in the scene contour map, calculate a transformation parameter between a corresponding to-be-processed contour map and the target contour sub-map based on distances between contour points in the target contour sub-map and contour points in the corresponding to-be-processed contour map. The matching contour map determination module is specifically configured to, for each target contour sub-map in the scene contour map, perform transformation on a to-be-processed contour map corresponding to the target contour sub-map according to the calculated transformation parameter, to obtain a matching contour sub-map of the target object. The target contour map determination module is specifically configured to extract, from the scene contour map, a target contour map of a local part of the target object according to the matching contour sub-map. The plurality of template profile graphs are stored in a preset database, and the database records serial numbers of each profile point in each template profile graph and longitudinal coordinates of the profile points.
9. An electronic device, comprising: The method comprises the following steps: A memory for storing a computer program; A processor for executing the program stored in the memory to realize the method of any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the method of any one of claims 1-6.
Citation Information
Patent Citations
Image contour identification method and device, equipment and medium
CN110222703A
Image object recognition method and device, electronic equipment and storage medium
CN110287943A