Scale-invariant contour matching method, device and storage medium based on machine vision

By extracting multi-scale contour context descriptors and chord ratio and chord angle features, and combining clustering and random sampling consensus algorithms, the high computational complexity and insufficient robustness of contour matching methods under scale and rotation changes are solved, achieving efficient and accurate object localization.

CN122265666APending Publication Date: 2026-06-23HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU HUICUI INTELLIGENT TECH CO LTD
Filing Date
2026-05-28
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing contour matching methods struggle to achieve high-precision, real-time object recognition when faced with scale variations, rotational variations, complex background interference, and occlusion. They also suffer from high computational complexity and are prone to getting trapped in local optima.

Method used

By extracting multi-scale contour context descriptors and combining chord ratio and chord angle features, scale and rotation parameters are estimated. Then, by using cluster analysis and random sampling consensus algorithm to eliminate mismatches, joint estimation of scale and rotation is achieved.

Benefits of technology

It reduces computational complexity, achieves high-performance matching in real-time or near real-time, enhances robustness against occlusion and background interference, ensures geometric consistency and accuracy of localization results, and adapts to non-uniform scaling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122265666A_ABST
    Figure CN122265666A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of image detection, and discloses a scale-invariant contour matching method and device based on machine vision and a storage medium, the method comprising the following steps: extracting a target contour from a template and a query image and detecting key points; constructing a multi-scale contour context descriptor for each key point, the descriptor being composed of chord length ratios and chord angle features under multi-scale in a local neighborhood; performing feature matching, estimating scale and rotation transformation parameters according to chord length ratios and chord angles of a matched descriptor pair, and combining key point coordinates to calculate a translation parameter to generate a similarity transformation hypothesis; clustering all hypotheses as points in a high-dimensional parameter space to obtain candidate instances; for each candidate instance, fitting an accurate similarity transformation model and eliminating false matching by using a random sample consensus algorithm through matched point pairs associated with the candidate instance, and outputting final positioning parameters of a target object. The application realizes efficient, accurate and scale- and rotation-invariant contour matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image detection technology, specifically to a scale-invariant contour matching method, device, and storage medium based on machine vision. Background Technology

[0002] In applications such as industrial automation, robot guidance, quality inspection, and augmented reality, accurate, robust, and rapid identification and localization of predefined objects in images is a core technical requirement. Contour-based matching methods have become one of the mainstream solutions for object recognition due to their robustness to changes in lighting, missing textures, and local occlusion. Their basic principle is to use the geometric contour of an object as a feature template, searching for instances of objects with similar shapes in the target image and outputting their position coordinates and rotation angles. This type of method has been widely used in fields such as electronic component assembly, food sorting, and logistics package recognition.

[0003] However, real-world applications face numerous challenges. First, variations in the distance between the object and the camera, or the object's own size, can cause changes in its imaging scale within the image, meaning its size is not fixed. Second, the target object may appear at any position in the image and rotate at any angle. Furthermore, complex background interference, image noise, partial occlusion, and slight non-rigid deformations that may occur in the object are also key factors affecting recognition performance. Therefore, a practical contour matching method must maintain high matching accuracy while possessing scale invariance, rotation invariance, and robustness against noise and occlusion, while also meeting high processing speed requirements for real-time performance.

[0004] Existing contour matching methods mainly include shape context-based methods and gradient orientation pyramid-based template matching methods. The former estimates transformation parameters by calculating the shape context descriptors of contour points and performing point-to-point matching, but its high computational complexity makes it difficult to meet real-time requirements. The latter constructs a multi-scale image pyramid and performs a sliding window search in a four-dimensional space of position, scale, and rotation. The computational cost increases exponentially with the search dimension, especially when the scale range is large or the rotation search angle is wide, resulting in a significant speed bottleneck. Furthermore, both methods typically decouple the scale and rotation searches, making them prone to getting trapped in local optima, leading to missed detections or decreased local accuracy. They also have limited adaptability to nonlinear scale changes such as anisotropic scaling and complex geometric deformations. Summary of the Invention

[0005] The purpose of this invention is to provide a scale-invariant contour matching method, device, and storage medium based on machine vision to solve the problems mentioned in the background art.

[0006] According to one aspect of this application, a scale-invariant contour matching method based on machine vision is provided, comprising the following steps: Based on a template image, extracting a first contour of a target object in the template image; detecting multiple first key points from the first contour; and extracting a multi-scale contour context descriptor for each first key point to construct a template feature set; wherein the multi-scale contour context descriptor is constructed based on the chord ratio and chord angle features calculated under multiple preset scale parameters within the local contour neighborhood of the first key point; Based on a query image, extracting a second contour of the target object in the query image; detecting multiple second key points from the second contour; and extracting the multi-scale contour context descriptor for each second key point to construct a query feature set; and matching each descriptor in the query feature set with the template feature set. The descriptors in the template space are matched. For each successfully matched descriptor pair, the scaling transformation parameters and rotation transformation parameters are estimated based on the corresponding chord ratio and chord angle features. Combined with the coordinates of the first key point and the second key point, the translation transformation parameters are calculated to generate a similarity transformation hypothesis representing the transition from the template space to the query space. The generated similarity transformation hypotheses are then used as points in a multidimensional parameter space for cluster analysis to obtain at least one cluster center, with each cluster center representing a candidate target instance. For each candidate target instance, all descriptor pairs supporting its corresponding cluster center and their associated first and second key points are obtained. Based on these key point pairs, a similarity transformation model is fitted using a random sampling consensus algorithm, and mismatches are eliminated to obtain the target object positioning parameters.

