Tutorial on using Android for Image Processing Projects
EE368 Digital Image Processing, Spring 2010
Macintosh Version
Introduction
In this tutorial, we will learn how to set up the Android software development environment and how to implement image processing operations on an Android-based mobile device (e.g., the DROID phone that you have received for the class assignments). Android is an open-source platform developed by Google and the Open Handset Alliance on which interesting and powerful new applications can be quickly developed and distributed to many mobile device users. There is a growing community of Android developers and a growing market for Android-based devices (e.g., Motorola DROID, HTC DROID ERIS, Google Nexus One). Android also comes with a vast library of useful functions, including functions for user interfaces, image/bitmap manipulation, and camera control that we will frequently use in EE368. We look forward to seeing your novel image processing algorithms and applications running on Android-based devices as the quarter progresses.
The tutorial is split into two parts. In the first part, we will explain how to download and install the Android software tools onto your computer. Then, in the second part, we will explain how to develop image processing programs that can run on an Android-based mobile device.
Part I: Creating the Software Development Environment
We will use the Google Android SDK and the Eclipse IDE to design, implement, and debug Android-compatible programs in this class.[1]
Downloading and Installing Eclipse
http://www.eclipse.org/downloads/
/Users/yourname/Desktop/EE368-Android/eclipse
./eclipse &
/Users/yourname/Desktop/EE368-Android/eclipse/workspace
Figure 1. Start-up screen of the Eclipse IDE.
Downloading and Installing Android SDK
http://developer.android.com/sdk/index.html
/Users/yourname/Desktop/EE368-Android/android-sdk-mac
http://www.peachpit.com/articles/article.aspx?p=31442&seqNum=4
http://dl-ssl.google.com/android/eclipse/
http://developer.android.com/sdk/index.html
http://developer.android.com/sdk/installing.html
http://developer.android.com/sdk/eclipse-adt.html
Figure 2. Android preferences panel in Eclipse.
Figure 3. Android update panel in Eclipse.
Linking Your Phone to Your Computer
http://developer.android.com/guide/developing/device.html#setting-up
(Note: You may need to restart your computer after installing the USB driver in order for the phone to show up in Eclipse.)
Part II: Developing Image Processing Programs for Android
Now that the Google Android SDK, the Java Runtime, and the Eclipse IDE are all set up on your computer, we are ready to start writing image processing programs that can run an Android-compatible mobile device.
Hello World Example
First, we will build a simple Android program in Eclipse. This simple example will also help you to become familiar with how to create an Android project, how to (auto) compile source code, and how to run the generated executable on the mobile device.
Please follow the instructions on this page to develop the “Hello World” program:
http://developer.android.com/resources/tutorials/hello-world.html
Note: In case there are strange errors when the project is created about “R.java”, simply add a comment line (e.g., “// dummy comment”) at the top of “gen : com.example.helloandroid : R.java” and save the file. This will make the errors disappear.
In the external “Hello World” tutorial, they only run the “Hello World” program in an emulator. Additionally, we will now also run the program on the actual Android-based phone. Make sure your phone is properly linked to your computer.
Figure 4. “Hello World” program running on Android-based phone.
EE368 Viewfinder Example
Now, having grasped the fundamentals of building and running an Android application, we will create a more complicated project involving the onboard camera and real-time image processing.
Project name: ViewfinderEE368
Check the box for Android 2.0.1
Application name: Viewfinder EE368
Package name: com.example.viewfinderee368
Check the box for Create Activity and enter: ViewfinderEE368
Min SDK Version: 6
http://ee368.stanford.edu/Android/ViewfinderEE368/AndroidManifest.xml
http://ee368.stanford.edu/Android/ViewfinderEE368/ViewfinderEE368.java
Figure 5. “Viewfinder EE368” program running on Android-based phone.
Real-time Phone Debugging in Eclipse
It is actually possible to view real-time messages from the phone in Eclipse, which can be very helpful for debugging and code development.
[1] Parts of this tutorial borrow explanations from the official Android developers’ website (developer.android.com).