Image recognition methods, devices, electronic equipment and storage media

By using contour delineation and feature extraction methods, contour feature data of images are obtained and similarity is calculated, which solves the problems of large sample data requirements and large computational resource requirements of deep learning models in image recognition, and achieves efficient and accurate image recognition.

CN118470355BActive Publication Date: 2026-11-10CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410501360.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-24
Publication Date
2026-11-10
Estimated Expiration
2044-04-24

AI Technical Summary

Technical Problem

Existing image recognition technologies that rely on deep learning models suffer from problems such as large sample data requirements, large computational resource requirements, poor model interpretability, adversarial attacks, and poor transfer learning generalization ability.

Method used

By employing methods such as contour delineation, feature extraction and summarization, basic data labeling, and similarity quantification, the similarity between target objects is calculated by acquiring contour feature data of the target object image and calculating the overlap degree and transformation cost, thereby reducing the use of computing resources.

Benefits of technology

It achieves efficient and rapid recognition in small sample image recognition, reduces computational complexity and resource requirements, improves recognition efficiency and accuracy, and solves the shortcomings of deep learning models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470355B_ABST
    Figure CN118470355B_ABST
Patent Text Reader

Abstract

This application provides an image recognition method, apparatus, electronic device, and storage medium. The image recognition method includes: acquiring first contour feature data of a first target image and second contour feature data of a second target image; calculating the overlap difference and transformation cost when the first contour feature data is transformed to achieve maximum overlap with the second contour feature data; and calculating the similarity between the first target image and the second target image based on the overlap difference and the transformation cost. Compared with methods that obtain similarity through deep learning models, this application does not require model training, a large amount of sample data and computational resources, and avoids the shortcomings of deep learning models. Therefore, the image recognition is less complex, more efficient, and more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image recognition technology, and in particular to an image recognition method, apparatus, electronic device and storage medium. Background Technology

[0002] Image recognition refers to the technology of using computers to process, analyze, and understand images in order to identify targets and objects of various patterns. Image recognition can be applied to various scenarios such as face recognition, product recognition, and object comparison.

[0003] In current technologies, image recognition technology mainly relies on deep learning models, such as Convolutional Neural Networks (CNNs). However, deep learning models have some drawbacks, such as requiring large amounts of sample data, consuming large amounts of computational resources, having poor model interpretability, and exhibiting poor generalization ability in the face of adversarial attacks and transfer learning. Summary of the Invention

[0004] In view of the above problems, embodiments of this application propose an image recognition method, apparatus, electronic device and storage medium to reduce the complexity of image recognition and improve the efficiency and accuracy of image recognition.

[0005] According to one aspect of an embodiment of this application, an image recognition method is provided, the method comprising:

[0006] Acquire the first contour feature data of the first target image and the second contour feature data of the second target image;

[0007] Calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data;

[0008] Based on the overlap difference and the transformation cost, the similarity between the first target and the second target is calculated.

[0009] According to another aspect of the embodiments of this application, an image recognition device is provided, the device comprising:

[0010] The acquisition module is used to acquire the first contour feature data of the first target image and the second contour feature data of the second target image;

[0011] The calculation module is used to calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data; and to calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost.

[0012] According to another aspect of the embodiments of this application, an electronic device is provided, comprising: one or more processors; and one or more computer-readable storage media having instructions stored thereon; wherein, when the instructions are executed by the one or more processors, the processors perform the image recognition method as described in any of the preceding claims.

[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, causes the processor to perform the image recognition method as described in any of the preceding claims.

[0014] In this embodiment, first contour feature data of a first target image and second contour feature data of a second target image are obtained; the overlap difference and transformation cost are calculated when the first contour feature data is transformed to achieve maximum overlap with the second contour feature data; and the similarity between the first target and the second target is calculated based on the overlap difference and the transformation cost. Therefore, in this embodiment, by transforming the contour feature data of the target image to obtain the overlap difference and transformation cost, and calculating the similarity based on the overlap difference and transformation cost, compared to obtaining similarity through a deep learning model, no model training is required, no large amount of sample data and computational resources are needed, and the drawbacks of deep learning models are not present. Therefore, image recognition has lower complexity, higher efficiency, and higher accuracy. Attached Figure Description

[0015] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some drawings of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a flowchart illustrating the steps of an image recognition method according to an embodiment of this application.

[0017] Figure 2 This is a schematic diagram of a pixel block division according to an embodiment of this application.

[0018] Figure 3 This is a schematic diagram of pixel block storage according to an embodiment of this application.

[0019] Figure 4 This is a schematic diagram of a pixel block numbering according to an embodiment of this application.

[0020] Figure 5 This is a schematic diagram of an edge pixel block according to an embodiment of this application.

[0021] Figure 6 This is a schematic diagram of the coordinates of an edge pixel block according to an embodiment of this application.

[0022] Figure 7 This is a schematic diagram of a contour chain according to an embodiment of this application.

[0023] Figure 8 This is a schematic diagram of an image element according to an embodiment of this application.

[0024] Figure 9 This is a schematic diagram of a direction angle and length according to an embodiment of this application.

[0025] Figure 10 This is a schematic diagram of the center point of the contour in an embodiment of this application.

[0026] Figure 11 This is a schematic diagram of another contour center point according to an embodiment of this application.

[0027] Figure 12 This is a schematic diagram of the offset vector of a contour feature point according to an embodiment of this application.

[0028] Figure 13 This is a flowchart illustrating the steps of another image recognition method according to an embodiment of this application.

[0029] Figure 14 This is a schematic diagram of an outermost contour feature chain according to an embodiment of this application.

[0030] Figure 15 This is a schematic diagram of the outermost contour feature points of an embodiment of this application.

[0031] Figure 16 This is a structural block diagram of an image recognition device according to an embodiment of this application.

[0032] Figure 17 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0033] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0034] In this embodiment, addressing the shortcomings of existing image recognition methods using deep learning models, a method inspired by line drawing is proposed. This method aims to provide the similarity between target objects in an image through processes such as contour drawing, feature extraction and summarization, basic data labeling, similarity measurement and evaluation. This enables efficient and rapid recognition of a limited number of small sample images (videos, pictures), reduces the use of computing resources, and makes the decision-making process clearer. It effectively solves the problem of rapid and efficient recognition under conditions such as small samples, different proportions of the same shape, shape deformation, and shape incompleteness.

[0035] This application provides a low-cost, high-efficiency alternative to image recognition technology, thereby enriching and improving innovative methods in the field of image recognition and offering a novel option to address the shortcomings of deep learning models. This application simulates biological visual recognition mechanisms in areas such as image blur judgment and contour representation, drawing on line drawing techniques to achieve a low-cost, high-efficiency computer technology method for image recognition that differs from deep learning models. The processes described in this application can be implemented through computer programming.

[0036] Reference Figure 1 The diagram shows a flowchart of the steps of an image recognition method according to an embodiment of this application.

[0037] like Figure 1 As shown, the image recognition method may include the following steps:

[0038] Step 101: Obtain the first contour feature data of the first target image and the second contour feature data of the second target image.

[0039] In this embodiment, the first target image contains a first target object. The first target image can be an entire image of the first target object (such as an entire face image), or it can be a partial image of the first target object segmented from the entire image containing the first target object (such as an image of the eyes, nose, etc., in an entire face image). Similarly, the second target image contains a second target object. The second target image can be an entire image of the second target object, or it can be a partial image of the first target object segmented from the image containing the second target object.

[0040] In one optional implementation, the process of acquiring the first contour feature data of the first target image may include the following steps A1 to A4:

[0041] Step A1: Obtain the first contour chain of the first target object image.

[0042] For example, the process of obtaining the first contour chain of the first target image may include the following steps A11 to A12:

[0043] Step A11: Obtain pixel blocks of the first target image and filter out edge pixel blocks from the pixel blocks.

[0044] The first target image consists of multiple pixels, which can be divided into multiple pixel blocks. Each pixel block consists of several clusters of adjacent pixels. The basic processing unit for subsequent steps is the pixel block. The size of the pixel block can be preset according to actual needs, with a minimum of one pixel. The smaller the pixel block, the higher the image recognition accuracy, but the greater the computational cost. Alternatively, the pixel block size can be automatically adapted through complex program design.

[0045] Figure 2 This is a schematic diagram illustrating a method of dividing pixel blocks according to an embodiment of this application. For example... Figure 2 As shown, an image contains multiple pixels. These pixels are divided into multiple pixel blocks, and each pixel block contains multiple pixels. For example, Figure 2 Each pixel block contains 2×2 pixels (2×2 is only used as an example and is not intended to limit the embodiments of this application).

[0046] For example, to obtain pixel block data of the first target image, the pixel block data of the first target image can be saved to a table (which can be called a pixel block table) in a database (such as a MySQL database, etc.), which represents the set of pixel blocks of the first target image. Figure 3 This is a schematic diagram of pixel block storage according to an embodiment of this application, such as... Figure 3 As shown, pixel block data can be saved into a database table Gi with M rows and N columns, where M and N are positive integers.

[0047] The pixel blocks of the first target image are numbered sequentially, and the set of pixel blocks of the first target image Oi can be represented as Oi{G1, G2, G3, ..., Gi}. Figure 4 This is a schematic diagram of pixel block numbering according to an embodiment of this application. For example... Figure 4 As shown, multiple pixel blocks are numbered sequentially (e.g., Figure 4 The G1, G2, ...) in the image are then saved as a set of pixel blocks.

[0048] For example, pixel block data may include, but is not limited to, the color of the pixel block, the coordinates of the pixel block, etc. The color of the pixel block can be the dominant color value of the pixels contained in the pixel block (e.g., the color value with the most pixels), and the coordinates of the pixel block can be the row and column numbers of the pixel block, with the horizontal axis representing the column number and the vertical axis representing the row number.

[0049] Read the pixel block data from the pixel block set of the first target image, and filter out the edge pixel blocks from the pixel blocks of the first target image. There are multiple edge pixel blocks.

[0050] For example, edge filtering conditions can be preset, and pixel blocks in the pixel blocks of the first target image that meet the edge filtering conditions can be regarded as edge pixel blocks. The edge filtering conditions may include, but are not limited to: adjacent to at least one blank pixel block, adjacent to at least one pixel block of other color, etc.

[0051] Figure 5 This is a schematic diagram of an edge pixel block according to an embodiment of this application. Figure 5 As shown, the pixel blocks enclosed by the rectangle are the edge pixel blocks. It should be noted that... Figure 5 The edge pixel blocks shown may only be a portion of the edge pixel blocks; other edge pixel blocks may also exist in this image.

[0052] For example, the edge pixel block data of the first target image can be obtained by saving the edge pixel block data of the first target image to a table (which can be called a contour table) in a database (such as a MySQL database, etc.), which represents the set of edge pixel blocks of the first target image.

[0053] For example, edge pixel block data may include, but is not limited to, the coordinates of the edge pixel blocks, etc. The coordinates of an edge pixel block can be the row and column numbers of that edge pixel block, with the horizontal axis representing the column number and the vertical axis representing the row number.

[0054] Figure 6 This is a schematic diagram illustrating the coordinates of an edge pixel block according to an embodiment of this application. For example... Figure 6 As shown, the pixel blocks enclosed by the rectangle are the edge pixel blocks, and each edge pixel block has its own coordinates, for example... Figure 6 In this context, (x, y), (x1, y1), and (x2, y2) represent the coordinates of the edge pixel blocks.

[0055] For example, if the target image is complex and special, and some edge pixel blocks found interfere with the extraction of contour features, it is possible to design correction or removal for the program, and the specific processing can be carried out according to actual needs.

[0056] For example, artificial intelligence technology (such as image edge recognition technology, etc.) can also be used to filter out edge pixel blocks from the pixel blocks of the first target image. The specific processing can be carried out based on actual experience.

[0057] Step A12, repeat the following operation until there are no remaining edge pixel blocks: select a starting edge pixel block, starting from the starting edge pixel block, sequentially select edge pixel blocks that are connected to the current edge pixel block in a set direction, and when there are no edge pixel blocks connected to the current edge pixel block or when returning to the starting edge pixel block, form a first contour chain from the selected edge pixel blocks.

[0058] For example, the starting edge pixel block can be the edge pixel block closest to coordinate (0, 0), or the starting edge pixel block can be the edge pixel block furthest from coordinate (0, 0). Of course, the starting edge pixel block can also be other edge pixel blocks, and this embodiment does not limit this.

[0059] For example, the direction can be set to either clockwise or counterclockwise, and this embodiment does not limit this.

[0060] For example, the first contour chain can be a loop connected end to end (e.g., returning to the starting edge pixel block), or a winding single chain (e.g., there are no edge pixel blocks connected to the current edge pixel block and it does not return to the starting edge pixel block). The first contour chain of the first target image is at least one, and each first contour chain contains multiple edge pixel blocks.

[0061] For example, starting from the edge pixel block whose coordinates are closest to (0,0) in the contour table, proceed clockwise (or counterclockwise, but always in the same direction), from left to right, from top to bottom, and visit the next adjacent (interconnected) edge pixel blocks in sequence until you return to the starting edge pixel block or there are no adjacent edge pixel blocks. The interconnected edge pixel blocks visited in sequence form a contour chain.

[0062] Figure 7 This is a schematic diagram of a contour chain according to an embodiment of this application. For example... Figure 7 As shown, the pixel blocks enclosed by the rectangle are the edge pixel blocks, and the interconnected edge pixel blocks can form a contour chain.

[0063] Step A2: Select the first contour feature point from the first contour chain.

[0064] For each first contour chain, first contour feature points are selected from the edge pixel blocks of the first contour chain. Each first contour chain may include multiple first contour feature points, and each first contour feature point has corresponding coordinates.

[0065] For example, edge pixel blocks with slope changes, inflection points, singularities, and endpoints in the first contour chain can be obtained as first contour feature points. Specifically, edge pixel blocks in the first contour chain with a second derivative of 0 or a jump in the second derivative can be determined as first contour feature points.

[0066] Figure 8 This is a schematic diagram of an image element according to an embodiment of this application. For example... Figure 8 As shown, the image includes pixels, pixel blocks, contour chains, and contour feature points.

[0067] Step A3: Based on the first contour feature points, obtain the first contour feature chain, the first contour feature points of the first contour feature chain, and the first contour center point of the first contour feature chain.

[0068] For example, first contour feature points belonging to the same first contour chain are grouped into a first contour feature chain. The first contour feature points that make up the first contour feature chain are the first contour feature points of the first contour feature chain. The center point corresponding to the first contour feature point of the first contour feature chain is obtained, and this center point is taken as the first contour center point of the first contour feature chain.

[0069] The center point of the first contour can be obtained by calculating the geometric center point of the planar region covered by the feature points of the first contour. The specific calculation process can be handled according to actual experience, and will not be discussed in detail in this embodiment.

[0070] For example, the first contour feature point of the first contour feature chain can be represented as: {D1, D2, D3, ..., Dn}; the first contour feature chain can be represented as: {D1D2, D2D3, ..., DnD1} (here the first contour feature chain is a closed loop chain); the first contour center point of the first contour feature chain can be represented as C(Xc, Yc).

[0071] Step A4: Obtain the first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain as the first contour feature data.

[0072] For example, the process of acquiring the first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain may include the following steps A41 to A44:

[0073] Step A41: For each first contour feature chain, obtain the coordinates of the first contour feature point of the first contour feature chain.

[0074] The first contour feature point is obtained by filtering from the edge pixel blocks. Since the coordinates of the edge pixel blocks have been obtained, the coordinates of the first contour feature point can also be obtained.

[0075] Step A42: Based on the coordinates of the first contour feature points, obtain the offset vector of the first contour feature chain as the first contour feature chain data.

[0076] For example, the process of obtaining the offset vector of the first contour feature chain based on the coordinates of the first contour feature point may include: obtaining the coordinates of the starting first contour feature point of the first contour feature chain; calculating the direction angle and length between the starting first contour feature point and the ending first contour feature point of the first contour feature chain based on the coordinates of the first contour feature point, as the head and tail vectors of the first contour feature chain; calculating the direction angle and length between adjacent first contour feature points on the first contour feature chain based on the coordinates of the first contour feature point, as the chain body vector of the first contour feature chain; and using the coordinates of the starting first contour feature point, the head and tail vectors, and the chain body vector as the offset vector of the first contour feature chain.