[0007] Preferably, extracting the multi-scale contour context descriptor for a key point includes: taking the key point as the center, extracting a relative arc length neighborhood before and after the key point along its contour; within the relative arc length neighborhood, resampling at fixed normalized arc length intervals to obtain a local contour point set; for each preset scale parameter, calculating the chord vector of each sampled point in the local contour point set relative to the key point; calculating the chord length ratio feature based on the ratio of the magnitude of the chord vector to the current total contour length and the preset scale parameter; calculating the chord angle feature based on the angle between the chord vector and the contour tangent vector at the key point; and combining and normalizing all the chord length ratio features and chord angle features obtained under each preset scale parameter in a predetermined order to form the multi-scale contour context descriptor.

[0008] Preferably, estimating the scale transformation parameter for a successfully matched descriptor pair includes: comparing the matching degree between the chord ratio feature subsets corresponding to different preset scale parameters in the descriptor pair; and taking the preset scale parameter with the highest matching degree as the preliminary estimate of the scale transformation parameter.

[0009] Preferably, estimating the rotation transformation parameters for a successfully matched descriptor pair includes: calculating the difference in the chord angle features of all corresponding sampling points in the descriptor pair; statistically analyzing the distribution of the difference, and using its principal modulus as a preliminary estimate of the rotation transformation parameters.

[0010] Preferably, the hypothetical clustering is specifically based on the mean-shift clustering algorithm, wherein each of the similarity transformation hypotheses is accompanied by a weight, which is determined based on the matching similarity of its corresponding descriptor pair and the degree of consistency of the estimated rotation transformation parameters among the sampling points within the descriptor pair.

[0011] Preferably, the random sampling consensus algorithm fits the similarity transformation model, and its minimum sampling set is two pairs of matching key points. Specifically, it includes: randomly selecting two pairs of points from the matching point pairs corresponding to the cluster center to solve the similarity transformation model; calculating the projection error of the remaining matching point pairs under the model; retaining the matching point pairs with projection errors less than a preset threshold as interior points; and refitting the final similarity transformation model using all interior points through the least squares method.

[0012] In another aspect, this application also provides a scale-invariant contour matching system based on machine vision, comprising: a template feature construction module, configured to extract a first contour of a target object in a template image based on a template image, detect multiple first key points from the first contour, and extract a multi-scale contour context descriptor for each first key point to construct a template feature set; wherein the multi-scale contour context descriptor is constructed based on the chord ratio feature and chord angle feature calculated under multiple preset scale parameters within the local contour neighborhood of the first key point; a query feature construction module, configured to extract a second contour of a target object in a query image based on a query image, detect multiple second key points from the second contour, and extract the multi-scale contour context descriptor for each second key point to construct a query feature set; and a matching module, configured to match each descriptor in the query feature set with the first key point. The template feature set descriptors are matched. For each successfully matched descriptor pair, the scaling transformation parameters and rotation transformation parameters are estimated based on the corresponding chord ratio feature and chord angle feature. Combined with the coordinates of the first key point and the second key point, the translation transformation parameters are calculated to generate a similarity transformation hypothesis representing the transition from the template space to the query space. The clustering module is used to perform clustering analysis on the generated multiple similarity transformation hypotheses as points in a multidimensional parameter space to obtain at least one cluster center. Each cluster center represents a candidate target instance. The output module is used to obtain all the descriptor pairs that support the corresponding cluster center and their associated first key point and second key point for each candidate target instance. Based on these key point pairs, a similarity transformation model is fitted using a random sampling consensus algorithm, and mismatches are eliminated to obtain the target object positioning parameters.

[0013] This application also provides a computer device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the machine vision-based scale-invariant contour matching method as described above.

[0014] In another aspect, this application provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor to implement the machine vision-based scale-invariant contour matching method as described above.

[0015] In another aspect of this application, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the scale-invariant contour matching method based on machine vision as described above.

[0016] This application significantly reduces computational complexity in the four-dimensional space of position, scale, and rotation by extracting local contour descriptors jointly encoded by scale and rotation information, and transforming the global dense search into hypothesis generation and parameter space clustering based on feature matching, thus achieving high-performance matching in real-time or near real-time. The descriptor and matching mechanism achieve joint optimal estimation of scale and rotation parameters, avoiding suboptimal solutions that may be caused by traditional decoupled search. At the same time, the characteristics of local features enhance robustness to occlusion and background interference. Combined with subsequent weighted clustering and random sampling consistency verification, false matches are effectively eliminated, ensuring the geometric consistency and accuracy of the final localization result. Based on the feature neighborhood definition and multi-scale description of relative arc length, the method has a certain adaptability to non-uniform scaling of object imaging. The overall framework is flexible and can adapt to more complex affine or perspective transformations by extending the descriptor and geometric model. Attached Figure Description

[0017] Figure 1 A schematic diagram of a scale-invariant contour matching method based on machine vision provided in an embodiment of the present invention; Figure 2 A visual schematic diagram of key point detection provided in the embodiments of this disclosure; Figure 3 A schematic diagram of the multi-scale contour context (MSCC) extraction process provided in the embodiments of this disclosure; Figure 4 A visual flowchart illustrating the MSCC extraction process provided in this embodiment of the disclosure; Figure 5 This is a schematic diagram of the similarity transformation hypothesis generation process provided in the embodiments of this disclosure; Figure 6 A schematic diagram illustrating the principle of generating geometric hypotheses through single-pair feature matching in an embodiment of this disclosure; Figure 7 This is a visual diagram illustrating the clustering process provided in an embodiment of the present disclosure; Figure 8 A visualization diagram of a RANSAC-based fitting model provided in an embodiment of this disclosure; Figure 9 A schematic diagram of a scale-invariant contour matching system based on machine vision is provided in an embodiment of the present invention. Figure 10 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] It should be noted that all user information (including but not limited to user device information, user personal information, object information corresponding to device usage data, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, device usage data, etc.) involved in all embodiments of this disclosure are information and data authorized by the user or fully authorized by all parties.

