Image matching method and device, storage medium and electronic equipment
By using the first network model to extract the features of the target image, and using the network model trained by aggregated image features, the problem of low accuracy of traditional image matching methods under changes in illumination and viewing angles is solved, and the accuracy of image matching is improved.
Patent Information
- Application Number
- CN202310344386.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-03-31
AI Technical Summary
Traditional image matching methods are easily affected by changes in illumination and viewing angle, resulting in low image matching accuracy.
The target image features of the target image are extracted through the first network model, and matching is performed based on the features. The network model is trained by the aggregate image features of the sample image, and the aggregate image features include image features of the sample image at different rotation angles.
It improves the accuracy of image matching and can better reflect the characteristics of the target image at different rotation angles, thereby improving the accuracy of matching.
Smart Images

Figure CN118736248A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular, to an image matching method, device, storage medium and electronic device. Background Art
[0002] Image matching technology is widely used in many fields of daily life. It can be used for tasks such as visual navigation, image stitching, 3D reconstruction, visual positioning, scene depth calculation, target detection and tracking. In the drone business, image matching is mainly used for visual positioning of drones.
[0003] Traditional image matching methods such as SIFT (Scale-invariant Feature Transform), SURF (Speeded Up Robust Features), and ORB (Oriented FAST and Rotated BRIEF) are all based on geometric features for matching, which are easily affected by changes in lighting and viewing angles, resulting in low image matching accuracy. Therefore, how to improve the accuracy of image matching has become an urgent problem to be solved. Summary of the invention
[0004] In order to solve the above problems, the present disclosure provides an image matching method, device, storage medium and electronic device.
[0005] In a first aspect, the present disclosure provides an image matching method, comprising:
[0006] Inputting a target image to be matched into a first network model to obtain target image features output by the first network model;
[0007] Determining whether the target image matches a preset image according to the target image feature;
[0008] The first network model is trained by using sample images and aggregated image features corresponding to the sample images, and the aggregated image features are obtained by using image features of the sample images at different rotation angles.
[0009] Optionally, before inputting the target image to be matched into the first network model, the method further includes:
[0010] The target neural network model is trained according to the sample image features of the sample image to obtain the first network model, wherein the sample image features include the aggregated image features and the estimated image features, and the estimated image features are the image features of the sample image obtained through the target neural network.
[0011] Optionally, the training a target neural network model according to the sample image features of the sample image to obtain the first network model includes:
[0012] According to the sample image, the model training steps are executed cyclically until it is determined that the trained target neural network model meets the preset stop iteration condition, and the trained target neural network model is used as the first network model;
[0013] The model training step includes:
[0014] Inputting the sample image into the target neural network model to obtain the estimated image features;
[0015] Obtaining aggregated image features corresponding to the sample image;
[0016] Determining a target loss value according to the estimated image features and the aggregated image features;
[0017] When it is determined according to the target loss value that the target neural network model does not satisfy the preset stop iteration condition, the parameters of the target neural network model are updated according to the target loss value to obtain a trained target neural network model.
[0018] Optionally, the acquiring the aggregated image features corresponding to the sample image includes:
[0019] Rotate the sample image according to a preset rotation direction and / or multiple preset rotation angles to obtain multiple rotated images corresponding to the sample image;
[0020] The multiple rotated images are input into a preset second network model to obtain the aggregated image features.
[0021] Optionally, the second network model includes a plurality of feature extraction subnetworks, and different feature extraction subnetworks correspond to different preset rotation angles. Inputting the plurality of rotated images into the preset second network model to obtain the aggregated image features includes:
[0022] Inputting the plurality of rotated images into the plurality of feature extraction subnetworks respectively to obtain rotated image features output by each of the feature extraction subnetworks;
[0023] For each of the rotated image features, rotating the rotated image feature according to a preset rotation angle corresponding to the rotated image feature and / or in a direction opposite to the preset rotation direction, to obtain a reversely rotated image feature corresponding to the rotated image feature;
[0024] Vector splicing processing is performed on the multiple reverse-rotation image features to obtain the aggregated image feature.
[0025] Optionally, the aggregated image features include aggregated image feature point information and aggregated image description information, and the estimated image features include estimated image feature point information and estimated image description information; and determining the target loss value according to the estimated image features and the aggregated image features includes:
[0026] Determining a first loss value according to a difference between the aggregated image feature point information and the estimated image feature point information;
[0027] determining a second loss value according to a difference between the aggregated image description information and the estimated image description information;
[0028] Determining a third loss value according to the aggregated image feature point information and the aggregated image description information;
[0029] The target loss value is determined according to the first loss value, the second loss value, and the third loss value.
[0030] Optionally, the sample image includes a first sample image and a second sample image, and there is an overlapping area between the first sample image and the second sample image, and determining the third loss value according to the aggregated image feature point information and the aggregated image description information includes:
[0031] Determining a plurality of sampling points within the overlapping area;
[0032] Determine first feature point information and first image description information corresponding to each sampling point from the aggregated image features corresponding to the first sample image, and determine second feature point information and second image description information corresponding to each sampling point from the aggregated image features corresponding to the second sample image;
[0033] The third loss value is determined according to a first difference between the plurality of first feature point information and the plurality of second feature point information, and a second difference between the plurality of first image description information and the plurality of second image description information.
[0034] Optionally, determining whether the target image matches a preset image according to the target image feature includes:
[0035] Determining a degree of matching between the target image and the preset image according to the target image feature;
[0036] When the matching degree is greater than or equal to a preset matching degree threshold, it is determined that the target image matches the preset image.
[0037] In a second aspect, the present disclosure provides an image matching device, comprising:
[0038] An acquisition module, used for inputting a target image to be matched into a first network model to obtain target image features output by the first network model;
[0039] A matching module, used to determine whether the target image matches a preset image according to the target image features;
[0040] The first network model is trained by using sample images and aggregated image features corresponding to the sample images, and the aggregated image features are obtained by using image features of the sample images at different rotation angles.
[0041] Optionally, the device further comprises:
[0042] A model training module is used to train a target neural network model according to sample image features of the sample image to obtain the first network model, wherein the sample image features include the aggregated image features and the estimated image features, and the estimated image features are the image features of the sample image obtained through the target neural network.
[0043] Optionally, the model training module is further used to:
[0044] According to the sample image, the model training steps are executed cyclically until it is determined that the trained target neural network model meets the preset stop iteration condition, and the trained target neural network model is used as the first network model;
[0045] The model training step includes:
[0046] Inputting the sample image into the target neural network model to obtain the estimated image features;
[0047] Obtaining aggregated image features corresponding to the sample image;
[0048] Determining a target loss value according to the estimated image features and the aggregated image features;
[0049] When it is determined according to the target loss value that the target neural network model does not satisfy the preset stop iteration condition, the parameters of the target neural network model are updated according to the target loss value to obtain a trained target neural network model.
[0050] Optionally, the model training module is further used to:
[0051] Rotate the sample image according to a preset rotation direction and / or multiple preset rotation angles to obtain multiple rotated images corresponding to the sample image;
[0052] The multiple rotated images are input into a preset second network model to obtain the aggregated image features.
[0053] Optionally, the second network model includes a plurality of feature extraction subnetworks, and different feature extraction subnetworks correspond to different preset rotation angles. The model training module is further used for:
[0054] Inputting the plurality of rotated images into the plurality of feature extraction subnetworks respectively to obtain rotated image features output by each of the feature extraction subnetworks;
[0055] For each of the rotated image features, rotating the rotated image feature according to a preset rotation angle corresponding to the rotated image feature and / or in a direction opposite to the preset rotation direction, to obtain a reversely rotated image feature corresponding to the rotated image feature;
[0056] Vector splicing processing is performed on the multiple reverse-rotation image features to obtain the aggregated image feature.
[0057] Optionally, the aggregated image features include aggregated image feature point information and aggregated image description information, and the estimated image features include estimated image feature point information and estimated image description information; and the model training module is further used to:
[0058] Determining a first loss value according to a difference between the aggregated image feature point information and the estimated image feature point information;
[0059] determining a second loss value according to a difference between the aggregated image description information and the estimated image description information;
[0060] Determining a third loss value according to the aggregated image feature point information and the aggregated image description information;
[0061] The target loss value is determined according to the first loss value, the second loss value, and the third loss value.
[0062] Optionally, the sample image includes a first sample image and a second sample image, and there is an overlapping area between the first sample image and the second sample image. The model training module is further used to:
[0063] Determining a plurality of sampling points within the overlapping area;
[0064] Determine first feature point information and first image description information corresponding to each sampling point from the aggregated image features corresponding to the first sample image, and determine second feature point information and second image description information corresponding to each sampling point from the aggregated image features corresponding to the second sample image;
[0065] The third loss value is determined according to a first difference between the plurality of first feature point information and the plurality of second feature point information, and a second difference between the plurality of first image description information and the plurality of second image description information.
[0066] Optionally, the matching module is further used to:
[0067] Determining a degree of matching between the target image and the preset image according to the target image feature;
[0068] When the matching degree is greater than or equal to a preset matching degree threshold, it is determined that the target image matches the preset image.
[0069] In a third aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect of the present disclosure.
[0070] In a fourth aspect, the present disclosure provides an electronic device, including:
[0071] a memory having a computer program stored thereon;
[0072] A processor is used to execute the computer program in the memory to implement the steps of the method described in the first aspect of the present disclosure.
[0073] Through the above technical solution, the target image to be matched is input into the first network model to obtain the target image features output by the first network model; according to the target image features, it is determined whether the target image matches the preset image; wherein, the first network model is obtained by training the sample image and the aggregated image features corresponding to the sample image, and the aggregated image features are obtained by the image features of the sample image at different rotation angles. That is to say, the present disclosure extracts the target image features of the target image through the first network model, and then matches the target image with the preset image according to the target image features. Since the first network model is obtained by training the aggregated image features of the sample image, the aggregated image features include the image features of the sample image at different rotation angles, so that the target image features extracted according to the first network model can also reflect the image features of the target image at different rotation angles, and the accuracy of image matching according to the target image features will also be higher.
[0074] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0076] Figure 1 is a flowchart of an image matching method according to an exemplary embodiment of the present disclosure;
[0077] Figure 2 is a flowchart of another image matching method according to an exemplary embodiment of the present disclosure;
[0078] Figure 3 is a flowchart showing a model training step according to an exemplary embodiment of the present disclosure;
[0079] Figure 4 is a schematic diagram of a model training method according to an exemplary embodiment of the present disclosure;
[0080] Figure 5 is a block diagram of an image matching device according to an exemplary embodiment of the present disclosure;
[0081] Figure 6 is a block diagram of another image matching device according to an exemplary embodiment of the present disclosure;
[0082] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0083] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0084] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0085] In the description below, words such as “first” and “second” are only used for the purpose of distinguishing the description and should not be understood as indicating or implying relative importance or order.
[0086] First, the application scenario of the present invention is explained. The traditional image matching method needs to first find the maximum or minimum points of pixels in the image as the feature points of the image, and then use the surrounding pixels of these feature points to calculate the corresponding descriptors. Therefore, it is easily affected by the changes in lighting and perspective, resulting in a relatively low accuracy of image matching. In the related art, although the image matching method based on deep learning can solve the problems of lighting, perspective changes, etc., the direction of the descriptor used in the image matching process is fixed.
[0087] The inventors of the present disclosure discovered that in the visual positioning scenario of a drone, there may be a certain angle between the global three-dimensional map used by the drone and the yaw angle of the drone, resulting in the current image collected by the drone and the preset image to be matched may not be in the same direction. When the direction of the descriptor is fixed, the image matching accuracy is also relatively low.
[0088] In order to solve the above-mentioned problems, the present disclosure provides an image matching method, device, storage medium and electronic device, which extract target image features of a target image through a first network model, and then match the target image and a preset image according to the target image features. Since the first network model is trained by aggregated image features of sample images, the aggregated image features include image features of the sample image at different rotation angles, so that the target image features extracted according to the first network model can also reflect the image features of the target image at different rotation angles, and the accuracy of image matching according to the target image features will also be higher.
[0089] The present disclosure is described below in conjunction with specific embodiments.
[0090] Figure 1 1 is a flowchart of an image matching method according to an exemplary embodiment of the present disclosure. The method can be used in an electronic device, which can be a drone, a terminal, etc. The present disclosure does not limit this. In the present embodiment, a drone is used as an example for description. Figure 1 As shown, the method may include:
[0091] S101. Input a target image to be matched into a first network model to obtain target image features output by the first network model.
[0092] Among them, the target image can be an environmental image collected by the drone during flight, and the first network model can be a student network, which can be trained by multiple sample images and aggregated image features corresponding to each sample image. The aggregated image features can be obtained by image features of the sample images at different rotation angles.
[0093] In this step, after the target image is acquired, the target image may be input into the first network model, and features of the target image may be extracted through the first network model to obtain target image features of the target image.
[0094] S102: Determine whether the target image matches a preset image according to the target image feature.
[0095] The preset image may be a plurality of pre-stored environment images. Taking the visual positioning scenario of the drone as an example, environment images of multiple locations may be acquired in advance, and the plurality of environment images and the location information corresponding to each environment image may be stored. The drone may determine the current location of the drone through the environment image that matches the target image. For example, if the drone matches the target environment image, the current location of the drone may be determined according to the location information corresponding to the target environment image.
[0096] In this step, after the target image feature of the target image is obtained, the target image and the preset image can be compared according to the target image feature. In a possible implementation, the matching degree between the target image and the preset image can be determined according to the target image feature. When the matching degree is greater than or equal to a preset matching degree threshold, it is determined that the target image matches the preset image. The preset matching degree threshold can be preset based on experience. For example, the matching degree between the target image and the preset image can be determined according to the target image feature by a method of the prior art, which will not be described in detail here.
[0097] In the case that the preset image includes multiple ones, the matching degree between the target image and each preset image may be determined, and whether the target image matches the preset image may be determined based on the matching degree.
[0098] Using the above method, the target image features of the target image are extracted through the first network model, and then the target image and the preset image are matched according to the target image features. Since the first network model is trained by the aggregated image features of the sample image, the aggregated image features include the image features of the sample image at different rotation angles. Therefore, the target image features extracted according to the first network model can also reflect the image features of the target image at different rotation angles, and the accuracy of image matching according to the target image features will also be higher.
[0099] Figure 2 is a flowchart of another image matching method according to an exemplary embodiment of the present disclosure, such as Figure 2 As shown, the method may also include:
[0100] S103: training a target neural network model according to sample image features of the sample image to obtain a first network model.
[0101] Among them, the sample image can be an environmental image collected during the flight of the drone, and the sample image includes multiple images. The sample image features include the aggregated image features and the estimated image features. The estimated image features are the image features of the sample image obtained through the target neural network.
[0102] In this step, after obtaining the sample image, the estimated image features corresponding to the sample image can be obtained through the target neural network, and the aggregated image features corresponding to the sample image can be obtained through the preset second network model. The target loss value is determined according to the estimated image features and the aggregated image features, and the parameters of the target neural network model are updated according to the target loss value to obtain the trained target neural network model. When the trained target neural network model meets the preset stop iteration condition, the trained target neural network model is used as the first network model. Among them, the second network model can be a teacher network, which can be trained by the model training method of the prior art, and will not be repeated here.
[0103] In a possible implementation, the model training steps can be executed cyclically according to the sample image until it is determined that the trained target neural network model meets the preset stop iteration condition, and the trained target neural network model is used as the first network model. Figure 3 is a flowchart of a model training step according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the model training steps may include:
[0104] S31, inputting the sample image into the target neural network model to obtain the estimated image features.
[0105] In this step, one sample image may be selected from a plurality of sample images and input into the target neural network model, and features of the sample image may be extracted by the target neural network model to obtain the estimated image features.
[0106] S32: Obtain aggregated image features corresponding to the sample image.
[0107] In a possible implementation, features of the sample image may be extracted from multiple directions. For example, features of the sample image may be extracted from four directions: top, bottom, left, and right of the sample image to obtain multiple image features. The multiple image features are fused to obtain the aggregated image feature.
[0108] In a possible implementation, the sample image can be rotated according to a preset rotation direction and / or multiple preset rotation angles to obtain multiple rotated images corresponding to the sample image; the multiple rotated images are input into a preset second network model to obtain the aggregated image features. Wherein, the preset rotation direction can be clockwise or counterclockwise, which is not limited in the present disclosure. The preset rotation angle can be determined according to a preset number of rotations. For example, if the preset number of rotations is 4, the preset rotation angle may include 0°, 90°, 180°, and 270°. The preset number of rotations can be preset according to the hardware configuration of the drone. For example, if the computing power of the drone is relatively strong, a larger preset number of rotations can be set, for example, the preset number of rotations can be 6. If the algorithm of the drone is relatively weak, a smaller preset number of rotations can be set, for example, the preset number of rotations can be 3.
[0109] For example, if the preset rotation direction is clockwise, and the preset rotation angles include 0°, 90°, 180°, and 270°, the sample image can be rotated in the clockwise direction by 0°, 90°, 180°, and 270°, respectively, to obtain four rotated images corresponding to the sample image. The four rotated images are input into the second network model, and features of the four rotated images are extracted through the second network model to obtain aggregated image features corresponding to the sample image.
[0110] It should be noted that, in the above-mentioned embodiment, the sample image is rotated according to a preset rotation direction and a plurality of preset rotation angles. The present disclosure may also rotate the sample image only according to the preset rotation direction without limiting the angle of each rotation. The present disclosure may also rotate the sample image multiple times only according to a plurality of preset rotation angles without limiting the direction of each rotation.
[0111] Among them, the second network model can include multiple feature extraction subnetworks, different feature extraction subnetworks correspond to different preset rotation angles, and the weights of multiple feature extraction subnetworks can be the same, that is, multiple feature extraction subnetworks are exactly the same. It should be noted that targeted training can also be performed on different feature extraction subnetworks, and different weights can be set, which is not limited in the present disclosure. If the sample image is rotated only according to the preset rotation direction, different feature extraction subnetworks can also correspond to different preset rotation directions.
[0112] In a possible implementation, after acquiring a plurality of rotated images, the plurality of rotated images may be respectively input into the plurality of feature extraction subnetworks to acquire a rotated image feature output by each of the feature extraction subnetworks; for each of the rotated image features, the rotated image feature may be rotated according to a preset rotation angle corresponding to the rotated image feature and / or in a direction opposite to the preset rotation direction to obtain a reversely rotated image feature corresponding to the rotated image feature; and vector splicing processing may be performed on the plurality of reversely rotated image features to obtain the aggregated image feature.
[0113] It should be noted that the specific method of rotating the rotated image feature mentioned above can be determined according to the method of rotating the sample image. For example, if multiple rotated images are obtained by rotating the sample image according to a preset rotation direction and multiple preset rotation angles, then the rotated image feature is rotated according to the preset rotation angle corresponding to the rotated image feature and in the opposite direction of the preset rotation direction; if multiple rotated images are obtained by rotating the sample image according to the preset rotation direction, then the rotated image feature is rotated in the opposite direction of the preset rotation direction corresponding to the rotated image feature; if multiple rotated images are obtained by rotating the sample image according to multiple preset rotation angles, then the rotated image feature is rotated according to the preset rotation angle corresponding to the rotated image feature. For example, the rotated image feature can be rotated in the opposite direction according to the preset rotation angle. For example, if the preset rotation angle is 30°, the rotated image feature can be rotated -30°.
[0114] For example, if the preset rotation direction is clockwise, the preset rotation angles include 0°, 90°, 180°, and 270°, and the feature extraction subnetwork includes feature extraction subnetwork A, feature extraction subnetwork B, feature extraction subnetwork C, and feature extraction subnetwork D, then the rotated image A obtained by rotating the sample image 0° clockwise can be input into the feature extraction subnetwork A, and feature extraction is performed on the rotated image A through the feature extraction subnetwork A to obtain rotated image feature A, and the rotated image feature A is rotated 0° counterclockwise to obtain reversely rotated image feature A; the rotated image B obtained by rotating the sample image 90° clockwise is input into the feature extraction subnetwork B, and feature extraction is performed on the rotated image B through the feature extraction subnetwork B. Obtain a rotated image feature B, and rotate the rotated image feature B by 90° counterclockwise to obtain a reversely rotated image feature B; input the rotated image C obtained by rotating the sample image by 180° clockwise into the feature extraction subnetwork C, extract features from the rotated image C through the feature extraction subnetwork C, obtain rotated image feature C, and rotate the rotated image feature C by 180° counterclockwise to obtain a reversely rotated image feature C; input the rotated image D obtained by rotating the sample image by 270° clockwise into the feature extraction subnetwork D, extract features from the rotated image D through the feature extraction subnetwork D, obtain rotated image feature D, and rotate the rotated image feature D by 270° counterclockwise to obtain a reversely rotated image feature D. After obtaining the reversely rotated image feature A, the reversely rotated image feature B, the reversely rotated image feature C, and the reversely rotated image feature D, the reversely rotated image feature A, the reversely rotated image feature B, the reversely rotated image feature C, and the reversely rotated image feature D may be subjected to vector splicing processing to obtain the aggregated image feature. For example, if the reverse-rotated image is represented in RGB form, the vectors of the R, G, and B channels of the reverse-rotated image feature A, the reverse-rotated image feature B, the reverse-rotated image feature C, and the reverse-rotated image feature D may be respectively concatenated to obtain the aggregated image feature.
[0115] It should be noted that if the preset rotation angle is When rotating the sample image, the sample image can be rotated in the dimensions of the R channel and the G channel of the sample image. When rotating the rotated image feature, the rotated image feature can be rotated in the dimensions of the R channel and the G channel of the rotated image feature. The execution order of the above step S31 and step S32 is only an example. The present disclosure does not limit the execution order of step S31 and step S32. Step S31 and step S32 can be executed simultaneously.
[0116] S33: Determine a target loss value according to the estimated image feature and the aggregated image feature.
[0117] In a possible implementation, the aggregated image feature includes aggregated image feature point information and aggregated image description information, and the estimated image feature includes estimated image feature point information and estimated image description information; after determining the aggregated image feature corresponding to the sample image, a first loss value may be determined according to the difference between the aggregated image feature point information and the estimated image feature point information; a second loss value may be determined according to the difference between the aggregated image description information and the estimated image description information; a third loss value may be determined according to the aggregated image feature point information and the aggregated image description information; and the target loss value may be determined according to the first loss value, the second loss value, and the third loss value. The aggregated image feature point information includes information about feature points in the rotated image, the aggregated image description information includes description information corresponding to each feature point, the estimated image feature point information includes information about feature points in the sample image, and the estimated image description information includes description information corresponding to each feature point, and the description information is used to characterize local image information at the location of the feature point. For example, the description information may be a descriptor of the prior art.
[0118] It should be noted that the present disclosure does not limit the order of determining the first loss value, the second loss value, and the third loss value. The first loss value, the second loss value, and the third loss value can be determined simultaneously, or they can be determined in a preset order.
[0119] For example, the first loss value can be calculated by the following formula:
[0120] L1=(Score1-Score2) 2 (1)
[0121] Among them, L1 is the first loss value, Score1 is the aggregated image feature point information, and Score2 is the estimated image feature point information.
[0122] The second loss value can be calculated by the following formula:
[0123] L2=(Desc1-Desc2) 2 (2)
[0124] Wherein, L2 is the second loss value, Desc1 is the aggregated image description information, and Desc2 is the estimated image description information.
[0125] It should be understood that in some feasible implementations, the multiple sample images involved in training the target neural network model include a first sample image and a second sample image, and there may be an overlapping area between the first sample image and the second sample image. The first feature point information and the first image description information corresponding to each of the sampling points are determined from the aggregated image features corresponding to the first sample image, and the second feature point information and the second image description information corresponding to each of the sampling points are determined from the aggregated image features corresponding to the second sample image. By way of example, the aggregate image feature includes a first aggregate image feature corresponding to the first sample image and a second aggregate image feature corresponding to the second sample image, the first aggregate image feature includes first aggregate image feature point information and first aggregate image description information, and the second aggregate image feature includes second aggregate image feature point information and second aggregate image description information; after determining the aggregate image feature, a plurality of sampling points may be determined in the overlapping area, wherein the plurality of sampling points may be randomly determined and are not limited herein; for each of the sampling points, the first feature point information corresponding to the sampling point is determined from the first aggregate image feature point information, the first image description information corresponding to the sampling point is determined from the first aggregate image description information, the second feature point information corresponding to the sampling point is determined from the second aggregate image feature point information, and the second image description information corresponding to the sampling point is determined from the second aggregate image description information; the third loss value is determined according to a first difference between the plurality of first feature point information and the plurality of second feature point information, and a second difference between the plurality of first image description information and the plurality of second image description information.
[0126] It should be noted that the number of randomly determined sampling points can be determined according to the computing power of the drone. If the computing power of the drone is relatively strong, more sampling points can be determined. For example, the number of sampling points can be 512. If the computing power of the drone is relatively strong, more sampling points can be determined. For example, the number of sampling points can be 256.
[0127] For example, after 512 sampling points are randomly determined in the overlapping area of the first sample image and the second sample image, for each sampling point, the first feature point information corresponding to the sampling point can be determined from the first aggregated image feature point information according to the coordinate information of the sampling point, the first image description information corresponding to the sampling point can be determined from the first aggregated image description information, the second feature point information corresponding to the sampling point can be determined from the second aggregated image feature point information, and the second image description information corresponding to the sampling point can be determined from the second aggregated image description information. After determining the first feature point information, the second feature point information, the first image description information, and the second image description information of each sampling point, the third loss value can be calculated by the following formula:
[0128]
[0129] Wherein, L3 is the third loss value, C is the number of sampling points, d represents the dth sampling point among C sampling points, q represents the qth sampling point among C sampling points, s d is the first feature point information corresponding to the dth sampling point, s′ d is the second feature point information corresponding to the dth sampling point, s q is the first feature point information corresponding to the qth sampling point, s′ q is the second feature point information corresponding to the qth sampling point, f d is the first image description information corresponding to the dth sampling point, f′ d is the second image description information corresponding to the d-th sampling point, and M() is the contrast loss function of the prior art.
[0130] After determining the first loss value, the second loss value, and the third loss value, the target loss value can be calculated using the following formula:
[0131] L=L1+L2+L3 (4)
[0132] Among them, L is the target loss value.
[0133] S34. When it is determined according to the target loss value that the target neural network model does not satisfy the preset stop iteration condition, the parameters of the target neural network model are updated according to the target loss value to obtain a trained target neural network model.
[0134] The preset stop iteration condition may be any stop iteration condition in the prior art, and the present disclosure does not limit this.
[0135] In this step, after determining the target loss value, it can be determined whether the target loss value is less than or equal to the preset loss value threshold. If the target loss value is less than or equal to the preset loss value threshold, it means that the target neural network model meets the preset stop iteration condition, and the target neural network model is used as the first network model; if the target loss value is greater than the preset loss value threshold, it means that the target neural network model does not meet the preset stop iteration condition, and the parameters of the target neural network model are updated according to the target loss value to obtain the trained target neural network model.
[0136] It should be noted that the above steps S31 to S34 are a processing flow for a sample image. After obtaining the trained target neural network model, the trained target neural network model can be used as a new target neural network model, and a new sample image can be determined from multiple sample images, and the above steps S31 to S34 can be continued to be executed until it is determined that the trained target neural network model meets the preset stop iteration condition.
[0137] Figure 4 is a schematic diagram of a model training method according to an exemplary embodiment of the present disclosure, such as Figure 4 As shown, after the sample image is input into the second network model, the sample image is rotated n times by the second network model, and the rotation angles include θ0, θ1, ..., θ n-1 , obtain n rotated images after the sample image is rotated, input the n rotated images into n feature extraction subnetworks respectively, extract features of the n rotated images through the n feature extraction subnetworks, obtain n rotated image features, for each rotated image feature, reversely rotate the rotated image feature according to the rotation angle corresponding to the rotated image feature, and obtain reversely rotated image features. Taking the rotation angle θ1 as an example, after the sample image is rotated by θ1 to obtain rotated image 1, the rotated image 1 is input into the feature extraction subnetwork 1 to obtain rotated image feature 1, and the rotated image feature 1 is rotated by -θ1 to obtain reversely rotated image feature 1. After obtaining n reversely rotated image features, the n reversely rotated image features are vector-joined to obtain the feature point information of the aggregated image and the description information of the aggregated image.
[0138] The sample image is input into the target neural network model, and feature extraction is performed through the feature extraction subnetwork in the target neural network model to obtain the estimated image features corresponding to the sample image, and the estimated image features include estimated image feature point information and estimated image description information. The target loss value is determined according to the aggregated image feature point information, the aggregated image description information, the estimated image feature point information, and the estimated image description information, and the parameters of the target neural network model are updated according to the target loss value.
[0139] Through the above-mentioned model training method, the sample image is rotated to obtain rotated images of the sample image at different rotation angles, the rotation image features of each rotated image are extracted, and each rotated image feature is rotated again in the opposite direction to obtain multiple reverse rotation image features, and the multiple reverse rotation image features are vector-joined to obtain aggregated image features. The aggregated image features fuse the image features of the sample image at different rotation angles, so that the first network model trained according to the aggregated image features can also extract the image features of the image at different rotation angles, thereby improving the accuracy of the first network model in extracting image features.
[0140] Figure 5 is a block diagram of an image matching device according to an exemplary embodiment of the present disclosure. Figure 5 As shown, the device may include:
[0141] An acquisition module 501 is used to input a target image to be matched into a first network model to obtain target image features output by the first network model;
[0142] A matching module 502 is used to determine whether the target image matches a preset image according to the target image feature;
[0143] The first network model is trained by a sample image and aggregated image features corresponding to the sample image, and the aggregated image features are obtained by image features of the sample image at different rotation angles.
[0144] Optionally, Figure 6 is a block diagram of another image matching device according to an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the device also includes:
[0145] The model training module 503 is used to train the target neural network model according to the sample image features of the sample image to obtain the first network model. The sample image features include the aggregated image features and the estimated image features. The estimated image features are the image features of the sample image obtained through the target neural network.
[0146] Optionally, the model training module 503 is further used to:
[0147] According to the sample image, the model training steps are executed cyclically until it is determined that the trained target neural network model meets the preset stop iteration condition, and the trained target neural network model is used as the first network model;
[0148] The model training steps include:
[0149] Inputting the sample image into the target neural network model to obtain the estimated image features;
[0150] Obtaining aggregated image features corresponding to the sample image;
[0151] Determining a target loss value according to the estimated image feature and the aggregated image feature;
[0152] When it is determined according to the target loss value that the target neural network model does not satisfy the preset stop iteration condition, the parameters of the target neural network model are updated according to the target loss value to obtain a trained target neural network model.
[0153] Optionally, the model training module 503 is further used to:
[0154] Rotate the sample image according to a preset rotation direction and / or multiple preset rotation angles to obtain multiple rotated images corresponding to the sample image;
[0155] The multiple rotated images are input into a preset second network model to obtain the aggregated image features.
[0156] Optionally, the second network model includes a plurality of feature extraction subnetworks, and different feature extraction subnetworks correspond to different preset rotation angles. The model training module 503 is further used for:
[0157] Inputting the multiple rotated images into the multiple feature extraction sub-networks respectively to obtain the rotated image features output by each of the feature extraction sub-networks;
[0158] For each of the rotated image features, the rotated image feature is rotated according to a preset rotation angle corresponding to the rotated image feature and / or in a direction opposite to the preset rotation direction to obtain a reversely rotated image feature corresponding to the rotated image feature;
[0159] Vector splicing is performed on the multiple reverse-rotation image features to obtain the aggregated image feature.
[0160] Optionally, the aggregated image feature includes aggregated image feature point information and aggregated image description information, and the estimated image feature includes estimated image feature point information and estimated image description information; the model training module 503 is further used to:
[0161] Determining a first loss value according to a difference between the aggregated image feature point information and the estimated image feature point information;
[0162] Determining a second loss value according to a difference between the aggregated image description information and the estimated image description information;
[0163] Determining a third loss value according to the aggregated image feature point information and the aggregated image description information;
[0164] The target loss value is determined according to the first loss value, the second loss value and the third loss value.
[0165] Optionally, the sample image includes a first sample image and a second sample image, there is an overlapping area between the first sample image and the second sample image, the aggregated image feature includes a first aggregated image feature corresponding to the first sample image and a second aggregated image feature corresponding to the second sample image, and the model training module 503 is further used to:
[0166] Determine a plurality of sampling points within the overlapping region;
[0167] Determine first feature point information and first image description information corresponding to each sampling point from the aggregated image features corresponding to the first sample image, and determine second feature point information and second image description information corresponding to each sampling point from the aggregated image features corresponding to the second sample image;
[0168] The third loss value is determined according to a first difference between the plurality of first feature point information and the plurality of second feature point information, and a second difference between the plurality of first image description information and the plurality of second image description information.
[0169] Optionally, the matching module 502 is further configured to:
[0170] Determining a degree of matching between the target image and the preset image according to the target image feature;
[0171] When the matching degree is greater than or equal to a preset matching degree threshold, it is determined that the target image matches the preset image.
[0172] Through the above-mentioned device, the target image features of the target image are extracted through the first network model, and then the target image and the preset image are matched according to the target image features. Since the first network model is trained by the aggregated image features of the sample image, the aggregated image features include the image features of the sample image at different rotation angles, so that the target image features extracted according to the first network model can also reflect the image features of the target image at different rotation angles, and the accuracy of image matching according to the target image features will also be higher.
[0173] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0174] Figure 7 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment of the present disclosure. Figure 7 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output interface 704, and a communication component 705.
[0175] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned image matching method. The memory 702 is used to store various types of data to support the operation of the electronic device 700. For example, these data may include instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The input / output interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0176] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned image matching method.
[0177] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned image matching method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned image matching method.
[0178] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned image matching method when executed by the programmable device.
[0179] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings. However, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, the technical solution of the present disclosure can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present disclosure. It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0180] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. An image matching method, characterized in that: include: Inputting a target image to be matched into a first network model to obtain target image features output by the first network model; Determining whether the target image matches a preset image according to the target image feature; The first network model is trained by using sample images and aggregated image features corresponding to the sample images, and the aggregated image features are obtained by using image features of the sample images at different rotation angles.
2. The method according to claim 1, characterized in that Before inputting the target image to be matched into the first network model, the method further includes: The target neural network model is trained according to the sample image features of the sample image to obtain the first network model, wherein the sample image features include the aggregated image features and the estimated image features, and the estimated image features are the image features of the sample image obtained through the target neural network.
3. The method according to claim 2, characterized in that The step of training a target neural network model according to the sample image features of the sample image to obtain the first network model comprises: According to the sample image, the model training steps are executed cyclically until it is determined that the trained target neural network model meets the preset stop iteration condition, and the trained target neural network model is used as the first network model; The model training step includes: Inputting the sample image into the target neural network model to obtain the estimated image features; Obtaining aggregated image features corresponding to the sample image; Determining a target loss value according to the estimated image features and the aggregated image features; When it is determined according to the target loss value that the target neural network model does not satisfy the preset stop iteration condition, the parameters of the target neural network model are updated according to the target loss value to obtain a trained target neural network model.
4. The method according to claim 3, characterized in that The acquiring of the aggregated image features corresponding to the sample image comprises: Rotate the sample image according to a preset rotation direction and / or multiple preset rotation angles to obtain multiple rotated images corresponding to the sample image; The multiple rotated images are input into a preset second network model to obtain the aggregated image features.
5. The method according to claim 4, characterized in that The second network model includes a plurality of feature extraction subnetworks, and different feature extraction subnetworks correspond to different preset rotation angles. Inputting the plurality of rotated images into the preset second network model to obtain the aggregated image features includes: Inputting the plurality of rotated images into the plurality of feature extraction subnetworks respectively to obtain rotated image features output by each of the feature extraction subnetworks; For each of the rotated image features, rotating the rotated image feature according to a preset rotation angle corresponding to the rotated image feature and / or in a direction opposite to the preset rotation direction, to obtain a reversely rotated image feature corresponding to the rotated image feature; Vector splicing processing is performed on the multiple reverse-rotation image features to obtain the aggregated image feature.
6. The method according to claim 3, characterized in that The aggregated image features include aggregated image feature point information and aggregated image description information, and the estimated image features include estimated image feature point information and estimated image description information; and determining the target loss value according to the estimated image features and the aggregated image features includes: Determining a first loss value according to a difference between the aggregated image feature point information and the estimated image feature point information; determining a second loss value according to a difference between the aggregated image description information and the estimated image description information; Determining a third loss value according to the aggregated image feature point information and the aggregated image description information; The target loss value is determined according to the first loss value, the second loss value, and the third loss value.
7. The method according to claim 6, characterized in that The sample image includes a first sample image and a second sample image, and there is an overlapping area between the first sample image and the second sample image. The determining the third loss value according to the aggregated image feature point information and the aggregated image description information includes: Determining a plurality of sampling points within the overlapping area; Determine first feature point information and first image description information corresponding to each sampling point from the aggregated image features corresponding to the first sample image, and determine second feature point information and second image description information corresponding to each sampling point from the aggregated image features corresponding to the second sample image; The third loss value is determined according to a first difference between the plurality of first feature point information and the plurality of second feature point information, and a second difference between the plurality of first image description information and the plurality of second image description information.
8. The method according to any one of claims 1 to 7, characterized in that: The determining, according to the target image feature, whether the target image matches a preset image comprises: Determining a degree of match between the target image and the preset image according to the target image feature; When the matching degree is greater than or equal to a preset matching degree threshold, it is determined that the target image matches the preset image.
9. An image matching device, characterized in that: include: An acquisition module, used for inputting a target image to be matched into a first network model to obtain target image features output by the first network model; A matching module, used to determine whether the target image matches a preset image according to the target image features; The first network model is trained by using sample images and aggregated image features corresponding to the sample images, and the aggregated image features are obtained by using image features of the sample images at different rotation angles.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.
11. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image matching method based on edge direction and gradient characteristics
CN110197232A
Cross-view image matching method for unmanned aerial vehicle image and satellite image
CN112580546A
Small sample target detection method based on multi-angle information and related equipment
CN115731210A
System and service providing method for parking fee managemen
KR102194432B1