[0077] Since the first contour chain is obtained by starting from the initial edge pixel block and selecting edge pixel blocks sequentially according to the set direction, the order of the first contour feature points on the first contour feature chain can be known based on the order of the edge pixel blocks. Therefore, the starting first contour feature point and the ending first contour feature point of the first contour feature chain can be determined, and the coordinates of the starting first contour feature point and the ending first contour feature point of the first contour feature chain can be obtained.

[0078] The directional angle between the starting first contour feature point and the ending first contour feature point refers to the directional angle from the starting first contour feature point to the ending first contour feature point (specifically, it can be the angle from the horizontal line rotated counterclockwise to the line connecting the starting and ending first contour feature points). The length between the starting and ending first contour feature points refers to the distance between them (in pixels).

[0079] The directional angle between adjacent first contour feature points (specifically, between any two adjacent first contour feature points) refers to the directional angle from the preceding first contour feature point to the following first contour feature point (specifically, it can be the angle from the horizontal line rotated counterclockwise to the line connecting the preceding and following first contour feature points). The length between adjacent first contour feature points refers to the distance between two adjacent first contour feature points (in pixels).

[0080] For example, the offset vector of the first contour feature chain can be represented as: {coordinates of the starting first contour feature point, [start and end vectors], [chain body vector]}.

[0081] The start and end vectors can be represented as: [start and end direction angle, start and end length]. Here, the start and end direction angle is the angle between the starting and ending first contour feature points, and the start and end length is the length between the starting and ending first contour feature points. If the first contour feature chain is a closed loop chain with its start and end points connected, then the start and end vectors of the first contour feature chain are [0, 0].

[0082] The chain body vector can be represented as: {[D1D2 direction angle, D1D2 length], [D2D3 direction angle, D2D3 length], ...}. Here, D1D2, D2D3, ... represent two adjacent first contour feature points; the D1D2 direction angle is the angle from D1 to D2; the D1D2 length is the distance from D1 to D2; the D2D3 direction angle is the angle from D2 to D3; and the D2D3 length is the distance from D2 to D3.

[0083] Figure 9 This is a schematic diagram illustrating one direction, angle, and length according to an embodiment of this application. For example... Figure 9 As shown, the D1D2 direction angle refers to the angle from the horizontal line to the line connecting D1 and D2 when rotated counterclockwise, and the D1D2 length refers to the length of the line connecting D1 and D2.

[0084] Step A43: Based on the coordinates of the first contour feature points, obtain the coordinates of the first contour center point of the first contour feature chain, and use it as the first contour center point data of the first contour feature chain.

[0085] After obtaining the coordinates of each first contour feature point on the first contour feature chain, the coordinates of the first contour center point of the first contour feature chain can be calculated based on the coordinates of each first contour feature point on the first contour feature chain. For the specific calculation process, any applicable calculation method can be selected based on practical experience; this embodiment will not elaborate further. For example, the first contour center point can be obtained by calculating the geometric center point of the planar region covered by the first contour feature points, simulating the visual focal point to obtain the geometric center point of the graphic.

[0086] Figure 10 This is a schematic diagram of the center point of a contour according to an embodiment of this application. For example... Figure 10 As shown, the contour center point C of the contour feature chain can be calculated by using the contour feature points (endpoints, vertices, etc.) on the contour feature.

[0087] Figure 11 This is a schematic diagram of another contour center point according to an embodiment of this application. For example... Figure 11 As shown, the contour center point C of the contour feature chain can be calculated by using the contour feature points on the contour feature chain.

[0088] Step A44: Based on the coordinates of the first contour feature point and the coordinates of the first contour center point, obtain the offset vector of the first contour feature point of the first contour feature chain, and use it as the first contour feature point data of the first contour feature chain.

[0089] For example, the process of obtaining the offset vector of the first contour feature point of the first contour feature chain based on the coordinates of the first contour feature point and the coordinates of the first contour center point may include: for each first contour feature point of the first contour feature chain, calculating the direction angle and length between the first contour center point and the first contour feature point based on the coordinates of the first contour feature point and the coordinates of the first contour center point, and using this as the offset vector of the first contour feature point.

[0090] The directional angle between the first contour center point and the first contour feature point refers to the directional angle from the first contour center point to the first contour feature point (specifically, it can be the angle from the horizontal line rotated counterclockwise to the line connecting the first contour center point and the first contour feature point). The length between the first contour center point and the first contour feature point refers to the distance between the first contour center point and the first contour feature point (in pixels). The offset vector of the first contour feature point is the offset of the first contour feature point relative to the direction of the first contour center point by a unit amount (the unit amount can be customized relative to a number of pixels).

[0091] For example, the offset vector of the first contour feature point can be represented as: [direction angle, length].

[0092] For example, the offset vector S = [180°, 7] of the first contour feature point means that the first contour feature point is 7 units to the left of the center point of the first contour. If it is 7 units in the direction of 30 degrees to the upper right, then S = [30°, 7].

[0093] Figure 12 This is a schematic diagram of the offset vector of a contour feature point according to an embodiment of this application. For example... Figure 12 As shown, the direction angle of feature point 1 refers to the angle from the horizontal direction to the line connecting feature point 1 and center point C when rotated counterclockwise. The length of feature point 1 refers to the length of the line connecting feature point 1 and center point C. The direction angle of feature point 1 is a1 degrees, and the length of feature point 1 is d1. Therefore, the offset vector of feature point 1 is represented as [a1 degrees, d1]. The direction angle of feature point 2 refers to the angle from the horizontal direction to the line connecting feature point 2 and center point C when rotated counterclockwise. The length of feature point 2 refers to the length of the line connecting feature point 2 and center point C. The direction angle of feature point 2 is a2 degrees, and the length of feature point 2 is d2. Therefore, the offset vector of feature point 2 is represented as [a2 degrees, d2].

[0094] In this embodiment, the relevant vector parameters are represented using symbolic and numerical relativistic methods. This is inspired by biological vision's ability to distinguish features such as position, size, and orientation, rather than employing mathematical formulas. Instead, it involves simply judging the differences in position, size, and orientation between feature points. The design method of the offset vector expression simplifies the calculation of contour transformation and contour feature comparison during contour feature transformation (described later), and is more in line with the characteristics of biological vision in recognizing and comparing objects.

[0095] For example, the process of obtaining the second contour feature data of the second target image can be the same as the process of obtaining the first contour feature data of the first target image described above. Specifically, refer to the process of obtaining the first contour feature data of the first target image described above. This embodiment will not be discussed in detail here.

[0096] For example, to improve the performance of image recognition, the contour feature data of the base target image can be acquired and stored in advance. The process of acquiring the contour feature data of the base target image can be the same as the process of acquiring the first contour feature data of the first target image described above. Specifically, refer to the process of acquiring the first contour feature data of the first target image described above. This embodiment will not be discussed in detail here.

[0097] For example, the above method can be applied to extract contour feature data from frequently used basic target object images such as circles, triangles, polygons, multi-wave curves, broken lines, inner arcs, and outer arcs. This contour feature data is then stored in a basic primitive annotation dataset. These basic primitives (basic target object images) are further spatially combined, and artificial intelligence technology combined with human intervention is used for concept naming and labeling, gradually forming multi-layered, higher-level basic primitive annotation datasets. These datasets can include text, classic patterns, feature graphics, etc. The scale is gradually increased during application development, and data samples adapted to multi-domain features are categorized, thereby improving the accuracy and efficiency of image recognition, as well as the performance of image annotation and image retrieval.

[0098] Accordingly, the process of obtaining the second contour feature data of the second target image may include: obtaining the second contour feature data of the second target image from the contour feature data of the base target image.

[0099] Step 102: Calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data.

[0100] The first contour feature data includes first contour feature chain data, first contour feature point data of the first contour feature chain, and first contour center point data of the first contour feature chain; the second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain.

[0101] By normalizing, transforming, and transforming the first contour feature data of the first target image with pixel blocks as the basic unit, the first contour feature data of the first target image is made to overlap with the second contour feature data of the second target image to the greatest extent (the parameters tend to be equal), and the transformation cost and overlap difference are calculated.

[0102] In implementation, the above transformation process can be performed on each of the first contour feature chains, that is, transformed into each of the second contour feature chains respectively.

