Summary of the invention
The present invention provides a kind of template matching methods, improve matching precision.
It is achieved in order to solve the above technical problems, the present invention adopts the following technical solutions:
A kind of template matching method, the matching process include:
Default multiple groups template, every group of template includes multiple template;
The minimum between the feature vector of input picture and the multiple template of first group of template is calculated separately using DTW algorithm
Cumulative distance;
(a) judge the relationship of calculated minimum cumulative distance and refusal threshold value;
(a1) if all distances both greater than refuse threshold value, the input picture is exported not within the scope of template;
(a2) if only one distance is less than refusal threshold value, the feature vector of calculating input image and multiple groups template below
In corresponding templates minimum cumulative distance, and judge calculated all distances whether both less than refusal threshold value, if so, defeated
Corresponding template out;If it is not, exporting the input picture not within the scope of template;
(a3) if there are two or more than two distances be less than refusal threshold value, obtain minimum value therein, calculate this most
The difference of small value and other distances, judges whether that all differences are all larger than differential threshold;
If so, the corresponding template of output minimum value;
If it is not, then the minimum between the corresponding templates in the feature vector of calculating input image and next group of template it is accumulative away from
From return step (a), until output result.
Further, presetting template group number is 3~5 groups.
A kind of template matches device, comprising: default unit, for presetting multiple groups template, every group of template includes multiple template;
Minimum cumulative distance computing unit calculates separately the multiple of the feature vector of input picture and first group of template using DTW algorithm
Minimum cumulative distance between template;Output unit is judged, for judging calculated minimum cumulative distance and refusing threshold value
Relationship;When all distances both greater than refuse threshold value, the input picture is exported not within the scope of template;In only one distance
When less than refusal threshold value, the minimum of the feature vector of calculating input image and the corresponding templates in multiple groups template below it is accumulative away from
From, judge calculated all distances whether both less than refusal threshold value, if so, exporting corresponding template;If it is not, it is defeated to export this
Enter image not within the scope of template;When two or more distances are less than refusal threshold value, minimum value therein is obtained, is counted
Calculate the difference of the minimum value Yu other distances;Judge whether that all differences are all larger than differential threshold, if so, output minimum value
Corresponding template;If it is not, then the minimum between the corresponding templates in the feature vector of calculating input image and next group of template is tired
Count distance.
A kind of gesture identification method, which comprises
Input picture pretreatment;
Input picture characteristic vector pickup;
Template matching is carried out using feature vector of the template matching method to input picture.
Further, in the template matching method, presetting template group number is 3~5 groups.
A kind of gesture identifying device, comprising: pretreatment unit, for being pre-processed to input picture;Feature vector mentions
Unit is taken, for carrying out characteristic vector pickup to input picture;Template matches device, for the feature vector to input picture into
Row template matching.
Compared with prior art, the advantages and positive effects of the present invention are: template matching method and device of the invention with
And gesture identification method and device, input picture is carried out by using preset multiple groups template, refusal threshold value, differential threshold
Match, solves the problems, such as that matching precision is low in the prior art, False Rate is high, improve the precision and accuracy of template matching, mention
The high accuracy of gesture identification, reduces the False Rate of gesture identification.
After a specific embodiment of the invention is read in conjunction with the figure, the other features and advantages of the invention will become more clear
Chu.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, below with reference to drawings and examples,
Invention is further described in detail.
The template matching method and device and gesture identification method and device of the present embodiment, by using preset multiple groups
Template, and refusal threshold value and differential threshold are set, the accuracy of identification of matching algorithm is improved, matching result accuracy, drop are improved
Low False Rate.In the following, being carried out by specific embodiment to template matching method and device and gesture identification method and device
It is described in detail.
The template matching method of the present embodiment specifically includes following step, shown in Figure 1.
Step S1: default multiple groups template, every group of template includes multiple template.
Since user is when doing same gesture different moments, gesture angle may change, it is therefore desirable to default more
Group template.
For example, presetting 3 groups of templates, every group of template includes 3 templates (i.e. 3 gestures).3 templates of first group of template are
A1、B1、C1, 3 templates of second group of template are A2、B2、C2, 3 templates of third group template are A3、B3、C3。
A1、A2、A3" fist " is represented, still the angle of " fist " may be different;B1、B2、B3" cloth " is represented, but " cloth "
Angle may be different;C1、C2、C3" scissors " is represented, but the angle of " scissors " may be different.
Same template (gesture) in difference group template is corresponding templates, such as A1、A2、A3For corresponding templates, B1、B2、B3For
Corresponding templates, C1、C2、C3For corresponding templates.
Step S2: using DTW algorithm calculate separately input picture feature vector and first group of template multiple template it
Between minimum cumulative distance.
Step S3: judge the relationship of calculated minimum cumulative distance and refusal threshold value m.
If in calculated all minimum cumulative distances, there are two or it is more than two be less than refusal threshold value, then execute step
Rapid S4.
If in calculated all minimum cumulative distances, only one is less than refusal threshold value, S10 is thened follow the steps.
If calculated all minimum cumulative distances both greater than refuse threshold value, then it is assumed that input picture and the template are not
Match, thens follow the steps S15.
In the present embodiment, the value range for refusing threshold value m can be chosen according to the actual situation.Refuse threshold by setting
Value, can quickly filter out unmatched template and matching precision.
Step S4: the minimum value in all minimum cumulative distances is obtained.
Step S5: judge whether this group of template is last group of template.
If so, the corresponding template of the minimum value is output template, step S8 is executed;
If it is not, thening follow the steps S6.
Step S6: the difference of the minimum value and other minimum cumulative distances is calculated.
Step S7: judge whether that all differences are all larger than differential threshold e.
If so, thening follow the steps S8.
If it is not, thening follow the steps S9.
In the present embodiment, the value range of differential threshold e can be chosen according to the actual situation.By the way that difference threshold is arranged
Value had not only been avoided that match time was long, speed is slow, but also can guarantee matching precision.
Step S8: corresponding template is exported, is exited.
Step S9: the minimum between corresponding templates in the feature vector of calculating input image and next group of template it is accumulative away from
From return step S3, until output result.
Step S10: judge whether this group of template is last group of template.
If so, the corresponding template of minimum cumulative distance for being less than refusal threshold value is output template, step S13 is executed.
If it is not, thening follow the steps S11.
Step S11: the minimum of the feature vector of calculating input image and the corresponding templates in multiple groups template below it is accumulative away from
From.
Multiple groups template refers to below, does not calculate the multiple groups mould with the minimum cumulative distance of input picture feature vector
Plate.
Step S12: judge the calculated all minimum cumulative distances of S11 whether both less than refusal threshold value m.
If so, thinking input picture and the template matching, step S13 is executed.
If not, then it is assumed that input picture and the template mismatch, and then follow the steps S14.
Step S13: corresponding template is exported, is exited.
Step S14: the input picture is exported not within the scope of template, is exited.
Step S15: the input picture is exported not within the scope of template, is exited.
The template matching method of the present embodiment, by using preset multiple groups template, refusal threshold value, differential threshold to input
Image is matched, and solves the problems, such as that matching precision is low in the prior art, False Rate is high, so that the precision of template matching is into one
Step is improved, and improves template matching accuracy, improves the accuracy of gesture identification, reduces opponent in gesture identification
The False Rate of gesture;And method is simple, is easily achieved.
In the present embodiment, the group number for presetting template is 3~5 groups, both ensure that with enough templates to input figure
As being matched, guarantee matching precision, and template group number is avoided excessively to influence matching speed.
In the following, being specifically described with default 3 groups of templates.For example, presetting 3 groups of templates, every group of template includes 3 templates
(i.e. 3 gestures).3 templates of i.e. first group template are A1、B1、C1, 3 templates of second group of template are A2、B2、C2, third
3 templates of group template are A3、B3、C3.Wherein, A1、A2、A3It represents " fist ", B1、B2、B3It represents " cloth ", C1、C2、C3It represents
" scissors ".
(21) it is calculated separately between the feature vector (assuming that being E) of input picture and first group of template using DTW algorithm
Minimum cumulative distance, is denoted as respectively
(22) judge the relationship of calculated all minimum cumulative distances and refusal threshold value m.
If a1, all minimum cumulative distancesBoth greater than refuse threshold value m, then exports the input figure
As exiting not within the scope of template.
If only one is (assuming that be in a2, all minimum cumulative distances) be less than refusal threshold value, then continue to count
Calculate the feature vector E and corresponding template (A in rear two groups of templates of input picture2、A3) minimum cumulative distanceWith
IfWithBoth less than refuse threshold value m, then it is assumed that input picture and the template matching export corresponding template (A1、A2Or
A3), it exits;Otherwise, the input picture is exported not within the scope of template, is exited.
If in a3, all minimum cumulative distances, there are two or more than two be less than refusal threshold value, it is assumed that Both less than m, then (such as minimum value is the minimum value for obtaining in all minimum cumulative distances), calculate this most
The difference of small value and other minimum cumulative distances, calculation formula are Judge institute
Whether some differences are both greater than differential threshold e, if so, exporting corresponding template (A1、A2Or A3);If it is not, i.e. in all differences
The case where in value in the presence of less than e (such as), then the feature vector of calculating input image with it is corresponding in next group of template
Template (A2,C2) minimum cumulative distanceWithIt recycles (22), specific steps are as follows:
JudgementWith the relationship of refusal threshold value m.
If b1,WithBoth greater than m then exports the image not within the scope of template, exits.
If b2, only one be less than m, it is assumed that beIt is corresponding with next group of template then to calculate feature vector E
Template (A3) minimum cumulative distanceIfLess than m, then corresponding template (A is exported1、A2Or A3), it exits;Otherwise,
The image is exported not within the scope of template, is exited.
If b3,WithBoth less than m obtains the minimum value in the two (assuming that being), calculate the minimum value withDifference,If the difference is greater than differential threshold e, corresponding template (A is exported1、A2Or
A3);If the difference is less than differential threshold e, the feature vector of calculating input image and the corresponding templates (A in next group of template3,
C3) minimum cumulative distanceWithContinue cycling through (22), specific steps are as follows:
JudgementWithWith the relationship of refusal threshold value m.
If c1,WithBoth greater than m then exports the image not within the scope of template, exits.
If c2, only one be less than m, it is assumed that beIt is since this group of template is last group of template, then directly defeated
Corresponding template (A out1、A2Or A3), it exits.
If c3,WithBoth less than m obtains the minimum value in the two (assuming that being), since this group of template is
Last group of template then directly exports corresponding template (A1、A2Or A3), it exits.
So far, obtained output as a result, exporting corresponding template or exporting the image not within the scope of template.
Based on the design of above-mentioned template matching method, the present embodiment also proposed a kind of template matches device, the template
Coalignment mainly includes default unit, minimum cumulative distance computing unit, judges output unit, shown in Figure 2.
Default unit, for presetting multiple groups template, every group of template includes multiple template.
Minimum cumulative distance computing unit calculates separately the feature vector and first group of mould of input picture using DTW algorithm
Minimum cumulative distance between the multiple template of plate.
Output unit is judged, for judging the relationship of calculated minimum cumulative distance and refusal threshold value;It is all away from
When from both greater than refusal threshold value, the input picture is exported not within the scope of template;When only one distance is less than refusal threshold value,
The minimum cumulative distance of the feature vector of calculating input image and the corresponding templates in multiple groups template below, judges calculated institute
There is distance whether both less than refusal threshold value, if so, exporting corresponding template;If it is not, exporting the input picture not in template model
In enclosing;When two or more distances are less than refusal threshold value, minimum value therein is obtained, the minimum value and other are calculated
The difference of distance;Judge whether that all differences are all larger than differential threshold, if so, the corresponding template of output minimum value;If it is not,
The then minimum cumulative distance between the corresponding templates in the feature vector of calculating input image and next group of template.
The course of work of specific template matches device, is described in detail in above-mentioned template matching method, not superfluous herein
It states.
The template matches device of the present embodiment, by using preset multiple groups template, refusal threshold value, differential threshold to input
Image is matched, and solves the problems, such as that matching precision is low in the prior art, False Rate is high, so that the precision of template matching is into one
Step is improved, and improves template matching accuracy, improves the accuracy of gesture identification, reduces opponent in gesture identification
The False Rate of gesture.
Based on the design of above-mentioned template matching method, the present embodiment also proposed a kind of gesture identification method, specifically include
Following step, it is shown in Figure 3.
Step S31: input picture pretreatment.
Step S32: input picture characteristic vector pickup.
Step S33: template matching is carried out using feature vector of the above-mentioned template matching method to input picture.
In template matching method, the group number for presetting template is 3~5 groups.
Based on the design of above-mentioned gesture identification method, the present embodiment also proposed a kind of gesture identifying device, the gesture
Identification device mainly includes pretreatment unit, characteristic vector pickup unit, template matches device, shown in Figure 4.
Pretreatment unit is for pre-processing input picture;Characteristic vector pickup unit is used to carry out input picture
Characteristic vector pickup;Template matches device is used to carry out template matching to the feature vector of input picture.The template matching dress
Setting main includes presetting unit, minimum cumulative distance computing unit, judging output unit, and shown in Figure 2, for details, reference can be made to upper
State bright, details are not described herein again.
The gesture identification method and device of the present embodiment, using above-mentioned template matching method to the feature of input picture to
Amount carries out template matching, in template matching method, by presetting multiple groups template, and refusal threshold value and differential threshold is arranged, mentions
The high precision and accuracy of template matching reduces the False Rate of gesture identification to improve the accuracy of gesture identification.
The above embodiments are merely illustrative of the technical solutions of the present invention, rather than is limited;Although referring to aforementioned reality
Applying example, invention is explained in detail, for those of ordinary skill in the art, still can be to aforementioned implementation
Technical solution documented by example is modified or equivalent replacement of some of the technical features;And these are modified or replace
It changes, the spirit and scope for claimed technical solution of the invention that it does not separate the essence of the corresponding technical solution.