Ryan, Daniel James
November 22, 2022 | Author: Anonymous | Category: N/A
Short Description
Download Ryan, Daniel James...
Description
640 × 480 640
0.7 − 6
640 × 480 = 307200
640 × 480 = 307200
imageHeight × 0.80
480 × 0.80
= × imageWidth imageWidth =
5
× 640 = 76 × 640 = 48640
5
imageWidth × imageHeight imageHeight = = 640 × 480 = 307200
640 × 480
O (1)
ω
k
k
k
a
ω
k
b
a b
c
ω
k
b c a
k
k
b
k
ω
ω 0.95993
a
a b
b
a
c
c
96 96..9%
1 ≤ n ≤ 5
n
q
O (1)
p
d( p, q ) = ( p − q ) + ( p ( p − q ) + ( p ( p − q ) x
2
x
y
2
y
z
2
z
5
d( p , q ) i
i
i=1
c
c
c
c
c
c
c
c
c
c
cac
c
cac = = c c ac + ccost
[m, n]
0 ≤ w{x,y,z } ≤ 1
x
w
d ( p, q ) = w ( p − q ) + w ( p − q ) + w ( p − q )
x
2
x
y
y
2
y
z
z
2
z
w{x,y,z }
[m, n]
c
c
2
c cost d ac ac c = = c c + 2
wh
wv
w
c
wd
cac = = c cac + w ccost
w{h,v,d} w = { 1, 1, 0.5}
b
prevStart + prevStart + 2b × 3
prevS tart + tart + 2b
prevS tart
p
p p b
p
q
u
u
p = p = 875mm 875mm
b
q = = 1475mm 1475mm
q
q
p
p q
p = q + + s( p − q )
p
p
s
q
0 ≤ s ≤ 1
n
n
y
s
w
t
n
0 < w < 1
st = = w wyyt + (1 − w)st−1
p
v
p
l
t b r
p
r
=
v (1 /2 − py ) pz 1 v (− /2 − py ) = pz v (1 /2r − px ) = pz 1 v (− /2r − px ) = pz
contourData = contourData = I I ContourT ContourT racking.Start racking.StartT T racking racking((... ...))
DepthFrameReady
DepthDistanceUpdated
DepthDistanceUpdated
DepthDistanceUpdated
RangeFinder.PixelsInRange((...) RangeFinder.PixelsInRange ...)
v o i d D e p t h D i s t a nc nc e U p d a t e d ( d e p t h D i is s t a n c eD eD a t a , w i dt dt h , h e i g ht ht ) { / / F il i l te t e r d ep e p th t h d at a t a t o o nl n l y c on o n ta t a in i n d at a t a i n a s p ec ec if i f ie i e d d ep e p th t h i nt n t er e r va va l . va r p i x e l s In In R a n g e = R a n g e F i n d e r . P i x e l s I n R a n g e ( d e p t h D i s t a n c e D a t a , m i n D is is t a n c ce e , m a x D i s ta ta n c e ) ; I C o n t o u r T r a c k i n g . S t a r t T r a c k i ng ng ( p i x e l s I n R an an g e , w i dt dt h , h e i g ht ht ) ; }
ContourDataReady
Fingertip
ICurveDetection.FindCurves(... ICurveDetection.FindCurves( ...))
IFingerRecognition.FindFingertipLocations (... ...))
ICurveDetection.FindCurves(contourPoints ICurveDetection.FindCurves( contourPoints))
Fingertip
ContourDataReady
void C o n t o u r D a ta ta R e a d y ( c o n t o u rP rP o i n ts ts , p i x l es es ) { rv e s = I C u r v e D e t e c t i o n . F i n d C u r v e s ( c o n t o u r P o i n t s ) ; va r c u rv I F i n g e r R e c o g n i t i o n . F i n d F i n g e r t i p L o ca ca t i o n s ( c u r ve ve s , p i xe xe l s , w i dt dt h , h e i g ht ht ) ; }
recordedGesture
Hand
I GestureRecognit GestureRecognition.A ion.AnalyzeF nalyzeF rame( rame(... ...))
false
Hand
true
Hand
GestureRecognized
preventH andInconsitencies andI nconsitencies
GestureRecorded
preventH andInconsitencies andI nconsitencies
GestureRecorded
v o i d F i n g e r t i p L o ca ca t i o n s R e a d y ( f i n g e r t ti ips) { / / C on o n ve v e rt r t f in i n g er er ti t i ps p s t o a H an a n d o bj b j ec ec t . va r c u r r e nt nt H a n d = ne w Hand ( f i n g e r t i p s ) ; if ( E n a b l e S m o o t h i n g ) c u r r e n t Ha Ha n d = S m o o t h i n g . E x p o n e n t i a l S m o o t h i n g ( c u r r e n t H a n d , p r e v H a n d , smoothingFactor); / / T h is is i s t he h e p r e di di c ti t i o n a l g or or i th th m . if ( p r e v e n t H a n d I n c o n s i t e n c i e s ) HandEnhancements .PreventHandIncosistency(currentHand); se e i f ( IGestureRecognition .Recognizing || IGestureRecognition .Recording) els IGestureRecognition .AnalyzeFrame(currentHand); p r ev ev H a an n d = c u r re re n tH tH a n d ; }
v o i d G e s t u r e R e co co g n i z e d ( r e c o g n i z e d G e es sture) { / / H er e r e g oe o e s c od o d e t ha ha t a ct ct u po p o n t he he r ec e c o gn gn iz i z ed e d g es e s tu t u re re . }
IFingerRecognition
F indFingertipLo indF ingertipLocatio cations ns
void G e s t u r e R ec ec o r d e d ( r e c o r d e d G e s tu tu r e ) { IGestureRecognition .StoreGesture(recordedGesture); }
Kinect ContourTracking CurveDetection F ingerRecognition ingerRecognition
GestureRecognition
IKinect.RelativeHeadPosition((...) IKinect.RelativeHeadPosition ...)
void U p d a t e ( G a m e T i m e g a m e T i m e ) { va r o r ig i g i n = ne w V e c t o r 3 ( , , 1 ) ; va r s m o o t hW h W e i gh gh t i ng n g = . 1 f; f; if ( I K i n e c t . I s T r a c k i n g S k e l e t o n ) P e r s p e c t i v e C a m e r a . P o s it it i on on = IKinect .Relat iveHeadPositi on( horizontalOffset , floorToKinectOffset , s c r e e n To To K i n e c tO tO f f s e t , s c r e e n Wi Wi d t h ) ; else S m o o t h S t e p Ca Ca m e r a P o s i t io io n ( o r i g i n , s m o o t h W ei ei g h t i n g ) ; / / R et e t ur u r n t o o ri r i gi gi n . base . U p d a t e ( g a m e T i m e ) ; }
k
k
k
k
k
IKinect
contou con tourP rP oints, oints, k, omega omega
curvePoints = ∅ curvePoints = icurrent ← 0 contourP contourP oints.Size oints.Size
contourPoints i < k i = = contourPoints.Size contourPoints.Size − k + i i = = i i − k b = = Create CreateV V ector ector((contourPoints contourPoints[[i ], contou contourP rP oints oints[[i ]) i > contourPoints.Size − k i = = k k − conto contourP urP oints.Size oints.Size + i i = = i i + k a = = Create CreateV V ector ector((conto contourP urP oints[ oints[i ], contou contourP rP oints oints[[i ]) i < k i = 0 i = = i i − k b = = Create CreateV V ector ector((contourPoints contourPoints[[i ], contou contourP rP oints oints[[i ]) −k i i > = = k kcontourPoints.Size contourP urP oints.Size oints.Size i = = i i − conto + k a = = Create CreateV V ector ector((conto contourP urP oints[ oints[i ], contou contourP rP oints oints[[i ]) c = Creat = CreateV eV ector ector((a, a, b)
current
b
b
current
current
current
current
a
a
current
current
current
a
current
b
current
a
current
b
b
current
current
a
a
current
curvePoints = curvePoints = curveP curveP oints oints ∩ {contou contourP rP oints[ oints[icurrent ], a, b, c}
b
(curvePoints curvePoints))
v o i d C o n t o u r D at at a R e a d y ( c o n t o u r rP Point ts s , p i x l es es ) { va r c u rv rv e s = I C u r v e D e t e c t i o n . F i n d C u r v e s ( c o n t o u r P o i n t s ) ; er t i p s = I F i n g e r R e c o g n i t i o n . F i n d F i n g e r t i p L o c a t i o n s ( c u r v e s , va r f i n g er p ix i x el e l s , w id i d th th , h e i ig ght); va r f i n g er er C o u n t = f i n g e r t ti ips.Count; if ( u p d a t e D e p t h D i s t a c e T h r e s h o l d ) { AutoscanForDistanceThreshold(fingerCount); r e t u r n ; / / D o n ’ t d o a ny n y th t h in i n g e ls l s e w hi h i le l e s ca c a n i s i n p ro r o gr g r es es s . } } is t a n c e T h r e s h o ol ld(fingerCount) v o i d A u t o s c a n F o r D is { / / T he h e D i s ta t a n c eT eT h r es e s h o ld ld o b je j e c t h o ld ld s t he h e m in i n a nd n d m ax a x d i st s t a nc nc e . DistanceThreshold newDistanceThreshold; in i s h e d = D i s t a n c e S c a n n e r . T w o H a n d S c a n ( f i n g e r C o u n t , bool s c a n F in d i s t a n c e T h r e s h o l d , ou t n e w D i s t a n c e T h r e s h o l d ) ; / / d i s ta t a n c eT eT h r es e s h o ld ld i s a g l ob ob a l v a ri r i a bl b l e u s ed ed b y t he h e r a ng ng e f i nd nd e r . d i s t a n c e Th Th r e s h o l d = n e w D i s t a n c eT eT h r e s h o l d ;
u p d a t e D e p t h Di Di s t a c e T h r e s h ho o l d = ! s c a n F i n i s h ed ed ; }
p u bl bl i c s e al a l e d c l as as s Main { p r i v a te nl y I K i n e c t k i n e c t D e v i c e ; te r e a d o nl te r e a d o nl p r i v a te nl y R a n g e F i n d e r r a n g e F i n d e r ; p r i v a te nl y I C o n t o u r T r a c k i n g c o n t o u r T r a c k i n g ; te r e a d o nl te r e a d o nl p r i v a te nl y I C u r v e D e t e c t i o n c u r v e D e t e c t i o n ; te e r e a d o nl nl y I F i n g e r R e c o g n i t i o n f i n g e r R e c o g n i t i o n ; privat te r e a d o nl p r i v a te nl y D i s t a n c e S c a n n e r d i s t a n c e S c a n n e r ; privat te e r e a d o nl nl y I G e s t u r e R e c o g n i t i o n g e s t u r e R e c o g n i t i o n ; te e r e a d o nl nl y I P r e d i c t i o n p r e d i c t i o n ; privat te r e a d o nl p r i v a te nl y H a n d E n h a n c e m e n t s h a n d E n h a n c e m e n t s ; p r i v a te nl y D e b u g I n f o d e b u g I n f o ; te r e a d o nl p r i v a t e Hand p r e v H a n d ; public Main( IKinect kinectDevice) { / / D i st s t a nc n c e s i n m i ll l l i me me t e r . c o n st st i n t m i n D e pt p t h D is i s t a nc nc e = 8 ; ; / / T h e m i ni n i m um u m d i st s t a nc n c e w h er er e t he he K in i n ec e c t f or or X bo b o x 3 6 6 c an an d et e t ec e c t o bj b j ec e c ts ts . c o n st st i n t m a x D e pt pt h D i s t a n c e = 4 ; ; this . k in in e ec ct tD De ev vi ic ce
= ki in ne ec ct tD De ev vi ic ce;
va r s e n s o r De De p t h R a n g e = ne w D i s t a n c e T h r e s h o l d { M i n Di Di s t an an c e = m i n D e pt pt h D i s ta ta n c e , M a x D i s t a an n c e = m a x D e p t h Di Di s t a n c e } ; rangeFinder
= ne w R a n g e F i n d e r () ;
contourTracking
= ne w C o n t o u r T r a c k i n g () ;
curveDetection fi in ng ge er rR Re ec co og gn ni it ti io on n
= ne w C u r v e D e t e c t i o n () ; = ne w F i n g e r R e c o g n i t i o n ( r a n g e F i n d e r ) ;
distanceScanner
= ne w D i s t a n c e S c a n n e r ( s e n s o r D e p t h R a n g e ) ;
ge es s t ur ur e eR R e co c o g ni ni t io io n
= ne w G e s t u r e R e c o g n i t i o n () ;
prediction
= ne w P r e d i c t i o n () ;
h a n dE dE n ha ha nc nc e me me n ts ts
= ne w H a n d E n h a n c e m e n t s ( p r e d i c t i o n ,
gestureRecognition); debugInfo
= ne w D e b u g I n f o () ;
InitializeDistanceThreshold(minDepthDistance); InitializeDebugInfo(); CreateEvents(); }
p u b l i c I C o n t o u r T r a c ki ki n g C o n t o u r Tr Tr a c k i n g { g e t { r e t u r n c o n to t o u r Tr Tr a c ki ki n g ; } } p u b l i c I C u r v e D e t e ct ct i o n C u r v e D e te te c t i o n { g e t { r e t u r n c u r ve v e D et et e c t ti ion; } } p u b l i c I F i n g e r R e c o g n it it i o n F i n g e r R e c og og n i t i o n { g e t { r e t u r n f i n ge g e r R ec e c o g ni ni t i on on ; } } it i o n G e s t u r e R e co co g n i t i o n { g e t { r e t u r n p u b l i c I G e s t u r e R e c o g n it g e s tu t u r e Re R e c o gn gn i t io io n ; } } p u b l i c D e b u g I nf nf o D e b u g I nf nf o { g e t { r e t u r n d e b ug ug I nf nf o ; } } privat te e void InitializeD Di i s t a n c e T h r e sh sh o l d ( in t m i n D e p t h D i s t a n c e ) { c o n st n c e I nt n t e r va va l = 1 5 5 ; st i n t d i s t a nc D i s t a n c e T h r e s h o l d = ne w D i s t a n c e T h r e s h o l d { M i n D i s ta ta n c e = m i n D e pt pt h D i s ta ta n c e , M a xD xD i s t ta a n c e = m i n De D e p t hD hD i s ta ta n c e + distanceInterval }; debugInfo. DistanceThreshold = DistanceThreshold ; } te e void InitializeDebugInfo() privat { d e b u g I nf nf o . G e s t u r e D e b u g I n f o = g e s t u r e R ec ec o g n i t i o n as IGestureRecognitionDebug; } te e void CreateEvents() privat {
k in in e c tD tD e v ic ic e . De D e p th th Di Di st st a nc nc eU eU pd pd a te te d
+ = ne w
D e p t h D i s t a nc nc e E v e n t H a n d le le r ( k i n e c t D e v i c e _ D e p t h D i s t a n ce ce U p d a t e d ) ; c on on t ou ou rT rT r ac ac k i ng ng . Co C o n to to u rD rD at at a Re Re a dy dy
+ = ne w
ContourReady(contourTracking_ContourDataReady); f i n g e r R e co co g n i t i o n . F i n g e r t i p L o c at at i o n s R e a d y + = ne w F i n g e r t i pP pP o i n t s ( f i n g e r R e c o g n i t i o n _ F i ng ng e r t i p L o c a t i o n sR sR e a d y ) ; ge es st tu ur re eR Re ec co og gn ni it ti io o n . Ge Ge s st tu ur re eR Re ec co og gn ni iz ze ed
+ = ne w
GestureReady(gestureRecognition_GestureRecognized); g es es tu tu r re eR Re ec co og gn ni it ti io on n. .G Ge es st tu ur r eR eR e ec co or rd de ed
+ = ne w
GestureRecorded(gestureRecognition_GestureRecorded); } te e void kinectDevice e_ _ D e p t h D i s t a n c eU eU p d a t e d ( s h o r t [] privat d e p t h D i s t a n c e D a t a , in t w i d t h , in t h e i g h t )
{ W i dt dt h = w i d dt th; H e ig ig h t = h e ig ig h t ; Pixel [ ] p i x xe elsI In n R an an g e = rangeFinder.PixelsInRange(depthDistanceData , DistanceThreshold .MinDistance , DistanceThreshold .MaxDistance); d e b u g I nf nf o . R a n g e D a t a = p i x e l s I nR nR a n g e ; c o n t o u r Tr Tr a c k i n g . S t a r t T r a c ki ki n g ( p i x e l s I n R Ra a n g e , w i dt dt h , h e i g ht ht ) ; }
te v o i d c o n t o u r T r a c k p r i v a te ki i n g _ C o n t o u r D a ta ta R e a d y ( I E n u m e r a b l e < e < V e c t or or > xe els) contourPoints , Pixel [ ] p i x { I E n u m e r a b l e Po o i n t > c u r v es es = e < C u r v e P curveDetection.FindCurves(contourPoints); e < F i n g e r t i p I E n u m e r a b l e < p > p o oi in nt ts = f i n g e r R e co co g n i t i o n . F i n d F i n g e r t i pL pL o c a t i o n s ( c u r ve ve s , p i xe xe l s , W i dt dt h , H e i g ht ht ) ; in t f i n g er er C o u un nt = ((IL Li i st s t < F i n g e r t i p > p > ) p o i n t s ) . C o u n t ; if ( U p d a t e D e p t h D i s t a c e T h r e s h o l d ) { AutoscanForDistanceThreshold(fingerCount); o n t d o a ny n y th t h in i n g e ls l s e w hi h i le l e s ca c a n i s i n p ro r o gr g r es es s . r e t u r n ; / / D on }
}
te v o i d A u t o s c a n F o r p r i v a te rD D i s t a n c e T h r e sh sh o l d ( in t f i n g e r C o u n t ) { DistanceThreshold newDistanceThreshold; bool s c a n F i n i is shed = distanceS Sc c a n n e r . T w o H a n d S c an an ( f i n g e r C ou ou n t , d , ou t n e w D i s t a n c e T h r e s h o l d ) ; D i s t a n c e T h r e s h o l d , D i s t a n c e T h r e s h o l d = n e w D i s t a n ce ce T h r e s h o l d ; U p d a t e D e p t h Di Di s t a c e T h r e s ho ho l d = ! s c a n F i n i s h e d ; d e b u g I nf nf o . A u t o s c a n I n P r o g r e ss ss = U p d a t e D e p t h D is is t a c e T h r e s h ol ol d ; debugInfo. DistanceThreshold = DistanceThreshold ;
}
privat te e void f i n g e r R e c o g n i t i o n _ F i n g e r t i p L o c a t i o n s R e a d y (I (I E n u m e r a b l e < e < F i n g e r t i p > p > points) { Hand c u r r e nt nt H a n d = ne w Hand ( p o i n t s ) ; if ( E n a b l e S m o o t h i n g ) c u r r e n t Ha Ha n d = S m o o t h i n g . E x p o n e n t i a l S m o o t h i n g ( c u r r e n t H a n d , p r e vH vH a n d , S m o o t h i n gF gF a c t o r ) ; if ( P r e v e n t H a n d I n c o n s i t e n c i e s ) h a n d E n h an an c e m e n t s . P r e v e n t H a n d I n co co s i s t e n c y ( c u r r e n t H an an d ) ; ls s e i f ( g e s t u r e R e c o g n it it i o n . R e c o g n i z i n g | | el gestureRecognition.Recording) gestureRecognition.AnalyzeFrame(currentHand); d e b u g I nf nf o . F o u n d H a n d I n c o n s i s t en en c i e s = handEnhancements.FixedInconsistencies; debugInfo.FingertipLocationsReadyCounter++; p r ev ev H a an n d = c u rr rr e n t tH Hand; } privat te e void gestureRecog gn n i t i o n _ G e s t u r e Re Re c o g n i z e d ( G e s t u r e recognizedGesture) { d e b u g I nf nf o . G e s t u r e R e c o g n i z ed ed = t r u e ; } te e void gestureRecog gn n i t i o n _ G e s t u r eR eR e c o r d e d ( G e s t u r e privat recordedGesture) { gestureRecognition.StoreGesture(recordedGesture); } p u b l ic le S m o ot ot h i ng n g F a ct ct o r { g e t ; s e t ; } ic d o u b le p u b l ic b l e S mo mo o t hi h i n g { g et e t ; s et et ; } ic b o o l E n a bl publi ic c b o o l P r e v e nt n t H a nd n d I n co c o n s it i t e n ci c i e s { g et e t ; s et et ; } p r i v a t e D i s t a n c e T h r e s h ol ol d D i s t a n c e T hr hr e s h o l d { g e et t; se et t; }
p u b l ic ic b o o l U p d a t eD e D e p th t h D i st s t a c eT e T h r es e s h o ld l d { g et e t ; s et et ; }
p r i v a te ei g gh ht { ge et t; se et t; } te i n t H ei te e i n t W id id t th h { ge et t; se et t; } privat }
View more...
Comments