-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e352f38
commit 7aaea27
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
android-motion-detection | ||
======================== | ||
|
||
Android code to detection motion by comparing two images. | ||
Android code to detection motion from by comparing two pictures. | ||
|
||
## Introduction | ||
|
||
Android code to detection motion from by comparing two pictures. It comes with an Activity that initializes a camera and grabs two pictures and compares them. | ||
|
||
* Created by Justin Wetherell | ||
* github: http://github.com/phishman3579/android-motion-detection | ||
* e-mail: [email protected] | ||
* Twitter: @phishman3579 | ||
|
||
## Details | ||
|
||
You essentially have to override an onPreviewFrame(byte[] data, Camera cam) method and convert from the default YUV to RGB: | ||
|
||
int[] rgb = ImageProcessing.decodeYUV420SPtoRGB(data, width, height); | ||
|
||
Create an object which you'll use for motion detection code: | ||
|
||
IMotionDetection detector = new RgbMotionDetection(); | ||
|
||
Call the detect() method passing in the parameters obtained above. | ||
|
||
boolean detected = detector.detect(rgb, width, height) | ||
|
||
If the boolean "detected" variable is true then it has detected motion. | ||
|
||
The RGB detection code is located in RgbMotionDetection.java class. The image processing code is located in ImageProcessing.java static class. The Activity to tie it all together is in MotionDetectionActivity.java. | ||
|
||
I have created a MotionDetection class that detects motion comparing RGB values called RgbMotionDetection.java, a class that detects motion comparing Luminance values called LumaMotionDetection.java, and a class that detects motion comparing avergae Luminance values in regions called AggregateLumaMotionDetection.java. |