Image processing method, device, electronic device and storage medium
By connecting images and using a neural network model to determine feature point matching, the problem of insufficient feature point matching accuracy is solved and higher image registration accuracy is achieved.
Patent Information
- Application Number
- CN202210226669.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-09
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-03-09
AI Technical Summary
Existing image registration algorithms rely on feature point descriptors during the feature point matching process, resulting in insufficient accuracy when the image is distorted or the descriptor dimension is low, making it difficult to improve the accuracy of feature point matching.
Feature points are extracted by connecting the first image and the second image, using a neural network model to determine matching points based on the relative positional relationship between feature points, and fusing the positional relationship of feature points in the feature map to avoid relying solely on descriptors for matching. .
It improves the accuracy of feature point matching, avoids the limitations of traditional algorithms, and enhances the accuracy of image registration.
Smart Images

Figure CN114627169B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision of artificial intelligence, and more specifically, to methods, devices, equipment and storage media for image processing. Background Art
[0002] Image registration algorithms have a huge application scenario in industrial artificial intelligence (AI) quality inspection. In the current industrial AI quality inspection platform, industrial manufacturing components, especially 3C components, are usually small and precisely constructed, so the cameras are designed to shoot at multiple angles for locations where defects frequently occur. When it comes to a specific camera, there will be a fixed "region of interest (ROI) area" for clear photos, while the rest of the area is relatively blurry and left for other cameras to take photos. The image registration method is to align the ROI area of the captured image with the standard image so that the subsequent defect comparison learning module can effectively locate and identify defects in the ROI area.
[0003] Image registration is the process of matching two images acquired under different conditions (different time, different imaging devices, different angles, lighting conditions, etc.). The image registration process can be roughly divided into four parts: feature point detection and special description, feature point matching, external point filtering, and pose estimation. Among them, feature point detection and feature description will obtain the position and descriptor of each feature point in the image; feature point matching is to obtain the matching relationship between the feature points in the two images based on the position and descriptor of the feature points in the two images. Feature point matching is a core part of the image registration algorithm.
[0004] The commonly used feature point matching method currently mainly determines the feature point matching relationship based on the distance information of the feature point descriptor. Since this method only considers the descriptor, errors will occur when the descriptor is not accurate enough. For example, when the image is distorted or the descriptor dimension is low, the descriptor may not be accurate enough. Therefore, how to improve the accuracy of feature point matching is an urgent problem to be solved. Summary of the invention
[0005] The embodiments of the present application provide an image processing method, apparatus, device, and storage medium, which can help improve the accuracy of feature point matching.
[0006] In a first aspect, a method for image processing is provided, comprising:
[0007] Performing feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image;
[0008] Connecting the first image and the second image to obtain a third image;
[0009] Extracting feature points from the third image to obtain a first feature map;
[0010] Inputting the first position and the first feature map into a neural network model to obtain a second position in the second image corresponding to the first position according to the relative position relationship between feature points of the first feature map;
[0011] According to the second position, a second feature point matching the first feature point is determined in the second image.
[0012] In a second aspect, a method for training a model is provided, comprising:
[0013] Performing feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image;
[0014] Performing homography transformation on the first image sample to obtain a second image sample and a fourth position corresponding to the third position in the second image sample;
[0015] Connecting the first picture sample and the second picture sample to obtain a third picture sample;
[0016] Performing feature extraction on the third image sample to obtain a second feature map;
[0017] Inputting the third position and the second feature map into a neural network model to obtain position information corresponding to the third position in the second image sample according to the relative position relationship between feature points of the second feature map;
[0018] The neural network model is trained according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
[0019] In a third aspect, an image processing device is provided, comprising:
[0020] a detection unit, configured to perform feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image;
[0021] a connecting unit, configured to connect the first image and the second image to obtain a third image;
[0022] A feature extraction unit, configured to extract feature points from the third image to obtain a first feature map;
[0023] A neural network model, configured to input the first position and the first feature map, so as to obtain a second position in the second image corresponding to the first position according to a relative position relationship between feature points of the first feature map;
[0024] A determining unit is used to determine, according to the second position, a second feature point in the second image that matches the first feature point.
[0025] In a fourth aspect, a device for training a model is provided, comprising:
[0026] a detection unit, configured to perform feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image;
[0027] a transformation unit, configured to perform a homography transformation on the first picture sample to obtain a second picture sample and a fourth position corresponding to the third position in the second picture sample;
[0028] a connecting unit, configured to connect the first picture sample and the second picture sample to obtain a third picture sample;
[0029] A feature extraction unit, configured to extract features from the third image sample to obtain a second feature map;
[0030] a training unit, configured to input the third position and the second feature map into a neural network model, so as to obtain position information corresponding to the third position in the second image sample according to a relative position relationship between feature points of the second feature map; and
[0031] The neural network model is trained according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
[0032] In a fifth aspect, the present application provides an electronic device, including:
[0033] a processor adapted to implement computer instructions; and,
[0034] The memory stores computer instructions, where the computer instructions are suitable for being loaded by the processor and executing the method of the first aspect or the method of the second aspect.
[0035] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are read and executed by a processor of a computer device, the computer device executes the method of the first aspect or the method of the second aspect mentioned above.
[0036] In a seventh aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of the first aspect or the method of the second aspect.
[0037] Since the embodiment of the present application can fuse the relative position relationship between feature points in the feature map of the third image, the obtained feature point descriptor can characterize the relative position relationship between feature points in the third image, such as moving different position points further apart and moving the same position points closer together, thereby avoiding the limitations of traditional algorithms that rely solely on feature point descriptors for matching, and can help improve the accuracy of feature point matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of an application scenario involved in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a specific application scenario involved in an embodiment of the present application;
[0040] Figure 3 is a schematic flow chart of an image processing method according to an embodiment of the present application;
[0041] Figure 4 A schematic diagram of a network architecture provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of a neural network model provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of the self-attention mechanism;
[0044] Figure 7 is a schematic flow chart of a method for training a model according to an embodiment of the present application;
[0045] Figure 8 A schematic block diagram of an image processing device provided in an embodiment of the present application;
[0046] Fig. 9 A schematic block diagram of a device for training a model provided in an embodiment of the present application;
[0047] Fig.10 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0049] It should be understood that in the embodiment of the present application, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based only on A, and B can also be determined based on A and / or other information.
[0050] In the description of the present application, unless otherwise specified, "at least one" means one or more, and "plurality" means two or more than two. In addition, "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0051] It should also be understood that the first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects, without any distinction of order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0052] It should also be understood that the specific features, structures or characteristics related to the embodiments in the specification are included in at least one embodiment of the present application. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner.
[0053] In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or device.
[0054] The solution provided in this application may involve artificial intelligence technology.
[0055] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0056] It should be understood that artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0057] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0058] The embodiments of the present application may involve computer vision (CV) technology in artificial intelligence technology. Computer vision is a science that studies how to make machines "see". To put it more concretely, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0059] The embodiments of the present application may also involve machine learning (ML) in artificial intelligence technology. ML is a multi-disciplinary cross-discipline involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all fields of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching.
[0060] In addition, the solution provided in the embodiments of the present application may also involve image registration technology.
[0061] Figure 1 A schematic diagram of an application scenario involved in an embodiment of the present application.
[0062] like Figure 1 As shown, it includes an acquisition device 101, a computing device 102, and a display device 103. The acquisition device 101 is used to acquire images, such as images to be registered. The computing device 102 is used to process the images acquired by the acquisition device 101, such as performing image registration. The display device 103 is used to display the registered images processed by the computing device 102.
[0063] Exemplarily, the computing device 101 may be a user device, such as a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), or other terminal devices with a browser function installed.
[0064] Exemplarily, the computing device 102 may be a server. The server may be one or more. When there are multiple servers, there are at least two servers for providing different services, and / or there are at least two servers for providing the same service, such as providing the same service in a load balancing manner, which is not limited in the embodiments of the present application. A neural network model may be provided in the server, and the server provides support for the training and application process of the neural network model. An image processing device may also be provided in the server for registering images, and the server provides support for the application process of the image processing device.
[0065] The above-mentioned server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The server can also become a node of the blockchain.
[0066] Exemplarily, when the computing device 102 has a display function, the display device 103 may be a display in the computing device 102 .
[0067] Exemplarily, the display device 103 and the computing device 102 are different devices, and the display device 103 is connected to the computing device 102 via a network. The network may be a wireless or wired network such as an intranet, the Internet, a global system of mobile communication (GSM), a wideband code division multiple access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, a call network, or the like.
[0068] Exemplarily, the application scenarios of this application include but are not limited to industrial AI quality inspection. Figure 2 A schematic diagram of a system architecture diagram of an industrial AI quality inspection platform 200 is shown, which includes an image registration module 210 and a defect comparison learning module 220. Exemplarily, the image registration module 210 can apply an image registration algorithm to perform image registration on original images of components taken at different angles by multiple cameras (e.g., camera 1, camera 2, ... camera 20) to obtain a registration map; the defect comparison learning module 220 can perform defect comparison learning on the registration map and the standard device of the component to obtain a defect comparison result map to determine whether the component has defects.
[0069] Feature point matching is a core part of the image registration algorithm. Commonly used feature point matching algorithms include BruteForce matching algorithm and FLANN matching algorithm. BruteForce is a violent search algorithm, and FLANN is a nearest neighbor algorithm. BruteForce's matching algorithm is better than FLANN's matching algorithm.
[0070] The BruteForce matching algorithm, also known as the brute force search algorithm, works as follows: Based on the feature point detection algorithm, the feature point positions and descriptors of the two images can be obtained, a feature point is selected on the first image, and then the descriptor distance test is performed with each feature point of the second image in turn, and finally the closest feature point is returned. The descriptor represents a vector of a point, which usually describes the position, adjacent relationship and other information of the point. The descriptors of different points should have sufficient differences, while the descriptors of the same point are usually close.
[0071] Usually, the BruteForce algorithm will perform cross-validation, that is, the best match (i, j) will be returned only when the descriptor distance between the i-th feature point in A and the j-th feature point in B is closest, and the j-th feature point in B is also closest to the i-th feature point in A (no other point in A is closest to j). In other words, the two feature points must match each other.
[0072] The matching accuracy of the feature point matching method based on the BruteForce matching algorithm is mainly limited by the accuracy of the feature point descriptor. Once the image is severely distorted, the descriptor generated by the local image will be quite inaccurate, which will seriously affect the final feature point matching effect.
[0073] In view of this, embodiments of the present application provide an image processing method, apparatus, device, and storage medium, which can improve feature point matching effects.
[0074] Specifically, in an embodiment of the present application, feature detection can first be performed on the first image to obtain a first feature point and a first position of the first feature point in the first image, and then the first image and the second image can be connected to obtain a third image, and feature points can be extracted from the third image to obtain a feature map. Thereafter, the first position and the feature map are input into a neural network model to obtain a second position in the second image corresponding to the first position based on the relative position relationship between the feature points of the first feature map. Finally, the second feature point corresponding to the first feature point can be determined in the second image based on the second position.
[0075] Since the embodiment of the present application can fuse the relative position relationship between feature points in the feature map of the third image, the obtained feature point descriptor can characterize the relative position relationship between feature points in the third image, such as moving different position points further apart and moving the same position points closer together, thereby avoiding the limitations of traditional algorithms that rely solely on feature point descriptors for matching, and can help improve the accuracy of feature point matching.
[0076] The technical solution provided by the embodiments of the present application is described below in conjunction with the accompanying drawings.
[0077] Figure 3 A schematic flow chart of an image processing method 300 according to an embodiment of the present application is shown. The image processing method 300 can be executed by any electronic device with data processing capability. For example, the electronic device can be implemented as a server. For another example, the electronic device can be implemented as Figure 1 computing device 102, or Figure 2 The image registration module 220 in the present application is not limited to this. Exemplarily, the method 300 can be used for image registration.
[0078] In some embodiments, the computing device may include (e.g., deploy) a machine learning model, which may be used to execute the image processing method 300. Exemplarily, the machine learning model may be a deep learning model, a neural network model, or other models, without limitation. Figure 4 4 is a schematic diagram of a network architecture provided by an embodiment of the present application, which includes a feature point detection unit 410, a connection unit 420, a feature extraction unit 430, and a neural network model 450. Figure 4 The steps in method 300 are described with reference to the network architecture in FIG.
[0079] It should be understood that Figure 4 An example of a machine learning model for image processing is shown, which is only intended to help those skilled in the art understand and implement the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. Those skilled in the art can make equivalent transformations or modifications based on the examples given here, and such transformations or modifications should still fall within the protection scope of the embodiments of the present application.
[0080] like Figure 3 As shown, the image processing method 300 may include steps 310 to 240 .
[0081] 310 , perform feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image.
[0082] For example, Figure 4 As shown, the first image may be a picture of a component taken by a camera, for example, may include a first ROI of the picture of the component. Exemplarily, the size of the first image may be expressed as (3, h, w), where 3 represents the red, green, blue (RGB) three channels of the first image, and h and w represent the height and width of the first image, respectively.
[0083] Exemplarily, the feature point detection unit 410 may perform feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image. As a specific example, the first feature point may include a corner point or an edge point of a component, without limitation. As a specific example, the first position may be a coordinate (x 1 ,y 1 ), where 0≤x 1 ≤h,0≤y 1 ≤w.
[0084] Exemplarily, the feature point detection unit 410 may be a traditional or deep feature point detection network, without limitation. As an example, the first feature point may include n feature points (n, 2), where n is a positive integer.
[0085] 320. Connect the first image and the second image to obtain a third image.
[0086] For example, see Figure 4 , the first image and the second image may be concatenated by the connection unit 420 to obtain a third image. Here, connection may also be replaced by splicing, merging, etc., all of which represent the same or similar meanings. Exemplarily, the first image and the second image have the same size, for example, both are (3, h, w), then the size of the third image obtained by merging the first image and the second image together by column may be (3, h, 2w).
[0087] Exemplarily, the second image may be an image that needs to be registered with the first image, for example, a picture of a component taken by a camera, for example, a second ROI that may include the picture of the component. The component in the first image is the same as the component in the second image, except that the first image and the second image are two images acquired under different conditions (for example, different time, different imaging device, different angle and / or different lighting conditions). For example, Figure 2 In the application scenario shown, the first image may be a picture of a component taken by camera 1 , and the second image may be a picture of the component taken by camera 2 .
[0088] 330, extract feature points from the third image to obtain a first feature map.
[0089] For example, see Figure 4, the feature extraction unit 430 may perform feature point extraction on the third image to obtain the first feature map. The first feature map may include two-dimensional features of the feature points, and the two-dimensional features represent the position information of the feature points in the third image. As an example, the feature extraction unit 430 may be a convolutional neural network (CNN), and the CNN may be a conventional backbone for extracting features, such as resnet50, without limitation. Optionally, after feature point extraction is performed on the third image, upsampling may be performed to obtain the first feature map of the same size as the input third image, for example (d, h, 2w), where d is the number of channels of the first feature map.
[0090] 340, input the first position and the first feature map into a neural network model to obtain a second position in the second image corresponding to the first position according to the relative position relationship between the feature points of the first feature map. As a specific example, the second position may be a coordinate (x 2 ,y 2 ), where 0≤x 2 ≤h,0≤y 2 ≤w.
[0091] For example, see Figure 4 , the first position and the first feature map can be input into the neural network model 440, and the neural network model 440 outputs the second position. Figure 4 As shown, the neural network model 440 may include an encoder 441 and a decoder 442.
[0092] In some optional embodiments, the first feature map can be input into the encoder 441 to encode the first feature map to obtain the full image information of the first feature map; and the full image information and the above-mentioned first position are input into the decoder 442 to decode the first position according to the full image information to obtain the above-mentioned second position. Among them, the full image information includes the relative position relationship between the feature points in the first feature map (i.e., the position correlation of each feature point in the third image). Since the feature points in the full image information can integrate the position correlation of the third image (e.g., the entire image), the feature point descriptor obtained in this way can characterize the relative position relationship between the feature points in the third image, for example, in the third image, different position points (i.e., non-corresponding points in the first image and the second image) are pulled further apart, and the same position points (i.e., corresponding points in the first image and the second image) are pulled closer.
[0093] As a possible implementation, see Figure 5, the encoder 441 may include a first position encoding unit 502 and a first multi-head attention mechanism 501. The first multi-head attention mechanism 501 is used to perform an attention operation. Figure 5 , the first feature map can be input into the first position encoding unit 502 to obtain the position information of the feature points of the first feature map. Optionally, after obtaining the position information of the feature points of the first feature map, the position information and the feature points of the first feature map can be vectorized to obtain a first representation vector. As an implementation method of inputting the position information and the feature points of the first feature map into the first multi-head attention mechanism 501, the first representation vector can be input into the first multi-head attention mechanism 501 to obtain the above-mentioned full-image information. Exemplarily, the full-image information can be represented as a coding matrix output by the first multi-head attention mechanism 501.
[0094] It should be noted that when performing the attention operation on the first feature map, the first feature map needs to be serialized, for example, stretching the two-dimensional image into a one-dimensional sequence, which will cause the position information of each point in the first feature map to be lost. As a specific example, the position coordinates (x i ,y i ) can be expressed as (y i ×h+x i ), thus losing the position information (x i ,y i ). In order to avoid the loss of position information of points in the first feature map, before the first feature map is input into the first multi-head attention mechanism, the first feature map can be position-encoded by a first position encoding unit to obtain the relative distance between the feature points.
[0095] Exemplarily, the first position encoding unit may be a sine encoder, which is not limited in the present application. Specifically, the sine encoder may perform position encoding according to the following formula:
[0096]
[0097] Among them, pos represents the serial number of the token obtained after the input is divided into image blocks (tokens). For example, when there are 250 tokens after the token switch, for the 250th token, pos = 250; i corresponds to the embedding size (embedding size). Assuming that the embedding size of the tokenembedding layer is 4, then i represents the i-th element in the embedding vector. For example, a token is embedded as [0.1, 0.15, 0.12, 0.03] by the token embedding, then i = 0 corresponds to the position of 0.1, and i = 1 corresponds to the position of 0.15. Since 2i and 2i+1 are used to divide the odd and even columns of the embedding matrix, the maximum value of i is equal to embedding_size / 2. For example, if the embedding size is 4, the maximum value of i is 2; d model Indicates embedding size.
[0098] As a possible implementation, see Figure 5 , the decoder 442 may include a second position encoding unit 504 and a second multi-head attention mechanism 503. The second multi-head attention mechanism 503 is used to perform an attention operation. Figure 5 , the above-mentioned first position can be input into the second position encoding unit 504 to obtain the position information of the first position. Optionally, after obtaining the position information of the first position, the position information can be represented by a vector to obtain a second representation vector. As an implementation method of inputting the position information of the first position and the full image information into the second multi-head attention mechanism 503, the second representation vector and the full image information output by the first multi-head attention mechanism can be input into the second multi-head attention mechanism 503 to decode the position information of the first position according to the full image information. Since the full image information can bring the same points closer, the second position corresponding to the first position in the second image can be obtained. In other words, the first position and the second position can correspond to the same point in the third image.
[0099] For example, the multi-head attention mechanism can be composed of multiple self-attention mechanisms. Figure 6 A schematic diagram of the self-attention mechanism is shown, where the matrices Q, K, and V are query values, key values, and values, respectively, Softmax represents the normalized exponential function, and MatMul represents matrix multiplication. The output of the self-attention mechanism represents the similarity of each element between Q and K, for example, it can be expressed as follows:
[0100]
[0101] Among them, d k represents the number of columns of the Q and K matrices, i.e., the vector dimension, and T represents the matrix transpose. Indicates that the output of Softmax() is matrix multiplied by V.
[0102] Exemplarily, in the first multi-head attention mechanism, the input Q, K, and V are the same, for example, the position information of the feature points of the first feature map and the vector representation of the feature points of the first feature map. The first multi-head attention mechanism can divide the first feature map into multiple parts (for example, it can be divided into 4 or 8 parts in the channel dimension) to perform self-attention operations, so that the correlation between each point in the first feature map and other points can be calculated, which helps to capture richer feature information of the first feature map.
[0103] Exemplarily, after the self-attention operation, the feature points in the first feature map can be integrated with the position correlation of the entire third image, so that the obtained feature point descriptor can characterize the relative position relationship between the feature points, for example, the same points (i.e., the corresponding points in the first image and the second image) are pulled closer, and the different points (non-corresponding points in the first image and the second image) are pulled further apart.
[0104] In the second multi-head attention mechanism, the input Q is, for example, a vector representation of the first position, and the input K and V are, for example, the encoded information output by the first multi-head attention mechanism, that is, the above-mentioned full-image information. By decoding the input Q by the second multi-head attention mechanism, the content of the corresponding query can be obtained. For example, when the first position in the first image is input, since the full-image information can bring the same points closer, the second position corresponding to the first position in the second image can be obtained (that is, the two are the same points).
[0105] In some optional embodiments, the neural network model may include a Transformer structure, which is not limited in this application.
[0106] 350. Determine, in the second image, a second feature point that matches the first feature point according to the second position.
[0107] Since the embodiment of the present application can fuse the relative position relationship between feature points in the feature map of the third image, the obtained feature point descriptor can characterize the relative position relationship between feature points in the third image, such as moving different position points further apart and moving the same position points closer together, thereby avoiding the limitations of traditional algorithms that rely solely on feature point descriptors for matching, and can help improve the accuracy of feature point matching.
[0108] In some optional embodiments, before the above step 340, a model may be trained to obtain the neural network model. The training data of the neural network model includes feature points and feature point position information of the first image sample. Exemplarily, the first image sample may be subjected to homography transformation to obtain a second image sample; then, the neural network model may be trained based on the first image sample and the second image sample to obtain the trained neural network model.
[0109] Exemplarily, the homography transformation may be a mapping relationship from one plane to another plane. The homography matrix may generally be a 3×3 matrix with 8 degrees of freedom and may be determined by 4 point pairs, which is not limited in the present application.
[0110] For example, see Figure 4 , the first image sample and the second image sample can be transformed by the homography transformation unit 450 to obtain the feature points and feature point position information of the second image sample. Among them, the feature points in the first image sample are matched with the feature points in the second image sample, and the feature point position information in the first image sample is also corresponding to the feature point position information in the second image sample. That is to say, the embodiment of the present application can train the neural network model according to the feature points and the position information of the feature points of the first image sample, and the matching feature points and the position information of the matching feature points in the second image sample to obtain a trained neural network model.
[0111] Figure 7 A schematic flow chart of a method 400 for training a model according to an embodiment of the present application is shown. The method 400 for training a model can be executed by any electronic device with data processing capability. For example, the electronic device can be implemented as a server. For another example, the electronic device can be implemented as Figure 1 The computing device 102 in the present application is not limited to this. Figure 7 As shown, method 400 includes steps 410 to 450 .
[0112] In some embodiments, the computing device may include (e.g., deploy) a machine learning model, which may be used to execute the method 400 for training the model. Exemplarily, the machine learning model may be a deep learning model, a neural network model, or other models, without limitation. Exemplarily, the machine learning model may be Figure 4 The network architecture in FIG. 4 further includes a homography transformation unit 450 and a loss unit 460 when the network architecture is used for training the model. Figure 4 The steps in method 400 are described with reference to the network architecture in FIG.
[0113] 410 , perform feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image sample.
[0114] 420 , perform homography transformation on the first image sample to obtain a second image sample and a fourth position corresponding to the third position in the second image sample.
[0115] For example, it can be Figure 4 The homography transformation unit 450 in transforms the first image sample to obtain the second image sample and the fourth position. For example, the homography transformation can refer to the above description and will not be repeated here.
[0116] 430 , connect the first picture sample and the second picture sample to obtain a third picture sample.
[0117] 440 , extract features from the third image sample to obtain a second feature map.
[0118] Specifically, the operations on the first image sample and the second image sample in steps 410 to 440 can refer to Figure 3 The operations on the first image and the second image in steps 310 to 330 are not repeated here.
[0119] 450, input the third position and the second feature map into a neural network model to obtain position information corresponding to the third position in the second image sample based on the relative position relationship between the feature points of the second feature map.
[0120] For example, the neural network model can be Figure 4 The neural network model in step 450 is the same as the process of obtaining the position information corresponding to the third position. Figure 3 The process of obtaining the second position is similar, you can refer to Figure 3 The description in step 340 is not repeated here.
[0121] 460. Train the neural network model according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
[0122] Here, the fourth position can be used as the true value corresponding to the third position and input into the neural network model to implement training of the model parameters.
[0123] For example, see Figure 4, the loss calculation unit 460 can calculate the position information of the fourth feature point matching the third feature point in the second picture sample output by the decoder 442 and the loss of the fourth position, and then update the parameters of the neural network model based on the loss, such as the back propagation gradient algorithm.
[0124] In some optional embodiments, when the neural network model includes an encoder and a decoder, the dimension of the query result output by the decoder is related to the input dimension of the encoder and the decoder, for example, it can be (n, d). At this time, the dimension of the fourth position, that is, the input true value, is (n, 2), so the output dimension of the decoder can be reduced from (n, d) to (n, 2) through a multi-layer perceptron (Multi-Layer Perception, MLP) network, and then the L2 loss can be calculated using the loss 460 unit, and the entire network can be trained according to the L2 loss. Among them, the MLP includes an input layer, an output layer, and multiple intermediate hidden layers, and the layers can be fully connected.
[0125] The specific implementation modes of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above implementation modes. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific implementation modes can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different implementation modes of the present application can also be arbitrarily combined, and as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0126] It should also be understood that in the various method embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. It should be understood that these sequence numbers can be interchanged where appropriate, so that the embodiments of the present application described can be implemented in an order other than those shown or described.
[0127] The above describes the method embodiment of the present application in detail. Figures 8 to 10 , describing an apparatus embodiment of the present application.
[0128] Figure 8 600 is a schematic block diagram of an image processing apparatus 600 according to an embodiment of the present application. Figure 8 As shown, the image processing device 600 may include a detection unit 610, a connection unit 620, a feature extraction unit 630, a neural network model 640 and a determination unit 650.
[0129] A detection unit 610 is configured to perform feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image;
[0130] A connecting unit 620, configured to connect the first image and the second image to obtain a third image;
[0131] A feature extraction unit 630 is used to extract feature points from the third image to obtain a first feature map;
[0132] A neural network model 640, configured to input the first position and the first feature map, so as to obtain a second position in the second image corresponding to the first position according to a relative position relationship between feature points of the first feature map;
[0133] The determining unit 650 is configured to determine, in the second image according to the second position, a second feature point that matches the first feature point.
[0134] Optionally, the neural network model 640 includes the encoder and the decoder, and the neural network model 640 is specifically used for:
[0135] Inputting the first feature map into the encoder to encode the first feature map to obtain full image information of the first feature map, wherein the full image information includes the relative position relationship between feature points of the first feature map;
[0136] The full image information and the first position are input into the decoder, so as to decode the first position according to the full image information to obtain the second position.
[0137] Optionally, the encoder includes a first position encoding unit and a first multi-head attention mechanism.
[0138] Optionally, the first encoder unit is specifically configured to: input the first feature map, and output position information of feature points of the first feature map;
[0139] The first multi-head attention mechanism is specifically used to: input the position information of the feature points and the feature points of the first feature map, and output the full map information.
[0140] Optionally, the decoder includes a second position encoding unit and a second multi-head attention mechanism.
[0141] Optionally, the second position encoding unit is specifically used to: input the first position and output position information of the first position;
[0142] The second multi-head attention mechanism is specifically used to: input the position information of the first position and output the second position.
[0143] Optionally, the neural network model includes a Transformer structure.
[0144] Optionally, the training data of the neural network model includes feature points and feature point position information of the first image sample.
[0145] Optionally, the device 600 further includes a training unit, configured to:
[0146] Performing homography transformation on the first image sample to obtain a second image sample;
[0147] The neural network model is trained according to the first image sample and the second image sample to obtain the trained neural network model.
[0148] Optionally, the first image includes a first region of interest ROI of a picture of a component, and the second image includes a second ROI of the picture of the component.
[0149] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, it will not be repeated here. Specifically, in this embodiment, the image processing device 600 may correspond to the corresponding subject of the method 300 of the embodiment of the present application, and the aforementioned and other operations and / or functions of each module in the device 600 are respectively to implement the various methods above, or the corresponding processes in each method, and for the sake of brevity, they will not be repeated here.
[0150] Fig. 9 FIG. 7 is a schematic block diagram of a training model apparatus 700 provided in an embodiment of the present application. Fig. 9 As shown, the apparatus 700 includes a detection unit 710 , a transformation unit 720 , a connection unit 730 , a feature extraction unit 740 and a training unit 750 .
[0151] A detection unit 710 is configured to perform feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image;
[0152] a transformation unit 720, configured to perform a homography transformation on the first picture sample to obtain a second picture sample and a fourth position corresponding to the third position in the second picture sample;
[0153] A connecting unit 730, configured to connect the first picture sample and the second picture sample to obtain a third picture sample;
[0154] A feature extraction unit 740 is used to extract features from the third image sample to obtain a second feature map;
[0155] a training unit 750, configured to input the third position and the second feature map into a neural network model, so as to obtain position information corresponding to the third position in the second image sample according to the relative position relationship between feature points of the second feature map; and
[0156] The neural network model is trained according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
[0157] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, it will not be repeated here. Specifically, the device 700 for training the model in this embodiment may correspond to the corresponding subject of the method 400 for executing the embodiment of the present application, and the aforementioned and other operations and / or functions of each module in the device 700 are respectively to implement the various methods above, or the corresponding processes in each method, and for the sake of brevity, they will not be repeated here.
[0158] The above describes the device and system of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0159] like Fig.10 It is a schematic block diagram of an electronic device 800 provided in an embodiment of the present application.
[0160] like Fig.10 As shown, the electronic device 800 may include:
[0161] The memory 810 and the processor 820, the memory 810 is used to store the computer program and transmit the program code to the processor 820. In other words, the processor 820 can call and run the computer program from the memory 810 to implement the method in the embodiment of the present application.
[0162] For example, the processor 820 may be configured to execute the steps in the above method 300 or 400 according to the instructions in the computer program.
[0163] In some embodiments of the present application, the processor 820 may include but is not limited to:
[0164] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0165] In some embodiments of the present application, the memory 810 includes but is not limited to:
[0166] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0167] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 810 and executed by the processor 820 to complete the coding method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device 800.
[0168] Optionally, the electronic device 800 may further include:
[0169] The transceiver 830 may be connected to the processor 820 or the memory 810 .
[0170] The processor 820 may control the transceiver 830 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 830 may include a transmitter and a receiver. The transceiver 830 may further include an antenna, and the number of antennas may be one or more.
[0171] It should be understood that the various components in the electronic device 800 are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0172] According to one aspect of the present application, a communication device is provided, including a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory, so that the encoder executes the method of the above method embodiment.
[0173] According to one aspect of the present application, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0174] According to another aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of the above method embodiment.
[0175] In other words, when implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.
[0176] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0177] In the several embodiments provided in the present application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0178] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0179] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for image processing, characterized in that: include: Performing feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image; splicing the first image and the second image to obtain a third image; Extracting feature points from the third image to obtain a first feature map; Inputting the first position and the first feature map into a neural network model to obtain a second position in the second image corresponding to the first position according to the relative position relationship between feature points of the first feature map; determining, in the second image, a second feature point matching the first feature point according to the second position; The step of inputting the first position and the first feature map into a neural network model to obtain a second position in the second image corresponding to the first position according to a relative position relationship between feature points of the first feature map includes: Inputting the first feature map into an encoder of the neural network model to encode the first feature map to obtain full image information of the first feature map, wherein the full image information includes a relative position relationship between feature points of the first feature map; the encoder includes a first position encoding unit and a first multi-head attention mechanism; Inputting the full image information and the first position into a decoder of the neural network model to decode the first position according to the full image information to obtain the second position; the decoder includes a second position encoding unit and a second multi-head attention mechanism; The step of inputting the full image information and the first position into a decoder of the neural network model to decode the first position according to the full image information to obtain the second position comprises: Inputting the first position into the second position encoding unit to obtain position information of the first position; The position information of the first position is input into the second multi-head attention mechanism to obtain the second position.
2. The method according to claim 1, characterized in that The step of inputting the first feature map into the encoder of the neural network model to encode the first feature map to obtain full image information of the first feature map includes: Inputting the first feature map into the first position encoding unit to obtain position information of feature points of the first feature map; The position information of the feature points and the feature points of the first feature map are input into the first multi-head attention mechanism to obtain the full-image information.
3. The method according to claim 1 or 2, characterized in that: The neural network model includes a Transformer structure.
4. The method according to claim 1 or 2, characterized in that: The training data of the neural network model includes feature points and feature point position information of the first image sample.
5. The method according to claim 4, characterized in that Before inputting the first position and the first feature map into the neural network model, the method further includes: Performing homography transformation on the first image sample to obtain a second image sample; The neural network model is trained according to the first image sample and the second image sample to obtain the trained neural network model.
6. The method according to claim 1 or 2, characterized in that: The first image includes a first region of interest ROI of a picture of a component, and the second image includes a second ROI of the picture of the component.
7. A method for training a neural network model, used in the method of claim 1, characterized in that: include: Performing feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image; Performing homography transformation on the first image sample to obtain a second image sample and a fourth position corresponding to the third position in the second image sample; Splicing the first picture sample and the second picture sample to obtain a third picture sample; Performing feature extraction on the third image sample to obtain a second feature map; Inputting the third position and the second feature map into a neural network model to obtain position information corresponding to the third position in the second image sample according to the relative position relationship between feature points of the second feature map; The neural network model is trained according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
8. An image processing device, characterized in that: include: a detection unit, configured to perform feature detection on the first image to obtain a first feature point and a first position of the first feature point in the first image; A connection unit, configured to connect the first image and the second image to obtain a third image; A feature extraction unit, used for extracting feature points from the third image to obtain a first feature map; A neural network model, configured to input the first position and the first feature map, so as to obtain a second position in the second image corresponding to the first position according to a relative position relationship between feature points of the first feature map; a determining unit, configured to determine, in the second image, a second feature point matching the first feature point according to the second position; Wherein, the neural network model is specifically used for: Inputting the first feature map into an encoder of the neural network model to encode the first feature map to obtain full image information of the first feature map, wherein the full image information includes a relative position relationship between feature points of the first feature map; the encoder includes a first position encoding unit and a first multi-head attention mechanism; Inputting the full image information and the first position into a decoder of the neural network model to decode the first position according to the full image information to obtain the second position; the decoder includes a second position encoding unit and a second multi-head attention mechanism; Wherein, the decoder is specifically used for: Inputting the first position into the second position encoding unit to obtain position information of the first position; The position information of the first position is input into the second multi-head attention mechanism to obtain the second position.
9. A device for training a neural network model, used in the device of claim 8, characterized in that: include: a detection unit, configured to perform feature detection on the first image sample to obtain a third feature point and a third position of the third feature point in the first image; a transformation unit, configured to perform a homography transformation on the first picture sample to obtain a second picture sample and a fourth position corresponding to the third position in the second picture sample; a connecting unit, configured to connect the first picture sample and the second picture sample to obtain a third picture sample; A feature extraction unit, configured to extract features from the third image sample to obtain a second feature map; a training unit, configured to input the third position and the second feature map into a neural network model, so as to obtain position information corresponding to the third position in the second image sample according to a relative position relationship between feature points of the second feature map; as well as The neural network model is trained according to the position information corresponding to the third position and the fourth position to obtain the trained neural network model.
10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores instructions, and when the processor executes the instructions, the processor executes the method according to any one of claims 1 to 7.
11. A computer storage medium, characterized in that: Used to store a computer program, the computer program comprising instructions for executing the method according to any one of claims 1 to 7.
12. A computer program product, characterized in that The method comprises a computer program code, and when the computer program code is executed by an electronic device, the electronic device executes the method according to any one of claims 1 to 7.