[0020] According to one aspect of the present invention, embodiments of the present invention provide a scale-invariant contour matching method based on machine vision. This method is particularly suitable for scenarios in fields such as industrial automation, robot guidance, quality inspection, and augmented reality, where there are complex backgrounds, varying lighting, partial occlusion, and the target object may exhibit arbitrary rotation angles and different imaging scales (i.e., size variations). In some application scenarios, the target object may also undergo slight affine deformation or anisotropic scaling. This method, through an innovative local contour feature descriptor and a matching framework based on hypothesis generation and verification, can efficiently, accurately, and robustly achieve the detection and localization of target objects, and is especially suitable for online vision systems with high real-time or near-real-time requirements.

[0021] This method requires basic image acquisition equipment such as industrial cameras, image processing units such as industrial control computers, embedded processors or GPUs, and corresponding algorithm implementation environments such as computer vision libraries. A prerequisite for implementing this method is that the target object possesses clear, stable, and extractable contour features in both the template image and the query image. The template image is typically a clear image of the target object at a known pose and "unit scale." In some embodiments, to improve the contour extraction quality, appropriate preprocessing, such as Gaussian filtering for noise reduction, can be applied to the image. The implementation process of the method will be described in detail below, combining each technical step.

[0022] like Figure 1As shown in the figure, an embodiment of the present invention discloses a schematic diagram of a scale-invariant contour matching method based on machine vision, including the following steps: S1, based on a template image, extracting a first contour of a target object in the template image, detecting multiple first key points from the first contour, and extracting a multi-scale contour context descriptor for each first key point to construct a template feature set; wherein, the multi-scale contour context descriptor is composed of chord ratio features and chord angle features calculated based on multiple preset scale parameters within the local contour neighborhood of the first key point; S2, based on a query image, extracting a second contour of a target object in the query image, detecting multiple second key points from the second contour, and extracting the multi-scale contour context descriptor for each second key point to construct a query feature set; S3, matching each descriptor in the query feature set with the template. The descriptors in the feature set are matched. For each successfully matched descriptor pair, the scaling transformation parameters and rotation transformation parameters are estimated based on the corresponding chord ratio feature and chord angle feature. Combined with the coordinates of the first key point and the second key point, the translation transformation parameters are calculated to generate a similarity transformation hypothesis representing the transition from the template space to the query space. S4, the generated multiple similarity transformation hypotheses are used as points in a multidimensional parameter space for cluster analysis to obtain at least one cluster center. Each cluster center represents a candidate target instance. S5, for each candidate target instance, all the descriptor pairs that support its corresponding cluster center and their associated first key point and second key point are obtained. Based on these key point pairs, a similarity transformation model is fitted using a random sampling consensus algorithm, and mismatches are eliminated to obtain the target object positioning parameters.

[0023] In some embodiments, step S1 is an offline processing procedure aimed at establishing a unique and discriminative feature representation for the target object to be matched. According to embodiments of this disclosure, this specifically includes first contour extraction, first keypoint detection, multi-scale contour context (MSCC) descriptor extraction, and template feature set construction.

[0024] Specifically, first, a template image containing the target object is obtained. Specifically, edge detection algorithms such as Canny, Sobel, or Sobel variants can be used to extract the contour of the target object from the template image. Since real-world images may contain noise, texture, or discontinuous edges, in some embodiments, after edge detection, the extracted edges can be post-processed, such as smoothing, connecting breakpoints, and removing small noise areas, ultimately resulting in one or more ordered sequences of contour points.

[0025] Preferably, polygon approximation algorithms such as the Douglas-Peucker algorithm can be used to further simplify the contour, reducing the number of contour points while preserving the main geometric shape, thereby reducing the computational complexity in subsequent calculations. For isolated target objects, a closed contour line can usually be obtained. Assuming the final target object contour is the first contour, its point sequence is denoted as... ,in These are the pixel coordinates of the contour points in the image plane.

[0026] Next, key point detection is performed. Specifically, starting from the first contour... Multiple highly discriminative points, known as first key points, are detected. These key points are typically points where the geometric properties of the contour change significantly. According to one embodiment of this disclosure, the first key points may be selected from curvature extrema or inflection points on the contour. For a discrete contour point sequence, each point can be calculated... The curvature is estimated by the discrete curvature of the keypoint. A common method is to fit a local arc based on several contour points in the neighborhood of the keypoint or to calculate it using the cross product of the vectors formed by the keypoint and its neighbors. Curvature extrema correspond to the points with the greatest curvature on the contour, such as sharp corners, the midpoints of arcs, or the turning points of flat areas, and have good characterization for different shapes. Inflection points are the points where the sign of curvature changes, which also reflect significant changes in the shape of the contour. After detecting curvature extrema or inflection points, points with excessively small absolute curvature values ​​or overly dense neighborhoods can be filtered out to ensure the stability and representativeness of the keypoints. Let the first set of keypoints finally detected be denoted as . Each key point Besides coordinate information In addition, its unit tangent vector at that point is also recorded. The tangent vector can be obtained by calculating the difference vectors of adjacent contour points before and after the key point and then normalizing them.

[0027] For example, please refer to Figure 2 , Figure 2 This is a visual schematic diagram illustrating keypoint detection provided in an embodiment of this disclosure. Figure 2 In the image, (a) is the template image, (b) is the contour and key points extracted based on the template image, and (c) is a magnified view of the local coordinate system of the key points.