[0103] In one optional implementation, the process of calculating the overlap difference and transformation cost when transforming the first contour feature data to achieve maximum overlap with the second contour feature data may include the following steps B1 to B4:

[0104] Step B1: Transform the first contour feature data into the second contour feature data by aligning the center points to obtain the first intermediate contour feature data.

[0105] For example, the process of transforming the first contour feature data into the second contour feature data by center point coincidence to obtain the first intermediate contour feature data may include: calculating the center point transformation parameters when the first contour center point data is transformed to coincide with the second contour center point data; and transforming the first contour feature point data according to the center point transformation parameters to obtain the first intermediate contour feature data.

[0106] For example, the center point transformation parameters may include, but are not limited to, changes in direction angle and changes in length.

[0107] In implementation, for each first contour feature chain, the center point transformation parameters can be calculated to transform the first contour center point data of the first contour feature chain to coincide with the second contour center point data of each second contour feature chain.

[0108] In implementation, for each first contour feature chain, the data of each first contour feature point in the first contour feature chain can be transformed according to the transformation parameters of the center point of the first contour feature chain to obtain the first intermediate contour feature data. It is understandable that changes in the first contour feature point data will also cause changes in the corresponding first contour feature chain data.

[0109] The first intermediate contour feature data includes first intermediate contour feature chain data, first intermediate contour feature point data of the first intermediate contour feature chain, and first intermediate contour center point data of the first intermediate contour feature chain. Similar to the first contour feature data, the first intermediate contour feature chain data may include the offset vector of the first intermediate contour feature chain, the first intermediate contour feature point data may include the offset vector of the first intermediate contour feature point, and the first intermediate contour center point data may include the coordinates of the first intermediate contour center point.

[0110] For example, the coordinates of the first contour center point Cb of the first contour feature chain Ob are (8, 0), and the coordinates of the second contour center point Ca of the second contour feature chain Oa are (4, 3). These can be converted into vector expressions: Cb[0°, 8], Ca[45°, 5]. Moving Cb to Ca increases the direction angle by 45° and decreases the length by 3. Then, increasing the direction angle of the offset vector of the first contour feature point of the first contour feature chain by 45° and decreasing the length by 3 completes the transformation from the first contour feature chain Ob to the first intermediate contour feature chain Ob1, giving Ob and Oa the same center point and completing the normalization of Ob to the center point of Oa.

[0111] Step B2: Transform the first intermediate contour feature data into the second contour feature data by the same proportion to obtain the second intermediate contour feature data, and calculate the cost of the same proportion transformation.

[0112] For example, the process of performing a year-on-year transformation on the first intermediate contour feature data to obtain the second intermediate contour feature data and calculating the year-on-year transformation cost may include: calculating a first average distance from the first intermediate contour feature point data to the first intermediate contour center point data, calculating a second average distance from the second contour feature point data to the second contour center point data, using the ratio of the first average distance to the second average distance as a year-on-year transformation parameter; transforming the first intermediate contour feature point data according to the year-on-year transformation parameter to obtain the second intermediate contour feature data; and using the product of the year-on-year transformation parameter and the year-on-year transformation weight as the year-on-year transformation cost.

[0113] In implementation, for each first contour feature chain, the first average distance from the first intermediate contour feature point data to the first intermediate contour center point data can be calculated, and the second average distance from the second contour feature point data to the second contour center point data can be calculated. The ratio of the first average distance to the second average distance can be used as the year-on-year transformation parameter.

[0114] In implementation, for each first contour feature chain, the first intermediate contour feature point data can be transformed according to the aforementioned proportional transformation parameters. It is understood that changes in the first contour feature point data will also cause changes in the corresponding first contour feature chain data.

[0115] The second intermediate contour feature data includes second intermediate contour feature chain data, second intermediate contour feature point data of the second intermediate contour feature chain, and second intermediate contour center point data of the second intermediate contour feature chain. Similar to the first contour feature data, the second intermediate contour feature chain data may include the offset vector of the second intermediate contour feature chain, the second intermediate contour feature point data may include the offset vector of the second intermediate contour feature point, and the second intermediate contour center point data may include the coordinates of the second intermediate contour center point.

[0116] For example, calculate the average distance r1 from the first intermediate contour feature point to the center point of the first intermediate contour in the first intermediate contour feature chain Ob1, and the average distance r0 from the second contour feature point to the center point of the second contour in the second contour feature chain Oa, and use r1 / r0 as the proportional transformation parameter. Then, change the length of the offset vector of the first intermediate contour feature point of the first intermediate contour feature chain Ob1 according to r1 / r0 (while keeping the direction and angle unchanged), thus completing the proportional transformation from the first intermediate contour feature chain Ob1 to the second intermediate contour feature chain Ob2.

[0117] Year-on-year transformation cost = (r1 / r0) × year-on-year transformation weight

[0118] Step B3: Perform a plastic transformation on the second intermediate contour feature data to obtain the third intermediate contour feature data, and calculate the plastic transformation cost and the overlap difference.

[0119] For example, the process of performing a plastic transformation on the second intermediate contour feature data to obtain third intermediate contour feature data, and calculating the plastic transformation cost and the overlap difference, may include: performing a shape transformation on the second intermediate contour feature data to transform the second intermediate contour feature data to achieve the maximum overlap with the second contour feature data, thereby obtaining third intermediate contour feature data; obtaining shape transformation parameters, and using the product of the shape transformation parameters and shape transformation weights as the plastic transformation cost; obtaining the vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data, and using the sum of the products of each vector deviation and the deviation weight as the overlap difference.

[0120] For example, the shape transformation may include, but is not limited to, rotation transformation, scaling transformation, translation transformation, etc. Different shape transformations correspond to different shape transformation parameters and shape transformation weights. The cost of the shape transformation is the sum of the products of each shape transformation parameter and shape transformation weight.

[0121] For example, rotation transformation corresponds to rotation transformation parameters and rotation transformation weights; the rotation transformation parameters can include the rotation angle. Scaling transformation corresponds to scaling transformation parameters and scaling transformation weights; the scaling transformation parameters can include the scaling ratio. Translation transformation corresponds to translation transformation parameters and translation transformation weights; the translation transformation parameters can include the translation distance.

[0122] For example, the vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data may include a direction angle deviation and a length ratio. The direction angle deviation corresponds to the direction angle deviation weight, and the length ratio corresponds to the length deviation weight.

[0123] In one optional embodiment, the process of transforming the shape of the second intermediate contour feature data may include: performing overall shape transformation and local shape transformation on the second intermediate contour feature data in sequence.

[0124] For example, after the aforementioned center point coincidence transformation and proportional transformation, the center points of the second intermediate contour feature chain Ob2 and the second contour feature chain Oa are the same (approximately) and their size ratios are the same (approximately). Then, the second intermediate contour feature chain Ob2 is rotated, scaled, and translated as a whole (all contour feature points and contour feature chains) in sequence. Then, local contour feature points are rotated, scaled, and translated to achieve the highest degree of overlap between the third intermediate contour feature chain Ob3 and the second contour feature chain Oa (the closer the vector direction angles of each contour feature point on the contour feature chain are, the closer the vector lengths are, and the fewer redundant or missing contour feature points there are, the higher the degree of overlap). During the rotation, scaling, and translation processes, rotation, scaling, and translation can be performed in a set order. Furthermore, during each shape transformation, shape transformations are performed sequentially according to preset shape transformation parameters. The next shape transformation is performed when the degree of overlap no longer increases but decreases.

[0125] The vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data includes the direction angle deviation and the length ratio. The expression for calculating the overlap difference between multiple sets of nearest third intermediate contour feature point data and second contour feature point data is as follows:

[0126] Overlap difference = Σ(direction angle deviation i × direction angle deviation weight + length ratio pi × length deviation weight) = direction angle deviation 1 × direction angle deviation weight + length ratio p1 × length deviation weight + direction angle deviation 2 × direction angle deviation weight + length ratio pi × length deviation weight + ... + direction angle deviation n × direction angle deviation weight + length ratio pn × length deviation weight.

[0127] Coincidence = 1 / coincidence difference

[0128] The smaller the overlap difference, the higher the overlap. When the overlap difference = 0, it means that the two compared objects are completely identical.

[0129] The operations performed to achieve maximum overlap are: ① rotation, ② scaling, ③ translation, and ④ local transformation. The required parameters are calculated sequentially: cost of rotation transformation, cost of scaling transformation, cost of translation transformation, and cost of local transformation.

