void testApp::draw() { kinect.draw(0, 0, 480, 320); flame++; if (flame > 5) { flame = 0; colorImg->setFromPixels(kinect.getPixels(), kinect.width, kinect.height); } }
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); byte[] pixels = OFAndroid.getImgPixels(); if (pixels != null) { for (int i=0;i<w;i++) { for (int j=0;j<h;j++){ int index = (j * w + i) * 3; bitmap.setPixel(i, j, Color.rgb(pixels[index++], pixels[index++], pixels[index])); } } try { // save adcard FileOutputStream fos = new FileOutputStream("/sdcard/screenshot.jpg"); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); } catch (Exception e) { // check exception }
FaceDetector.Face[] faces = new FaceDetector.Face[1]; if (bitmap != null) { FaceDetector detector = new FaceDetector(w, h, faces.length); int numFaces = detector.findFaces(bitmap, faces);
} else { /* * search turn */ Random random = new Random(); int res = random.nextInt(3); if (res == 0) DroidBot.getInstance().turnRight2(); else if (res == 1) DroidBot.getInstance().turnRight4(); else if (res == 2) DroidBot.getInstance().turnLeft2(); else if (res == 3) DroidBot.getInstance().turnLeft4(); }
if (pointX > 0 && pointX < w/4) { DroidBot.getInstance().turnRight2(); // right position } else if (pointX >= w/4 && pointX <= 3*w/4) { ; // center position } else if (pointX > 3*w/4 && pointX <= w) { DroidBot.getInstance().turnLeft2(); // left position }
int angle = 30 - pointY*30/h; if (angle > 0 && angle <= 30) OFAndroid.setAngle(angle);
int dist = OFAndroid.getDistance(pointX, pointY); if (dist < 100) DroidBot.getInstance().walkBack4(); else if (dist >= 100 && dist < 150) DroidBot.getInstance().walkToward4(); else if (dist >= 150 && dist < 200) DroidBot.getInstance().walkToward8(); else if (dist >= 200 && dist < 300) DroidBot.getInstance().walkToward16(); else if (dist >= 300) DroidBot.getInstance().walkToward32();
service vncserver /data/androidvncserver -k /dev/input/event0 -t /dev/input/event0