tags:

views:

43

answers:

1

Is it physically possible to have the iphone camera detect motion? If so, How do you do it?

Thanks!

A: 

You mean technically :) ? Physically it already does (in the sense of taping motion).

Technically you could use the interfaces defined in AVFoundation.framework, create bitmaps from selected frames and compare them. Usually you would make the images monochromatic (or turn them into binary images, it depends on your actual project), and compare the pixels. If a particular amount of connected pixels has changed, there must have been motion.

You would convert the images color space to gray-scale to have a better performance when comparing. It depends again on your project how many shades of gray you need. The picky part is the comparing algorithm for sure. A naive method would be just to count the changed (connected) pixels (making the image gray-scale can save you a lot of false positives). You could also do a Binary Search

thatsdisgusting
Well im scanning for motion of people. So what do you recommend? Just grayscale or binary? Is there a difference?
You said use the `AVFoundation.framework` what are some method to do this that are in there?
@shorty876 To find out how to use the AVFoundation framework consider reading: http://developer.apple.com/iphone/library/documentation/AudioVideo/Conceptual/MultimediaPG/UsingVideo/UsingVideo.htmlA binary image is just a special case of gray-scale image. A pixel there may only have one of two states. In gray-scale image a pixel would be black or white. You achieve this by setting all pixels with >= 50% brightness to white and all others to black. For tracking people i would use as many shades as possible.
thatsdisgusting