[0130] Rotation transformation cost = Rotation angle × Rotation transformation weight

[0131] Scaling cost = Scaling ratio × Scaling weight

[0132] Translation cost = Translation distance × Translation weight

[0133] The rotation cost, scaling cost, and translation cost are all values ​​that represent the overall movement or deformation of the Ob2 contour feature chain.

[0134] The cost of local transformation is the rotation, scaling, or translation of certain contour feature points in the contour feature chain, with the aim of achieving maximum overlap.

[0135] Local transformation cost = Σ(local transformation amount × local transformation weight) = local rotation angle × local rotation transformation weight + local scaling ratio × local scaling transformation weight + local translation distance × local translation transformation weight.

[0136] Cost of plastic transformation = Cost of rotation transformation + Cost of scaling transformation + Cost of translation transformation + Cost of local transformation.

[0137] Step B4: The sum of the same-year transformation cost and the same-plastic transformation cost is taken as the transformation cost.

[0138] Step 103: Calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost.

[0139] For example, the process of calculating the similarity between the first target object and the second target object based on the overlap difference and the transformation cost may include: calculating the sum of the overlap difference and the transformation cost, and taking the ratio of the value 1 to the sum as the similarity between the first target object and the second target object.

[0140] The weighting coefficients mentioned above include: proportional transformation weight, direction angle deviation weight, length deviation weight, rotation transformation weight, scaling transformation weight, translation transformation weight, local rotation transformation weight, local scaling transformation weight, and local translation transformation weight. Theoretically, the values ​​of each weighting coefficient should be set as follows: local > global > length deviation > direction angle deviation > scaling > rotation > proportional > translation. These coefficient parameters can be adjusted to their optimal values ​​based on experience gained from extensive image recognition practices.

[0141] Reference Figure 13 The diagram illustrates a flowchart of another image recognition method according to an embodiment of this application.

[0142] like Figure 13 As shown, the image recognition method may include the following steps:

[0143] Step 1201: Obtain the first contour feature data of the first target image and the second contour feature data of the second target image.

[0144] Step 1202: Calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data.

[0145] Step 1203: Calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost.

[0146] Step 1204: Determine whether the first target object and the second target object are the same based on the similarity.

[0147] In one alternative implementation, when the total similarity or a preset proportion of similarity is greater than or equal to a preset threshold, it can be determined that the first target object and the second target object are the same.

[0148] In this embodiment of the application, considering that an important strategy for biometric visual recognition to achieve efficient and rapid judgment is fuzzy judgment, in order to quickly and cost-effectively distinguish objects, the main approach is to distinguish and compare the general outline of the object with key local features. For example, the principle is to identify a person by a silhouette or a mole. Therefore, a layered calculation method is proposed. The first layer serves as a preliminary and rapid fuzzy recognition and screening, and the second layer serves as a precise calculation of similarity.

[0149] For example, the first contour feature data includes a first outermost contour feature data and a first inner contour feature data, and the second contour feature data includes a second outermost contour feature data and a second inner contour feature data.

[0150] For example, the process of acquiring first contour feature data of a first target image may include: acquiring a first contour chain of the first target image; selecting first contour feature points from the first contour chain; based on the first contour feature points, acquiring a first outermost contour feature chain, the first outermost contour feature point of the first outermost contour feature chain, the first outermost contour center point of the first outermost contour feature chain, a first inner contour feature chain, the first inner contour feature point of the first inner contour feature chain, and the first inner contour center point of the first inner contour feature chain; acquiring the first outermost contour feature chain data, the first outermost contour feature point data of the first outermost contour feature chain, and the first outermost contour center point data of the first outermost contour feature chain as the first outermost contour feature data; acquiring the first inner contour feature chain data, the first inner contour feature point data of the first inner contour feature chain, and the first inner contour center point data of the first inner contour feature chain as the first inner contour feature data.

[0151] For example, the process of obtaining the first outermost contour feature chain based on the first contour feature points may include: selecting the first contour feature point with the largest abscissa, the first contour feature point with the smallest abscissa, the first contour feature point with the largest ordinate, and the first contour feature point with the smallest ordinate from the first contour feature points, and forming the first outermost contour feature chain by combining the selected first contour feature points. The first outermost contour feature chain is usually a closed loop chain with the first and last points connected.

[0152] For example, the process of obtaining the first internal contour feature chain based on the first contour feature point is the same as the process of obtaining the first contour feature chain based on the first contour feature point in the above embodiment. For details, please refer to the relevant description above. This embodiment will not be discussed in detail here.

[0153] The process of obtaining the first outermost contour feature chain data, the first outermost contour feature point data of the first outermost contour feature chain, and the first outermost contour center point data of the first outermost contour feature chain as the first outermost contour feature data, and the process of obtaining the first inner contour feature chain data, the first inner contour feature point data of the first inner contour feature chain, and the first inner contour center point data of the first inner contour feature chain as the first inner contour feature data, are the same as the process of obtaining the first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain as the first contour feature data. For details, please refer to the relevant description above. This embodiment will not be discussed in detail here.

[0154] Figure 14 This is a schematic diagram of an outermost contour feature chain according to an embodiment of this application. For example... Figure 14 As shown, the outermost contour feature points are combined to form the outermost contour feature chain.

[0155] Figure 15 This is a schematic diagram of the outermost contour feature points of an embodiment of this application. For example... Figure 15 As shown, the outermost contour feature points on the outermost contour feature chain are the contour feature points located on the outermost perimeter.

[0156] In one optional implementation, the process of calculating the overlap difference and transformation cost when transforming the first contour feature data to achieve maximum overlap with the second contour feature data, calculating the similarity between the first target object and the second target object based on the overlap difference and the transformation cost, and determining whether the first target object and the second target object are the same based on the similarity may include:

[0157] Calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve the maximum overlap with the second outermost contour feature data. Based on the outermost overlap difference and the outermost transformation cost, calculate the outermost similarity between the first target object and the second target object.

[0158] When the outermost similarity is less than a preset threshold, it is determined that the first target object and the second target object are different;

[0159] When the outermost similarity is greater than or equal to the preset threshold, calculate the internal overlap difference and internal transformation cost when the first internal contour feature data is transformed to achieve the maximum overlap with the second internal contour feature data. Based on the internal overlap difference and the internal transformation cost, calculate the internal similarity between the first target object and the second target object.

[0160] When the internal similarity (all or a preset proportion) is greater than or equal to the preset threshold, the first target object and the second target object are determined to be the same.

[0161] When the internal similarity (all or a preset proportion) is less than the preset threshold, the first target object and the second target object are determined to be different.

[0162] In one optional implementation, the process of calculating the overlap difference and transformation cost when transforming the first contour feature data to achieve maximum overlap with the second contour feature data, calculating the similarity between the first target object and the second target object based on the overlap difference and the transformation cost, and determining whether the first target object and the second target object are the same based on the similarity may include:

[0163] Calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve the maximum overlap with the second outermost contour feature data. Based on the outermost overlap difference and the outermost transformation cost, calculate the outermost similarity between the first target object and the second target object.

[0164] Calculate the internal overlap difference and internal transformation cost when the first internal contour feature data is transformed to achieve the maximum overlap with the second internal contour feature data. Based on the internal overlap difference and the internal transformation cost, calculate the internal similarity between the first target object and the second target object.

[0165] When the outermost similarity is less than a preset threshold and the internal similarity (all or a preset proportion) is greater than or equal to the preset threshold, it can be determined that the first target object and the second target object are partially the same.

[0166] When the outermost similarity is less than a preset threshold and the internal similarity (all or a preset proportion) is less than the preset threshold, it can be determined that the first target object and the second target object are locally different.

[0167] When the outermost similarity is greater than or equal to the preset threshold and the internal similarity (all or preset proportion) is greater than or equal to the preset threshold, it can be determined that the first target object and the second target object are the same.

[0168] When the outermost similarity is greater than or equal to the preset threshold and the internal similarity (all or a preset proportion) is less than the preset threshold, it can be determined that the first target object and the second target object are different.

