Weitere ähnliche Inhalte Ähnlich wie Using Android Things to Detect & Exterminate Reptilians (20) Kürzlich hochgeladen (20) Using Android Things to Detect & Exterminate Reptilians8. Beer Can Music Player (03)
(03)
http://nilhcem.com/android-things/discovering-the-I2C-api-creating-a-capacitive-sensor-driver
12. Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
13. Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
14. Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
15. Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
16. Compatible boards (06)
• Raspberry Pi 3
• NXP i.MX7D/i.MX6UL
• Intel Edison/Joule (discontinued)
(06)
https://developer.android.com/things/hardware/developer-kits.html
23. Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
24. Facts
• Humans don't use their brain to its full capacity
• Humans are distracted by media, entertainment, and
politics.
• Borders, country lines lead to endless wars and conflicts
27. Reptilian conspiracy theory (08)
(08)
https://www.theatlantic.com/national/archive/2013/04/12-million-americans-believe-lizard-people-run-our-country/
316706/
28. Reptilian
• Altered our DNA so we don't fully use our brain
• Control humans with media / politics
• Have, through the generations, ruled the world
32. TensorFlow codelabs
• TensorFlow for Poets (10)
• TensorFlow for Poets 2: Optimize for Mobile (11)
• Android Things Image Classifier (12)
(12)
https://codelabs.developers.google.com/codelabs/androidthings-classifier/index.html
(11)
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2/
(10)
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/
39. Mobile model optimizations
python tensorflow/python/tools/optimize_for_inference.py
--input=~/tf_files/retrained_graph.pb
--output=~/tf_files/optimized_graph.pb
--input_names="Mul"
--output_names="final_result"
41. TensorFlow Inference
val inferenceInterface = TensorFlowInferenceInterface(getAssets(), MODEL_FILE)
val labels = loadLabels() // [ "reptilian", "reptile", "human" ]
fun doRecognize(image: Bitmap) {
val pixels = image.toPixelsArray()
inferenceInterface.feed(INPUT_NODE, pixels, NETWORK_STRUCTURE)
inferenceInterface.run(arrayOf(OUTPUT_NODE))
val outputs = FloatArray(labels.size)
inferenceInterface.fetch(OUTPUT_NODE, outputs)
}
48. AndroidManifest.xml
<application>
<uses-library android:name="com.google.android.things" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.IOT_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
49. MainActivity
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
57. Peripheral I/O APIs (14)
• GPIO
• PWM
• I²C
• I²S
• SPI
• UART
(14)
https://developer.android.com/things/sdk/pio/index.html
61. val pioService = PeripheralManagerService()
val ledGpio = pioService.openGpio("BCM4")
66. Drivers are standard
Android libraries (16)
(17)
(17)
https://github.com/amitshekhariitbhu/awesome-android-things
(16)
https://github.com/androidthings/contrib-drivers
72. val display = Ssd1306("I2C1")
val bmp = BitmapFactory.decodeResource(resources, R.drawable.background)
BitmapHelper.setBmpData(display, 0, 0, bmp, false)
display.show()
83. Arduino to the rescue
void loop() {
distance = getDistanceInCentimeters();
Serial.println(distance);
delay(1000);
}
85. Read data from USB (20)
Hcsr04LiveData(this)
.observe({lifecycle}) { distanceInCm ->
Log.i(TAG, "Distance (cm): $distanceInCm")
}
(20)
https://github.com/Nilhcem/usbfun-androidthings
88. git commit -m "Kill reptilian when detected"
if (detected.isReptilian()) {
exterminate()
}
95. Moving the servo
val servo = Servo("PWM0")
servo.setAngleRange(0.0, 180.0)
servo.setPulseDurationRange(1.0, 2.0)
servo.enable = true
servo.angle = servo.minimumAngle
108. val colorAnimator = ValueAnimator.ofFloat(0f, 360f).apply {
duration = 8000
repeatCount = ValueAnimator.INFINITE
repeatMode = ValueAnimator.REVERSE
addUpdateListener { animator ->
val leds = getLedsColors(animator.animatedValue)
ledstrip.write(leds)
}
start()
}
109. val path = Path().apply {
moveTo(0f, 0f)
lineTo(0.001f, 400f / 2000f) // 0 secs -> 2.5 fps
lineTo(3f / 23f, 400f / 2000f) // 3 secs -> 2.5 fps
lineTo(6f / 23f, 20f / 2000f) // 6 secs -> 50.0 fps
lineTo(18f / 23f, 20f / 2000f) // 18 secs -> 50.0 fps
lineTo(1f, 1f) // 23 secs -> 0.5 fps
}
val frameDelayAnimator = ValueAnimator.ofInt(0, 2000).apply {
duration = 23000
repeatCount = 0
interpolator = PathInterpolator(path)
start()
}
117. Using Android Things to
Detect & Exterminate Reptilians
• Twitter:
@Nilhcem
• Slides:
bit.ly/reptilethings