[0028] According to embodiments of this disclosure, please refer to Figure 3 and Figure 4 , Figure 3 This is a schematic diagram of the multi-scale contour context (MSCC) extraction process provided in the embodiments of this disclosure. Figure 4This is a schematic diagram of the visualization process for MSCC extraction provided in this embodiment of the disclosure. This step is an offline processing procedure aimed at constructing a local contour feature that is invariant or explicitly encoded by scale scaling and rotation transformations. Exemplarily, it specifically includes the following steps: S301: Determine the local contour neighborhood. Specifically, using key points... Taking the origin as the reference point, a neighborhood is extracted along the first contour containing the origin in both the forward and backward directions. The length of this neighborhood is not a fixed pixel value, but is defined using a relative arc length. According to an embodiment of this disclosure, a relative arc length ratio can be selected as... ,For example Then take the point on the contour. Forward (along the positive direction of the profile) total arc length The point, and the total arc length backward (along the negative direction of the contour). The point is used as the boundary of the neighborhood. For the first outline The total length. This neighborhood definition method based on relative arc length allows the neighborhood range to adapt to the overall size of the contour.

[0029] S302: Local contour resampling. Specifically, within the determined relative arc length neighborhood, the original sequence of contour points may be unevenly distributed. Resampling is required to obtain a regular feature representation. According to embodiments of this disclosure, resampling is performed at fixed normalized arc length intervals. Uniform sampling is performed. The normalized arc length interval... It is relative to the total length of the outline. The proportion, for example By key points Within the immediate vicinity of the contour, samples are taken along the contour at fixed intervals to obtain an ordered set of local contour sampling points, denoted as . Among them, points The arc length of the arc itself is denoted as 0, and the arc length of the arc in front of it is denoted as 0. sampling points The relative arc length is , From arrive The contour arc length (positive for positive, negative for negative). Resampling ensures that the number of sampling points in the neighborhood of each keypoint and their relative position distribution on the contour are normalized, regardless of the original contour resolution.

[0030] S303: Multi-scale feature calculation. Specifically, this involves calculating two key features: chord length ratio and chord angle, and performing the calculation under multiple preset scale parameters. A set of scale parameters is defined. ,in For example, you can set ,Right now These parameters represent multiple observation scales relative to the template's "unit scale." For each preset scale parameter... and local contour sampling point set Each sampling point in (including key points) (Itself), perform the following operations: First, calculate the chord vector. This is from the key point. Pointing to sampling point The vector. Secondly, calculate the chord length ratio feature. : ;in, It is the magnitude of the chord vector, i.e., the Euclidean distance. The ratio of chord lengths... The meaning is: at the current observation scale Below, the ratio of the local chord length to the overall size of the contour. If the object in the query image is a template... Times, then on the scale The calculated template chord ratio should theoretically be the same as that calculated on scale. The calculated chord length ratio of the query image is matched. Therefore, by different By calculating and comparing the chord length ratios, information about scale changes can be inferred. Next, calculate the chord angle feature. : ;in, This is the key point. The unit tangent vector at that location (which has been calculated in the aforementioned embodiments). This indicates the calculation of the angle between two vectors, and the range of values ​​is usually [value missing]. or chord angle It encodes the geometric orientation of a local contour segment relative to the tangent direction of the keypoint. When the entire object rotates, the tangent vector at the keypoint... Chord vectors They will rotate synchronously by the same angle, therefore the chord angle The difference directly reflects the rotation angle. .

[0031] S304: Descriptor vector construction. Specifically, after S303, for each keypoint... This yields a three-dimensional data block: for Each scale parameter and Local sampling points (including) itself, Each point has a chord length ratio at each scale. At the same time, each point also has a chord angle. (Scale-independent). According to embodiments of this disclosure, these features are arranged and flattened in a predetermined order to form a one-dimensional feature vector. One possible arrangement order is: first, fix a scale parameter. Iterate through all local sampling points and compare their chord lengths. Arrange them sequentially; then arrange the chord angles of all local sampling points. Then for the next scale parameter Repeat the above process until all The scale parameters have been processed. The resulting original feature vector has a dimension of [dimensionality missing]. To eliminate dimensional differences and improve numerical stability, the original eigenvector is normalized. Specifically, the mean and standard deviation of the vector can be calculated, followed by zero-mean, unit-variance standardization (Z-score normalization). .

[0032] Normalized vector This is the key point. A multi-scale contour context (MSCC) descriptor. It can also store auxiliary information corresponding to this descriptor, including keypoint coordinates. The set of relative arc lengths of local sampling points and the reference chord set used in template calculation. (i.e., the calculation here) This supplementary information will be used in subsequent hypothesis generation steps.

[0033] Then, iterate through all the first key points. Perform the above steps for each keypoint to obtain its MSCC descriptor and auxiliary information. Organize this information from all keypoints to form a template feature set. . It can be a data structure such as a list or a database, where each record corresponds to a template key point, including fields such as descriptor vectors. Image coordinates Lists of relative arc lengths, lists of reference chord angles, etc.

[0034] In some embodiments, step S3 is an online processing procedure, similar to the offline processing procedure, with the aim of extracting features comparable to a template from the query image acquired in real time. According to embodiments of this disclosure, this specifically includes second contour extraction, second keypoint detection, MSCC descriptor extraction, and query feature set construction.

[0035] Specifically, similar to S301, an edge detection algorithm is used to extract edges from the image, and post-processing is performed to obtain one or more sets of contours. The query image may contain target objects, background clutter, and other objects. Assume the set of all extracted contours is... For each contour, it is treated as a potential target contour for subsequent processing.

[0036] For each contour extracted from the query image The same method as S302 is used to detect key points, i.e., second key points. For example, the same method is used to detect curvature extrema or inflection points, and the unit tangent vector at each key point is calculated. Let the set of second key points detected from all contours be denoted as . .

[0037] For each second keypoint in the query image The MSCC descriptor is extracted using the exact same procedure as S303. It should be noted that the calculation of the chord length ratio... When, in the formula This should be the current critical point. Outline Total length In calculating the chord angle At that time, key points were used. Its own tangent vector Ultimately, for each second key point Generate its MSCC descriptor And also record its coordinates. Relative arc length of local sampling points and the calculated chord angle The descriptors and auxiliary information of all second key points constitute the query feature set. .