[0169] In this embodiment, a hierarchical calculation method is designed. The first layer calculates and compares the outermost contour feature chains. If the similarity is very poor, it can be determined with a high probability that the two compared objects are different (of course, if the calculation in the next layer finds that the similarity of certain important contour feature chains (with high complexity or large size proportion) is extremely high, it can also be used to determine that the two compared objects are the same, one being a part of the other). The second layer iterates and calculates and compares all other contour feature chains, in order from largest to smallest, near to far, and complex to simple. This hierarchical similarity calculation and analysis method conforms to the characteristics of biological visual recognition: firstly, it allows for fuzzy judgment of object contours, quickly distinguishing species, and even recognizing an object from a shadow; further, it allows for more refined judgment through local features (e.g., judging an animal as a "tiger" by its stripes and the "king" character on its head). By abstracting the image of an object into a combination of points and lines, the method of comparing objects is simplified to comparing and judging points and lines, which also conforms to the characteristics of biological visual recognition (e.g., recognizing people, animals, etc., from a simple cartoon with just a few lines).

[0170] The image recognition method in this application embodiment is not a replacement for deep learning technology, but rather a new method that can provide modern deep learning image recognition technology with high efficiency, speed, minimal computation, and a clear decision-making process under the condition of a limited number of small sample images (videos, pictures). It can work in close collaboration with deep learning technology (for example, in the contour extraction aspect of this application embodiment, artificial intelligence technology can be combined and applied). It provides a new multimodal fusion approach for feature extraction and feature dimensionality reduction of input images, enabling automatic learning of abstract features in images.

[0171] One of the innovative technical points of this application is that it simulates and draws on the basic mechanisms of line drawing techniques in terms of fuzzy judgment and contour representation, thereby realizing a low-cost and efficient computer technology method for image recognition that is different from neural network deep learning. It is designed to conform to the characteristics of biological visual recognition: a hierarchical similarity calculation and analysis method; abstracting the image of an object into a combination of points and lines, and simplifying the comparison method of objects into a comparison and judgment of points and lines. The pixel blocks of the target object are used to extract the edge contours, and then the pixel data of the object edge contours are sampled hierarchically. An innovative algorithm is proposed, which uses appropriate parameters of the contour features of each level of the target object and contour feature point information as the main parameters for efficient and rapid comparison of similarity between objects. The decision speed of lower levels is fast, and the decision accuracy of higher levels is high, which conforms to the characteristics of fuzzy judgment in biological visual recognition. The hierarchy is set by sampling density and depth, with higher levels having higher sampling density and deeper depth. Each level calculates the contour feature vector parameters of the target object (a sequence of multiple vector values ​​including position, size, and orientation information).

[0172] Reference Figure 16The diagram shows a structural block diagram of an image recognition device according to an embodiment of this application.

[0173] like Figure 16 As shown, the image recognition device may include the following modules:

[0174] The acquisition module 1501 is used to acquire the first contour feature data of the first target image and the second contour feature data of the second target image;

[0175] The calculation module 1502 is used to calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data; and to calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost.

[0176] Optionally, the acquisition module 1501 includes:

[0177] The first acquisition unit is used to acquire the first contour chain of the first target object image;

[0178] A selection unit is used to select a first contour feature point from the first contour chain;

[0179] The second acquisition unit is used to acquire, based on the first contour feature point, a first contour feature chain, a first contour feature point of the first contour feature chain, and a first contour center point of the first contour feature chain.

[0180] The third acquisition unit is used to acquire the first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain as the first contour feature data.

[0181] Optionally, the first acquisition unit is specifically used to acquire pixel blocks of the first target image, and filter out edge pixel blocks from the pixel blocks; repeat the following operation until there are no remaining edge pixel blocks: select a starting edge pixel block, starting from the starting edge pixel block, sequentially select edge pixel blocks that are connected to the current edge pixel block in a set direction, and when there are no edge pixel blocks connected to the current edge pixel block or when returning to the starting edge pixel block, form a first contour chain from the selected edge pixel blocks.

[0182] Optionally, the first contour chain includes multiple edge pixel blocks; the selection unit is specifically used to determine the edge pixel blocks on the first contour chain whose second derivative is 0 and whose second derivative jumps as first contour feature points.

[0183] Optionally, the third acquisition unit includes:

[0184] The first coordinate acquisition subunit is used to acquire the coordinates of the first contour feature points of the first contour feature chain for each first contour feature chain.

[0185] The first vector acquisition subunit is used to acquire the offset vector of the first contour feature chain based on the coordinates of the first contour feature point, and use it as the first contour feature chain data.

[0186] The second coordinate acquisition subunit is used to acquire the coordinates of the first contour center point of the first contour feature chain based on the coordinates of the first contour feature point, and use it as the first contour center point data of the first contour feature chain.

[0187] The second vector acquisition subunit is used to acquire the offset vector of the first contour feature point of the first contour feature chain based on the coordinates of the first contour feature point and the coordinates of the first contour center point, and use it as the first contour feature point data of the first contour feature chain.

[0188] Optionally, the first vector acquisition subunit is specifically used to acquire the coordinates of the starting first contour feature point of the first contour feature chain; based on the coordinates of the first contour feature point, calculate the direction angle and length between the starting first contour feature point and the ending first contour feature point of the first contour feature chain, as the head and tail vectors of the first contour feature chain; based on the coordinates of the first contour feature point, calculate the direction angle and length between adjacent first contour feature points on the first contour feature chain, as the chain body vector of the first contour feature chain; and use the coordinates of the starting first contour feature point, the head and tail vectors, and the chain body vector as the offset vector of the first contour feature chain.

[0189] Optionally, the second vector acquisition subunit is specifically used to calculate the direction angle and length between the first contour center point and the first contour feature point for each first contour feature point in the first contour feature chain, based on the coordinates of the first contour feature point and the coordinates of the first contour center point, as the offset vector of the first contour feature point.

[0190] Optionally, the computing module 1502 includes:

[0191] The first transformation unit is used to transform the first contour feature data into the second contour feature data by center point coincidence transformation to obtain the first intermediate contour feature data.

[0192] The second transformation unit is used to perform a year-on-year transformation on the first intermediate contour feature data to the second contour feature data to obtain the second intermediate contour feature data, and to calculate the year-on-year transformation cost.

[0193] The third transformation unit is used to perform a plastic transformation on the second intermediate contour feature data to obtain the third intermediate contour feature data, and to calculate the plastic transformation cost and the overlap difference.

[0194] The cost calculation unit is used to take the sum of the same-year transformation cost and the same-plastic transformation cost as the transformation cost.

[0195] Optionally, the first contour feature data includes first contour feature chain data, first contour feature point data of the first contour feature chain, and first contour center point data of the first contour feature chain; the second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain.

[0196] The first transformation unit is specifically used to calculate the center point transformation parameters when the first contour center point data is transformed to coincide with the second contour center point data; and to transform the first contour feature point data according to the center point transformation parameters to obtain the first intermediate contour feature data.

[0197] Optionally, the first intermediate contour feature data includes first intermediate contour feature chain data, first intermediate contour feature point data of the first intermediate contour feature chain, and first intermediate contour center point data of the first intermediate contour feature chain; the second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain; the second transformation unit is specifically used to calculate a first average distance from the first intermediate contour feature point data to the first intermediate contour center point data, calculate a second average distance from the second contour feature point data to the second contour center point data, and use the ratio of the first average distance to the second average distance as a year-on-year transformation parameter; transform the first intermediate contour feature point data according to the year-on-year transformation parameter to obtain the second intermediate contour feature data; and use the product of the year-on-year transformation parameter and the year-on-year transformation weight as the year-on-year transformation cost.

[0198] Optionally, the second intermediate contour feature data includes second intermediate contour feature chain data, second intermediate contour feature point data of the second intermediate contour feature chain, and second intermediate contour center point data of the second intermediate contour feature chain. The second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain. The third transformation unit is specifically used to perform shape transformation on the second intermediate contour feature data so that the second intermediate contour feature data is transformed to achieve maximum overlap with the second contour feature data, thereby obtaining third intermediate contour feature data; obtaining shape transformation parameters, and using the product of the shape transformation parameters and shape transformation weights as the plastic transformation cost; obtaining the vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data, and using the sum of the products of each vector deviation and the deviation weight as the overlap difference.

[0199] Optionally, the third transformation unit is specifically used to sequentially perform overall shape transformation and local shape transformation on the second intermediate contour feature data.

