A tool identification method based on probabilistic program inference

Through probabilistic program inference and edge detection technology, we design probabilistic programs for straight knives and curved knives, use average measures and cuckoo search algorithms to optimize geometric shapes, and solve the data utilization efficiency, interpretability and robustness of tool identification methods in the existing technology. This solves the problem of insufficient accuracy and achieves efficient and accurate tool identification.

CN114120009BActive Publication Date: 2024-10-29JIMEI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111375135.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2024-10-29
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

Existing tool identification methods have deficiencies in data utilization efficiency, interpretability and robustness, making it difficult to effectively identify and warn of tool injuries in crowded places.

Method used

A method based on probabilistic program inference is used to extract tool contour data through edge detection, and probabilistic programs for straight knives and curved knives are designed. The average measure and cuckoo search algorithm are used to optimize the geometric shape and improve the accuracy and credibility of identification.

Benefits of technology

It achieves efficient identification of tools, can output a relatively complete contour under noise and incomplete data, improves the accuracy and credibility of identification, and has high data utilization efficiency, good interpretability and strong robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114120009B_ABST
    Figure CN114120009B_ABST
Patent Text Reader

Abstract

The present invention discloses a tool recognition algorithm based on probability program inference, which relates to the field of image recognition technology. The algorithm comprises the following steps: S1: for any tool image, an edge detection method is used to extract the contour data of the tool and convert it into a data point set; S2: corresponding probability programs are designed for straight knives and curved knives respectively; S3: the same tool image is inferred using a straight knife probability program and a curved knife probability program respectively to obtain a straight knife candidate shape and a curved knife candidate shape, and then the shape with the greatest similarity is selected from the candidate shapes as the final shape. The technical solution of the present invention uses an edge detection method to obtain the tool contour and uses a probability program inference for recognition, which is not easily affected by noise and can output a relatively complete contour, thereby improving the accuracy and credibility of recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and in particular to a tool recognition method based on probability program inference. Background Art

[0002] Knives are essential tools in life. While they facilitate human life, they also pose certain safety risks. In crowded places such as shopping malls, hospitals, and transportation hubs, if knives can be identified based on the images taken by cameras and early warnings can be issued, the risk of people being injured by knives can be reduced.

[0003] The current mainstream tool recognition method is the high-dimensional function fitting method represented by deep learning. Although the principle of the high-dimensional function fitting method is relatively simple and has a wide range of applications, it has shortcomings such as low data utilization efficiency, poor interpretability, and weak robustness. Compared with the high-dimensional function fitting method, the probabilistic program inference method uses a low-dimensional probabilistic program with combination and causality to represent the target concept to be identified for identification, which has the advantages of high data utilization efficiency, good interpretability, and strong robustness.

[0004] Therefore, in order to improve the accuracy and reliability of tool identification, this paper designs a tool identification method based on probabilistic program inference. The key to the algorithm is to formulate a tool similarity metric (called average measure) based on the error from geometric shapes to data point sets, so that the metric can robustly evaluate the similarity between geometric shapes and imperfect (noisy, outlier or incomplete) data point sets. Summary of the invention

[0005] The present invention aims to provide a tool identification method based on probabilistic program inference, which uses an edge detection method to obtain the tool contour and uses probabilistic program inference for identification. It is not easily affected by noise and can output a relatively complete contour, thereby improving the accuracy and credibility of identification.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] A tool identification method based on probabilistic program inference, the algorithm includes the following steps:

[0008] S1: For any tool image, edge detection method is used to extract the tool contour data and convert it into a data point set. The steps of extracting the tool contour are as follows:

[0009] S1-1: Use Gaussian filter to smooth the image;

[0010] S1-2: Use the Canny algorithm object to detect and binarize, and connect the edges;

[0011] S1-3: Use OpenCV algorithm to extract contour data from the image processed in S1-2;

[0012] S1-4: Convert the contour data into a dataset for subsequent use;

[0013] S2: Design corresponding probability programs for straight knives and curved knives respectively:

[0014] The probability program for straight knives is constructed as follows:

[0015] Draw a vertical line r11 extending from the point where the blade arc completely turns into a straight line to the blade back, and draw a ray r12 from the blade tip to the outside of the blade back. r11 and r12 intersect at a certain point, and r11=r12. At the same time, draw a perpendicular line L11 to r11 with the blade tip as the starting point. Let the angle between r12 and L11 be Angle, then the blade tip angle ;

[0016] The construction method of the probabilistic program of Scimitar is as follows:

[0017] A scimitar usually has two curved blades, so the two blades are constructed using the construction method of a straight knife, obtaining r11, r12 and Angle1 of the blade, and r21 and r22 of the second blade. At the same time, let the angle between r22 and r12 be Angle2, then the blade tip angle is:

[0018] ;

[0019] S3: The straight knife probability program and the curved knife probability program are used to infer the same tool image, respectively, to obtain the straight knife candidate shape and the curved knife candidate shape, and then the shape with the greatest similarity is selected from the candidate shapes as the final shape. The probability program inference steps are as follows:

[0020] S3-1: Run the probability program according to the current parameter values ​​and obtain the corresponding geometric shape;

[0021] S3-2: Calculate the similarity between the geometric shape and the image data point set using the average measurement method;

[0022] S3-3: Use the cuckoo search algorithm to update the parameter values ​​of the probability program, and repeat the above steps until the similarity between the geometric shape and the image data point set remains basically unchanged.

[0023] The principle and beneficial effects of this technical solution:

[0024] The present invention uses edge detection method to extract the contour data of tool image, designs corresponding probability programs for straight knife and curved knife respectively, and then uses straight knife probability program and curved knife probability program to infer the same tool image respectively, obtains straight knife candidate shape and curved knife candidate shape, and then selects the shape with the greatest similarity from the candidate shapes as the final shape. One of the key steps is probability program inference, and its principle is to use cuckoo search algorithm to continuously update and optimize geometric shapes so that the contour of the tool can be fully detected, and its data utilization efficiency is high, interpretability is good, and robustness is strong. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 A contour extraction diagram of a straight knife using the edge detection method provided in an embodiment of the present invention;

[0026] Figure 2 A contour extraction diagram of a scimitar using the edge detection method provided in an embodiment of the present invention;

[0027] Figure 3 A straight knife probability program parameter diagram provided by an embodiment of the present invention;

[0028] Figure 4 A scimitar probability program parameter diagram provided by an embodiment of the present invention;

[0029] Figure 5 A flowchart of probability program inference provided by an embodiment of the present invention;

[0030] Figure 6 The overall flow chart of the tool identification algorithm provided by the embodiment of the present invention;

[0031] Figure 7 A test result diagram provided for an embodiment of the present invention;

[0032] Figure 8 A diagram showing the similarity evolution process of a straight knife and its probability inference provided by an embodiment of the present invention;

[0033] Fig. 9 A diagram of the similarity evolution process of the scimitar and its probability inference provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments:

[0035] like Figure 6As shown in the figure, a tool recognition method based on probabilistic program inference is used to obtain the tool contour using an edge detection method and recognize it using probabilistic program inference. It is not easily disturbed by noise and can output a relatively complete contour, thereby improving the accuracy and reliability of recognition. Even in a large set of data points, the algorithm in this paper can still maintain a strong noise resistance and the program has good robustness. The algorithm includes the following steps:

[0036] S1: For any tool image, edge detection method is used to extract the tool contour data and convert it into a data point set;

[0037] The steps of edge detection method in S1 to extract tool contour are as follows:

[0038] S1-1: Use Gaussian filter to smooth the image;

[0039] S1-2: Use the Canny algorithm object to detect and binarize the image, and connect the edges;

[0040] S1-3: Use OpenCV algorithm to extract contour data from the image processed in S1-2;

[0041] S1-4: Convert the contour data into a dataset for subsequent use, e.g. Figure 1 and Figure 2 shown.

[0042] The advantage of the Canny algorithm is that it is not easily affected by noise and can output a relatively complete contour. The detection principle of the Canny algorithm is to find the local maximum value of the image gradient, and use high and low thresholds to detect strong edges and weak edges respectively. Their connections will be output as edges.

[0043] S2: Design corresponding probability programs for straight swords and curved swords respectively;

[0044] The probability program construction method of the straight knife is as follows:

[0045] The shape of a straight knife is described as a shape where the tip of the knife is composed of a line segment and an arc with one end point intersecting, and the other end point of the arc extending outward. Among the common types of knives, fruit knives are mostly of this shape, such as Figure 1 shown.

[0046] There are 5 parameters of straight knife that can be determined according to the shape of the tool, such as Figure 3 The detailed meanings of the parameters are as follows:

[0047] X0: The horizontal coordinate of the tool tip (the intersection of the arc and the line segment) in the two-dimensional pixel matrix of the image.

