Attempts to find humans through OpenCV facedetect. Utilizes a pan / tilt kit and LKOptical track points to track human after detection.
So far you have to use Eclipse and change the FindHuman.java file in the service directory to set your Arduino pin and com port settings, etc. Then start it like you would any other MRL Service.
This java code sets everything up:
-
// create services ==============================================
-
Runtime.createAndStart("runtime", "Runtime");
-
Arduino arduino = (Arduino) Runtime.createAndStart("arduino", "Arduino");
-
Speech speech = (Speech) Runtime.createAndStart("speech", "Speech");
-
Servopan = (Servo) Runtime.createAndStart("pan", "Servo");
-
Servo tilt = (Servo) Runtime.createAndStart("tilt", "Servo");
-
Twitter witter = (Twitter) Runtime.createAndStart("twitter", "
-
OpenCV opencv = (OpenCV) Runtime.create("opencv", "OpenCV");
-
PID xpid = (PID) Runtime.createAndStart("xpid", "PID");
-
PID ypid = (PID) Runtime.createAndStart("ypid", "PID");
-
Java java = (Java) Runtime.createAndStart("java", "Java");
-
Sphinx ear = (Sphinx) Runtime.createAndStart("sphinx", "Sphinx");
-
-
//xpid ==============================================
-
xpid.setMode(1);
-
xpid.setOutputRange(-1, 1);
-
xpid.setPID(7.0, 0.2, 0.5);
-
xpid.setControllerDirection(0);
-
xpid.setSetpoint(80);// #setpoint now is 80 instead of 160 because of 2
-
// PD filters
-
-
// ypid ==============================================
-
ypid.setMode(1);
-
ypid.setOutputRange(-1, 1);
-
ypid.setPID(7.0, 0.2, 0.5);
-
ypid.setControllerDirection(0);
-
ypid.setSetpoint(60); // set point is now 60 instead of 120 because of 2
-
// PD filters
-
xpid.invert();
-
-
//twitter ==============================================
-
// twitter.setSecurity("","","","");
-
twitter.configure();
-
// twitter.tweet("#myrobotlab is Awesome!")
-
-
// arduino ==============================================
-
arduino.setSerialDevice("/dev/ttyACM0", 57600, 8, 1, 0);
-
-
// opencv ==============================================
-
opencv.startService();
-
opencv.addFilter("Gray", "Gray");
-
// add enough pyramid down filters to get 160x120 resolution
-
// opencv.addFilter("PyramidDown1", "PyramidDown");
-
// opencv.addFilter("PyramidDown2", "PyramidDown");
-
opencv.addFilter("lk", "LKOpticalTrack");
-
opencv.addListener("publishOpenCVData", this.getName(), "input",
-
OpenCVData.class);
-
opencv.setCameraIndex(1);
-
// ear ============
-
ear.addCommand("find human", opencv.getName(), "capture");
-
ear.addCommand("kill all humans", this.getName(), "stopEverything");
-
ear.addCommand("happy fun", this.getName(), "tweetOn");
-
ear.addCommand("two two four", this.getName(), "tweetOff");
-
ear.addCommand("talk to me", this.getName(), "speechOn");
-
ear.addCommand("no talking", this.getName(), "speechOff");
-
ear.addComfirmations("yes");
-
ear.addNegations("no");
-
ear.attach(speech);
-
ear.startListening();
-
-
// now get the servos working ============================
-
arduino.attach(pan.getName(), 14);
-
arduino.attach(tilt.getName(), 15);
-
pan.moveTo(90);
-
tilt.moveTo(90);
-
lights(0, 1, 0);
And then this method is where all the magic happens. The FaceDetect and LKOptical filters pump an OpenCVData object to this method for processing:
-
public void input(OpenCVData opencvData) {...}
BWAHAHAHAHA !
Awesome...
Thanks for making the service..
Thanks for making the video...
Thanks for adding the video to the Service page !
I'm wondering ...
0:13 - it sets an LK Point on your shirt?
The red light is lock & kill - LEDs are a nice touch :D - it's cool to see the Sentry do mood swings :)
The biggest question is why the tight spiral when a LKOptical point is set? Is this intentional or is it from hysteresis ?
This is turning into a WICKED COOL SENTRY !!!!
hysteresis
The tight spiral is from hysteresis, the servo's keep compensating, maybe if I change the PID settings it will be better.
There is still a problem where the camera is in motion, and I'm not sure if there is a problem with the commands in the input method "overlapping",, for example if the last time the code ran through the input method and it changed the servo postion, if the servo is in the right position for the next time through the input method. So I think there are some delay effects with setting the LKOptical filter'ss tracking point.
Hmmm... I have
Hmmm... I have seen hysteresis a lot... never as a spiral...
are you sure the spiral code isn't running at the same time LKTrack is trying to track :D ?
To me the motion makes sense - both are pumping info to the servo - LK / PID system is trying to keep it on the point and the servo search is trying to spiral ... add them together and you get tiny spiral :)
Was "no talking" supposed to
Was "no talking" supposed to have shut it up ? :)
I love the spiral search - I noticed that when you got up - you left the field of view and the lkpoint was lost..
an interesting algorithm might be to follow the trajectory of the last LKPoint and start a spiral (small to big) from guestimated point location..