[0038] In some embodiments, step S4 aims to efficiently transform the high-dimensional feature matching problem into a hypothesis generation problem in the geometric parameter space, thereby avoiding the huge overhead of exhaustive search in the four-dimensional space of position, scale, and rotation in traditional methods.

[0039] First, for the query feature set Each descriptor in It is necessary to use the template feature set The process involves finding the most similar descriptor among the given elements. This is essentially a nearest neighbor search problem. According to embodiments of this disclosure, efficient approximate nearest neighbor search algorithms, such as KD-Tree-based search, locality-sensitive hashing, or the FLANN library, can be employed to accelerate the matching process. Specifically, for each... ,from Find the first pair of elements with the smallest Euclidean distance or cosine similarity. 10 descriptors are used as candidate matches. It can be set to 1 or a smaller number such as 3. Each pair Form a candidate descriptor pair, where From The corresponding template key points are .

[0040] For each successful candidate descriptor pair We need to estimate a similarity transformation hypothesis from the template space to the query space. This process makes full use of the geometric information encoded in the MSCC descriptor.

[0041] Specifically, please refer to Figure 5 and Figure 6 , Figure 5 This is a schematic diagram of the similarity transformation hypothesis generation process provided in the embodiments of this disclosure. Figure 6 For single-pair feature matching Generative geometric hypothesis The schematic diagram.

[0042] First, in S501, estimate the scaling transformation parameters. According to a preferred embodiment of this disclosure, the estimation of the scaling parameters is based on the chord length ratio feature in the descriptor. Specifically, for a matched descriptor pair... All of them include Preset scale parameters The calculated chord length ratio feature subset. Theoretically, if the query object is a template... If the template is 1 times larger, then the template size is... The chord length ratio feature should be compared with the query image in terms of scale. The feature that best matches is the descriptor. Since the descriptor is a set of discrete... The calculation is performed below, so it is possible to compare two descriptors under different conditions. Inferring from the degree of matching on subsets According to one embodiment of this disclosure, the following steps can be taken: Subset extraction: from descriptors... and In the process, the parameters corresponding to each scale are extracted respectively. The chord length is proportional to the eigenvector. Let be... For the corresponding scale in the template descriptor The subvector composed of all chord length ratio features Similarly.

[0043] Similarity calculation: Calculate the sub-vectors of the template descriptor at each scale. Subvectors of query descriptors at various scales The similarity between them, for example, by calculating the negative Euclidean distance or cosine similarity, yields a... The similarity matrix.

[0044] Parameter estimation: Analyze the similarity matrix. Ideally, when hour, and They should be highly similar. Therefore, find the element with the highest similarity in the matrix and its corresponding row index. and column indexes Satisfying Relationships Since the template is registered at a "unit scale," its scale parameter can be considered to be 1. Therefore, a simplified estimate is: directly find the... The one with the highest overall match The corresponding scale parameters and use it as a scaling parameter. Preliminary estimate ,Right now This method is based on the assumption that the ratio of the object scale to the template scale in the query image will make the chord length ratio distribution of the query descriptor most closely approximate that of the template at a certain point. The distribution below.

[0045] In S502, the rotational transformation parameters are estimated. According to a preferred embodiment of this disclosure, the estimation of rotation transformation parameters is based on the chord angle features in the descriptor. Specifically, for a matched descriptor pair... Each of them stores the chord angle corresponding to its local sampling point. and Since the descriptor matched successfully, it means there are two key points. and And their local neighborhoods are geometrically corresponding. Therefore, corresponding sampling points (i.e., those with the same relative arc length) The sampling points, due to resampling normalization, can be considered as indexes. The difference in chord angles (corresponding to each other) should be approximately equal to the rotation angle of the entire object. According to embodiments of this disclosure, the following steps can be taken: Calculate the difference: for all corresponding sampling point indices in the descriptor pair Calculate the difference in chord angles. Because angle calculations may have periodic issues, such as... arrive Angle normalization is required to ensure the difference is within a reasonable continuous range, for example, through a function. To calculate.

[0046] Statistical principal model: the calculated Fluctuations may occur due to local deformation, noise, or matching errors. To obtain robust estimates, statistics on all... For example, constructing a histogram based on the distribution of points. This is because correct matching pairs of points are generated. The values ​​should cluster around the true rotation angle, while erroneous or noise points will be more dispersed. Therefore, the dominant modulus of this distribution, i.e., the most frequently occurring value or the peak value obtained through kernel density estimation, is used as the rotation transformation parameter. Preliminary estimate .

[0047] In S503, calculate the translation transformation parameters. In obtaining the scaling estimate and rotation estimation Then, combine the key points of the template. coordinates and query key points coordinates The translation transformation parameters can be calculated directly. The formula for similarity transformation is: ;in, It is a rotation matrix. Therefore, the translation parameters can be calculated using the following formula: .

[0048] Thus, the similarity transformation hypothesis is generated. .

[0049] According to embodiments of this disclosure, in order to distinguish between reliable and unreliable hypotheses in subsequent cluster analysis, each generated hypothesis can be... Assign a weight Preferably, the weight is based on two factors: the matching similarity of the descriptor pairs. And the degree of consistency of the estimated rotation transformation parameters among the sampling points within the descriptor pair. .

[0050] Matching similarity The distance or similarity score obtained by the approximate nearest neighbor search in the aforementioned embodiments can be used directly. For example, the inverse of the distance or the value transformed by the exponential function can be used so that the higher the similarity, the greater the weight contribution.

