Created
November 20, 2012 01:34
-
-
Save michelleboisson/4115382 to your computer and use it in GitHub Desktop.
Controlling an IP camera with an Android device
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
/** | |
* <p>This uses the Ketai Sensor Library for Android: http://ketaiMotion.org</p> | |
* | |
* | |
*/ | |
import ketai.sensors.*; | |
KetaiSensor sensor; | |
float accelerometerX, accelerometerY, accelerometerZ; | |
float r, g, b; | |
String data; | |
String panLeft; | |
void setup() | |
{ | |
sensor = new KetaiSensor(this); | |
sensor.start(); | |
orientation(PORTRAIT); | |
textAlign(CENTER, CENTER); | |
textSize(36); | |
panLeft = "http://128.122.151.22/axis-cgi/com/ptz.cgi?camera=1&move=left"; | |
} | |
void draw() | |
{ | |
float r = map(accelerometerX, -10, 10, 0, 255); | |
float g = map(accelerometerY, -10, 10, 0, 255); | |
float b = map(accelerometerZ, -10, 10, 0, 255); | |
background(r, g, b); | |
text("Accelerometer: \n" + | |
"x: " + nfp(accelerometerX, 2, 3) + "\n" + | |
"y: " + nfp(accelerometerY, 2, 3) + "\n" + | |
"z: " + nfp(accelerometerZ, 2, 3), width/2, height/2); | |
//load this url to move the camera | |
if (r < 125) { | |
println("moving left"); | |
loadStrings(panLeft); | |
//link(panLeft); | |
} | |
else { | |
println("not moving"); | |
} | |
} | |
void onAccelerometerEvent(float x, float y, float z) | |
{ | |
accelerometerX = x; | |
accelerometerY = y; | |
accelerometerZ = z; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment