Target matching method and apparatus, computer readable medium
By determining feature points from the contour during the target matching process and calculating contour similarity, the problem of high computational cost in existing technologies is solved, achieving more efficient and accurate target matching.
Patent Information
- Application Number
- CN202011054139.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-30
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2040-09-30
AI Technical Summary
Existing technologies involve a large amount of computation during target matching, requiring the comparison of a large number of pixels, resulting in high consumption of computing resources.
By determining feature points from the contour of the target and corresponding feature points from the sub-image, contour similarity is calculated, and comparisons are performed only between feature points, reducing the amount of pixel calculation.
This reduces the computational cost of target matching and improves the accuracy and efficiency of the matching results.
Smart Images

Figure CN114359571B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, and more particularly to methods and apparatus for target matching, and computer-readable media. Background Technology
[0002] With the continuous development and progress of image recognition technology, it has been widely used in various industries, enabling target matching.
[0003] Currently, in the process of achieving target matching, it is necessary to compare each pixel on the first target in the image containing the first target with each pixel on the second target in the image containing the second target to determine the similarity between the first target and the second target. When the similarity between the first target and the second target exceeds a threshold, it is determined that the first target and the second target are matched.
[0004] The current target matching scheme requires comparing each pixel on the first and second targets, which involves a large amount of computation. Summary of the Invention
[0005] In view of this, the target matching method, apparatus, and computer-readable medium provided by the present invention can reduce the computational load of target matching.
[0006] In a first aspect, embodiments of the present invention provide a target matching method, comprising:
[0007] Acquire a first image including the first contour of the first target;
[0008] Determine at least one first feature point from the first contour in the first image;
[0009] Determine the position information of each of the first feature points;
[0010] At least one sub-image is extracted from the second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target;
[0011] For each of the sub-images, the following is performed:
[0012] Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image;
[0013] Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image;
[0014] When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target.
[0015] Secondly, embodiments of the present invention provide a target matching apparatus, comprising:
[0016] An acquisition module is used to acquire a first image including a first contour of a first target;
[0017] A determining module is configured to determine at least one first feature point from the first contour in the first image, and to determine the position information of each first feature point;
[0018] A cropping module is used to crop at least one sub-image from a second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target;
[0019] A matching module is used to perform the following for each of the sub-images:
[0020] Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image;
[0021] Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image;
[0022] When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target.
[0023] Thirdly, embodiments of the present invention provide a target matching apparatus, comprising: at least one memory and at least one processor;
[0024] The at least one memory is used to store a machine-readable program;
[0025] The at least one processor is configured to invoke the machine-readable program to execute the method provided in the first aspect above.
[0026] Fourthly, embodiments of the present invention provide a computer-readable medium storing computer instructions, which, when executed by a processor, cause the processor to perform the method provided in the first aspect.
[0027] According to the technical solutions provided in the first to fourth aspects above, at least one first feature point is determined from the first contour of the first target, and at least one second feature point is determined from each sub-image. Based on each first feature point and each second feature point, the similarity between the first contour and the second contour is determined. When the similarity is greater than a preset similarity threshold, the second target is determined to match the first target. In this embodiment of the invention, it is not necessary to calculate each pixel on the first target and the second target. It is only necessary to determine the first feature point from the first contour of the first target to characterize the features of the first target, and correspondingly, determine the second feature point to characterize the features of the second target. This reduces the number of pixels involved in the calculation and reduces the computational load of target matching.
[0028] In a first possible implementation, combining any of the above aspects, when the first contour includes at least two sub-contours, each first feature point can be determined in the following way:
[0029] For each of the sub-contours in the first contour, the following is performed:
[0030] Extract the sub-contour from the first contour;
[0031] Generate a first sampled image including the sub-contour, wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image;
[0032] The first sliding window is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window.
[0033] The first sliding window is used to slide in the first sampled image with a first step length, and the pixel point located at a specific position of the first sliding window and on the sub-contour is taken as the first feature point.
[0034] In this embodiment of the invention, a sub-contour is extracted, and a first sampled image including the sub-contour is generated. This first sampled image contains only one sub-contour. After sampling this first sampled image, first feature points on the sub-contour can be obtained. When sampling the first sampled image, sampling is performed through a first sliding window. The more pixels the sub-contour includes, the longer the size of the first sliding window. This increases the ratio of the number of first feature points on the sub-contour with fewer pixels to the total number of first feature points on the first contour, thus increasing the importance of the sub-contour with fewer pixels in representing the first target. Through each first feature point, the details of the first target can be represented more accurately. Therefore, when matching the first target with a second target in a sub-image based on each first feature point and each second feature point in the sub-image, the accuracy of the matching result can be improved.
[0035] In a second possible implementation, combining any of the above aspects, when the first contour includes at least two sub-contours, each first feature point can also be determined in the following way:
[0036] For each of the sub-contours in the first contour, the following is performed:
[0037] Extract the sub-contour from the first contour;
[0038] Generate a second sampled image including the sub-contour, wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image;
[0039] The second step length is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step length is.
[0040] The second sliding window is used to slide in the second sampled image with the second step size, and the pixel point located at a specific position of the second sliding window and on the sub-contour is taken as the first feature point.
[0041] In this embodiment of the invention, a sub-contour is extracted, and a second sampled image including the sub-contour is generated. This second sampled image contains only one sub-contour. After sampling this second sampled image, first feature points on the sub-contour can be obtained. When sampling the second sampled image, sampling is performed through a second sliding window with a second step size. The more pixels the sub-contour includes, the longer the second step size. This increases the ratio of the number of first feature points on the sub-contour with fewer pixels to the total number of first feature points on the first contour, thus increasing the importance of the sub-contour with fewer pixels in representing the first target. Through each first feature point, the details of the first target can be represented more accurately. This improves the accuracy of the matching results when matching the first target with a second target in a sub-image based on each first feature point and each second feature point in the sub-image.
[0042] In the third possible implementation, combining any of the above aspects, each first feature point can be determined using a sliding window, specifically implemented as follows:
[0043] Determine the third sliding window and the third step size for sampling the first image;
[0044] The third sliding window is used to slide in the first image with the third step size, and the pixel point located at a specific position of the third sliding window and on the first contour is taken as the first feature point.
[0045] In this embodiment of the invention, sampling is performed on the first image through a third sliding window to obtain each first feature point. This method makes the distribution of the collected first feature points more uniform and can more accurately represent the features of the first contour. As a result, when matching the first target with the second target in the sub-image based on each first feature point and the second feature points in each sub-image, the accuracy of the matching result can be improved.
[0046] In a fourth possible implementation, combining any of the above aspects, the first possible implementation, the second possible implementation, or the first possible implementation can determine each second feature point based on the relative position of the first feature point in the first image. Specifically, each second feature point can be determined from the sub-image in the following way:
[0047] The location information of the first feature point includes: the relative position of the first feature point in the first image;
[0048] Determining at least one second feature point from the sub-image based on the position information of each first feature point includes:
[0049] For each of the first feature points, perform the following:
[0050] Based on the relative position of the first feature point in the first image, a second feature point corresponding to the first feature point is determined, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
[0051] In this embodiment of the invention, the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image. This improves the accuracy of the matching result when matching the first target with the second target in the sub-image based on each first feature point and each second feature point in the sub-image.
[0052] In the fifth possible implementation, combining the fourth possible implementation described above, a first feature vector is determined based on the feature values of each first feature point, and a second feature vector is determined based on the feature values of each second feature point. Then, the similarity between the first contour and the second contour in the sub-image is determined based on the first and second feature vectors. Specifically, the similarity between the first contour and the second contour can be determined in the following way:
[0053] After determining at least one first feature point, the method further includes:
[0054] Determine the feature value of each of the first feature points;
[0055] A first feature vector is generated based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point.
[0056] Determining the similarity between the first contour and the second contour in the sub-image based on the at least one first feature point and the at least one second feature point includes:
[0057] Determine the feature value of each of the second feature points in the sub-image;
[0058] For each element in the first feature vector, the following steps are performed to obtain the second feature vector:
[0059] When the element in the first feature vector is the j-th element of the first feature vector.
[0060] Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector;
[0061] Determine the second feature point corresponding to the first feature point of the target;
[0062] The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector;
[0063] Based on the first feature vector and the second feature vector, the similarity between the first contour and the second contour in the sub-image is determined.
[0064] In this embodiment of the invention, for the first image, a first feature vector is obtained based on the feature values of each first feature point. For each sub-image, a second feature vector is obtained based on the feature values of each second feature point. In addition, the relative positions of any j-th element of the first feature vector and the j-th element of the second feature vector are the same. When determining the similarity based on the first feature vector and the second feature vector, elements corresponding to the same relative position can be compared to obtain a more accurate similarity.
[0065] In the sixth possible implementation, combined with the fifth possible implementation, the first feature vector is obtained based on the determined order of each first feature point when generating the first feature vector. Specifically, the first feature vector can be generated in the following way:
[0066] The first feature vector is generated based on the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
[0067] In this embodiment of the invention, the order of elements in the first feature vector is determined according to the determination order of each first feature point. Correspondingly, in conjunction with the fifth possible implementation described above, the order of elements in the second feature vector is also determined by the determination order of each first feature point.
[0068] In the seventh possible implementation, combined with the fifth possible implementation, each element of the second feature vector is compared with the element in the first feature vector corresponding to the same relative position to determine the similarity between the second contour and the first contour. Specifically, the similarity between the second contour and the first contour can be determined in the following way:
[0069] For each element in the second feature vector, perform the following:
[0070] When the element in the second feature vector is the k-th element of the second feature vector.
[0071] When the kth element in the second feature vector is the same as the kth element in the first feature vector, the kth element in the second feature vector is determined to be a candidate element;
[0072] When the kth element in the second feature vector is a candidate element, determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector. If there is, then the kth element in the second feature vector is regarded as a similar element.
[0073] The similarity between the first contour and the second contour in the sub-image is obtained by dividing the number of similar elements in the second feature vector by the total number of elements in the second feature vector.
[0074] In this embodiment of the invention, when the k-th element in the second feature vector is the same as the k-th element in the first feature vector, it indicates that the second feature point corresponding to the k-th element in the second feature vector and the first feature point corresponding to the k-th element in the first feature vector are located at the same relative position and have the same feature value. Therefore, it can be determined that these two pixels have high similarity, and the k-th element in the second feature vector can be marked as a candidate element. When the k-th element in the second feature vector is a candidate element, if there are no candidate elements among the elements adjacent to the k-th element, it indicates that the similarity between the second feature point corresponding to the element adjacent to the k-th element and the corresponding first feature point is low. Therefore, the second feature point corresponding to the k-th element in the second feature vector is considered a noise point. This embodiment of the invention can remove noise points from the sub-image, thereby making the similarity between the determined second contour and the first contour more accurate.
[0075] In the seventh possible implementation, combined with the fifth possible implementation, all first feature points are located on the first contour, and the gradient direction of the first feature point is used as its feature value. For second feature points located on the second contour, the gradient direction of the second feature point is used as its feature value. For second feature points not located on the second contour, a preset value is used as their feature value. Specifically, the feature values of each feature point can be determined in the following way:
[0076] Determining the feature value of each of the first feature points includes:
[0077] For each of the first feature points, determine the gradient direction of the first feature point and use the gradient direction of the first feature point as the feature value of the first feature point;
[0078] Determining the feature value of each of the second feature points in the sub-image includes:
[0079] For each of the second feature points, perform the following:
[0080] Determine whether the second feature point is located on the second contour in the sub-image;
[0081] When the second feature point is located on the second contour, the gradient direction of the second feature point is determined;
[0082] The gradient direction of the second feature point is taken as the feature value of the second feature point;
[0083] When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
[0084] In this embodiment of the invention, the gradient direction is used to characterize the features of a pixel, and the gradient direction is used as the feature value of the pixel. If the second feature point is not located on the second contour, then the second feature point cannot characterize the features of the second contour. Therefore, it is not necessary to determine the gradient direction of the second contour. Instead, a preset value is used as the feature value of the second feature point that is not located on the second contour. When determining the similarity between the first contour and the second contour, the second feature point that is not located on the second contour is not similar to any of the first feature points, thereby making the similarity between the second contour and the first contour more accurate. Attached Figure Description
[0085] Figure 1 This is a flowchart of a target matching method provided in one embodiment of the present invention;
[0086] Figure 2 This is a flowchart of a method for determining a first feature point according to an embodiment of the present invention;
[0087] Figure 3 This is a flowchart of another method for determining a first feature point provided in one embodiment of the present invention;
[0088] Figure 4 This is a flowchart of another method for determining a first feature point provided in an embodiment of the present invention;
[0089] Figure 5 This is a schematic diagram of a first image provided in one embodiment of the present invention;
[0090] Figure 6 This is a schematic diagram of a sub-image provided in one embodiment of the present invention;
[0091] Figure 7 This is a flowchart of a method for determining the similarity between a first contour and a second contour according to an embodiment of the present invention;
[0092] Figure 8This is a flowchart of generating a first feature vector provided in one embodiment of the present invention;
[0093] Figure 9 This is a flowchart of another method for determining the similarity between a first contour and a second contour, provided in one embodiment of the present invention;
[0094] Figure 10 This is a flowchart of a method for determining the feature value of a second feature point according to an embodiment of the present invention;
[0095] Figure 11 This is a flowchart of another target matching method provided in one embodiment of the present invention;
[0096] Figure 12 This is a schematic diagram of another first image provided in one embodiment of the present invention;
[0097] Figure 13 This is a schematic diagram of another sub-image provided in one embodiment of the present invention;
[0098] Figure 14 This is a schematic diagram of a target matching device provided in one embodiment of the present invention;
[0099] Figure 15 This is a schematic diagram of another target matching device provided in one embodiment of the present invention;
[0100] Figure 16 This is a schematic diagram of another target matching device provided in one embodiment of the present invention;
[0101] Figure 17 This is a schematic diagram of another target matching device provided in one embodiment of the present invention;
[0102] Figure 18 This is a schematic diagram of another target matching device provided in one embodiment of the present invention;
[0103] Figure 19 This is a schematic diagram of another target matching device provided in one embodiment of the present invention;
[0104] Figure 20 This is a schematic diagram of another target matching device provided in one embodiment of the present invention.
[0105] List of reference numerals in the attached diagram:
[0106] 101~105, 201~204, 301~304, 401~402: Method steps
[0107] 701~705, 801~802, 901~903, 1001~1004, 1101~1110: Method steps
[0108] 501: First sub-profile 502: Second sub-profile 601: Third sub-profile
[0109] 602: Fourth sub-outline; 1201: Fifth sub-outline; 1202: Sixth sub-outline
[0110] 1301: Seventh Sub-Outline 1302: Eighth Sub-Outline
[0111] 1401: Get Module 1402: Determine Module 1403: Capture Module
[0112] 1404: Matching module; 14021: First extraction unit; 14022: First generation unit
[0113] 14023: Window Determination Unit; 14024: First Sampling Unit; 14025: Second Extraction Unit
[0114] 14026: Second generation unit; 14027: Step size determination unit; 14028: Second sampling unit
[0115] 14029: First determining unit; 14020: Third sampling unit; 1801: Vector generation module
[0116] 14041: Second determining unit; 14042: Vector generation unit; 14043: Third determining unit
[0117] 140431: Candidate element determination sub-segment; 140432: Similar element determination sub-segment; 140433: Similarity determination sub-segment.
[0118] Yuan Yuan Yuan
[0119] 2001: Memory; 2002: Processor Detailed Implementation
[0120] As mentioned earlier, current target matching processes require comparing each pixel on the first target in an image containing the first target with each pixel on the second target in an image containing the second target to determine their similarity. A match is determined when the similarity exceeds a threshold. Current target matching methods involve comparing each pixel on both targets, resulting in significant computational overhead.
[0121] In this embodiment of the invention, at least one first feature point is determined from the first contour of the first target, and at least one second feature point is determined from each sub-image. Based on each first feature point and each second feature point, the similarity between the first contour and the second contour is determined. When the similarity is greater than a preset similarity threshold, the second target is determined to match the first target. In this embodiment of the invention, it is not necessary to calculate each pixel on the first target and the second target. It is only necessary to determine the first feature point from the first contour of the first target to characterize the features of the first target, and correspondingly, determine the second feature point to characterize the features of the second target. This reduces the number of pixels involved in the calculation and lowers the computational load of target matching.
[0122] The target matching method and apparatus provided in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0123] like Figure 1 As shown, this embodiment of the invention provides a target matching method, including:
[0124] Step 101: Obtain a first image including the first contour of the first target;
[0125] Step 102: Determine at least one first feature point from the first contour in the first image;
[0126] Step 103: Determine the position information of each of the first feature points;
[0127] Step 104: Extract at least one sub-image from the second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target;
[0128] Step 105: For each of the sub-images, perform the following:
[0129] Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image;
[0130] Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image;
[0131] When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target.
[0132] In this embodiment of the invention, at least one first feature point is determined from the first contour of the first target, and at least one second feature point is determined from each sub-image. Based on each first feature point and each second feature point, the similarity between the first contour and the second contour is determined. When the similarity is greater than a preset similarity threshold, the second target is determined to match the first target. In this embodiment of the invention, it is not necessary to calculate each pixel on the first target and the second target. It is only necessary to determine the first feature point from the first contour of the first target to characterize the features of the first target, and correspondingly, determine the second feature point to characterize the features of the second target. This reduces the number of pixels involved in the calculation and lowers the computational load of target matching.
[0133] It should be noted that: the first contour is the contour of the first target, and the first image only includes the contour of the first target. The first feature point is a pixel in the first image, which can be used to characterize the features of the first target. The second feature point is a pixel in a sub-image, which can be used to characterize the features of the second target. Optionally, the size of each sub-image is the same as the size of the first image; specifically, the length of the sub-image is the same as the length of the first image, and the width of the sub-image is the same as the width of the first image.
[0134] In this embodiment of the invention, sub-images can be cropped from the second image using a sliding window. The size of the sliding window is the same as the size of the first image, ensuring that the size of the cropped sub-images is the same as the size of the first image. Each sub-image includes a contour. Cropped images that do not include a contour are not considered sub-images and are not processed. The contours in the sub-images are used as second contours, which are then used as the contours of a second target.
[0135] In this embodiment of the invention, the similarity between the second contour of the second target and the first contour of the first target in the sub-image is determined. This similarity is used to characterize the degree of similarity between the first target and the second target. Then, based on this similarity, it is determined whether the second target and the first target match. If the similarity is greater than a preset similarity threshold, it means that the second target and the first target are similar, that is, the second target and the first target match, that is, the first target is identified from the second image.
[0136] Optionally, based on Figure 1 The target matching method shown can determine each first feature point through a sliding window. Specifically, each first feature point can be determined in the following three ways:
[0137] The first method:
[0138] like Figure 2 As shown, when the first contour includes at least two sub-contours, each first feature point can be determined in the following way:
[0139] Step 201: For each of the sub-contours in the first contour, extract the sub-contour from the first contour;
[0140] Step 202: Generate a first sampled image including the sub-contour, wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image;
[0141] Step 203: Determine the first sliding window based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window;
[0142] Step 204: Using the first sliding window, slide it across the first sampled image with a first step length, and take the pixel point located at a specific position of the first sliding window and on the sub-contour as the first feature point.
[0143] In this embodiment of the invention, a sub-contour is extracted from the first contour, and a first sampled image containing only the sub-contour is generated. Then, the first sampled image is sampled using a first sliding window to obtain each first feature point on the sub-contour, which can avoid the influence of other sub-contours on the sub-contour during the sampling process.
[0144] In this embodiment of the invention, the size of the first sampled image is the same as that of the first image, and the relative position of the sub-contour in the first sampled image is the same as its relative position in the first image. That is, the relative position of each pixel on the sub-contour in the first sampled image is the same as its relative position in the first image. For example, if pixel A of the sub-contour is located in the nth row and mth column of the first image, then pixel A is also located in the nth row and mth column of the first sampled image. When the size of the first sampled image is the same as that of the first image, and the relative position of the sub-contour in the first sampled image is the same as its relative position in the first image, the first feature point obtained by sampling the first sampled image is equivalent to the first feature point in the first image. For example, if a first feature point located at (n, m) is obtained by sampling the first sampled image, then the position of this first feature point in the first image is also (n, m), where (n, m) represents the position in the nth row and mth column of the image.
[0145] In this embodiment of the invention, when the step size of the first sliding window remains unchanged, the more pixels a sub-contour includes, the longer the size of the first sliding window (optionally, the size of the first sliding window is proportional to the number of pixels included in the sub-contour). This ensures that the number of first feature points is positively correlated with the number of pixels included in the sub-contour. Moreover, the size of the first sliding window of a sub-contour with fewer pixels is smaller than the size of the first sliding window of a sub-contour with more pixels. This makes the number of first feature points on the sub-contour with fewer pixels closer to the number of first feature points on the sub-contour with more pixels, increasing the ratio of the number of first feature points on the sub-contour with fewer pixels to the total number of first feature points on the first contour. This increases the importance of the sub-contour with fewer pixels in representing the first target. Through each first feature point, the details of the first target can be represented more accurately. This improves the accuracy of the matching result when matching the first target with the second target in the sub-image based on each first feature point and each second feature point in the sub-image.
[0146] In this embodiment of the invention, the first sliding window is a square with a side length of an odd number of pixels. The specific position of the first sliding window can be the center of the first sliding window. When determining the side length of the first sliding window, the number of pixels in the sub-contour can be divided by a preset first constant to obtain a first target value. The odd number with the smallest difference from the first target value is taken as the side length of the first sliding window.
[0147] The second method:
[0148] like Figure 3 As shown, when the first contour includes at least two sub-contours, each first feature point can be determined in the following way:
[0149] Step 301: For each of the sub-contours in the first contour, extract the sub-contour from the first contour;
[0150] Step 302: Generate a second sampled image including the sub-contour, wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image;
[0151] Step 303: Determine the second step length based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step length.
[0152] Step 304: Using the second sliding window, slide it in the second sampled image with the second step size, and take the pixel point located at a specific position of the second sliding window and located on the sub-contour as the first feature point.
[0153] In this embodiment of the invention, a sub-contour is extracted from the first contour, and a second sampling image containing only the sub-contour is generated. Then, the second sampling image is sampled using a second sliding window to obtain each first feature point on the sub-contour, which can avoid the influence of other sub-contours on the sub-contour during the sampling process.
[0154] In this embodiment of the invention, the size of the second sampled image is the same as that of the first image, and the relative position of the sub-contour in the second sampled image is the same as its relative position in the first image. That is, the relative position of each pixel on the sub-contour in the second sampled image is the same as its relative position in the first image. For example, if pixel B of the sub-contour is located in the nth row and mth column of the first image, then pixel B is also located in the nth row and mth column of the second sampled image. When the size of the second sampled image is the same as that of the first image, and the relative position of the sub-contour in the second sampled image is the same as its relative position in the first image, the first feature point obtained by sampling the second sampled image is equivalent to the first feature point in the first image. For example, if a first feature point located at (n, m) is obtained by sampling the second sampled image, then the position of this first feature point in the first image is also (n, m), where (n, m) represents the position in the nth row and mth column of the image.
[0155] In this embodiment of the invention, with the second sliding window remaining unchanged, the more pixels the sub-contour includes, the longer the second step size (optionally, the size of the second step size is proportional to the number of pixels included in the sub-contour). This ensures that the number of first feature points is positively correlated with the number of pixels included in the sub-contour. Moreover, the second step size of the sub-contour with fewer pixels is smaller than that of the sub-contour with more pixels, making the number of first feature points on the sub-contour with fewer pixels closer to the number of first feature points on the sub-contour with more pixels. This increases the ratio of the number of first feature points on the sub-contour with fewer pixels to the total number of first feature points on the first contour, thereby increasing the importance of the sub-contour with fewer pixels in representing the first target. Through each first feature point, the details of the first target can be represented more accurately, thus improving the accuracy of the matching results when matching the first target with the second target in the sub-image based on each first feature point and the second feature points in each sub-image.
[0156] In this embodiment of the invention, the second sliding window is a square with a side length of an odd number of pixels, and the specific position of the second sliding window is the center of the second sliding window.
[0157] In this embodiment of the invention, when determining the second step length, the number of pixels of the sub-contour can be divided by a preset second constant to obtain a second target value, and the integer with the smallest difference from the second target value is taken as the second step length.
[0158] The third method:
[0159] like Figure 4 As shown, each first feature point can be determined in the following way:
[0160] Step 401: Determine the third sliding window and the third step size for sampling the first image;
[0161] Step 402: Using the third sliding window, slide it in the first image with the third step size, and take the pixel point located at a specific position of the third sliding window and located on the first contour as the first feature point.
[0162] In this embodiment of the invention, sampling is performed on the first image through a third sliding window to obtain each first feature point. This method makes the distribution of the collected first feature points more uniform and can more accurately represent the features of the first contour. As a result, when matching the first target with the second target in the sub-image based on each first feature point and the second feature points in each sub-image, the accuracy of the matching result can be improved.
[0163] It should be noted that: in the first method, the length of the first step can be determined based on the number of pixels included in the sub-contour; specifically, the more pixels the sub-contour includes, the longer the first step. In the second method, the length of the second sliding window can be determined based on the number of pixels included in the sub-contour; specifically, the more pixels the sub-contour includes, the longer the size of the second sliding window. The first contour can include at least two sub-contours, and no two sub-contours intersect.
[0164] In this embodiment of the invention, when the first contour includes at least two sub-contours, each sub-contour is sampled to obtain a first feature point on each sub-contour. The first feature point is used to characterize the features of the first target, so that each sub-contour has at least one first feature point. The number of first feature points is positively correlated with the number of pixels included in the sub-contour. That is, the more pixels a sub-contour includes, the more first feature points it has. This makes the distribution of first feature points on the first contour more uniform, and allows each first feature point to characterize the features of each sub-contour of the first target. The more pixels a sub-contour has, the greater its weight in characterizing the features of the first target. By using each first feature point of the first target, the features of the first target can be characterized more comprehensively and accurately. This improves the accuracy of the matching results when matching with the second target in each sub-image cropped from the second image.
[0165] For example, Figure 5 It is a first image, which includes the outline of a first target, in Figure 5 In the image, the contour of the first target includes two sub-contours: a first sub-contour 501 and a second sub-contour 502. The number of pixels on the first sub-contour 501 is greater than the number of pixels on the second sub-contour 502. If the contours in the first image are sampled randomly, in one possible sampling result, all the sampled first feature points will come from the first sub-contour 501, while there will be no first feature points on the second sub-contour 502. Based on this sampling result, the sampled first feature points cannot characterize the features of the second sub-contour 502, and therefore cannot accurately characterize the features of the first target.
[0166] like Figure 6 As shown, Figure 6 A sub-image is shown. Figure 6 The outline in the image represents the outline of the second target. The outline of the second target also includes two sub-outlines: a third sub-outline 601 and a fourth sub-outline 602. The third sub-outline 601 is identical to the first sub-outline 501. The first feature points of the first target all originate from the first sub-outline 501. Therefore, based on these first feature points... Figure 5 The outline of the first target and Figure 6 The contour similarity of the second target is very high, but in reality, the second sub-contour 502 and the fourth sub-contour 602 are very different, so the matching result is inaccurate.
[0167] by Figure 5Taking the first image shown as an example, in this embodiment of the invention, based on the first or second method of determining each first feature point, at least one first feature point is determined on the first sub-contour 501, and at least one first feature point is determined on the second sub-contour 502. Because the first sub-contour 501 includes more pixels than the second sub-contour 502, the number of first feature points on the first sub-contour 501 is greater than the number of first feature points on the second sub-contour 502. For example, the number of first feature points on the first sub-contour 501 is 30, and the number of first feature points on the second sub-contour 502 is 10. The features of the first sub-contour 501 are characterized by 30 first feature points, and the features of the second sub-contour 502 are characterized by 10 first feature points. Thus, the features of the first target can be more accurately and comprehensively characterized by these 40 first feature points. Based on the target matching method provided by this embodiment of the invention, Figure 5 The outline of the first target in the middle and Figure 6 When comparing the contour of the second target in the model, since the second sub-contour 502 also has the first feature point, the difference between the first feature point on the second sub-contour 502 and the second feature point on the fourth sub-contour 602 is relatively large, thus making... Figure 5 The outline of the first target in the middle and Figure 6 The second target in the model has a lower similarity to the outline, resulting in a more accurate matching result.
[0168] Optionally, based on Figure 1 In one embodiment of the present invention, the target matching method shown includes the location information of the first feature point, which includes the relative position of the first feature point in the first image.
[0169] Determining at least one second feature point from the sub-image based on the position information of each first feature point includes:
[0170] For each of the first feature points, perform the following:
[0171] Based on the relative position of the first feature point in the first image, a second feature point corresponding to the first feature point is determined, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
[0172] For example, if the relative position of the first feature point A in the first image is (1, 1), then the second feature point corresponding to the first feature point A is the pixel located at (1, 1) in the sub-image.
[0173] Optionally, a first feature vector corresponding to the first image and a second feature vector corresponding to the sub-image can be generated using the feature values of each feature point. The first feature vector represents the features of the first target, and the second feature vector represents the features of the second target. Based on the first and second feature vectors, the similarity between the first and second contours is determined. Figure 7 As shown, the similarity between the first and second contours can be determined in the following ways:
[0174] After determining at least one first feature point, the method further includes:
[0175] Step 701: Determine the feature value of each of the first feature points;
[0176] Step 702: Generate a first feature vector based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point;
[0177] Determining the similarity between the first contour and the second contour in the sub-image based on the at least one first feature point and the at least one second feature point includes:
[0178] Step 703: Determine the feature value of each of the second feature points in the sub-image;
[0179] Step 704: For each element in the first feature vector, perform the following steps to obtain the second feature vector:
[0180] When the element in the first feature vector is the j-th element of the first feature vector.
[0181] Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector;
[0182] Determine the second feature point corresponding to the first feature point of the target;
[0183] The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector;
[0184] Step 705: Determine the similarity between the first contour and the second contour in the sub-image based on the first feature vector and the second feature vector.
[0185] In this embodiment of the invention, the first feature vector is composed of the feature values of each first feature point, and correspondingly, the second feature vector is composed of the feature values of each second feature point. Any j-th element of the first feature vector and the j-th element of the second feature vector have the same relative position. When determining the similarity based on the first and second feature vectors, elements corresponding to the same relative position can be compared to obtain a more accurate similarity.
[0186] For example, if the j-th element of the first feature vector is the feature value of the first feature point located at (n, m) in the first image, then the j-th element of the second feature vector is the feature value of the second feature point located at (n, m) in the sub-image.
[0187] The feature value of a pixel can be the gradient direction of the pixel, or parameters such as the gray level of the pixel.
[0188] Optionally, based on Figure 7 The target matching method shown allows the order of elements in the first feature vector to be determined based on the order in which the first feature points are determined. Specifically, the first feature vector can be generated in the following way:
[0189] The first feature vector is generated based on the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
[0190] Furthermore, the first contour includes at least two sub-contours, and is achieved through the aforementioned... Figure 2 The first method or Figure 3 In the second method of determining each first feature point, such as Figure 8 As shown, the first eigenvector can be determined in the following way:
[0191] Step 801: For each of the sub-contours, generate a sub-feature vector of the sub-contour according to the determination order of each first feature point on the sub-contour and the feature value of each first feature point on the sub-contour, wherein the determination order of each first feature point is the determined order of each first feature point on the sub-contour, and the i-th element of the sub-feature vector is the feature value of the i-th determined first feature point in the determined order.
[0192] Step 802: Generate the first feature vector based on the sub-feature vector of each sub-contour.
[0193] For example, the first contour includes sub-contour A and sub-contour B. On sub-contour A, first feature points 1, 2, 3, and 4 are determined sequentially; on sub-contour B, first feature points 5, 6, and 7 are determined sequentially. In the first image, the feature value of first feature point 1 is A1, the feature value of first feature point 2 is A2, the feature value of first feature point 3 is A3, the feature value of first feature point 4 is A4, the feature value of first feature point 5 is A5, the feature value of first feature point 6 is A6, and the feature value of first feature point 7 is A7. Based on the determination order of the first feature points on sub-contour A, the sub-feature vector of sub-contour A is determined to be (A1, A2, A3, A4). Based on the determination order of the first feature points on sub-contour B, the sub-feature vector of sub-contour B is determined to be (A5, A6, A7). Then, the sub-feature vectors of sub-contour A and sub-contour B are combined into a first feature vector, which is (A1, A2, A3, A4, A5, A6, A7). In addition, the order of the sub-feature vectors of each sub-contour in the first feature vector is not restricted.
[0194] If, in a sub-image, the feature value of the second feature point corresponding to the first feature point 1 is B1, the feature value of the second feature point corresponding to the first feature point 2 is B2, the feature value of the second feature point corresponding to the first feature point 3 is B3, the feature value of the second feature point corresponding to the first feature point 4 is B4, the feature value of the second feature point corresponding to the first feature point 5 is B5, the feature value of the second feature point corresponding to the first feature point 6 is B6, and the feature value of the second feature point corresponding to the first feature point 7 is B7, then, when the first feature vector is (A1, A2, A3, A4, A5, A6, A7), the second feature vector corresponding to this sub-image is (B1, B2, B3, B4, B5, B6, B7).
[0195] Optionally, based on Figure 7 The target matching method shown can determine the similarity between a first contour and a second contour based on whether the elements at the same relative positions in the first feature vector and the second feature vector are identical. Specifically, as... Figure 9 As shown, the similarity between the first and second contours can be determined in the following ways:
[0196] Step 901: For each element in the second feature vector, if the element in the second feature vector is the kth element in the second feature vector, and the kth element in the second feature vector is the same as the kth element in the first feature vector, then the kth element in the second feature vector is determined to be a candidate element.
[0197] Step 902: When the kth element in the second feature vector is a candidate element, determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector. If there is, then the kth element in the second feature vector is regarded as a similar element.
[0198] Step 903: Divide the number of similar elements in the second feature vector by the total number of elements in the second feature vector to obtain the similarity between the first contour and the second contour in the sub-image.
[0199] In this embodiment of the invention, when the k-th element in the second feature vector is the same as the k-th element in the first feature vector, it indicates that the second feature point corresponding to the k-th element in the second feature vector and the first feature point corresponding to the k-th element in the first feature vector are located at the same relative position and have the same feature value. Therefore, it can be determined that these two pixels have high similarity, and the k-th element in the second feature vector can be marked as a candidate element. When the k-th element in the second feature vector is a candidate element, if there are no candidate elements among the elements adjacent to the k-th element, it indicates that the similarity between the second feature point corresponding to the element adjacent to the k-th element and the corresponding first feature point is low. Therefore, the second feature point corresponding to the k-th element in the second feature vector is considered a noise point. This embodiment of the invention can remove noise points from the sub-image, thereby making the similarity between the determined second contour and the first contour more accurate.
[0200] In this embodiment of the invention, when the k-th element in the second feature vector is different from the k-th element in the first feature vector, the k-th element in the second feature vector is not a candidate element, let alone a similar element. When the k-th element in the second feature vector is a candidate element, if it is determined that there is no candidate element among the elements adjacent to the k-th element in the second feature vector, then the k-th element in the second feature vector is not a similar element.
[0201] For example, the first feature vector is (1, 2, 3, 4, 5, 1, 2, 3, 4, 5), and the second feature vector is (1, 2, 1, 7, 5, 0, 2, 3, 4, 2). Taking the second element of the second feature vector as an example, if the second element of the second feature vector is the same as the second element of the first feature vector, then the second element of the second feature vector is considered a candidate element. If the first element of the second feature vector is the same as the first element of the first feature vector, then the first element of the second feature vector is also a candidate element. Therefore, among the elements adjacent to the second element of the second feature vector, there is at least one candidate element, and the second element of the second feature vector is considered a similar element. Taking the 5th element in the second feature vector as an example, if the 5th element in the second feature vector is the same as the 5th element in the first feature vector, then the 5th element in the second feature vector is considered a candidate element. If the 4th element in the second feature vector is different from the 4th element in the first feature vector, then the 4th element in the second feature vector is not a candidate element. If the 6th element in the second feature vector is different from the 6th element in the first feature vector, then the 6th element in the second feature vector is not a candidate element. Therefore, there are no candidate elements among the elements adjacent to the 5th element in the second feature vector, and the 5th element in the second feature vector is not a similar element. Figure 8 The method shown identifies 5 similar elements in the second feature vector, namely the 1st, 2nd, 7th, 8th, and 9th elements in the second feature vector. The total number of elements in the second feature vector is 10. Dividing the number of similar elements (5) in the second feature vector by the total number of elements (10) in the second feature vector yields a similarity of 0.5 between the second contour and the first contour in the sub-image.
[0202] Optionally, based on Figure 7 The target matching method shown can use the gradient direction as the feature value of a pixel. The feature value of the first feature point can be determined in the following way:
[0203] For each of the first feature points, the gradient direction of the first feature point is determined, and the gradient direction of the first feature point is used as the feature value of the first feature point.
[0204] Optionally, based on Figure 7 The target matching method shown can use the gradient direction as the feature value of a pixel, such as... Figure 10 As shown, the eigenvalues of the second feature point can be determined in the following way:
[0205] Step 1001: For each second feature point, determine whether the second feature point is located on the second contour in the sub-image;
[0206] Step 1002: When the second feature point is located on the second contour, determine the gradient direction of the second feature point;
[0207] Step 1003: Use the gradient direction of the second feature point as the feature value of the second feature point;
[0208] Step 1004: When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
[0209] In this embodiment of the invention, the gradient direction is used to characterize the features of a pixel, and the gradient direction is used as the feature value of the pixel. If the second feature point is not located on the second contour, then the second feature point cannot characterize the features of the second contour. Therefore, it is not necessary to determine the gradient direction of the second contour. Instead, a preset value is used as the feature value of the second feature point that is not located on the second contour. When determining the similarity between the first contour and the second contour, the second feature point that is not located on the second contour is not similar to any of the first feature points, thereby making the similarity between the second contour and the first contour more accurate.
[0210] In this embodiment of the invention, a pre-defined correspondence between the gradient range and gradient direction of a pixel can be established. Different gradient ranges correspond to different gradient directions, and different gradient directions can be represented by different first values, where each first value represents a gradient direction. Therefore, in the correspondence, different gradient ranges correspond to different first values, and the aforementioned preset value is not just any first value used to represent a gradient direction. When a second feature point is located on the second contour of a sub-image, the gradient of the second feature point is determined, the gradient range to which the gradient of the second feature point belongs is determined, and then the first value corresponding to the gradient range to which the gradient of the second feature point belongs is determined. This first value is then used as the feature value of the second feature point. For example, eight gradient directions can be pre-defined, with different gradient directions corresponding to a gradient range, represented by numbers 1-8. The preset value needs to be different from these eight values; for example, the preset value can be set to 0.
[0211] The following describes in detail a target matching method provided by the present invention, specifically addressing the case where the first contour includes at least two sub-contours, through a concrete embodiment. As shown in Figure 11, the method may include the following steps:
[0212] Step 1101: Obtain a first image including a first contour of a first target, wherein the first contour includes at least two sub-contours.
[0213] Specifically, the first contour in the first image can be obtained through an edge extraction algorithm. For example, by using an edge extraction algorithm, the image including the first target is edge extracted to obtain the first contour of the first target, and the first image is generated.
[0214] Figure 5 A first image is shown, wherein the first contour of the first image includes a first sub-contour 501 and a second sub-contour 502, the first sub-contour 501 and the second sub-contour 502 not intersecting each other.
[0215] In addition, such as Figure 12 As shown, an embodiment of the present invention provides a first image, which includes two sub-contours, one sub-contour being a circular ring and the other sub-contour being the shape of the number "3". Figure 12 The image also shows the first feature point located on each sub-contour.
[0216] Step 1102: For each sub-contour, determine at least one first feature point on the sub-contour and determine the position information of each first feature point.
[0217] Specifically, it can be done through Figure 2 The method shown is for determining the first feature point or by... Figure 3 The method shown is used to determine the first feature point on the sub-contour.
[0218] For example, through Figure 2 The method shown for determining the first feature point is as follows: Figure 5 The first feature points on the first sub-contour 501 and the second sub-contour 502 are shown. A sampled image including the first sub-contour 501 and a sampled image including the second sub-contour 502 are generated respectively. The sliding window A corresponding to the first sub-contour 501 is a square with a side length of 3 pixels, and the sliding window B corresponding to the second sub-contour 502 is a square with a side length of 1 pixel. The first step length is 2. By sliding window A across the sampled image including the first sub-contour 501 with a preset first step length of 2, 30 first feature points are obtained. By sliding window B across the sampled image including the second sub-contour 502 with a preset first step length of 2, 10 first feature points are obtained.
[0219] Step 1103: Determine the feature value of each first feature point in the first image.
[0220] Step 1104: Generate the first feature vector based on the feature value of each first feature point.
[0221] For each sub-contour, a sub-feature vector is generated based on the determination order of the first feature points on the sub-contour and the feature values of the first feature points on the sub-contour. The i-th element of the sub-feature vector is the feature value of the i-th determined first feature point in the determination order.
[0222] For example, the first contour includes two sub-contours, and the sub-feature vectors of the two sub-contours are (1, 2, 3, 4, 5) and (5, 4, 3, 3, 1), respectively.
[0223] The sub-feature vectors (1, 2, 3, 4, 5) and (5, 4, 3, 3, 1) are concatenated to obtain the first feature vector (1, 2, 3, 4, 5, 5, 4, 3, 3, 1).
[0224] Step 1105: Extract at least one sub-image from the second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target.
[0225] Specifically, the sliding window can be slid across the second image until the entire second image is traversed to obtain at least one sub-image.
[0226] Step 1106: For each sub-image, based on the position information of each first feature point, determine at least one second feature point from the sub-image, and determine the feature value of each second feature point in the sub-image.
[0227] Specifically, the location information of the first feature point includes: the relative position of the first feature point in the first image;
[0228] Based on the relative position of the first feature point in the first image, a second feature point corresponding to the first feature point is determined, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
[0229] like Figure 13 As shown in the figure, an embodiment of the present invention provides a sub-image, which includes three sub-contours: the first sub-contour is in the shape of a ring, the second sub-contour is in the shape of the number "1", and the third sub-contour is in the shape of the number "9". Figure 13 It also shows Figure 12 The second feature point corresponding to the first feature point in the image.
[0230] Step 1107: For each element in the first feature vector, perform the following steps to obtain the second feature vector of the sub-image:
[0231] When the element in the first feature vector is the j-th element of the first feature vector.
[0232] Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector;
[0233] Determine the second feature point corresponding to the first feature point of the target;
[0234] The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector;
[0235] For example, the second feature vector obtained according to step 1107 is (1, 2, 1, 7, 5, 0, 2, 3, 4, 2).
[0236] Step 1108: For each element in the second feature vector of this sub-image, perform the following:
[0237] When the element in the second feature vector is the k-th element of the second feature vector.
[0238] When the kth element in the second feature vector is the same as the kth element in the first feature vector, the kth element in the second feature vector is determined to be a candidate element;
[0239] When the kth element in the second feature vector is a candidate element, determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector. If there is, then the kth element in the second feature vector is regarded as a similar element.
[0240] For example, the first feature vector is (1, 2, 3, 4, 5, 5, 4, 3, 3, 1), and the second feature vector is (1, 2, 1, 7, 5, 0, 4, 3, 3, 2). Based on step 1108, the 1st, 2nd, 5th, 7th, 8th, and 9th elements of the second feature vector are all candidate elements. Among them, the 1st, 2nd, 7th, 8th, and 9th elements of the second feature vector are all similar elements.
[0241] Step 1109: Divide the number of similar elements in the second feature vector by the total number of elements in the second feature vector to obtain the similarity between the first contour and the second contour in the sub-image.
[0242] For example, if the first feature vector is (1, 2, 3, 4, 5, 5, 4, 3, 3, 1) and the second feature vector is (1, 2, 1, 7, 5, 0, 4, 3, 3, 2), based on step 1109, the number of similar elements is determined to be 5, and the total number of elements in the second feature vector is 10. Then, the similarity between the first contour and the second contour is 0.5.
[0243] Step 1110: When the similarity is greater than the preset similarity threshold, determine that the second target corresponding to the second contour in the sub-image matches the first target.
[0244] Based on the target matching method provided in this invention, classification, localization, measurement, and defect detection can be achieved. For example, when a first target matches a second target in a sub-image, it can be determined that a first target exists in that sub-image.
[0245] The solution provided by the embodiments of the present invention can obtain a more uniformly distributed first feature point, that is, it can make the first feature point used to characterize the contour features of the first target more uniformly distributed, the local noise has less impact on the matching result, improve the robustness of target matching, improve the adaptability of target matching in complex environments, and is more suitable for working in collaboration with robots and other equipment.
[0246] The solution provided by the embodiments of the present invention has a wider range of application scenarios and enables machine vision equipment to have better detection performance. In application scenarios such as workpiece classification and counting, it can also achieve good matching results when some workpieces are occluded, has lower requirements for the external environment, and reduces the cost of deploying machine vision equipment.
[0247] like Figure 14 As shown, an embodiment of the present invention provides a target matching device, comprising:
[0248] An acquisition module 1401 is used to acquire a first image including a first contour of a first target;
[0249] A determining module 1402 is configured to determine at least one first feature point from the first contour in the first image, and to determine the position information of each first feature point;
[0250] A cropping module 1403 is configured to crop at least one sub-image from a second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target;
[0251] A matching module 1404 is used to perform the following for each of the sub-images:
[0252] Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image;
[0253] Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image;
[0254] When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target.
[0255] exist Figure 14 Based on the target matching device shown, such as Figure 15 As shown, the first contour includes at least two sub-contours;
[0256] The determining module 1402 includes:
[0257] A first extraction unit 14021 is configured to extract the sub-contour from the first contour for each of the sub-contours in the first contour.
[0258] A first generation unit 14022 is configured to generate a first sampled image including the sub-contour extracted by the first extraction unit 14021, wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image.
[0259] A window determination unit 14023 is used to determine a first sliding window based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window.
[0260] A first sampling unit 14024 is used to slide the first sliding window determined by the window determination unit 14023 in the first sampled image generated by the first generation unit 14022 with a first step length, and to take the pixel point located at a specific position of the first sliding window and located on the sub-contour as the first feature point.
[0261] exist Figure 14 Based on the target matching device shown, such as Figure 16 As shown, the first contour includes at least two sub-contours;
[0262] The determining module 1402 includes:
[0263] A second extraction unit 14025 is configured to extract the sub-contour from the first contour for each of the sub-contours in the first contour.
[0264] A second generation unit 14026 is configured to generate a second sampled image including the sub-contour extracted by the second extraction unit 14025, wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image;
[0265] A step size determination unit 14027 is used to determine a second step size based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step size is.
[0266] A second sampling unit 14028 is used to slide a second sliding window in the second sampled image generated by the second generation unit 14026 with the second step size determined by the step size determination unit 14027, and to take the pixel point located at a specific position of the second sliding window and located on the sub-contour as the first feature point.
[0267] exist Figure 14 Based on the target matching device shown, such as Figure 17 As shown, the determining module 1402 includes:
[0268] A first determining unit 14029 is used to determine a third sliding window and a third step size for sampling the first image;
[0269] A third sampling unit 14020 is used to slide the third sliding window determined by the first determining unit in the first image with the third step size determined by the first determining unit, and to take the pixel point located at a specific position of the third sliding window and located on the first contour as the first feature point.
[0270] exist Figure 14 Based on the target matching device shown, the position information of the first feature point includes: the relative position of the first feature point in the first image;
[0271] The matching module 1404 is used to determine a second feature point corresponding to each first feature point based on the relative position of the first feature point in the first image, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
[0272] Optionally, in one embodiment of the present invention, as Figure 18 As shown, the device further includes:
[0273] A vector generation module 1801 is configured to, after the determining module 1402 determines at least one first feature point, determine the feature value of each first feature point, and generate a first feature vector based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point.
[0274] The matching module 1404 includes:
[0275] A second determining unit 14041 is used to determine the feature value of each of the second feature points in the sub-image;
[0276] A vector generation unit 14042 is configured to perform the following steps for each element in the first feature vector to obtain a second feature vector:
[0277] When the element in the first feature vector is the j-th element of the first feature vector.
[0278] Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector;
[0279] Determine the second feature point corresponding to the first feature point of the target;
[0280] The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector;
[0281] A third determining unit 14043 is used to determine the similarity between the first contour and the second contour in the sub-image based on the first feature vector generated by the vector generation module and the second feature vector generated by the vector generation unit.
[0282] Optionally, based on Figure 18 The target matching apparatus shown includes a vector generation module 1801, which generates a first feature vector based on the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
[0283] based on Figure 18 The target matching device shown is as follows: Figure 19 As shown, the third determining unit 14043 includes:
[0284] A candidate element determination subunit 140431 is used to determine the k-th element of the second feature vector generated by the vector generation unit 14042 as a candidate element if the element in the second feature vector is the k-th element in the second feature vector and the k-th element in the second feature vector is the same as the k-th element in the first feature vector.
[0285] A similar element determination subunit 140432 is used to determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector when the candidate element determination subunit 140431 determines that the kth element in the second feature vector is a candidate element. If there is, the kth element in the second feature vector is regarded as a similar element.
[0286] A similarity determination subunit 140433 is used to divide the number of similar elements determined by the similar element determination subunit 140432 in the second feature vector by the total number of elements in the second feature vector to obtain the similarity between the first contour and the second contour in the sub-image.
[0287] based on Figure 18 The target matching device shown includes a vector generation module 1801, which is used to determine the gradient direction of each first feature point and use the gradient direction of the first feature point as the feature value of the first feature point.
[0288] The second determining unit 14041 is configured to perform the following for each of the second feature points:
[0289] Determine whether the second feature point is located on the second contour in the sub-image;
[0290] When the second feature point is located on the second contour, the gradient direction of the second feature point is determined;
[0291] The gradient direction of the second feature point is taken as the feature value of the second feature point;
[0292] When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
[0293] like Figure 20 As shown, one embodiment of the present invention provides a target matching method, including: at least one memory 2001 and at least one processor 2002;
[0294] The at least one memory 2001 is configured to store executable instructions;
[0295] The at least one processor 2002, coupled to the at least one memory 2001, is configured, when executing the executable instructions, to:
[0296] Acquire a first image including the first contour of the first target;
[0297] Determine at least one first feature point from the first contour in the first image;
[0298] Determine the position information of each of the first feature points;
[0299] At least one sub-image is extracted from the second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target;
[0300] For each of the sub-images, the following is performed:
[0301] Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image;
[0302] Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image;
[0303] When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target.
[0304] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0305] The first contour includes at least two sub-contours;
[0306] For each of the sub-contours in the first contour, the following is performed:
[0307] Extract the sub-contour from the first contour;
[0308] Generate a first sampled image including the sub-contour, wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image;
[0309] The first sliding window is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window.
[0310] The first sliding window is used to slide in the first sampled image with a first step length, and the pixel point located at a specific position of the first sliding window and on the sub-contour is taken as the first feature point.
[0311] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0312] The first contour includes at least two sub-contours;
[0313] For each of the sub-contours in the first contour, the following is performed:
[0314] Extract the sub-contour from the first contour;
[0315] Generate a second sampled image including the sub-contour, wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image;
[0316] The second step length is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step length is.
[0317] The second sliding window is used to slide in the second sampled image with the second step size, and the pixel point located at a specific position of the second sliding window and on the sub-contour is taken as the first feature point.
[0318] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0319] Determine the third sliding window and the third step size for sampling the first image;
[0320] The third sliding window is used to slide in the first image with the third step size, and the pixel point located at a specific position of the third sliding window and on the first contour is taken as the first feature point.
[0321] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0322] The location information of the first feature point includes: the relative position of the first feature point in the first image;
[0323] For each of the first feature points, perform the following:
[0324] Based on the relative position of the first feature point in the first image, a second feature point corresponding to the first feature point is determined, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
[0325] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 1702 is further configured, when executing the executable instructions, to:
[0326] After determining at least one first feature point, the method further includes:
[0327] Determine the feature value of each of the first feature points;
[0328] A first feature vector is generated based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point.
[0329] Determining the similarity between the first contour and the second contour in the sub-image based on the at least one first feature point and the at least one second feature point includes:
[0330] Determine the feature value of each of the second feature points in the sub-image;
[0331] For each element in the first feature vector, the following steps are performed to obtain the second feature vector:
[0332] When the element in the first feature vector is the j-th element of the first feature vector.
[0333] Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector;
[0334] Determine the second feature point corresponding to the first feature point of the target;
[0335] The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector;
[0336] Based on the first feature vector and the second feature vector, the similarity between the first contour and the second contour in the sub-image is determined.
[0337] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0338] The first feature vector is generated based on the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
[0339] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0340] For each element in the second feature vector, perform the following:
[0341] When the element in the second feature vector is the k-th element of the second feature vector.
[0342] When the kth element in the second feature vector is the same as the kth element in the first feature vector, the kth element in the second feature vector is determined to be a candidate element;
[0343] When the kth element in the second feature vector is a candidate element, determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector. If there is, then the kth element in the second feature vector is regarded as a similar element.
[0344] The similarity between the first contour and the second contour in the sub-image is obtained by dividing the number of similar elements in the second feature vector by the total number of elements in the second feature vector.
[0345] Optionally, in Figure 20 Based on the target matching method shown, the at least one processor 2002 is further configured, when executing the executable instructions, to:
[0346] For each of the first feature points, determine the gradient direction of the first feature point and use the gradient direction of the first feature point as the feature value of the first feature point;
[0347] For each of the second feature points, perform the following:
[0348] Determine whether the second feature point is located on the second contour in the sub-image;
[0349] When the second feature point is located on the second contour, the gradient direction of the second feature point is determined;
[0350] The gradient direction of the second feature point is taken as the feature value of the second feature point;
[0351] When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
[0352] The present invention also provides a computer-readable medium storing instructions for causing a machine to perform the target matching method as described herein. Specifically, a system or apparatus equipped with a storage medium storing software program code that implements the functions of any of the embodiments described above, and causing the computer (or CPU or MPU) of the system or apparatus to read and execute the program code stored in the storage medium.
[0353] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.
[0354] Examples of storage media used to provide program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.
[0355] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0356] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion module connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion module execute some and all of the actual operations, thereby realizing the function of any of the above embodiments.
[0357] It should be noted that not all steps and modules in the above processes and system structure diagrams are mandatory; some steps or modules can be omitted as needed. The execution order of each step is not fixed and can be adjusted as required. The system structure described in the above embodiments can be a physical structure or a logical structure. That is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or they may be jointly implemented by certain components in multiple independent devices.
[0358] In the above embodiments, the hardware modules can be implemented mechanically or electrically. For example, a hardware module may include permanent dedicated circuitry or logic (such as a dedicated processor, FPGA, or ASIC) to perform the corresponding operations. The hardware module may also include programmable logic or circuitry (such as a general-purpose processor or other programmable processor), which can be temporarily configured by software to perform the corresponding operations. The specific implementation method (mechanical, dedicated permanent circuitry, or temporarily configured circuitry) can be determined based on cost and time considerations.
[0359] The present invention has been shown and described in detail above with reference to the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above embodiments, those skilled in the art will know that more embodiments of the present invention can be obtained by combining the code review methods in the different embodiments. These embodiments are also within the protection scope of the present invention.
Claims
1. A method for target matching, characterized in that, include: Acquire a first image including the first contour of the first target; Determine at least one first feature point from the first contour in the first image; Determine the position information of each of the first feature points; At least one sub-image is extracted from the second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target; For each of the sub-images, the following is performed: Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image; Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image; When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target; The location information of the first feature point includes: the relative position of the first feature point in the first image; Determining at least one second feature point from the sub-image based on the position information of each first feature point includes: For each of the first feature points, perform the following: Based on the relative position of the first feature point in the first image, a second feature point corresponding to the first feature point is determined, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
2. The method according to claim 1, characterized in that, The first contour includes at least two sub-contours; Determining at least one first feature point from the first contour in the first image includes: performing the following for each of the sub-contours in the first contour: Extract the sub-contour from the first contour; Generate a first sampled image including the sub-contour, wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image; The first sliding window is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window. The first sliding window is used to slide in the first sampled image with a first step length, and the pixel point located at a specific position of the first sliding window and on the sub-contour is taken as the first feature point.
3. The method according to claim 1, characterized in that, The first contour includes at least two sub-contours; Determining at least one first feature point from the first contour in the first image includes: performing the following for each of the sub-contours in the first contour: Extract the sub-contour from the first contour; Generate a second sampled image including the sub-contour, wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image; The second step length is determined based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step length is. The second sliding window is used to slide in the second sampled image with the second step size, and the pixel point located at a specific position of the second sliding window and on the sub-contour is taken as the first feature point.
4. The method according to claim 1, characterized in that, Determining at least one first feature point from the first contour in the first image includes: Determine the third sliding window and the third step size for sampling the first image; The third sliding window is used to slide in the first image with the third step size, and the pixel point located at a specific position of the third sliding window and on the first contour is taken as the first feature point.
5. The method according to claim 1, characterized in that, After determining at least one first feature point, the method further includes: Determine the feature value of each of the first feature points; A first feature vector is generated based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point. Determining the similarity between the first contour and the second contour in the sub-image based on the at least one first feature point and the at least one second feature point includes: Determine the feature value of each of the second feature points in the sub-image; For each element in the first feature vector, the following steps are performed to obtain the second feature vector: When the element in the first feature vector is the j-th element of the first feature vector. Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector; Determine the second feature point corresponding to the first feature point of the target; The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector; Based on the first feature vector and the second feature vector, the similarity between the first contour and the second contour in the sub-image is determined.
6. The method according to claim 5, characterized in that, The step of generating a first feature vector based on the feature value of each first feature point includes: The first feature vector is generated based on the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
7. The method according to claim 5, characterized in that, Determining the similarity between the first contour and the second contour in the sub-image based on the first feature vector and the second feature vector includes: For each element in the second feature vector, perform the following: When the element in the second feature vector is the k-th element of the second feature vector. When the kth element in the second feature vector is the same as the kth element in the first feature vector, the kth element in the second feature vector is determined to be a candidate element; When the kth element in the second feature vector is a candidate element, determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector. If there is, then the kth element in the second feature vector is regarded as a similar element. The similarity between the first contour and the second contour in the sub-image is obtained by dividing the number of similar elements in the second feature vector by the total number of elements in the second feature vector.
8. The method according to claim 5, characterized in that, Determining the feature value of each of the first feature points includes: For each of the first feature points, determine the gradient direction of the first feature point and use the gradient direction of the first feature point as the feature value of the first feature point; Determining the feature value of each of the second feature points in the sub-image includes: For each of the second feature points, perform the following: Determine whether the second feature point is located on the second contour in the sub-image; When the second feature point is located on the second contour, the gradient direction of the second feature point is determined; The gradient direction of the second feature point is taken as the feature value of the second feature point; When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
9. A target matching device, characterized in that, include: An acquisition module (1401) is used to acquire a first image including a first contour of a first target; A determining module (1402) is configured to determine at least one first feature point from the first contour in the first image, and to determine the position information of each first feature point; A cropping module (1403) is configured to crop at least one sub-image from a second image, wherein the second image includes at least one contour, and the sub-image includes a second contour of a second target; A matching module (1404) is used to perform the following for each of the sub-images: Based on the location information of each of the first feature points, at least one second feature point is determined from the sub-image; Based on the at least one first feature point and the at least one second feature point, determine the similarity between the first contour and the second contour in the sub-image; When the similarity is greater than a preset similarity threshold, it is determined that the second target corresponding to the second contour in the sub-image matches the first target; The location information of the first feature point includes: the relative position of the first feature point in the first image; The matching module (1404) is used to determine a second feature point corresponding to each first feature point based on the relative position of the first feature point in the first image, wherein the relative position of the second feature point corresponding to the first feature point in the sub-image is the same as the relative position of the first feature point in the first image.
10. The apparatus according to claim 9, characterized in that, The first contour includes at least two sub-contours; The determining module (1402) includes: A first extraction unit (14021) is configured to extract the sub-contour from the first contour for each of the sub-contours in the first contour; A first generation unit (14022) is configured to generate a first sampled image including the sub-contour extracted by the first extraction unit (14021), wherein the relative position of the sub-contour in the first sampled image is the same as the relative position of the sub-contour in the first image. A window determination unit (14023) is used to determine a first sliding window based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the size of the first sliding window. A first sampling unit (14024) is used to slide the first sliding window determined by the window determining unit (14023) in the first sampling image generated by the first generating unit (14022) with a first step length, and to take the pixel point located at a specific position of the first sliding window and located on the sub-contour as the first feature point.
11. The apparatus according to claim 9, characterized in that, The first contour includes at least two sub-contours; The determining module (1402) includes: A second extraction unit (14025) is configured to extract the sub-contour from the first contour for each of the sub-contours in the first contour; A second generation unit (14026) is configured to generate a second sampled image including the sub-contour extracted by the second extraction unit (14025), wherein the relative position of the sub-contour in the second sampled image is the same as the relative position of the sub-contour in the first image; A step size determination unit (14027) is used to determine a second step size based on the number of pixels included in the sub-contour, wherein the more pixels the sub-contour includes, the longer the second step size is. A second sampling unit (14028) is used to slide a second sliding window in the second sampled image generated by the second generation unit (14026) with the second step determined by the step size determination unit (14027), and to take the pixel point located at a specific position of the second sliding window and located on the sub-contour as the first feature point.
12. The apparatus according to claim 9, characterized in that, The determining module (1402) includes: A first determining unit (14029) is used to determine a third sliding window and a third step size for sampling the first image; A third sampling unit (14020) is used to slide the third sliding window determined by the first determining unit (14029) in the first image with the third step determined by the first determining unit (14029), and to take the pixel point located at a specific position of the third sliding window and located on the first contour as the first feature point.
13. The apparatus according to claim 9, characterized in that, Further includes: A vector generation module (1801) is configured to determine the feature value of each first feature point after the determining module (1402) determines at least one first feature point, and generate a first feature vector based on the feature value of each first feature point, wherein each element in the first feature vector is the feature value of each first feature point. The matching module (1404) includes: A second determining unit (14041) is used to determine the feature value of each of the second feature points in the sub-image; A vector generation unit (14042) is configured to perform the following steps for each element of the first feature vector to obtain a second feature vector: When the element in the first feature vector is the j-th element of the first feature vector. Determine the target first feature point corresponding to the j-th element in the first feature vector, wherein the feature value of the target first feature point corresponding to the j-th element in the first feature vector is the j-th element in the first feature vector; Determine the second feature point corresponding to the first feature point of the target; The feature value of the second feature point corresponding to the first feature point of the target is taken as the j-th element of the second feature vector; A third determining unit is configured to determine the similarity between the first contour and the second contour in the sub-image based on the first feature vector generated by the vector generation module (1801) and the second feature vector generated by the vector generation unit (14042).
14. The apparatus according to claim 13, characterized in that, The vector generation module (1801) is used to generate the first feature vector according to the determination order of the at least one first feature point and the feature value of each first feature point, wherein the determination order is the order in which the at least one first feature point is determined, and the i-th element of the first feature vector is the feature value of the i-th determined first feature point in the determination order.
15. The apparatus according to claim 13, characterized in that, The third determining unit includes: A candidate element determination subunit (140431) is used to determine the k-th element of the second feature vector generated by the vector generation unit (14042) as a candidate element if the element in the second feature vector is the k-th element in the second feature vector and the k-th element in the second feature vector is the same as the k-th element in the first feature vector. A similar element determination subunit (140432) is used to determine whether there is at least one candidate element among the elements adjacent to the kth element in the second feature vector when the candidate element determination subunit (140431) determines that the kth element in the second feature vector is a candidate element. If there is, the kth element in the second feature vector is regarded as a similar element. A similarity determination subunit (140433) is used to divide the number of similar elements determined by the similar element determination subunit (140432) in the second feature vector by the total number of elements in the second feature vector to obtain the similarity between the first contour and the second contour in the sub-image.
16. The apparatus according to claim 13, characterized in that, The vector generation module (1801) is used to determine the gradient direction of each first feature point and use the gradient direction of the first feature point as the feature value of the first feature point. The second determining unit (14041) is configured to perform the following for each of the second feature points: Determine whether the second feature point is located on the second contour in the sub-image; When the second feature point is located on the second contour, the gradient direction of the second feature point is determined; The gradient direction of the second feature point is taken as the feature value of the second feature point; When the second feature point is not located on the second contour, a preset value is used as the feature value of the second feature point.
17. A target matching apparatus, characterized in that, include: At least one memory (2001) and at least one processor (2002); The at least one memory (2001) is used to store a machine-readable program; The at least one processor (2002) is configured to invoke the machine-readable program to perform the method described in any one of claims 1 to 8.
18. A computer-readable medium, characterized in that, The computer-readable medium stores computer instructions that, when executed by a processor, cause the processor to perform the method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Target object recognition method and apparatus
CN103810475A
Contour gradient-based target tracking method
CN108256394A