[0048] Y0: The vertical coordinate of the tool tip (the intersection of the arc and the line segment) in the two-dimensional pixel matrix of the image.

[0049] Length: The horizontal displacement of the blade arc from curved to straight.

[0050] Angle: An offset angle of the straight line relative to the other side of the arc. This angle determines the length, angle and position of the arc relative to the straight line. The ray emitted from the tool tip along the direction of the blade will intersect with a vertical connecting line at point (X1, Y1). This connecting line is the vertical connecting line drawn to the straight line at the turning point where the arc gradually approaches the straight line. Among them, the intersection point (X1, Y1) is the center of the circle, the ray length and the vertical connecting line are the radius, and the arc is a section of the circle. The tool tip angle A is shown in the following formula,

[0051]

[0052] The larger the Angle, the smaller the blade tip angle.

[0053] Azimuth: The rotation angle of the knife in the image. In this implementation, the straight side of the knife is horizontal, the arc side is downward, and the tip of the knife is on the left.

[0054] The probability program construction method of Scimitar is as follows:

[0055] The shape of a machete is described as the tip of the blade being composed of two arcs with one end point intersecting at one point, and the non-intersecting ends extending outwards to form line segments to form the shape of the blade. Among the common types of knives, daggers and mountaineering knives are mostly of this shape, such as Figure 2 shown.

[0056] The curved knife is composed of two intersecting arcs. Defining the two arcs separately using the arc definition method of the straight knife will result in too many parameters, which will seriously reduce the fitting effect and speed. Therefore, it is necessary to make one arc dependent on the change of another arc. Figure 4 As shown, the parameters have the following meanings:

[0057] X0: The horizontal coordinate of the knife tip (the intersection of the two blade arcs) in the two-dimensional pixel matrix of the image

[0058] Y0: The vertical coordinate of the knife tip (the intersection of the two blade arcs) in the two-dimensional pixel matrix of the image

[0059] Azimuth: The rotation angle of the knife in the image. In this implementation, the X-axis is horizontal, arc 1 is located below the X-axis, arc 2 is located above the X-axis, and the knife tip is located on the left side as the reference.

[0060] Angle1: When Azimuth is 0, the X axis is an offset angle relative to the other side of arc 1, and the value can be negative. Angle1 can determine the length, angle, and position of arc 1 relative to the X axis. The ray emitted from the tool tip along the direction of the blade will intersect with a vertical connecting line at point (X1, Y1), which is the vertical connecting line drawn to the straight line at the turning point where arc 1 gradually approaches the straight line. Among them, the intersection point (X1, Y1) is the center of the circle, the ray length and the vertical connecting line are the radius, and the arc is a section of the circle.

[0061] Angle2: The angle of the ray relative to Angle1, which is rotated counterclockwise. The sum of the angles of Angle1 and Angle2 is an offset angle of the X-axis relative to the other side of arc 2 (when Azimuth is 0). The ray emitted from the tool tip point along the blade direction will intersect with a vertical connecting line at point (X2, Y2). This connecting line is the vertical connecting line drawn to the straight line from the turning point where arc 2 gradually approaches the straight line. Among them, the intersection point (X2, Y2) is the center of the circle, the length of the ray and the vertical connecting line are the radius, and the arc is a section of the circle. The tool tip angle is shown in the following two formulas,

[0062]

[0063] Angle1 and Angle2 jointly determine the size of the tool tip. If Angle1 and (Angle1+Angle2) have the same sign, the tool tip angle A is the first formula; if the signs are opposite, the tool tip angle A is the second formula.

[0064] PM-a2: determines the sign of Angle2. To prevent blade arc 1 from overlapping with blade arc 2, it is necessary to ensure that the angle between them is not too small. Therefore, the value of Angle2 must be greater than 0. However, in order to meet the randomness of the probability program, Angle2 needs to have a parameter value less than 0. The PM-a2 parameter is added to determine the sign of Angle2.

[0065] Length1: The horizontal displacement of blade arc 1 from curved to straight.

[0066] Length1: The horizontal displacement of blade arc 2 from curved to straight.

[0067] S3: The straight knife probability program and the curved knife probability program are used to infer the same tool image, and the straight knife candidate shape and the curved knife candidate shape are obtained. Then, the shape with the greatest similarity is selected from the candidate shapes as the final shape, such as Figure 6 shown.

[0068] like Figure 5 As shown, the probability program inference steps in S3 are as follows:

[0069] S3-1: Run the probability program according to the current parameter values ​​and obtain the corresponding geometric shape;