[0051] Consistency It can be estimated. The difference of the chord angle between each sampling point The variance or standard deviation is used to measure this. A smaller variance indicates more consistent rotation angle estimates across all sampling points, suggesting a more reliable hypothesis and a greater contribution from the weights. The final weights can be the product or weighted sum of these two factors, for example: ;in, It describes the Euclidean distance between sub-pairs. It is the variance of the chord angle difference. By introducing weights, the subsequent clustering process can be more inclined to assume those hypotheses generated by high-quality, highly consistent matching.

[0052] According to embodiments of this disclosure, due to mismatches, noise, and multiple instances of the target object, the aforementioned embodiments generate a large number of similarity transformation hypotheses scattered throughout the parameter space. The purpose of this step is to aggregate these hypotheses that belong to the same instance of the target object.

[0053] Specifically, first, a parameter space point set is constructed. Specifically, all generated similarity transformation hypotheses are... and their corresponding weights This is considered as a weighted set of points in a four-dimensional parameter space. The four-dimensional parameters are scale, etc. Rotation Horizontal translation Vertical translation It is important to note that, due to the different physical meanings and dimensions of the parameters (scale is dimensionless, angle is in radians, and translation is in pixels), it is usually necessary to normalize the parameter space or set appropriate bandwidths for different dimensions before performing clustering, so that the clustering algorithms are comparable across dimensions.

[0054] Next, preferably, mean-shift clustering is used. Mean-shift clustering is a non-parametric clustering algorithm based on kernel density estimation, which can automatically find the mode (peak) of the data distribution without pre-specifying the number of clusters. For weighted point sets, the processing procedure is as follows: Initialize the bandwidth matrix. The bandwidth matrix determines the range of influence of the kernel function. For four-dimensional space, it can be set as a diagonal matrix. The choice of bandwidth is related to the data distribution density and can be set empirically or adaptively through algorithms. For example, scale bandwidth... It can be set to one-tenth of the expected scale variation range, angular bandwidth. It can be set to the radian value corresponding to a certain number of degrees, and the translation bandwidth. It can be set as a portion of the object's expected size.

[0055] Choose a kernel function: The Gaussian kernel function is typically used. For points... and nuclear center The Gaussian kernel function is: .

[0056] Iterative mean shift process: The algorithm starts with each data point (or a random seed point) as the initial cluster center. Then iteratively execute the following steps until convergence (the movement distance of the center point is less than a preset threshold): Calculate the current center... The weighted mean shift vector for a point set. Its mean shift vector It is given by the following formula: .

[0057] Update cluster centers: .

[0058] Clustering convergence and merging: Center points converged from different initial points are merged into the same cluster if the distance between them is less than a merging threshold. Ultimately, each independent convergence center... Considered as a cluster center, it represents a coarse parameter estimate of a candidate target instance. .

[0059] Association Hypothesis and Clustering: Record all clusters that eventually converge to the same cluster center. The original assumption point The descriptor pairs and keypoint pairs corresponding to these hypothetical points constitute the matching evidence supporting the candidate instance.

[0060] like Figure 7 As shown, Figure 7 This is a visualization diagram of the clustering process provided in the embodiments of this disclosure, that is, in a four-dimensional parameter space. In this study, the distribution of hypothetical points and the mean-shift clustering process are discussed. Mean-shift clustering automatically identifies densely distributed regions in the parameter space generated by real target instances from noisy hypotheses, while filtering out isolated and scattered hypotheses caused by mismatches.

[0061] in, Figure 7 In the diagram, (a) shows all the generative hypotheses in the location parameter space. The distribution in the image. Multiple dense clusters appear in the image, such as in the middle and right side, each representing a possible location of a candidate target instance, while scattered isolated points are mainly caused by mismatches; (b) shows the same set of hypotheses in the scale-rotation space. The distribution within. Where the horizontal axis represents the scale. The vertical axis represents the rotation angle. As can be seen in the figure, the points are assumed to be mainly clustered in the vicinity of a scale of approximately 1.0 and an angle of approximately 45° and -45°, which corresponds to the actual scale and orientation of the target object in the query image.

[0062] Despite numerous noisy assumptions, correct assumptions about real object instances will form distinct dense clusters in the joint parameter space of position, scale, and rotation. This invention utilizes clustering algorithms such as mean shift to automatically identify these dense clusters as candidate instances, thereby effectively filtering out noise and achieving robust detection.

[0063] In some embodiments, for step S5, the clustering step provides candidate instances and their supporting matching point pairs, but may still contain some mismatches. This step aims to eliminate these mismatches through a rigorous geometric consistency check and to fit more accurate transformation parameters based on the interior points.

[0064] Specifically, for each cluster center For each candidate target instance, obtain all descriptor pairs that support the clustering. Each descriptor pair corresponds to a pair of matching keypoints: template keypoints. and query key points Let the set of these key point pairs be denoted as... .

[0065] Preferably, the Random Sample Consensus (RANSAC) algorithm is used to fit the similarity transformation model and eliminate false matches. See also... Figure 8 , Figure 8 This is a visualization diagram of a RANSAC-based fitting model provided in an embodiment of this disclosure, wherein... Figure 8 In the diagram, (a) is the original image, (b) is the RANSAC iteration, and (c) is the final model.

[0066] Specifically, the model to be fitted is a two-dimensional similarity transformation model, and its parameters are: The model will take a point Mapped to The transformation formula is as described above. Solving the similarity transformation model requires at least two pairs of matching points. Because the similarity transformation has four degrees of freedom (scale, rotation, translation x, translation y), and a pair of points provides two equations (one for x coordinate and one for y coordinate), two pairs of non-collinear points can uniquely determine a set of similarity transformation parameters.

[0067] The RANSAC iterative process is as follows: Random sampling: from the set of matching points Two pairs of points are randomly selected as the interior point hypothesis set. To ensure numerical stability, pairs of points that are too close or highly collinear should be avoided.

