Disclosure of Invention
It is an object of the present application to provide an improved image matching method and apparatus to solve the technical problems mentioned in the background section above.
In a first aspect, the present application provides an image matching method, including: acquiring a reference image, wherein the reference image comprises image data arranged in a matrix; expanding the reference image to generate a plurality of expanded reference images, wherein the number of rows of image data contained in each expanded reference image is the same as the number of rows of image data contained in the reference image, and the number of columns of image data contained in each expanded reference image is equal to and greater than the number of columns of image data contained in the reference image; extracting a target image with the same size as the extended reference image from the image to be identified by adopting a direct memory access mode; and performing cross-correlation matching operation on the target image and each extended reference image to determine whether the target image is matched with the reference image.
In some embodiments, the expanding the reference image to generate a plurality of expanded reference images includes: generating a plurality of expansion templates, wherein each expansion template comprises initial image data arranged in a matrix, each expansion template comprises an area to be superposed and an expansion area, and the positions of the areas to be superposed in each expansion template are different from each other; superposing the image data of the reference image and the initial image data of the area to be superposed in each expanded template to generate a plurality of expanded reference images; the number of rows of the initial image data of the expanded template is equal to the number of rows of the image data of the reference image, and the number of columns of the initial image data of the area to be superposed is equal to the number of columns of the image data of the reference image.
In some embodiments, the number of the expansion templates is 4n, where n is a preset positive integer; the initial image data in matrix arrangement in each expansion template is zero.
In some embodiments, the extension area comprises a list of the initial image data, each extension template comprises 4n-1 extension areas, and each extension area is positioned on one side or two sides of the area to be overlapped, so that the positions of the areas to be overlapped are different from each other in different extension templates.
In some embodiments, the extracting a target image with a size equal to that of the extended reference image from the image to be recognized by using a direct memory access method includes: acquiring an image to be identified by using an image sensor, analyzing the image to be identified, and caching the image to be identified to an external memory; and extracting the target image with the size equal to that of the extended reference image from the external memory by adopting a direct memory access mode.
In some embodiments, the image data addresses of the target image are aligned with the bus addresses.
In a second aspect, the present application provides an image matching apparatus, comprising: the device comprises a reference image acquisition module, a processing module and a display module, wherein the reference image acquisition module is configured to acquire a reference image, and the reference image comprises image data arranged in a matrix; the extended reference image generation module is configured to extend the reference image to generate a plurality of extended reference images, wherein the number of rows of image data included in each extended reference image is the same as the number of rows of image data included in the reference image, and the number of columns of image data included in each extended reference image is equal to and greater than the number of columns of image data included in the reference image; the target image extraction module is configured to extract a target image with the size equal to that of the extended reference image from the image to be identified by adopting a direct memory access mode; and the matching operation module is configured for performing cross-correlation matching operation on the target image and each extended reference image to determine whether the target image is matched with the reference image.
In some embodiments, the extended reference image generation module comprises: the system comprises an expansion template generating unit, a storage unit and a display unit, wherein the expansion template generating unit is configured to generate a plurality of expansion templates, each expansion template comprises initial image data arranged in a matrix, each expansion template comprises an area to be superposed and an expansion area, and the positions of the areas to be superposed in each expansion template are different from each other; the superposition unit is configured to superpose the image data of the reference image and the initial image data of the region to be superposed in each expansion template to generate a plurality of expansion reference images; the number of rows of the initial image data of the expanded template is equal to the number of rows of the image data of the reference image, and the number of columns of the initial image data of the area to be superposed is equal to the number of columns of the image data of the reference image.
In some embodiments, the number of the expansion templates is 4n, where n is a preset positive integer; the initial image data in matrix arrangement in each expansion template is zero.
In some embodiments, the extension area comprises a column of image data, each extension template comprises 4n-1 extension areas, and each extension area is positioned on one side or two sides of the area to be overlapped, so that the areas to be overlapped are positioned in different positions in different extension templates.
In some embodiments, the target image extraction module is further configured to: acquiring an image to be identified by using an image sensor, analyzing the image to be identified, and caching the image to be identified to an external memory; and extracting the target image with the size equal to that of the extended reference image from the external memory by adopting a direct memory access mode.
In some embodiments, the image data addresses of the target image are aligned with the bus addresses.
In a third aspect, the present application provides a digital signal processing apparatus comprising: one or more processors; storage means for storing one or more programs; when executed by one or more processors, cause the one or more processors to implement any of the methods described above.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs any of the methods described above.
The image matching method and the device provided by the application, after a reference image is obtained, firstly, the reference image is expanded to generate a plurality of expanded reference images, the row number of image data of each expanded reference image is equal to the row number of the image data of the reference image, the column number of the image data of each expanded reference image is larger than the column number of the image data of the reference image, then, a target image with the size equal to that of each expanded reference image is extracted from an image to be identified by adopting a direct memory access mode, finally, the target image and each expanded reference image are subjected to cross-correlation matching operation to determine whether the target image can be matched with the reference image or not, the expanded reference image is generated by expanding the reference image, so that the size of the target image for the cross-correlation matching operation with each expanded reference image is larger than that of the reference image, and the times of extracting the target image from the image to be identified can be, the efficiency of image matching is improved.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which embodiments of the image matching method or image matching apparatus of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a digital signal processor 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the digital signal processor 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 101, 102, 103 to interact with the digital signal processor 105 via the network 104 to receive or transmit images, etc. Various client applications, such as a web browser application, image processing software, search-type applications, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting Picture browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The digital signal processor 105 may be a processor that provides various services, such as an image processor that provides support for image processor software on the terminal devices 101, 102, 103. The image processor may perform processing such as matching on the pattern to be recognized, and feed back the processing result (e.g., matching result) to the terminal device.
It should be noted that the image matching method provided in the embodiment of the present application is generally executed by the digital signal processor 105, and accordingly, the image matching apparatus is generally disposed in the digital signal processor 105.
It should be understood that the number of terminal devices, networks, and digital signal processors in fig. 1 are merely illustrative. There may be any number of terminal devices, networks, and digital signal processors, as desired for an implementation.
Continuing to refer to FIG. 2, a flow 200 of an embodiment of an image matching method according to the present application is shown. The image matching method provided by the embodiment can be applied to electronic equipment with certain computing capability, such as a digital signal processor and the like. The image matching method provided by the embodiment may include the following steps:
step 201, acquiring a reference image.
In this embodiment, the electronic device may acquire a reference image for image matching from a reference image library that stores reference images set in advance. The reference image library may be stored in a memory of the electronic device, or may be provided in an external memory of the electronic device. The reference image may be a rectangular image with a fixed size, and the reference image may be composed of a plurality of image data arranged in a matrix, for example, the reference image may be a gray scale image, where the image data may be a value of 0 to 255 for representing the gray scale value of each pixel in the reference image.
Step 202, expanding the reference image to generate a plurality of expanded reference images.
In this embodiment, based on the reference image obtained in step 201, the electronic device may expand the reference image to generate a plurality of expanded reference images having a size larger than that of the reference image. Specifically, the number of lines of the image data included in each extended reference image may be equal to the number of lines of the image data included in the reference image, and the number of columns of the image data included in each extended reference image may be greater than the number of columns of the image data included in the reference image. It can be seen that each extended reference picture may be similar to the shape of the reference picture, that is, the shape of each extended reference picture may also be a rectangle, and the length of each extended reference picture in the column direction is the same as the length of the reference picture in the column direction. Further, the number of columns of image data included in each extended reference image may be greater than the number of columns of image data included in the reference image. That is, the length of each extended reference image in the row direction may be larger than the length of the above-described reference image in the row direction.
Step 203, extracting a target image with the size equal to that of the extended reference image from the image to be identified by adopting a direct memory access mode.
In this embodiment, the electronic device may extract a target image from an image to be recognized by using a direct memory access method, where the size of the target image may be equal to the size of each extended reference image, so as to determine whether the target image matches the extended reference image by calculating the similarity between the target image and each extended reference image. It can be understood that the size of the extended reference image is larger than that of the reference image, so that the size of the target image is larger than that of the reference image, and compared with the case of acquiring the target image with the same size as the reference image, the method of the embodiment can reduce the number of times of extracting the target image from the image to be recognized.
And step 204, performing cross-correlation matching operation on the target image and each extended reference image to determine whether the target image is matched with the reference image.
In this embodiment, based on the target image extracted in step 203, the electronic device may perform a cross-correlation matching operation on the target image and each extended reference image by using a cross-correlation matching algorithm, and then obtain a result of the matching operation on the target image and each extended reference image. The electronic device may determine whether the target image and the reference image match each other according to a result of the matching operation. For example, if there is a mutual match between the result of any extended reference image and the target image matching operation, it may be determined that the reference image used to generate the extended reference image and the target image match with each other. It can be seen that the reference image can be matched to a target image with a size larger than that of the reference image through the generated extended reference image.
In the prior art, the time required for extracting the target image from the image to be recognized by adopting a direct memory access mode is usually longer than the time for performing one-time matching operation on the reference image and the target image by adopting a cross-correlation matching algorithm, which causes that electronic equipment cannot continuously perform matching operation and causes the waste of computing resources. Therefore, the image matching method of the embodiment performs the cross-correlation matching operation on the multiple extended reference images with the sizes larger than the reference image and the target image, that is, the target image can be extracted once, so that the computing resources of the electronic device can be fully utilized, the number of times that the target image can be extracted from the image to be recognized can be reduced by the target image with the sizes larger than the reference image, and the image matching speed is improved.
According to the image matching method provided by the embodiment of the application, firstly, a plurality of extended reference images with the size larger than that of the reference image are generated by using the reference image, then the target images with the size same as that of the extended reference images are extracted from the images to be recognized, and then the extended reference images and the target images are subjected to cross-correlation matching operation to determine the target images matched with the reference images in the images to be recognized.
With continuing reference to FIG. 3, which illustrates a flow 300 according to another embodiment of an image matching method of the present application, the flow 300 may include the steps of:
step 301, a reference image is acquired.
In this embodiment, an electronic device (e.g., a digital signal processor) may obtain a reference image for image matching from a preset reference image library storing reference images. The reference image may be a rectangular image, and the reference image may include image data arranged in a rectangle.
Step 302, generate a plurality of expanded templates.
In this implementation, the electronic device may further generate a plurality of extension templates. Each expansion template may include initial image data arranged in a matrix, and each expansion template may include a region to be superimposed, which may be used to superimpose image data of a reference image, and an expansion region. It should be noted that, the positions of the regions to be superimposed in the above-mentioned expansion templates are different from each other.
Here, the number of rows of the initial image data of the extended template may be equal to the number of rows of the image data of the reference image, the number of columns of the initial image data of the region to be superimposed in the extended template may be equal to the number of columns of the image data of the reference image, that is, the length of the extended template in the column direction may be equal to the length of the reference image in the column direction, and the length of the region to be superimposed of the extended template in the row direction may be equal to the length of the reference image in the row direction.
And 303, overlapping the image data of the reference image with the initial image data of the region to be overlapped in each extended template to generate a plurality of extended reference images.
In this embodiment, based on the plurality of extended templates generated in step 302, the electronic device may superimpose the reference image and the region to be superimposed in each extended template, that is, may superimpose the image data of the reference image and the initial image data of the region to be superimposed in each extended template, so as to generate a plurality of extended reference images. As can be seen, each generated extended reference image may include an overlapping region where the reference image has been overlapped and an extended region in the corresponding extended template, and the image data of each extended region is still the initial image data.
In some optional implementation manners of this embodiment, the electronic device may generate 4n expansion templates, where n may be a preset positive integer. For example, n may be 1, 2, 3, or the like, that is, the electronic device may generate 4 extended templates, 8 extended templates, or 12 extended templates, or the like.
In some optional implementation manners of this embodiment, the reference image may be a grayscale map, the image data of the reference image may be a numerical value from 0 to 255, and the initial image data included in each of the expansion templates may be "0". Therefore, when the image data of the reference image is superimposed on the initial image data of the region to be superimposed in the extended template, the image data of the region in the extended template on which the reference image is superimposed is generated to be the same as the image data of the reference image, and the image data of the extended region in the extended template on which the reference image is not superimposed is still the initial image data "0". It can be seen that the positions of the regions to be superimposed in different extended templates are different, and the regions in which the reference images are superimposed are also different, i.e. the corresponding generated extended reference images are different.
In some optional implementations of the present embodiment, the extension regions in the extension template may include a list of initial image data, and each extension template may include 4n-1 extension regions. The extension areas can be positioned on one side or two sides of the area to be overlapped, so that the positions of the area to be overlapped in different extension templates are different from each other. For example, if the preset positive integer n may be 1, the electronic device may generate 4 expansion templates, each expansion template may include one to-be-superimposed region and 3 expansion regions, and the 3 expansion regions may be respectively disposed on one side or two sides of the to-be-superimposed region, so that the 4 expansion templates are different from each other.
And 304, acquiring the image to be identified by using the image sensor, analyzing the image to be identified, and caching the image to be identified to an external memory.
In this embodiment, the electronic device may be connected to an external image sensor, and the image sensor may capture an image to be recognized, so that the electronic device may acquire the image to be recognized. And then the electronic equipment can analyze the image to be identified, generate a gray scale map which can be used for matching operation, and cache the analyzed image to be identified into an external memory. It should be noted that the size of the image to be recognized collected by the image sensor is usually large, and if the electronic device does not have enough memory to store the image to be recognized, the image to be recognized may be stored in a preset external storage.
It can be understood that, if the size of the image to be recognized collected by the image sensor is small, the electronic device has enough memory to store the analyzed image to be recognized, and at this time, the analyzed image to be recognized may also be directly stored in the memory of the electronic device without being stored in an external storage.
In step 305, a target image with the same size as the extended reference image is extracted from the external memory by direct memory access.
In this embodiment, based on the image to be recognized stored in the external storage in step 304, the electronic device may extract the target image from the image to be recognized stored in the external storage in a direct memory access manner, and the size of the target image is the same as that of the extended reference image generated in step 303. Generally, the size of the image to be recognized acquired by the image sensor is large, and the electronic device needs to extract different target images from the image to be recognized for multiple times so as to complete matching between the reference image and the image to be recognized.
It can be understood that, when the parsed image to be recognized is stored in the memory of the electronic device, the electronic device may directly extract the target image with the size equal to that of the extended reference image from the image to be recognized in the memory.
In some optional implementations of the embodiment, the address of the image data of the target image is aligned with the bus address, which may further increase the speed of extracting the target image.
Step 306, performing cross-correlation matching operation on the target image and each extended reference image to determine whether the target image is matched with the reference image.
In this embodiment, the electronic device may perform a cross-correlation matching operation on the target image extracted from the image to be recognized and each of the extended reference images. It is understood that the size of the image to be recognized is large, and the electronic device may extract a plurality of target images from the image to be recognized and perform cross-correlation matching on each target image and each extended reference image. When there is a cross-correlation match between any target image and any extended reference image as a result of a match, it may be determined that the reference image used to generate the extended reference image and the target image match each other.
Generally, the electronic device may generate 4n extended templates to form 4n different extended reference images, where a value of the preset positive integer n may be set according to a computing capability of the electronic device. That is, n may take a larger value if the computing speed of the electronic device is relatively fast.
As an application scenario, as shown in fig. 4A to 4J, the image matching method of the present embodiment may match a reference image shown in fig. 4B in an image to be recognized shown in fig. 4A, for example. For example, the electronic device may generate 4 expansion templates, as shown in fig. 4C to 4F, each expansion template may include an area to be superimposed and an expansion area, as shown in the figure, and positions of the areas to be superimposed in different expansion templates are different from each other. Superimposing the image data of the reference image shown in fig. 4B on the initial image data of the region to be superimposed in the extended template shown in fig. 4C to 4F may generate extended reference images as shown in fig. 4G to 4J, and it is seen that the size of each extended reference image may be larger than that of the reference image. The electronic device can extract a plurality of target images with the same size as the extended reference image shown in fig. 4G-4J from the image to be recognized shown in fig. 4A, and perform cross-correlation matching operation on each target image and the extended reference image shown in fig. 4G-4J, so that the identification of the target image matched with the reference image shown in fig. 4B in the image to be recognized shown in fig. 4A through the extended reference image shown in fig. 4G-4J can be realized.
According to the image matching method provided by the embodiment of the application, the reference images are firstly superimposed to the to-be-superimposed areas of the extended templates to generate the multiple extended reference images, then the target images with the same size as the extended reference images are extracted from the to-be-recognized images stored in the external memory, and the target images are matched with the extended templates in a cross-correlation manner, so that the target images matched with the reference images can be matched from the to-be-recognized images, the times of extracting the target images from the to-be-recognized images are reduced, and the image matching efficiency is improved.
With further reference to fig. 5, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of an image matching apparatus, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable in an electronic device.
As shown in fig. 5, the information pushing apparatus 500 of the present embodiment includes: a reference image acquisition module 501, an extended reference image generation module 502, a target image extraction module 503, and a matching operation module 504. The reference image obtaining module 501 may be configured to obtain a reference image, where the reference image includes image data arranged in a matrix; the extended reference image generation module 502 may be configured to extend the reference image to generate a plurality of extended reference images, where a row number of image data included in each extended reference image is the same as a row number of image data included in the reference image, and a column number of image data included in each extended reference image is equal to and greater than a column number of image data included in the reference image; the target image extracting module 503 may be configured to extract a target image with a size equal to that of the extended reference image from the image to be recognized by using a direct memory access manner; the matching operation module 504 may be configured to perform a cross-correlation matching operation on the target image and each extended reference image to determine whether the target image matches the reference image.
In some optional implementations of the present embodiment, the extended reference image generation module 502 may include an extended template generation unit (not shown) and an overlay unit (not shown). The expansion template generating unit can be configured to generate a plurality of expansion templates, wherein each expansion template comprises initial image data arranged in a matrix, each expansion template comprises an area to be superposed and an expansion area, and the positions of the areas to be superposed in each expansion template are different from each other; the superposition unit may be configured to superpose the image data of the reference image and the initial image data of the region to be superposed in each extended template, and generate a plurality of extended reference images; the number of rows of the initial image data of the expanded template is equal to the number of rows of the image data of the reference image, and the number of columns of the initial image data of the area to be superposed is equal to the number of columns of the image data of the reference image.
In some optional implementation manners of this embodiment, the number of the expansion templates is 4n, where n is a preset positive integer; the initial image data in matrix arrangement in each expansion template is zero.
In some optional implementations of the embodiment, the extension area includes a list of image data, each extension template includes 4n-1 extension areas, and each extension area is located on one side or both sides of the area to be superimposed, so that the positions of the areas to be superimposed in different extension templates are different from each other.
In some optional implementations of this embodiment, the target image extraction module 503 in the apparatus 500 may be further configured to acquire an image to be recognized by using an image sensor, parse the image to be recognized, and cache the image to be recognized in an external memory; and extracting the target image with the size equal to the size of the extended reference image from the external memory by adopting a direct memory access mode.
In some optional implementations of the embodiment, the image data addresses of the target image are aligned with the bus addresses.
It is to be noted that modules described in the image matching apparatus 500 correspond to respective steps in the method described with reference to fig. 2. Thus, the operations and features described above for the method are also applicable to the image matching apparatus 500 and the modules or units included therein, and are not described herein again.
Those skilled in the art will appreciate that the image matching apparatus 500 described above also includes some other well-known structures, such as internal circuits, processors, etc., which are not shown in fig. 5 in order to not unnecessarily obscure embodiments of the present disclosure.
Reference is now made to fig. 6, which is a block diagram illustrating a digital signal processing system suitable for use in implementing the electronic device of an embodiment of the present application. The digital signal processing system shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 6, the digital signal processing system 600 includes a processor 601 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from an external memory 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The I/O interface 605 may include a network interface, an external storage interface, a power interface, a signal acquisition interface, and the like. The network interface is used for connecting with network equipment 606 such as an external PC, the external storage interface is used for connecting with an external memory 607, the power interface is used for connecting with an external power supply system 608 which provides power signals for the digital signal processing system, and the signal acquisition interface is used for connecting with an image sensor 609 which acquires signals such as images.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. And may be stored in the ROM 602, and the processor 601 may specifically implement the function of image matching defined in the method of the present application by calling the computer program stored in the ROM 602.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules referred to in the embodiments of the present application may be implemented in a software manner, or may be implemented in a hardware manner. The described modules may also be provided in a processor, which may be described as: a processor comprises a reference image acquisition module, an extended reference image generation module, a target image extraction module and a matching operation module. The names of these modules do not in some cases constitute a limitation on the module itself, and for example, the reference image acquisition module may also be described as a "module configured to acquire a reference image".
As another aspect, the present application also provides a computer-readable storage medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable storage medium stores one or more programs that, when executed by one or more processors, cause the apparatus to: acquiring a reference image, wherein the reference image comprises image data arranged in a matrix; expanding the reference image to generate a plurality of expanded reference images, wherein the number of rows of image data contained in each expanded reference image is the same as the number of rows of image data contained in the reference image, and the number of columns of image data contained in each expanded reference image is equal to and greater than the number of columns of image data contained in the reference image; extracting a target image with the same size as the extended reference image from the image to be identified by adopting a direct memory access mode; and performing cross-correlation matching operation on the target image and each extended reference image to determine whether the target image is matched with the reference image.
As a further aspect, the present application also provides a digital signal processing apparatus including: one or more processors; a memory for storing one or more programs (which may include, for example, the computer-readable storage media described above); wherein the one or more programs, when executed by the one or more processors, cause the processors to implement the image matching methods provided herein.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.