Search code examples
androidstereo-3d

MPO Images from HTC Evo 3D


My team is developing an app for HTC phones that uses the stereo camera. In order to do our processing, we require the still images taken by the 3D camera to be in MPO format. By default it is returning JPS images.

How can I make the camera return MPO images? Is there someplace that this is documented?

I have spent a while on HTCs site but was unable to find source code for their API or camera app that might help (since their camera app can do MPO files).


Solution

  • I don't know an API for this, but it is pretty straight forward to do yourself. The JPS format is just a single image with the left half being one camera and the right half being another. So first step just convert it to two separate images. Create new bitmaps from it with rectangles for either side:
    http://developer.android.com/reference/android/graphics/Bitmap.html#createBitmap(android.graphics.Bitmap,%20int,%20int,%20int,%20int,%20android.graphics.Matrix,%20boolean)

    The MPO format is just two JPG images in one file, one after the other. So next write two JPG images using the compress method to the same file output stream:
    http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat,%20int,%20java.io.OutputStream)

    You can find a lot of sample code online for Android for cropping images and saving them to JPG, which is pretty much all you need.