[0200] Optionally, the apparatus further includes a determining module, configured to determine whether the first target object and the second target object are the same based on the similarity.

[0201] Optionally, the first contour feature data includes first outermost contour feature data and first inner contour feature data, and the second contour feature data includes second outermost contour feature data and second inner contour feature data.

[0202] The calculation module 1502 is specifically used to calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve maximum overlap with the second outermost contour feature data; and to calculate the outermost similarity between the first target object and the second target object based on the outermost overlap difference and the outermost transformation cost. Furthermore, when the outermost similarity is greater than or equal to the preset threshold, the module calculates the internal overlap difference and internal transformation cost when the first internal contour feature data is transformed to achieve maximum overlap with the second internal contour feature data; and to calculate the internal similarity between the first target object and the second target object based on the internal overlap difference and the internal transformation cost.

[0203] The determining module is specifically used to determine that the first target object and the second target object are different when the outermost similarity is less than a preset threshold; and to determine that the first target object and the second target object are the same when the internal similarity is greater than or equal to the preset threshold.

[0204] Optionally, the first contour feature data includes first outermost contour feature data and first inner contour feature data, and the second contour feature data includes second outermost contour feature data and second inner contour feature data.

[0205] The calculation module 1502 is specifically used to calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve maximum overlap with the second outermost contour feature data; and to calculate the outermost similarity between the first target object and the second target object based on the outermost overlap difference and the outermost transformation cost. It also calculates the internal overlap difference and internal transformation cost when the first internal contour feature data is transformed to achieve maximum overlap with the second internal contour feature data; and to calculate the internal similarity between the first target object and the second target object based on the internal overlap difference and the internal transformation cost.

[0206] The determining module is specifically used to determine that the first target object and the second target object are partially the same when the outermost similarity is less than a preset threshold and the internal similarity is greater than or equal to the preset threshold; and to determine that the first target object and the second target object are the same when the outermost similarity is greater than or equal to the preset threshold and the internal similarity is greater than or equal to the preset threshold.

[0207] Optionally, the calculation module 1502 includes: a similarity calculation unit, used to calculate the sum of the overlap difference and the transformation cost, and to use the ratio of the value 1 to the sum as the similarity between the first target and the second target.

[0208] Optionally, the apparatus further includes: a preprocessing module for pre-acquiring and storing contour feature data of a base target image; and an acquisition module specifically for acquiring second contour feature data of a second target image from the contour feature data of the base target image.

[0209] In this embodiment, the contour feature data of the target image is transformed to obtain the overlap difference and transformation cost, and the similarity is calculated based on the overlap difference and transformation cost. Compared with the method of obtaining similarity through deep learning models, there is no need for model training, no need for a large amount of sample data and computing resources, and there are no defects of deep learning models. Therefore, the image recognition is less complex, more efficient, and more accurate.

[0210] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0211] In embodiments of this application, an electronic device is also provided. This electronic device may include one or more processors and one or more computer-readable storage media storing instructions thereon, such as an application program. When the instructions are executed by the one or more processors, the processors cause the processors to perform the image recognition method of any of the above embodiments.

[0212] Reference Figure 17 The diagram illustrates a schematic representation of an electronic device structure according to an embodiment of this application. Figure 17 As shown, the electronic device includes a processor 1601, a communication interface 1602, a memory 1603, and a communication bus 1604. The processor 1601, communication interface 1602, and memory 1603 communicate with each other via the communication bus 1604.

[0213] Memory 1603 is used to store computer programs.

[0214] The processor 1601 is used to execute the program stored in the memory 1603 to implement the image recognition method of any of the above embodiments.

[0215] Communication interface 1602 is used for communication between the above-mentioned electronic device and other devices.

[0216] The aforementioned communication bus 1604 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, it is represented by only one thick line in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0217] The processor 1601 mentioned above may include, but is not limited to: a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0218] The aforementioned memory 1603 may include, but is not limited to: Read Only Memory (ROM), Random Access Memory (RAM), Compact Disc Read Only Memory (CD-ROM), Electronic Erasable Programmable Read Only Memory (EEPROM), Hard Disk, Floppy Disk, Flash Memory, etc.

[0219] In embodiments of this application, a computer-readable storage medium is also provided, on which a computer program is stored, which can be executed by a processor of an electronic device, and when the computer program is executed by the processor, the processor performs the image recognition method as described in any of the above embodiments.

[0220] The various embodiments in this specification are related to each other and are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other.

[0221] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where the application is located, and with the authorization granted by the owner of the relevant device.

[0222] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0223] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM, RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0224] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0225] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0226] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0227] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0228] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0229] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0230] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0231] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. In summary, the content of this specification should not be construed as a limitation of this application.

Claims

1. An image recognition method, characterized in that, The method includes: Acquire the first contour feature data of the first target image and the second contour feature data of the second target image; Calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data; Based on the overlap difference and the transformation cost, the similarity between the first target and the second target is calculated. The calculation of the overlap difference and transformation cost when the first contour feature data is transformed to the point where it achieves maximum overlap with the second contour feature data includes: The first contour feature data is transformed into the second contour feature data by coinciding the center point to obtain the first intermediate contour feature data. The first intermediate contour feature data is transformed into the second contour feature data by the same ratio to obtain the second intermediate contour feature data, and the cost of the same ratio transformation is calculated. Perform a plastic transformation on the second intermediate contour feature data to obtain the third intermediate contour feature data, and calculate the plastic transformation cost and the overlap difference. The sum of the proportional transformation cost and the same plastic transformation cost is taken as the transformation cost. The first intermediate contour feature data includes first intermediate contour feature chain data, first intermediate contour feature point data of the first intermediate contour feature chain, and first intermediate contour center point data of the first intermediate contour feature chain; the second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain. The step of performing a year-on-year transformation on the first intermediate contour feature data to obtain the second intermediate contour feature data, and calculating the year-on-year transformation cost, includes: Calculate the first average distance from the first intermediate contour feature point data to the first intermediate contour center point data, calculate the second average distance from the second contour feature point data to the second contour center point data, and use the ratio of the first average distance to the second average distance as the year-on-year transformation parameter. The first intermediate contour feature point data is transformed according to the year-on-year transformation parameters to obtain the second intermediate contour feature data. The product of the year-on-year transformation parameter and the year-on-year transformation weight is used as the year-on-year transformation cost. The second intermediate contour feature data includes second intermediate contour feature chain data, second intermediate contour feature point data of the second intermediate contour feature chain, and second intermediate contour center point data of the second intermediate contour feature chain. The second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain. The step of performing a plastic transformation on the second intermediate contour feature data to obtain the third intermediate contour feature data, and calculating the plastic transformation cost and overlap difference, includes: The second intermediate contour feature data is transformed to make the second intermediate contour feature data have the maximum overlap with the second contour feature data, thus obtaining the third intermediate contour feature data. Obtain the shape transformation parameters, and use the product of the shape transformation parameters and the shape transformation weights as the cost of the plastic transformation. Obtain the vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data, and use the sum of the products of each vector deviation and the deviation weight as the overlap difference.

2. The method according to claim 1, characterized in that, Obtain the first contour feature data of the first target object image, including: Obtain the first contour chain of the first target object image; Select a first contour feature point from the first contour chain; Based on the first contour feature point, obtain the first contour feature chain, the first contour feature point of the first contour feature chain, and the first contour center point of the first contour feature chain; The first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain are obtained as the first contour feature data.

3. The method according to claim 2, characterized in that, Obtaining the first contour chain of the first target object image includes: Obtain pixel blocks from the image of the first target object, and filter out edge pixel blocks from the pixel blocks; Repeat the following operation until there are no remaining edge pixel blocks: Select a starting edge pixel block, starting from the starting edge pixel block, sequentially select edge pixel blocks that are connected to the current edge pixel block in a set direction, and when there are no edge pixel blocks connected to the current edge pixel block or when returning to the starting edge pixel block, form a first contour chain from the selected edge pixel blocks.

4. The method according to claim 2, characterized in that, The first contour chain includes multiple edge pixel blocks; selecting a first contour feature point from the first contour chain includes: The edge pixel blocks on the first contour chain whose second derivative is 0 or whose second derivative jumps are identified as the first contour feature points.

