-
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.
Updated the HSL conversions and the state detector
git-svn-id: https://android-motion-detection.googlecode.com/svn/trunk@13 996b93ed-3e4d-4b21-1044-74bd19560d1d
- Loading branch information
1 parent
74d0316
commit b9d911e
Showing
6 changed files
with
206 additions
and
105 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -11,11 +11,18 @@ | |
* @author Justin Wetherell <[email protected]> | ||
*/ | ||
public class State { | ||
private int[][] map; | ||
private int[][] map = null; | ||
private int width; | ||
private int height; | ||
private int average; | ||
|
||
public State(State other) { | ||
this.map = other.map.clone(); | ||
this.width = other.width; | ||
this.height = other.height; | ||
this.average = other.average; | ||
} | ||
|
||
public State(int[] data, int width, int height) { | ||
if (data==null) return; | ||
|
||
|
@@ -27,15 +34,14 @@ public State(int[] data, int width, int height) { | |
|
||
// build map and stats | ||
average = 0; | ||
int ta = 0; | ||
for (int y = 0; y < height; y++) { | ||
for (int x = 0, xy = 0; x < width; x++, xy++) { | ||
ta = (int)(100*ImageProcessing.getBrightnessAtPoint(data[xy])); | ||
for (int y = 0, xy=0; y < this.height; y++) { | ||
for (int x = 0; x < this.width; x++, xy++) { | ||
int ta = ImageProcessing.getBrightnessAtPoint(data[xy]); | ||
map[y][x] = ta; | ||
average += ta; | ||
} | ||
} | ||
average = (int)(average / (width * height)); | ||
average = (average / (this.width * this.height)); | ||
} | ||
|
||
public int[][] getMap() { | ||
|
@@ -49,4 +55,25 @@ public int getWidth() { | |
public int getHeight() { | ||
return height; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder output = new StringBuilder(); | ||
output.append("h="+height+" w="+width+"\n"); | ||
for (int y = 0; y < height; y++) { | ||
output.append('|'); | ||
for (int x = 0;x < width; x++) { | ||
output.append(map[y][x]); | ||
output.append('|'); | ||
} | ||
output.append("\n"); | ||
} | ||
return output.toString(); | ||
} | ||
|
||
@Override | ||
public State clone() { | ||
State newState = new State(this); | ||
return newState; | ||
} | ||
} |
Oops, something went wrong.