Skip to content

Commit

Permalink
Merge pull request #52 from opennars/prVisionRefactor
Browse files Browse the repository at this point in the history
Vision refactor
  • Loading branch information
PtrMan authored Aug 18, 2018
2 parents fcc2f0f + ddb08ee commit 4bebf40
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/main/java/org/opennars/lab/vision/RasterHierachy.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ public void setFocus(int x, int y) {

public BufferedImage rasterizeImage(BufferedImage input) {
voter = new HashMap<>();
boolean putin=false; //vladimir

cnt--;
boolean putIn = cnt==0;
if(cnt==0) {
putin = true;
cnt=updaterate;
}

Expand Down Expand Up @@ -272,7 +272,7 @@ public BufferedImage rasterizeImage(BufferedImage input) {
int brightness = (red+green+blue)/3; //maybe not needed
int key=step+10*x+10000*y;

if(lastvalR.containsKey(key) && putin) {
if(lastvalR.containsKey(key) && putIn) {

double area = blockXSize * blockYSize;
double diff = Math.abs(fred - (lastvalR.get(key))) + Math.abs(fgreen - (lastvalG.get(key))) + Math.abs(fblue - (lastvalB.get(key)));
Expand All @@ -284,7 +284,7 @@ public BufferedImage rasterizeImage(BufferedImage input) {
lastvalG.put(key, fgreen);
lastvalB.put(key, fblue);

if(putin && step==numberRasters) { //only most finest raster
if(putIn && step==numberRasters) { //only most finest raster
int used_X = h-1;
int used_Y = j-1;
float USED_X = 2.0f*(used_X / (float) (res-1))-1.0f;
Expand All @@ -304,7 +304,7 @@ public BufferedImage rasterizeImage(BufferedImage input) {
}

// search for maximum vote to move heuristic
if(putin) {
if(putIn) {
Value maxvalue = null;
float threshold = 0.05f;
for (Integer key : voter.keySet()) {
Expand Down Expand Up @@ -349,23 +349,6 @@ public void process() {
//int counter = 0;

while( true ) {
/*
* Uncomment this section to scan the focal point across the frame
* automatically - just for demo purposes.
*/
/*
int xx = this.focusPoint.getX();
int yy = this.focusPoint.getY();
xx += 1;
if(xx > frameWidth)
{
xx = 0;
yy += 1;
if (yy > frameHeight)
yy = 0;
}
this.setFocus(xx, yy);
//*/
input = webcam.getImage();

synchronized( workImage ) {
Expand Down

0 comments on commit 4bebf40

Please sign in to comment.