5. The method according to claim 2, characterized in that, Acquiring the first contour feature chain data, the first contour feature point data of the first contour feature chain, and the first contour center point data of the first contour feature chain includes: For each first contour feature chain, obtain the coordinates of the first contour feature point of the first contour feature chain; Based on the coordinates of the first contour feature points, the offset vector of the first contour feature chain is obtained as the first contour feature chain data. Based on the coordinates of the first contour feature point, the coordinates of the first contour center point of the first contour feature chain are obtained as the first contour center point data of the first contour feature chain. Based on the coordinates of the first contour feature point and the coordinates of the first contour center point, the offset vector of the first contour feature point of the first contour feature chain is obtained, which is used as the first contour feature point data of the first contour feature chain.

6. The method according to claim 5, characterized in that, Based on the coordinates of the first contour feature points, the offset vector of the first contour feature chain is obtained, including: Obtain the coordinates of the starting first contour feature point of the first contour feature chain; Based on the coordinates of the first contour feature point, calculate the direction angle and length between the starting first contour feature point and the ending first contour feature point of the first contour feature chain, and use them as the start and end vectors of the first contour feature chain. Based on the coordinates of the first contour feature point, calculate the direction angle and length between adjacent first contour feature points on the first contour feature chain, and use them as the chain body vector of the first contour feature chain. The coordinates of the starting first contour feature point, the beginning and end vectors, and the chain body vector are used as the offset vectors of the first contour feature chain.

7. The method according to claim 5, characterized in that, Based on the coordinates of the first contour feature point and the coordinates of the first contour center point, the offset vector of the first contour feature point of the first contour feature chain is obtained, including: For each first contour feature point in the first contour feature chain, based on the coordinates of the first contour feature point and the coordinates of the first contour center point, the directional angle and length between the first contour center point and the first contour feature point are calculated as the offset vector of the first contour feature point.

8. The method according to claim 1, characterized in that, The first contour feature data includes first contour feature chain data, first contour feature point data of the first contour feature chain, and first contour center point data of the first contour feature chain; the second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain. The first contour feature data is transformed into the second contour feature data by aligning the center points to obtain the first intermediate contour feature data, including: Calculate the center point transformation parameters when the first contour center point data is transformed to coincide with the second contour center point data; The first contour feature point data is transformed according to the center point transformation parameters to obtain the first intermediate contour feature data.

9. The method according to claim 1, characterized in that, The second intermediate contour feature data is subjected to shape transformation, including: The second intermediate contour feature data are subjected to overall shape transformation and local shape transformation in sequence.

10. The method according to claim 1, characterized in that, The method further includes: Based on the similarity, it is determined whether the first target object and the second target object are the same.

11. The method according to claim 10, characterized in that, The first contour feature data includes first outermost contour feature data and first inner contour feature data, and the second contour feature data includes second outermost contour feature data and second inner contour feature data; Calculate the overlap difference and transformation cost when transforming the first contour feature data to achieve maximum overlap with the second contour feature data; calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost; and determine whether the first target object and the second target object are the same based on the similarity, including: Calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve the maximum overlap with the second outermost contour feature data. Based on the outermost overlap difference and the outermost transformation cost, calculate the outermost similarity between the first target object and the second target object. When the outermost similarity is less than a preset threshold, it is determined that the first target object and the second target object are different; When the outermost similarity is greater than or equal to the preset threshold, calculate the internal overlap difference and internal transformation cost when transforming the first internal contour feature data to achieve the maximum overlap with the second internal contour feature data. Based on the internal overlap difference and the internal transformation cost, calculate the internal similarity between the first target object and the second target object. When the internal similarity is greater than or equal to the preset threshold, determine that the first target object and the second target object are the same.

12. The method according to claim 10, characterized in that, The first contour feature data includes first outermost contour feature data and first inner contour feature data, and the second contour feature data includes second outermost contour feature data and second inner contour feature data; Calculate the overlap difference and transformation cost when transforming the first contour feature data to achieve maximum overlap with the second contour feature data; calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost; and determine whether the first target object and the second target object are the same based on the similarity, including: Calculate the outermost overlap difference and outermost transformation cost when the first outermost contour feature data is transformed to achieve the maximum overlap with the second outermost contour feature data. Based on the outermost overlap difference and the outermost transformation cost, calculate the outermost similarity between the first target object and the second target object. Calculate the internal overlap difference and internal transformation cost when the first internal contour feature data is transformed to achieve the maximum overlap with the second internal contour feature data. Based on the internal overlap difference and the internal transformation cost, calculate the internal similarity between the first target object and the second target object. When the outermost similarity is less than a preset threshold and the internal similarity is greater than or equal to the preset threshold, it is determined that the first target object and the second target object are partially identical. When the outermost similarity is greater than or equal to the preset threshold and the internal similarity is greater than or equal to the preset threshold, the first target object and the second target object are determined to be the same.

13. The method according to claim 1, characterized in that, Based on the overlap difference and the transformation cost, the similarity between the first target and the second target is calculated, including: Calculate the sum of the overlap difference and the transformation cost, and use the ratio of the value 1 to the sum as the similarity between the first target and the second target.

14. The method according to claim 1, characterized in that, Before acquiring the first contour feature data of the first target image and the second contour feature data of the second target image, the method further includes: acquiring and storing the contour feature data of the base target image in advance; Obtaining the second contour feature data of the second target image includes: obtaining the second contour feature data of the second target image from the contour feature data of the base target image.

15. An image recognition device, characterized in that, The device includes: The acquisition module is used to acquire the first contour feature data of the first target image and the second contour feature data of the second target image; The calculation module is used to calculate the overlap difference and transformation cost when the first contour feature data is transformed to achieve the maximum overlap with the second contour feature data; and to calculate the similarity between the first target object and the second target object based on the overlap difference and the transformation cost. The computing module includes: The first transformation unit is used to transform the first contour feature data into the second contour feature data by center point coincidence transformation to obtain the first intermediate contour feature data. The second transformation unit is used to perform a year-on-year transformation on the first intermediate contour feature data to the second contour feature data to obtain the second intermediate contour feature data, and to calculate the year-on-year transformation cost. The third transformation unit is used to perform a plastic transformation on the second intermediate contour feature data to obtain the third intermediate contour feature data, and to calculate the plastic transformation cost and the overlap difference. The cost calculation unit is used to take the sum of the same-year transformation cost and the same-plastic transformation cost as the transformation cost. The first intermediate contour feature data includes first intermediate contour feature chain data, first intermediate contour feature point data of the first intermediate contour feature chain, and first intermediate contour center point data of the first intermediate contour feature chain. The second contour feature data includes second contour feature chain data, second contour feature point data of the second contour feature chain, and second contour center point data of the second contour feature chain. The second transformation unit is specifically used to calculate a first average distance from the first intermediate contour feature point data to the first intermediate contour center point data, calculate a second average distance from the second contour feature point data to the second contour center point data, and use the ratio of the first average distance to the second average distance as a year-on-year transformation parameter. The first intermediate contour feature point data is transformed according to the year-on-year transformation parameter to obtain the second intermediate contour feature data. The product of the year-on-year transformation parameter and the year-on-year transformation weight is used as the year-on-year transformation cost. The second intermediate contour feature data includes second intermediate contour feature chain data, second intermediate contour feature point data of the second intermediate contour feature chain, and second intermediate contour center point data of the second intermediate contour feature chain. The third transformation unit is specifically used to perform shape transformation on the second intermediate contour feature data to transform it to achieve maximum overlap with the second contour feature data, thus obtaining third intermediate contour feature data; acquiring shape transformation parameters, and using the product of the shape transformation parameters and shape transformation weights as the plastic transformation cost; acquiring the vector deviation between the nearest third intermediate contour feature point data and the second contour feature point data, and using the sum of the products of each vector deviation and its weight as the overlap difference.

16. An electronic device, characterized in that, include: One or more processors; and One or more computer-readable storage media on which instructions are stored; When the instructions are executed by the one or more processors, the processors perform the image recognition method as described in any one of claims 1 to 14.

17. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, causes the processor to perform the image recognition method as described in any one of claims 1 to 14.

Citation Information

Patent Citations

  • Image comparison method based on contour similarity

    CN110766708A

  • Graph matching method and device, electronic equipment and storage medium

    CN112052909A