Efficient Algorithms for Shared Camera Control Vladlen Koltun, UC Berkeley Joint work with Sariel Har-Peled, Dezhen Song and Ken Goldberg Robotic Webcameras • • • Positioned at sites of wide interest Pan, tilt, zoom can be controlled on-line Existing implementations: users queue ShareCam • • Shared on-line camera control Geometric algorithms for finding the optimal camera frame Related Work • Shared on-line control over a single mechanism – Industrial robot arm [Goldberg, Chen, et al.] – Waste cleanup system [Cannon, McDonald, et al.] – Tele-Actor [Goldberg, Song, et al.] • Algorithms we describe are relevant in these scenarios as well Contribution • • Song, van der Stappen and Goldberg (2002), O(n2) Our work – Exact - O(n3/2 log3n) – ε-approximation - O(n logn) • Discretizing zoom values – Fixes the size of the camera rectangle – Two degrees of freedom (center point) Finding the Optimal Frame • • • Idea: Maximize user satisfaction Find a way to evaluate the satisfaction of a given user with a given camera rectangle Compute rectangle that maximizes cumulative user satisfaction Individual User Satisfaction • Intersection over maximum metric: Intersection Area Maximum Area user camera Individual Satisfaction Function Intersection (useri,cam(x,y)) SATi(x,y) = Maximum (useri,cam(x,y)) useri (x,y) Individual Satisfaction Function Intersection (useri,cam(x,y)) SATi(x,y) = Maximum (useri,cam(x,y)) useri (x,y) Global Satisfaction Function • • SAT(x,y) = ∑i SATi(x,y) We are searching for (x,y) that maximizes SAT(x,y) Approximation Algorithm • For a given ε>0 and every individual satisfaction function, consider its level sets at O(1/ε) heights Approximation Algorithm • For a given ε>0 and every individual satisfaction function, consider its level sets at O(1/ε) heights Approximation Algorithm • • Construct rectilinear paths between the level sets Decompose into rectangles Approximation Algorithm • The weighted rectangles “almost” approximate the satisfaction function Approximation Algorithm • • • We have a collection of weighted rectangles We locate the most heavily covered point The global satisfaction value of this point is at least (1-ε) of the optimum Approximation Algorithm • To locate the heaviest point – Sweep the plane with a vertical line – Rectangles define weighted intervals on the line – Maintain the heaviest point on the line using a segment tree – During the sweep, intervals are inserted and removed Analysis • • • • • The number of slices is O( log(1/ε)/ε ) The number of rectangles (per function) is O( [log(1/ε)/ε]2 ) The overall number of rectangles is N = O( n [log(1/ε)/ε]2 ) Every update of the segment tree during the sweep is O(log N) Overall running time is O(N log N) Exact Algorithm • • Sweep the satisfaction functions with a vertical line Maintain the global satisfaction function along the line with a KDS Exact Algorithm • • • • To avoid handling O(n2) events, partition points into n1/2 batches Each batch maintains an additional value: the sum of long functions When a long function changes we just update this value When a short function changes we rebuild the kinetic data structure Exact Algorithm • • • The number of events processed by each kinetic data structure is ≈O(n1/2) The kinetic data structures are rebuilt O(n) times The overall running time is O(n3/2 log3n) Implementation • • The approximation algorithm becomes faster than the algorithm of Song et al. only when n is in the hundreds of thousands. The bottleneck is updating the segment tree during the sweep. Each insertion or deletion takes O(log N), but there are 2N of them, and N is at least 50n Implementation Work in progress • • • • Hardware-assisted algorithm Continuous zoom range More than one camera frame Dynamic maintenance, obstacles, “weighted” users ... Thank you