While I was finding out how to use a webcam for motion detection with Java via JavaCV, I built this little robot head from LEGO Mindstorms with LeJOS on the NXT. Having Java on both sides of the USB connection makes communicating the direction ‘to look at’ simple and reliable.
I use JavaCV to find the largest difference (what moved the most) between successive images from the webcam and send its position in the webcam’s view to the NXT via the USB cable. The NXT reads the position and controls yaw-pitch on the two ‘neck’ motors to match.
Emily made the robot’s head from a small, plastic soft fruit punnet (the holes in the bottom fit just right onto the ends of LEGO struts) covered with kitchen tissue strips fixed with glue stick. Make-up is by washable marker pen.