Showing posts with label computer vision. Show all posts
Showing posts with label computer vision. Show all posts

Monday, December 10, 2012

3-3. Basic Programming of the Android Controller/Camera Part III

Finally, we get to the actual image capture for the Android brain!  After getting the default camera app working, my goal was to be able to get preview frame captures from the camera at a decent frame rate (at least a couple times a second) into a RGB pixel array.  In order to achieve this goal, I needed to be able to write and deploy a new Android app to the i.MX53. Google has a lot of tools to help a developer test his Android app, but figuring it out for the i.MX53 took a bit of head-scratching.  I basically followed these steps.



Micro USB port on the i.MX53 QSB
  1. Connect a micro-USB to USB cable between the QSB and your development machine (this is very important because it won't work over the port you used for boot-loading).
  2. Install Android SDK on your development machine.
  3. Install the Google Android USB driver.
  4. Generate a configuration ini file by typing 'android update adb' in the <android-sdk>/tools directory.  This file will be created in your .android directory and will be called adb_usb.ini.  Open this file and enter the Freescale device ID '0x15a2' on the last line.
  5. Start up communication between the QSB and development machine by going to <android-sdk>/platform-tools and typing 'adb devices'.  This will start up the Android Debugging Server and try to connect to the i.MX53.  You should see the device listed.
If this sounds painful, it was.  Each one of these steps I had to research came from a different source.  The most difficult one to figure out was the micro USB port step (#1).  This was confusing because the i.MX53 has so many different USB ports you can use so it was hard to figure out which port supported what.  Once I got hooked up, I was able to fire up the Eclipse IDE and install the Android plugin for it.  Included in the Android SDK is a sample Camera preview (<android-sdk>/samples/android-16/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.java).  In order to get a preview image in an RGB array, we can take this code as a base and add a PreviewCallback object, according to this blog.  Installing your application onto the i.MX53 is simply done through running the Eclipse project.  The android plugin will automatically try to connect to a specified attached device and install the application.  It will also try to run it; so you can see the results of the logs on the i.MX53 in the logcat viewer.

Tuesday, November 6, 2012

3-3. Basic Programming of the Android Controller/Camera

When I was trying to figure out what would be the brains of Porter, there were a few design considerations.
  • Computer Vision processing - a 640x480 raw RGB image takes up about a MB of memory, so if I wanted to do some object recognition or tracking with it, that put most "microcontrollers" like the Arduino off-limits.
  • Easily programmable - After poking around, I settled on Android as a platform OS, so I needed some hardware that had good support for Android.
  • Small form factor - It needs to fit into a small form factor to provide flexibility for the chassis design.
Freescale wired up for use
I finally have settled for my initial prototype on using Freescale's i.MX53 single board microprocessor (Their quick start kit costs $149).   It's about the size of a smartphone, is beefy enough to handle the computer vision with 1GB of RAM, and has multiple USB ports. Freescale used to be Motorola semiconductor, so they have a lot of history and a good user community. Also, Adeneo makes a nice BSP port of Android for the i.MX53, with driver support for cameras, mice, etc.  

There are a few other comparable boards on the market, most notably the PandaBoard ($161) and the Raspberry Pi ($35), which I might end up using for the final production robot, but I felt that at this point in development, Freescale's community and maturity of the Android port were enough to go with them.

i.MX53 hooked up to VGA monitor