We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Array compare and sort distant Help !
Page Index Toggle Pages: 1
Array compare and sort distant Help ! (Read 500 times)
Array compare and sort distant Help !
Dec 15th, 2009, 9:13am
 
Hi im using PFaceDetect library to multi detect face, but i still got noise and can't remember if the face are similar dimension.

so i want to slove this problem by compare the present positon with previous position with every face that i detect, and the nearlest by vector is right face.

i can find vector with dist()

by compare previous x y and present x y

but i don't know how to compare and swap array by the nearless first vector, it really hard for me Wink

i wat done all for every face over and over again like:

A(old) B(old) C(old)

compare with A(new) B(new) C(new)

then B(new) is nearest by vector with A(old)

and B(new) is new first order of position, like this every face postion


this source of original example

Code:
import pFaceDetect.*;
import JMyron.*;

PFaceDetect face;
JMyron m;
PImage img;

void setup() {
 size(320,240);
 m = new JMyron();
 m.start(width,height);
 m.findGlobs(0);
 face = new PFaceDetect(this,width,height,
 "haarcascade_frontalface_default.xml");
 frameRate(15);
 img = createImage(width,height,ARGB);
 rectMode(CORNER);
 noFill();
 stroke(255,0,0);
 smooth();
}

void draw() {
 background(0);
 m.update();
 arraycopy(m.cameraImage(),img.pixels);
 img.updatePixels();
 face.findFaces(img);
 image(img,0,0);
 drawFace();
}

void drawFace() {
 int [][] res = face.getFaces();
 if (res.length>0) {
   for (int i=0;i<res.length;i++) {
int x = res[i][0];
int y = res[i][1];
int w = res[i][2];
int h = res[i][3];
rect(x,y,w,h);
   }
 }
}

void stop() {
 m.stop();
 super.stop();
}


Thank for Help  Wink


Re: Array compare and sort distant Help !
Reply #1 - Dec 19th, 2009, 1:47pm
 
mh im not sure what you exactly mean. maybe you should use another class to save your data. maybe a TreeSet or something. it creates the order of your data like you want. and you can get things out and in like you want.
Page Index Toggle Pages: 1