[0068] Model calculation: Using these two pairs of points, a system of equations is constructed according to the similarity transformation formula, and the model parameters are directly solved. This can be solved by constructing a system of linear equations or by using geometric methods.

[0069] Calculation error and statistical interior points: For Each remaining pair of points Use the current temporary model to set its template points Transform to the query image space to obtain the predicted points. Then calculate the predicted point and the actual query point. Euclidean distance between If the error Less than the preset threshold For example, if the value is set to 2-5 pixels, which can be adjusted according to the image resolution and positioning accuracy requirements, then the point pair is considered to be an interior point of the current model.

[0070] Update the optimal model: Record the number of interior points corresponding to the current model. In multiple iterations, retain the model with the largest number of interior points and its corresponding set of interior points.

[0071] Iteration Termination: Set a maximum number of iterations, such as 2000, or dynamically calculate the required number of iterations based on the proportion of interior points in the current optimal model, and terminate when the maximum number of iterations is reached.

[0072] After the RANSAC iterations, the set of all interior points corresponding to the model with the largest number of interior points is selected. Using this set of interior points, the final similarity transformation model is refitted using the least squares method. The least squares method can effectively utilize the information of all interior points, obtaining more accurate and stable parameter estimates than using only two pairs of points. The least-squares fitting of similarity transformations can be transformed into a linear problem to be solved.

[0073] The final fitted similarity transformation parameters The output is the precise location, angle, and scale information of the candidate target instance. If multiple cluster centers exist, the above steps are repeated for each cluster center to output the localization results of multiple target instances.

[0074] The RANSAC step effectively resists outliers (outside points) in the matching set, which can account for a certain percentage (e.g., 50%), ensuring the geometric correctness and high accuracy of the final localization result.

[0075] This disclosure encodes scale and rotation information simultaneously in a local descriptor by defining a neighborhood based on relative arc length, extracting multi-scale chord ratio and chord angle features. Leveraging the characteristics of the MSCC descriptor, it directly and efficiently estimates the complete four-dimensional similarity transformation hypothesis from a pair of matching features, transforming the matching problem from a dense search in image space to parameter generation in feature space, significantly improving efficiency. Clustering weighted hypotheses in the four-dimensional parameter space robustly aggregates multiple weak pieces of evidence belonging to the same object instance, while suppressing isolated hypotheses generated by noise and mismatches. Introducing weights enhances the clustering's tendency towards high-quality matching. Based on the candidate instances and matching point pairs provided by clustering, rigorous geometric consistency verification is performed using RANSAC, ultimately eliminating mismatches and fitting high-precision transformation parameters.

[0076] Please see Figure 9 , Figure 9 A scale-invariant contour matching system 700 based on machine vision is provided for embodiments of the present invention. This system embodiment is similar to... Figure 1Corresponding to the illustrated method embodiment, this system can be specifically applied to various computer devices. The system specifically includes: a template feature construction module 901, used to extract a first contour of a target object from a template image, detect multiple first key points from the first contour, and extract a multi-scale contour context descriptor for each first key point to construct a template feature set; wherein the multi-scale contour context descriptor is composed of chord ratio and chord angle features calculated based on the local contour neighborhood of the first key point under multiple preset scale parameters; a query feature construction module 902, used to extract a second contour of a target object from a query image, detect multiple second key points from the second contour, and extract the multi-scale contour context descriptor for each second key point to construct a query feature set; and a matching module 903, used to match each descriptor in the query feature set with the descriptors in the template feature set. Row matching: For each successfully matched descriptor pair, based on its corresponding chord ratio feature and chord angle feature, the scaling transformation parameter and rotation transformation parameter are estimated, and combined with the coordinates of the first key point and the second key point, the translation transformation parameter is calculated, thereby generating a similarity transformation hypothesis representing the transition from the template space to the query space; Clustering module 904: Used to perform cluster analysis on the generated multiple similarity transformation hypotheses as points in a multidimensional parameter space to obtain at least one cluster center, each cluster center representing a candidate target instance; Output module 905: For each candidate target instance, used to obtain all the descriptor pairs supporting its corresponding cluster center and their associated first key point and second key point, and based on these key point pairs, fit a similarity transformation model through a random sampling consensus algorithm, and eliminate mismatches to obtain the target object positioning parameters.

[0077] Based on the same inventive concept, this application also provides a computer device, the method corresponding to which can be the method in the foregoing embodiments, and the principle of solving the problem is similar to that method. The computer device provided in this application includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute the methods and / or technical solutions of the foregoing embodiments of this application.

[0078] The computer device can be a user device, or a device formed by integrating user devices and network devices through a network, or it can be an application running on the aforementioned devices. The user device includes, but is not limited to, various terminal devices such as computers, mobile phones, tablets, smartwatches, and smart bands. The network device includes, but is not limited to, network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, and can be used to implement some processing functions when setting an alarm clock. Here, the cloud consists of a large number of hosts or network servers based on cloud computing. Cloud computing is a type of distributed computing, consisting of a virtual computer composed of a group of loosely coupled computer sets.

[0079] Figure 10 The diagram illustrates the structure of an apparatus suitable for implementing the methods and / or technical solutions in the embodiments of this application. The apparatus 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage portion 1008 into a random access memory (RAM) 1003. The RAM 1003 also stores various programs and data required for system operation. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0080] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, touchscreen, microphone, infrared sensor, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), LED display, OLED display, etc., and speakers, etc.; a storage section 1008 including one or more computer-readable media such as hard disk, optical disk, magnetic disk, semiconductor memory, etc.; and a communication section 1009 including a network interface card such as a LAN (local area network) card, modem, etc. The communication section 1009 performs communication processing via a network such as the Internet.

