Disclosure of Invention
The application provides a template reconstruction device and method based on two-dimensional linear transformation, and aims to solve the problem that the system data processing capacity is too large when a positioning algorithm template is modified.
In a first aspect, the present application provides a template reconstruction apparatus based on two-dimensional linear transformation, the apparatus comprising:
the modification unit is used for modifying the first template of the positioning algorithm to obtain a second template; executing the second template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the second template;
the notification unit is used for sending a reconstruction instruction to the reconstruction unit when the first template of the positioning algorithm is modified;
and the reconstruction unit is used for reconstructing the template of the visual algorithm based on the two-dimensional linear transformation according to the two-dimensional linear transformation matrix corresponding to the second template when a reconstruction instruction is received.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the reconstruction unit includes:
the acquisition subunit is used for acquiring an original search area of a current template of a visual algorithm based on two-dimensional linear transformation;
and the reconstruction subunit is used for reconstructing the template of the visual algorithm based on the two-dimensional linear transformation according to the original search area and the two-dimensional linear transformation matrix corresponding to the second template.
With reference to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the reconstruction subunit is specifically configured to obtain a two-dimensional linear transformation matrix corresponding to the second template output by the modification unit, and calculate an inverse matrix of the two-dimensional linear transformation matrix corresponding to the second template;
and reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the inverse matrix and the original search area.
With reference to the first aspect, in a third possible implementation manner of the first aspect, the obtaining unit includes:
the execution subunit is used for executing the first template on the training data and outputting a two-dimensional linear transformation matrix corresponding to the first template;
and the determining subunit is used for acquiring a two-dimensional linear transformation matrix which is output by the executing subunit and corresponds to the first template, and determining the original search area according to the two-dimensional linear transformation matrix corresponding to the first template and the current template of the visual algorithm based on the two-dimensional linear transformation.
With reference to the first aspect or the second possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the reconstruction subunit is specifically configured to reconstruct the template of the two-dimensional linear transformation-based visual algorithm according to the inverse matrix and the original search area by matrix multiplication.
In a second aspect, the present application provides a template reconstruction method based on two-dimensional linear transformation, including:
when a first template of a positioning algorithm is modified, acquiring a second template obtained through modification;
executing the second template on the training data to obtain a two-dimensional linear transformation matrix corresponding to the second template;
and reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the two-dimensional linear transformation matrix corresponding to the second template.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the reconstructing the template of the two-dimensional linear transformation based visual algorithm includes:
acquiring an original search area of a current template of a visual algorithm based on two-dimensional linear transformation;
and reconstructing the template of the visual algorithm based on the two-dimensional linear transformation according to the original search area and the two-dimensional linear transformation matrix corresponding to the second template.
With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the reconstructing the template of the two-dimensional linear transformation based visual algorithm according to the original search area and the two-dimensional linear transformation matrix corresponding to the second template includes:
calculating an inverse matrix of the two-dimensional linear transformation matrix corresponding to the second template;
and reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the inverse matrix and the original search area.
With reference to the second aspect, in a fourth possible implementation manner of the second aspect, the obtaining an original search area of a current template of a two-dimensional linear transformation-based visual algorithm includes:
executing the first template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the first template;
and determining an original search area according to the two-dimensional linear transformation matrix corresponding to the first template and the current template of the visual algorithm based on the two-dimensional linear transformation.
With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the template of the two-dimensional linear transformation-based visual algorithm is reconstructed according to matrix multiplication between the inverse matrix and the original search area.
According to the technical scheme, the template reconstruction device and the template reconstruction method based on the two-dimensional linear transformation, which are provided by the embodiment of the application, firstly, the modification unit modifies the first template of the positioning algorithm to obtain the second template; executing the second template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the second template; secondly, when the first template of the positioning algorithm is modified, the notification unit sends a reconstruction instruction to the reconstruction unit; then, when the reconstruction unit receives a reconstruction instruction, the template of the visual algorithm based on the two-dimensional linear transformation is reconstructed according to the two-dimensional linear transformation matrix corresponding to the second template.
By adopting the device and the method, when the template of the positioning algorithm is modified, the templates of other visual algorithms based on two-dimensional linear transformation are passively modified according to the modified template of the positioning algorithm, so that the programming quantity and the data processing quantity of software in the system are reduced, and the maintenance cost of the system is reduced. Meanwhile, for the distributed and independently debuggable visual software, the condition that the abnormal condition occurs in the next use because only the positioning algorithm is modified and the corresponding other visual algorithms are not modified is avoided.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the present application provides a template reconstruction device based on two-dimensional linear transformation, which is internally or externally installed in a visual image detection system, with reference to fig. 1, and the device includes:
the modification unit U100 is used for modifying the first template of the positioning algorithm to obtain a second template; executing the second template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the second template;
a notification unit U200, configured to send a reconstruction instruction to the reconstruction unit when the first template of the positioning algorithm is modified;
and the reconstruction unit U300 is configured to reconstruct the template of the two-dimensional linear transformation-based visual algorithm according to the two-dimensional linear transformation matrix corresponding to the second template when the reconstruction instruction is received.
In this embodiment, the modifying unit U100 modifies the first template of the positioning algorithm, i.e. the current template, as required, and the modified template is the second template. Meanwhile, the modification unit U100 executes the second template on the training data, and outputs a two-dimensional linear transformation matrix corresponding to the second template. For example, the modification unit U100 modifies the first template Ms of the positioning algorithm into a second template Ms 1; the positioning algorithm is executed again, and the two-dimensional linear transformation matrix C2 corresponding to the second template Ms1 is output.
The notification unit U200 generates a reconstruction instruction when the first template of the positioning algorithm is modified and sends it to the reconstruction unit U300, so that when the template of the positioning algorithm is modified, other visual algorithms based on the two-dimensional linear transformation are automatically modified by the reconstruction unit to match the modified second template of the positioning algorithm. When the reconstruction unit U300 receives the reconstruction instruction, the template of the two-dimensional linear transformation-based visual algorithm is reconstructed according to the two-dimensional linear transformation matrix corresponding to the second template.
For example, the reconstruction unit U300 receives the reconstruction instruction sent by the notification unit U200, and automatically reconstructs the templates of the two-dimensional linear transformation-based visual algorithms (such as the circle finding algorithm) to match the templates with the second template Ms1 without executing the algorithms.
Referring to fig. 2, in some preferred embodiments of the present application, the reconstruction unit U300 includes:
an obtaining subunit U310, configured to obtain an original search area of a current template of a visual algorithm based on two-dimensional linear transformation;
and a reconstruction subunit U320, configured to reconstruct the template of the two-dimensional linear transformation-based visual algorithm according to the original search area and the two-dimensional linear transformation matrix corresponding to the second template.
In this embodiment, after the modification unit U100 modifies the template of the positioning algorithm and notifies the reconstruction unit U300 through the notification unit U200, the obtaining subunit U310 obtains the original search area of the current template of the visual algorithm based on the two-dimensional linear transformation. The reconstruction subunit U320 reconstructs the template of the two-dimensional linear transformation based visual algorithm according to the obtained original search area and the two-dimensional linear transformation matrix corresponding to the second template.
For example, a two-dimensional linear transformation matrix C2 corresponding to the second template Ms1 output by the modification unit is acquired; the reconstruction subunit U330 may determine a new template Mf1 of the circle finding algorithm according to the two-dimensional linear transformation matrix C2 and the original search area D.
The original search area D may be understood as an original search area corresponding to a current template of the visual algorithm when the templates of the positioning algorithm and other visual algorithms based on the two-dimensional linear transformation are not modified. For example, the first template of the positioning algorithm is Ms, the first template Ms is executed, a two-dimensional linear transformation matrix C is output, the two-dimensional linear transformation matrix C is obtained based on the circle finding algorithm of the two-dimensional linear transformation, and a search area D is determined according to the two-dimensional linear transformation matrix C and the current template Mf, where D is an original search area corresponding to the current template of the circle finding algorithm based on the two-dimensional linear transformation.
Based on this, in some preferred embodiments of the present application, the obtaining subunit U310 includes:
the execution subunit U311 is configured to execute the first template on the training data, and output a two-dimensional linear transformation matrix corresponding to the first template;
and the determining subunit U312 is configured to obtain a two-dimensional linear transformation matrix corresponding to the first template output by the execution subunit, and determine the original search area according to the two-dimensional linear transformation matrix corresponding to the first template and the current template of the two-dimensional linear transformation-based visual algorithm.
For example, the execution subunit U311 executes the first template Ms on the training data, and outputs a two-dimensional linear transformation matrix C corresponding to the first template Ms; the determining subunit U312 obtains a two-dimensional linear transformation matrix C, and determines an original search area D according to the two-dimensional linear transformation matrix C and a current template Mf of a visual algorithm based on two-dimensional linear transformation, where D is Mf × C.
In a further preferred embodiment of the present application, the reconstructing subunit U320 reconstructs the template of the two-dimensional linear transformation based visual algorithm specifically by the following steps:
firstly, acquiring a two-dimensional linear transformation matrix corresponding to a second template, and calculating an inverse matrix of the two-dimensional linear transformation matrix corresponding to the second template;
for example, a two-dimensional linear transformation matrix C2 corresponding to the second template Ms1 is acquired, and the inverse of the matrix C2 is calculated;
secondly, reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the inverse matrix and the original search area.
Preferably, the reconstruction subunit U320 reconstructs the template of the two-dimensional linear transformation based visual algorithm according to a matrix multiplication between the inverse matrix and the original search region. For example, the reconstructed template Mf1 of the circle finding algorithm based on the two-dimensional linear transformation is the inverse of the original search region D × the two-dimensional linear transformation matrix C2.
According to the foregoing embodiment, in the template reconstruction apparatus based on two-dimensional linear transformation provided by the present application, first, the modification unit modifies the first template of the positioning algorithm to obtain the second template; executing the second template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the second template; secondly, when the first template of the positioning algorithm is modified, the notification unit sends a reconstruction instruction to the reconstruction unit; then, when the reconstruction unit receives a reconstruction instruction, the template of the visual algorithm based on the two-dimensional linear transformation is reconstructed according to the two-dimensional linear transformation matrix corresponding to the second template.
By adopting the device and the method, when the template of the positioning algorithm is modified, the templates of other visual algorithms based on two-dimensional linear transformation are passively modified according to the modified template of the positioning algorithm, so that the programming quantity and the data processing quantity of software in the system are reduced, and the maintenance cost of the system is reduced. Meanwhile, for the distributed and independently debuggable visual software, the condition that the abnormal condition occurs in the next use because only the positioning algorithm is modified and the corresponding other visual algorithms are not modified is avoided.
According to the foregoing template reconstruction apparatus based on two-dimensional linear transformation, this embodiment provides a template reconstruction method based on two-dimensional linear transformation, and referring to fig. 3, the method includes:
step S110, when the first template of the positioning algorithm is modified, obtaining a second template obtained by modification;
step S120, executing the second template on the training data to obtain a two-dimensional linear transformation matrix corresponding to the second template;
and step S130, reconstructing the template of the visual algorithm based on the two-dimensional linear transformation according to the two-dimensional linear transformation matrix corresponding to the second template.
Preferably, the step S130 of reconstructing the template of the two-dimensional linear transformation based visual algorithm according to the two-dimensional linear transformation matrix corresponding to the second template includes:
firstly, acquiring an original search area of a current template of a visual algorithm based on two-dimensional linear transformation;
and secondly, reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the original searching area and the two-dimensional linear transformation matrix corresponding to the second template.
Preferably, the reconstructing the template of the two-dimensional linear transformation based visual algorithm according to the original search area and the two-dimensional linear transformation matrix corresponding to the second template includes:
firstly, calculating an inverse matrix of the two-dimensional linear transformation matrix corresponding to the second template;
secondly, reconstructing the template of the vision algorithm based on the two-dimensional linear transformation according to the inverse matrix and the original search area.
Preferably, the template of the two-dimensional linear transformation-based visual algorithm is reconstructed by matrix multiplication according to the inverse matrix and the original search area.
Preferably, the obtaining of the original search area of the current template of the two-dimensional linear transformation-based visual algorithm includes:
firstly, executing the first template on training data, and outputting a two-dimensional linear transformation matrix corresponding to the first template;
secondly, determining an original search area according to the two-dimensional linear transformation matrix corresponding to the first template and the current template of the visual algorithm based on the two-dimensional linear transformation.
As can be seen from the foregoing embodiments, in the template reconstruction apparatus and method based on two-dimensional linear transformation provided in the embodiments of the present application, first, the modification unit modifies the first template of the positioning algorithm to obtain the second template; executing the second template on the training data, and outputting a two-dimensional linear transformation matrix corresponding to the second template; secondly, when the first template of the positioning algorithm is modified, the notification unit sends a reconstruction instruction to the reconstruction unit; then, when the reconstruction unit receives a reconstruction instruction, the template of the visual algorithm based on the two-dimensional linear transformation is reconstructed according to the two-dimensional linear transformation matrix corresponding to the second template.
By adopting the device and the method, when the template of the positioning algorithm is modified, the templates of other visual algorithms based on two-dimensional linear transformation are passively modified according to the modified template of the positioning algorithm, so that the programming quantity and the data processing quantity of software in the system are reduced, and the maintenance cost of the system is reduced. Meanwhile, for the distributed and independently debuggable visual software, the condition that the abnormal condition occurs in the next use because only the positioning algorithm is modified and the corresponding other visual algorithms are not modified is avoided.
In specific implementation, the present invention further provides a computer storage medium, where the computer storage medium may store a program, and the program may include some or all of the steps in the embodiments of the reconstruction method provided by the present invention when executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented as software plus a required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The same and similar parts in the various embodiments in this specification may be referred to each other. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the description in the method embodiment.
The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention.