200 likes | 331 Views
Divide & Conquer. Fibonacci (recursion). fib(n) = fib(n – 1) + fib(n – 2), fib(0) = fib(1) = 1. int fib( int n) { if (n == 0 || n == 1) return 1; else return fib(n – 1) + fib(n – 2); }. O(2 n ). Fibonacci (table). O(n). Dynamic Time Warping (DTW). Mapping between two sequences.
E N D
Fibonacci (recursion) fib(n) = fib(n – 1) + fib(n – 2), fib(0) = fib(1) = 1 int fib(int n) { if (n == 0 || n == 1) return 1; else return fib(n – 1) + fib(n – 2); } O(2n)
Fibonacci (table) O(n)
Mapping between two sequences Alignment is needed
ผลลัพธ์ที่ต้องการ เติมตารางขนาด N x M
Global Alignment N ∞ Best score … ∞ warping path ให้ถอยหลังไปตามทางที่เลือก min Sequence X 1 ∞ 0 0 ∞ ∞ ∞ ∞ ∞ 0 1 2 3 … M O(NM) Sequence Y
Local Alignment N ∞ Minscore … ∞ Maxindex Sequence X 1 ∞ C(x1,y1) C(x1,y2) C(x1,y3) C(x1,y4) … C(x1,yM) 0 0 ∞ ∞ ∞ ∞ ∞ ∞ 0 1 2 3 4 … M Sequence Y ลงมาแตะแถวล่างn = 1 ให้เร็วที่สุด
Homework (local alignment) Sequence X = 0, 2, 3, 2, 0, 2, 3, 2, 0 Sequence Y = 0,2,4,5,4,2,0,-2,-4,-5,-4,-2,0,2,3,2,0,2,3,2,0
Solution Sequence X x คือ infinity Sequence Y
Problems you will encounter and hints • Lagging due to searching for many motions. • Threading. • Sliding window (timing). • Use a buffer or a queue. • Multiple joints, each joint is in 3D. • No needs to use all joints • Player-position dependence. • Use an angle of a joint with a reference point. • Other solutions ??? • Players must stand at a fixed position (not good). • Use a distance from Kinect for moving forward and backward (or use a height of head, for example).
Architecture Key / mouse events Motions detected Motions Joint positions Time window Q1 DTW Q2 OverrideKB/Mouse Game Overflow(likely) Overflow(rare) One process(two threads, two queues) One process Core DTW is the major bottleneck.See parallelization (utilizing multiple-core) in the next chapter.
Time Window Sliding (small step)and run DTW in the time window Time Timewindow If the step size is too large,some motions will be missed.
Tips • ใช้เฉพาะ joint ที่สำคัญ ไม่ต้องใช้ทั้งหมด เพื่อให้ประมวลผลได้เร็ว • แปลง trajectory ใน 3D ให้เป็น angle (self-reference) Vector A Position of a joint in 3D (meter) z Vector B(reference) y x time Angle of a joint (degree) Absolutedistance !!! Θ Chest time Angle between vector A and B= cos-1(AB / |A||B|)