[0081] In particular, the methods and / or embodiments in this application can be implemented as computer software programs. For example, the embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 1001, it performs the functions defined in the methods of this application.

[0082] Another embodiment of this application provides a computer-readable storage medium having computer program instructions stored thereon, which can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of this application described above.

[0083] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0084] The flowcharts or block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-specific system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0085] Furthermore, the inclusion of a single word does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any particular order.

Claims

1. A scale-invariant contour matching method based on machine vision, characterized in that, include: Based on a template image, a first contour of the target object is extracted from the template image. Multiple first key points are detected from the first contour, and a multi-scale contour context descriptor is extracted for each first key point to construct a template feature set. The multi-scale contour context descriptor is constructed based on the chord ratio and chord angle features calculated under multiple preset scale parameters within the local contour neighborhood of the first key point. Based on a query image, a second contour of the target object is extracted from the query image. Multiple second key points are detected from the second contour, and the multi-scale contour context descriptor is extracted for each second key point to construct a query feature set. Each descriptor in the query feature set is matched with a descriptor in the template feature set, and a new descriptor is generated for each successfully matched descriptor. For each descriptor pair, based on its corresponding chord ratio and chord angle features, the scaling and rotation transformation parameters are estimated. Combined with the coordinates of the first and second key points, the translation transformation parameters are calculated, thereby generating a similarity transformation hypothesis representing the transition from the template space to the query space. The generated similarity transformation hypotheses are then used as points in a multidimensional parameter space for cluster analysis to obtain at least one cluster center, each representing a candidate target instance. For each candidate target instance, all descriptor pairs supporting its corresponding cluster center and their associated first and second key points are obtained. Based on these key point pairs, a similarity transformation model is fitted using a random sampling consensus algorithm, and mismatches are eliminated to obtain the target object positioning parameters.

2. The scale-invariant contour matching method based on machine vision according to claim 1, characterized in that, Extracting the multi-scale contour context descriptor for key points includes: taking the key point as the center, extracting a relative arc length neighborhood before and after the key point along its contour; within the relative arc length neighborhood, resampling at fixed normalized arc length intervals to obtain a local contour point set; for each preset scale parameter, calculating the chord vector of each sampled point in the local contour point set relative to the key point; calculating the chord length ratio feature based on the ratio of the magnitude of the chord vector to the current total contour length and the preset scale parameter; calculating the chord angle feature based on the angle between the chord vector and the contour tangent vector at the key point; and combining and normalizing all the chord length ratio features and chord angle features obtained under each preset scale parameter in a predetermined order to form the multi-scale contour context descriptor.

3. The scale-invariant contour matching method based on machine vision according to claim 2, characterized in that, Estimating the scale transformation parameter for a successfully matched descriptor pair includes: comparing the matching degree between the chord ratio feature subsets corresponding to different preset scale parameters in the descriptor pair; and taking the preset scale parameter with the highest matching degree as the preliminary estimate of the scale transformation parameter.

4. The scale-invariant contour matching method based on machine vision according to claim 2, characterized in that, Estimating the rotation transformation parameters for a successfully matched descriptor pair includes: calculating the difference in the chord angle features of all corresponding sampling points in the descriptor pair; statistically analyzing the distribution of the difference, and using its principal modulus as a preliminary estimate of the rotation transformation parameters.

5. The scale-invariant contour matching method based on machine vision according to claim 4, characterized in that, The hypothetical clustering is specifically based on the mean-shift clustering algorithm, wherein each of the similarity transformation hypotheses is accompanied by a weight, which is determined based on the matching similarity of its corresponding descriptor pair and the degree of consistency of the estimated rotation transformation parameters among the sampling points within the descriptor pair.

6. The scale-invariant contour matching method based on machine vision according to claim 1, characterized in that, The random sampling consensus algorithm fits the similarity transformation model. Its minimum sampling set consists of two pairs of matching key points. Specifically, it involves randomly selecting two pairs of points from the matching point pairs corresponding to the cluster centers to solve the similarity transformation model. Calculate the projection error of the remaining matching point pairs under this model; retain the matching point pairs whose projection error is less than a preset threshold as interior points; and refit the final similarity transformation model using the least squares method with all interior points.

7. A scale-invariant contour matching system based on machine vision, characterized in that, include: A template feature construction module is used to extract a first contour of a target object in a template image, detect multiple first key points from the first contour, and extract a multi-scale contour context descriptor for each first key point to construct a template feature set; wherein the multi-scale contour context descriptor is composed of chord ratio and chord angle features calculated based on the local contour neighborhood of the first key point under multiple preset scale parameters; a query feature construction module is used to extract a second contour of a target object in a query image, detect multiple second key points from the second contour, and extract the multi-scale contour context descriptor for each second key point to construct a query feature set; a matching module is used to match each descriptor in the query feature set with the descriptors in the template feature set, for each For each successfully matched descriptor pair, based on its corresponding chord ratio and chord angle features, the scaling and rotation transformation parameters are estimated, and the translation transformation parameters are calculated by combining the coordinates of the first and second key points, thereby generating a similarity transformation hypothesis representing the transition from the template space to the query space. A clustering module is used to perform clustering analysis on the generated multiple similarity transformation hypotheses as points in a multidimensional parameter space to obtain at least one cluster center, each cluster center representing a candidate target instance. An output module is used, for each candidate target instance, to obtain all the descriptor pairs supporting its corresponding cluster center and their associated first and second key points, and based on these key point pairs, to fit a similarity transformation model using a random sampling consensus algorithm, and to eliminate mismatches to obtain the target object positioning parameters.

8. A computer device, wherein the computer device is characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.

9. A computer-readable medium having computer program instructions stored thereon, characterized in that, The computer program instructions can be executed by a processor to implement the method as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.