Skip to content

Commit

Permalink
Updated some code comments
Browse files Browse the repository at this point in the history
git-svn-id: https://android-motion-detection.googlecode.com/svn/trunk@23 996b93ed-3e4d-4b21-1044-74bd19560d1d
  • Loading branch information
[email protected] committed Dec 15, 2011
1 parent 90922f5 commit c345666
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
25 changes: 13 additions & 12 deletions src/com/jwetherell/motion_detection/MotionDetectionActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.concurrent.atomic.AtomicBoolean;

import com.jwetherell.motion_detection.data.GlobalData;
import com.jwetherell.motion_detection.data.Preferences;
import com.jwetherell.motion_detection.detection.AggregateLumaMotionDetection;
import com.jwetherell.motion_detection.detection.IMotionDetection;
import com.jwetherell.motion_detection.detection.LumaMotionDetection;
Expand Down Expand Up @@ -55,9 +56,9 @@ public void onCreate(Bundle savedInstanceState) {
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

if (Globals.USE_RGB) {
if (Preferences.USE_RGB) {
detector = new RgbMotionDetection();
} else if (Globals.USE_LUMA) {
} else if (Preferences.USE_LUMA) {
detector = new LumaMotionDetection();
} else {
//Using State based (aggregate map)
Expand Down Expand Up @@ -194,12 +195,12 @@ public void run() {
try {
//Previous frame
int[] pre = null;
if (Globals.SAVE_PREVIOUS) pre = detector.getPrevious();
if (Preferences.SAVE_PREVIOUS) pre = detector.getPrevious();

//Current frame (with changes)
long bConversion = System.currentTimeMillis();
int[] img = null;
if (Globals.USE_RGB) {
if (Preferences.USE_RGB) {
img = ImageProcessing.decodeYUV420SPtoRGB(data, width, height);
} else {
img = ImageProcessing.decodeYUV420SPtoLuma(data, width, height);
Expand All @@ -209,31 +210,31 @@ public void run() {

//Current frame (without changes)
int[] org = null;
if (Globals.SAVE_ORIGINAL && img!=null) org = img.clone();
if (Preferences.SAVE_ORIGINAL && img!=null) org = img.clone();

if (img!=null && detector.detect(img, width, height)) {
// The delay is necessary to avoid taking a picture while in the
// middle of taking another. This problem can causes some phones
// to reboot.
long now = System.currentTimeMillis();
if (now > (mReferenceTime + Globals.PICTURE_DELAY)) {
if (now > (mReferenceTime + Preferences.PICTURE_DELAY)) {
mReferenceTime = now;

Bitmap previous = null;
if (Globals.SAVE_PREVIOUS && pre!=null) {
if (Globals.USE_RGB) previous = ImageProcessing.rgbToBitmap(pre, width, height);
if (Preferences.SAVE_PREVIOUS && pre!=null) {
if (Preferences.USE_RGB) previous = ImageProcessing.rgbToBitmap(pre, width, height);
else previous = ImageProcessing.lumaToGreyscale(pre, width, height);
}

Bitmap original = null;
if (Globals.SAVE_ORIGINAL && org!=null) {
if (Globals.USE_RGB) original = ImageProcessing.rgbToBitmap(org, width, height);
if (Preferences.SAVE_ORIGINAL && org!=null) {
if (Preferences.USE_RGB) original = ImageProcessing.rgbToBitmap(org, width, height);
else original = ImageProcessing.lumaToGreyscale(org, width, height);
}

Bitmap bitmap = null;
if (Globals.SAVE_CHANGES && img!=null) {
if (Globals.USE_RGB) bitmap = ImageProcessing.rgbToBitmap(img, width, height);
if (Preferences.SAVE_CHANGES && img!=null) {
if (Preferences.USE_RGB) bitmap = ImageProcessing.rgbToBitmap(img, width, height);
else bitmap = ImageProcessing.lumaToGreyscale(img, width, height);
}

Expand Down
3 changes: 2 additions & 1 deletion src/com/jwetherell/motion_detection/SensorsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@


/**
* This class extends Activity and processes sensor data and location data.
* This class extends Activity and processes sensor data and location data. It is used to
* detect when the phone is in motion, so we do not try to detect motion.
*
* @author Justin Wetherell <[email protected]>
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.jwetherell.motion_detection;
package com.jwetherell.motion_detection.data;

public class Globals {

/**
* This class is used to store preferences on how to decode images and what to save.
*
* @author Justin Wetherell <[email protected]>
*/
public class Preferences {
//Which motion detection to use
public static boolean USE_RGB = true;
public static boolean USE_LUMA = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public abstract class ImageProcessing {
public static final int S = 1;
public static final int L = 2;

private ImageProcessing() { }

/**
* Get RGB values from pixel.
* @param pixel Integer representation of a pixel.
Expand Down

0 comments on commit c345666

Please sign in to comment.