[0070] S3-2: Calculate the similarity between the geometric shape and the image data point set using the average measurement method;

[0071] S3-3: Use the cuckoo search algorithm to update the parameter values ​​of the probability program, and repeat the above steps until the similarity between the geometric shape and the image data point set remains basically unchanged.

[0072] Example verification:

[0073] The cuckoo search algorithm is used to fit the data point set and the geometric shape. The fitting effect of the straight knife and the curved knife increases with the increase of the number of cuckoo search iterations. The example effect is shown in Figure 7 The red point set in the figure is the data point set obtained by OpenCV, and the green point set is the geometric shape, which will change continuously as the optimization algorithm calculates the similarity.

[0074] like Figure 7 As shown in the figure, at the beginning (iterations = 10000), the shape of the tool fitting has roughly locked the position of the contour. In fact, when the number of iterations is small, the position of the tool fitting will change constantly, and the final fitted shape cannot be immediately determined. After a period of fitting (iterations = 50000), the probability program has tended to be stable, and more accurate parameters are constantly tried at the same position. After a period of stable fitting (iterations = 100000), it is difficult to judge the changes in the fitting effect by the naked eye. At the end of the program (iterations = 200000), the value of similarity has also changed very slightly, and the final result of the fitting is roughly determined around this number of iterations.

[0075] Figure 8 The right side shows the probability program of using straight knife Figure 8 The left figure shows the evolution of the similarity of the straight knife image inferred by the probability program. It can be seen that the similarity of the geometric shape finally obtained by the straight knife probability program is higher than that of the curved knife probability program, so the straight knife image is correctly identified as a straight knife.

[0076] Fig. 9 The right side shows the probability program of using the scimitar Fig. 9 The similarity evolution process of the scimitar image inferred by the probabilistic program is shown on the left. It can be seen that the similarity of the geometric shape finally obtained by the scimitar probabilistic program is higher than that of the straight knife probabilistic program, so the scimitar image is correctly identified as a scimitar.

[0077] The above is only an embodiment of the present invention, and the common knowledge such as the known specific technical solutions and / or characteristics in the solution is not described in detail here. It should be pointed out that for those skilled in the art, without departing from the technical solution of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A tool identification method based on probabilistic program inference, characterized in that: The following steps are involved: S1: For any tool image, edge detection method is used to extract the tool contour data and convert it into a data point set. The steps of extracting the tool contour are as follows: S1-1: Use Gaussian filter to smooth the image; S1-2: Use the Canny algorithm object to detect and binarize, and connect the edges; S1-3: Use OpenCV algorithm to extract contour data from the image processed in S1-2; S1-4: Convert the contour data into a dataset for subsequent use; S2: Design corresponding probability programs for straight knives and curved knives respectively: The probability program for straight knives is constructed as follows: Draw a vertical line r11 extending to the back of the blade from the point where the blade arc completely turns into a straight line, and draw a ray r12 from the blade tip to the outside of the blade back. r11 and r12 intersect at a certain point, and r11=r12. At the same time, draw a perpendicular line L11 to r11 with the blade tip as the starting point. Let the angle between r12 and L11 be Angle, then the blade tip angle A=(1-sin(Angle)) / cos(Angle); The construction method of the probabilistic program of Scimitar is as follows: A scimitar usually has two curved blades, so the two blades are constructed using the construction method of a straight knife, obtaining r11, r12 and Angle1 of the blade, and r21 and r22 of the second blade. At the same time, let the angle between r22 and r12 be Angle2, then the blade tip angle is: A=(1-sin(Angle1)) / cos(Angle1)-(1-sin(Angle1+Angle2)) / cos(Angle1+Angle2); S3: The straight knife probability program and the curved knife probability program are used to infer the same tool image, respectively, to obtain the straight knife candidate shape and the curved knife candidate shape, and then the shape with the greatest similarity is selected from the candidate shapes as the final shape. The probability program inference steps are as follows: S3-1: Run the probability program according to the current parameter values ​​and obtain the corresponding geometric shape; S3-2: Calculate the similarity between the geometric shape and the image data point set using the average measurement method; S3-3: Use the cuckoo search algorithm to update the parameter values ​​of the probability program, and repeat the above steps until the similarity between the geometric shape and the image data point set remains basically unchanged.

Citation Information

Patent Citations

  • Method for automatically and accurately measuring abrasion loss of cutter based on gray image probability

    CN110728667A

  • Precisive measurement of static knife profile

    CN1680072A