The content of the invention
The invention provides a kind of template matching method, improves matching precision.
To solve above-mentioned technical problem, the present invention is achieved using following technical proposals:
A kind of template matching method, the matching process include:
Multigroup template is preset, every group of template includes multiple template;
The minimum between the characteristic vector and the multiple template of first group of template of calculating input image is distinguished using DTW algorithms
Cumulative distance;
A () judges the relation of the minimum cumulative distance and refusal threshold value for calculating;
(a1) if all of distance both greater than refuses threshold value, export the input picture not in the range of template;
(a2) if only one of which distance is less than refusal threshold value, the characteristic vector of calculating input image and multigroup template below
In corresponding templates minimum cumulative distance, and judge all distances for calculating whether both less than refusal threshold value, it is if so, then defeated
Go out corresponding template;If it is not, exporting the input picture not in the range of template;
(a3) if there are two or more distances less than refusal threshold value, minima therein is obtained, this is calculated most
Little value and the difference of other distances, judge whether that all of difference is all higher than differential threshold;
If so, then export the corresponding template of minima;
If it is not, minimum then between the corresponding templates in the characteristic vector of calculating input image and next group of template it is accumulative away from
From return to step (a), until output result.
Further, it is 3~5 groups to preset template group number.
A kind of template matches device, including:Default unit, for presetting multigroup template, every group of template includes multiple template;
Minimum cumulative distance computing unit, the characteristic vector for distinguishing calculating input image using DTW algorithms are multiple with first group of template
Minimum cumulative distance between template;Judge output unit, for judging the minimum cumulative distance for calculating with refusal threshold value
Relation;When all of distance both greater than refuses threshold value, the input picture is exported not in the range of template;In only one of which distance
During less than refusal threshold value, the minimum of the corresponding templates in the characteristic vector of calculating input image and multigroup template below it is accumulative away from
From whether all distances that judgement is calculated both less than refuse threshold value, if so, then export corresponding template;If it is not, it is defeated to export this
Enter image not in the range of template;When two or more distances are less than refusal threshold value, minima therein, meter are obtained
Calculate the difference of the minima and other distances;Judge whether that all of difference is all higher than differential threshold, if so, then export minima
Corresponding template;If it is not, then the minimum between the corresponding templates in the characteristic vector of calculating input image and next group of template is tired out
Meter distance.
A kind of gesture identification method, methods described include:
Input picture pretreatment;
Input picture characteristic vector pickup;
Template matching is carried out to the characteristic vector of input picture using described template matching method.
Further, in the template matching method, it is 3~5 groups to preset template group number.
A kind of gesture identifying device, including:Pretreatment unit, for carrying out pretreatment to input picture;Characteristic vector is carried
Unit is taken, for characteristic vector pickup being carried out to input picture;Template matches device, for entering to the characteristic vector of input picture
Row template matching.
Compared with prior art, advantages of the present invention and good effect are:The present invention template matching method and device with
And gesture identification method and device, by being carried out to input picture using default multigroup template, refusal threshold value, differential threshold
Match somebody with somebody, solve the problems, such as in prior art that matching precision is low, False Rate is high, improve the precision and accuracy of template matching, carry
The high accuracy of gesture identification, reduces the False Rate of gesture identification.
After the specific embodiment of the present invention is read in conjunction with the accompanying, the other features and advantages of the invention will become more clear
Chu.
Specific embodiment
In order that the objects, technical solutions and advantages of the present invention become more apparent, below with reference to drawings and Examples,
The present invention is described in further detail.
The template matching method and device of the present embodiment and gesture identification method and device, by using default multigroup
Template, and refusal threshold value and differential threshold are set, the accuracy of identification of matching algorithm is improve, matching result accuracy, drop is improved
Low False Rate.Below, by specific embodiment, template matching method and device and gesture identification method and device are carried out
Describe in detail.
The template matching method of the present embodiment, specifically includes following step, shown in Figure 1.
Step S1:Multigroup template is preset, every group of template includes multiple template.
As user is not when same gesture is done in the same time, gesture angle is it may happen that change, it is therefore desirable to default many
Group template.
For example, 3 groups of templates are preset, 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 the 3rd group of template are A3、B3、C3。
A1、A2、A3" fist " is represented, but the angle of " fist " may be different;B1、B2、B3" cloth " is represented, but " cloth "
Angle may be different;C1、C2、C3" shears " are represented, but the angle of " shears " may be different.
Same template (gesture) in different group templates is corresponding templates, such as A1、A2、A3For corresponding templates, B1、B2、B3For
Corresponding templates, C1、C2、C3For corresponding templates.
Step S2:Distinguished using DTW algorithms calculating input image characteristic vector and first group of template multiple template it
Between minimum cumulative distance.
Step S3:The minimum cumulative distance that judgement is calculated and the relation for refusing threshold value m.
If in all of minimum cumulative distance for calculating, having two or more less than refusal threshold value, then performing step
Rapid S4.
If in all of minimum cumulative distance for calculating, only one of which is less than refusal threshold value, then execution step S10.
If all of minimum cumulative distance for calculating both greater than refuses threshold value, then it is assumed that input picture and the template are not
Match somebody with somebody, then execution step S15.
In the present embodiment, the span for refusing threshold value m can be chosen according to practical situation.By arranging refusal threshold
Value, can quickly filter unmatched template, can guarantee that matching precision again.
Step S4:Obtain the minima in all of minimum cumulative distance.
Step S5:Judge whether this group of template is last group of template.
If so, then the corresponding template of the minima be output template, execution step S8;
If it is not, then execution step S6.
Step S6:Calculate the difference of the minima and other minimum cumulative distances.
Step S7:Judge whether that all of difference is all higher than differential threshold e.
If so, then execution step S8.
If it is not, then execution step S9.
In the present embodiment, the span of differential threshold e can be chosen according to practical situation.By arranging difference threshold
Value, had both been avoided that match time length, speed were slow, can guarantee that matching precision again.
Step S8:Corresponding template is exported, is exited.
Step S9:The minimum between corresponding templates in the characteristic vector of calculating input image and next group of template it is accumulative away from
From return to step S3, until output result.
Step S10:Judge whether this group of template is last group of template.
If so, then less than refusal threshold value the corresponding template of minimum cumulative distance be output template, execution step S13.
If it is not, then execution step S11.
Step S11:The minimum of the corresponding templates in the characteristic vector of calculating input image and multigroup template below it is accumulative away from
From.
Multigroup template refers to below, does not calculate the multigroup mould with the minimum cumulative distance of input picture characteristic vector
Plate.
Step S12:Judge whether all minimum cumulative distance that S11 is calculated both less than refuses threshold value m.
If, then it is assumed that input picture and the template matching, execution step S13.
If not, then it is assumed that input picture is mismatched with the template, then execution step S14.
Step S13:Corresponding template is exported, is exited.
Step S14:The input picture is exported not in the range of template, is exited.
Step S15:The input picture is exported not in the range of template, is exited.
The template matching method of the present embodiment, by using default multigroup template, refusal threshold value, differential threshold to input
Image is matched, and solves the problems, such as in prior art that matching precision is low, False Rate is high so that the precision of template matching enters 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, be 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, it is ensured that matching precision, template group number is avoided excessively to affect matching speed again.
Below, it is specifically described with presetting 3 groups of templates.For example, 3 groups of templates are preset, every group of template includes 3 templates
(i.e. 3 gestures).That is 3 templates of first group of template are A1、B1、C1, 3 templates of second group of template are A2、B2、C2, the 3rd
3 templates of group template are A3、B3、C3.Wherein, A1、A2、A3Represent " fist ", B1、B2、B3Represent " cloth ", C1、C2、C3Represent
" shears ".
(21) distinguished using DTW algorithms between the characteristic vector (hypothesis is E) and first group of template of calculating input image
Minimum cumulative distance, is designated as respectively
(22) judge the relation of all minimum cumulative distance and refusal threshold value m for calculating.
If a1, all minimum cumulative distancesBoth greater than refuse threshold value m, then export the input figure
As, not in the range of template, exiting.
If in a2, all minimum cumulative distances, (hypothesis is only one of which) less than refusal threshold value, then continue meter
Calculate characteristic 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、A2, or
A3), exit;Otherwise, the input picture is exported not in the range of template, exit.
If in a3, all minimum cumulative distances, having two or more less than refusal threshold value, it is assumed that Both less than m, then (for example minima is the minima for obtaining in all minimum cumulative distances), calculate this most
Little value and the difference of other minimum cumulative distances, computing formula is Judge institute
Whether some differences are both greater than differential threshold e, if so, then export corresponding template (A1、A2, or A3);If it is not, i.e. in all differences
In value exist less than e situation (for example), then the characteristic vector of calculating input image with it is corresponding in next group of template
Template (A2,C2) minimum cumulative distanceWithCirculation (22), concretely comprises the following steps:
JudgeWith the relation of refusal threshold value m.
If b1,WithBoth greater than m, then export the image not in the range of template, exit.
If b2, only one of which are less than m, it is assumed that beCharacteristic vector E is calculated then corresponding with next group of template
Template (A3) minimum cumulative distanceIfLess than m, then corresponding template (A is exported1、A2, or A3), exit;Otherwise,
The image is exported not in the range of template, is exited.
If b3,WithBoth less than m, (hypothesis is the minima for obtaining in both), calculate the minima withDifference,If the difference is more than differential threshold e, corresponding template (A is exported1、A2, or
A3);If the difference is less than the corresponding templates (A in differential threshold e, the characteristic vector of calculating input image and next group of template3,
C3) minimum cumulative distanceWith(22) are continued cycling through, is concretely comprised the following steps:
JudgeWithWith the relation of refusal threshold value m.
If c1,WithBoth greater than m, then export the image not in the range of template, exit.
If c2, only one of which are less than m, it is assumed that beIt is as this group of template is last group of template, then directly defeated
Go out corresponding template (A1、A2, or A3), exit.
If c3,WithBoth less than m, (hypothesis is the minima for obtaining in both), as this group of template is for most
Later group template, then directly export corresponding template (A1、A2, or A3), exit.
So far, output result has been drawn, has exported corresponding template or export the image not in the range 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 multigroup template, every group of template includes multiple template.
Minimum cumulative distance computing unit, distinguishes the characteristic vector and first group of mould of calculating input image using DTW algorithms
Minimum cumulative distance between the multiple template of plate.
Judge output unit, for judging the relation of the minimum cumulative distance for calculating and refusal threshold value;It is all of away from
From both greater than refusal threshold value when, export the input picture not in the range of template;When only one of which distance is less than refusal threshold value,
The minimum cumulative distance of the corresponding templates in the characteristic vector of calculating input image and below multigroup template, judges the institute for calculating
There is distance whether both less than refusal threshold value, if so, then export 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, obtain minima therein, calculate the minima and other
The difference of distance;Judge whether that all of difference is all higher than differential threshold, if so, then export the corresponding template of minima;If it is not,
The then minimum cumulative distance between the corresponding templates in the characteristic vector of calculating input image and next group of template.
The course of work of specific template matches device, describes in detail in above-mentioned template matching method, not superfluous herein
State.
The template matches device of the present embodiment, by using default multigroup template, refusal threshold value, differential threshold to input
Image is matched, and solves the problems, such as in prior art that matching precision is low, False Rate is high so that the precision of template matching enters 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 to the characteristic vector of input picture using above-mentioned template matching method.
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
Identifying device mainly includes pretreatment unit, characteristic vector pickup unit, template matches device, shown in Figure 4.
Pretreatment unit is for carrying out pretreatment to input picture;Characteristic vector pickup unit is for carrying out to input picture
Characteristic vector pickup;Template matches device carries out template matching for the characteristic vector to input picture.The template matching dress
Put main including presetting unit, minimum cumulative distance computing unit, judging output unit, it is shown in Figure 2, specifically can be found in
State bright, here is omitted.
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 multigroup template, and arranges refusal threshold value and differential threshold, carries
The precision and accuracy of high template matching, so as to improve the accuracy of gesture identification, reduces the False Rate of gesture identification.
Above example is only illustrating technical scheme, rather than is limited;Although with reference to aforementioned reality
Apply example to be described in detail the present invention, for the person of ordinary skill of the art, still can be to aforementioned enforcement
Technical scheme described in example is modified, or carries out equivalent to which part technical characteristic;And these are changed or replace
Change, do not make the essence of appropriate technical solution depart from the spirit and scope of claimed technical solution of the invention.